This commit is contained in:
Digital Data - Marlon Schreiber
2019-03-22 15:48:41 +01:00
parent fb92a0fd1c
commit 676e9d40b8
17 changed files with 547 additions and 184 deletions

View File

@@ -6,6 +6,9 @@
</sectionGroup>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="DDWDResultHandler.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings />
<startup>
@@ -13,11 +16,11 @@
</startup>
<applicationSettings>
<DDWDResultHandler.My.MySettings>
<setting name="SQLSERVER_CS" serializeAs="String">
<setting name="SQLSERVER_CS_RH" serializeAs="String">
<value>Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_RENOLIT;Persist Security Info=True;User ID=sa;Password=dd</value>
</setting>
<setting name="SQLSERVER_CS_PMRefresh" serializeAs="String">
<value>Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd</value>
<value />
</setting>
</DDWDResultHandler.My.MySettings>
</applicationSettings>
@@ -40,4 +43,11 @@
</dependentAssembly>
</assemblyBinding>
</runtime>
<userSettings>
<DDWDResultHandler.My.MySettings>
<setting name="PMREFRESH_INTERVALL" serializeAs="String">
<value />
</setting>
</DDWDResultHandler.My.MySettings>
</userSettings>
</configuration>

View File

@@ -9,7 +9,7 @@ Public Class DDWDResultHandler
Private _database As DD_WMResulthandler.clsDatabase
Private _profil As clsProfil
Public Shared threadRunner As BackgroundWorker
Public Shared threadResultHandler As BackgroundWorker
Public Shared threadPMRefresh As BackgroundWorker
Private Logger As Logger
@@ -33,14 +33,6 @@ Public Class DDWDResultHandler
' Code zum Starten des Dienstes hier einfügen. Diese Methode sollte Vorgänge
' ausführen, damit der Dienst gestartet werden kann.
'EventLog1.WriteEntry("Dienst 'DD windream Result Handler' gestartet")
Try
If Not System.Diagnostics.EventLog.SourceExists("DDWMResultHandler") Then
System.Diagnostics.EventLog.CreateEventSource("DDWMResultHandler", "DigitalData Log")
End If
Catch ex As Exception
EventLog.WriteEntry("DDWMResultHandler", "ERROR in Creating source:" & ex.ToString(), EventLogEntryType.Error)
End Try
Try
Try
MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
@@ -52,59 +44,62 @@ Public Class DDWDResultHandler
End Try
If My.Settings.SQLSERVER_CS = String.Empty Then
Logger.Warn("Achtung: Es wurde noch kein Datenbank-ConnectionString hinterlegt.")
'If _database.Init(My.Settings.SQLSERVER_CS_RH, True) = False Then
' Logger.Warn("Achtung: Es konnte keine Verbindung zur Datenbank '" & My.Settings.SQLSERVER_CS_RH & "' hergestellt werden!")
' Else
If clsCURRENT.LOG_ERRORS_ONLY = False Then
MyLogger.Debug = True
Else
If _database.Init(My.Settings.SQLSERVER_CS, True) = False Then
Logger.Warn("Achtung: Es konnte keine Verbindung zur Datenbank '" & My.Settings.SQLSERVER_CS & "' hergestellt werden!")
Else
MyLogger.Debug = False
End If
oFirstRun = True
' '#Thread für Durchlauf generieren
DDWDResultHandler.threadResultHandler = New BackgroundWorker()
DDWDResultHandler.threadResultHandler.WorkerReportsProgress = True
DDWDResultHandler.threadResultHandler.WorkerSupportsCancellation = True
AddHandler threadResultHandler.DoWork, AddressOf RUN_RESULTHANDLER
AddHandler threadResultHandler.RunWorkerCompleted, AddressOf Thread_Completed
If clsCURRENT.LOG_ERRORS_ONLY = False Then
MyLogger.Debug = True
Else
MyLogger.Debug = False
End If
oFirstRun = True
' '#Thread für Durchlauf generieren
DDWDResultHandler.threadRunner = New BackgroundWorker()
DDWDResultHandler.threadRunner.WorkerReportsProgress = True
DDWDResultHandler.threadRunner.WorkerSupportsCancellation = True
AddHandler threadRunner.DoWork, AddressOf RUN_THREAD
AddHandler threadRunner.RunWorkerCompleted, AddressOf Thread_Completed
' '### Den Timer generieren
Dim Timer_Durchlauf As New System.Timers.Timer()
'Das Event hinterlegen welches bei "Tick" ausgelöst wird
AddHandler Timer_Durchlauf.Elapsed, AddressOf Thread_Run
' Set the Interval
Timer_Durchlauf.Interval = 60000
'ClassLogger.Add("Timer - Intervall: " & clsSQLITE.konf_intervall & " Minuten", False)
Timer_Durchlauf.Enabled = True
Logger.Debug("Timer gestartet")
' Und den Durchlauf das erste Mal starten
' '### Den Timer generieren
Dim Timer_Durchlauf As New System.Timers.Timer()
'Das Event hinterlegen welches bei "Tick" ausgelöst wird
AddHandler Timer_Durchlauf.Elapsed, AddressOf Thread_Run
' Set the Interval
Timer_Durchlauf.Interval = 60000
Timer_Durchlauf.Enabled = True
Logger.Debug("Timer gestartet")
' Und den Durchlauf das erste Mal starten
DDWDResultHandler.threadPMRefresh = New BackgroundWorker()
DDWDResultHandler.threadPMRefresh.WorkerReportsProgress = True
DDWDResultHandler.threadPMRefresh.WorkerSupportsCancellation = True
AddHandler threadPMRefresh.DoWork, AddressOf RUNPMRefresh
AddHandler threadPMRefresh.RunWorkerCompleted, AddressOf ThreadPMRefresh_Completed
DDWDResultHandler.threadPMRefresh = New BackgroundWorker()
DDWDResultHandler.threadPMRefresh.WorkerReportsProgress = True
DDWDResultHandler.threadPMRefresh.WorkerSupportsCancellation = True
AddHandler threadPMRefresh.DoWork, AddressOf RUNPMRefresh
AddHandler threadPMRefresh.RunWorkerCompleted, AddressOf ThreadPMRefresh_Completed
' '### Den Timer generieren
Dim TimerPMRefresh As New System.Timers.Timer()
'Das Event hinterlegen welches bei "Tick" ausgelöst wird
AddHandler TimerPMRefresh.Elapsed, AddressOf ThreadPMRefreshRun
' '### Den Timer generieren
Dim TimerPMRefresh As New System.Timers.Timer()
'Das Event hinterlegen welches bei "Tick" ausgelöst wird
AddHandler TimerPMRefresh.Elapsed, AddressOf ThreadPMRefreshRun
' Und den Durchlauf das erste Mal starten
threadRunner.RunWorkerAsync()
' Set the Interval
TimerPMRefresh.Interval = 120000 '2 minutes
'ClassLogger.Add("Timer - Intervall: " & clsSQLITE.konf_intervall & " Minuten", False)
TimerPMRefresh.Enabled = True
' Set the Interval
TimerPMRefresh.Interval = 120000 '2 minutes
'ClassLogger.Add("Timer - Intervall: " & clsSQLITE.konf_intervall & " Minuten", False)
TimerPMRefresh.Enabled = True
'End If
If My.Settings.SQLSERVER_CS_RH = "" And My.Settings.SQLSERVER_CS_PMRefresh <> "" Then
Logger.Info("Thread PM Refresh will now be started for initial Run as Resulthandler's ConnString is empty...")
threadPMRefresh.RunWorkerAsync()
Else
If My.Settings.SQLSERVER_CS_RH <> "" Then
Logger.Info("Thread ResultHandler will now be started for initial Run..")
threadResultHandler.RunWorkerAsync()
Logger.Info("Thread PM Refresh will be started after 2mins for initial Run..")
End If
End If
Catch ex As Exception
EventLog.WriteEntry("DDWMResultHandler", "Unexpected error in OnStart: " & ex.ToString(), EventLogEntryType.Error)
Logger.Error(ex)
@@ -112,8 +107,8 @@ Public Class DDWDResultHandler
End Sub
Public Sub Thread_Run()
If Not threadRunner.IsBusy Then
threadRunner.RunWorkerAsync()
If Not threadResultHandler.IsBusy Then
threadResultHandler.RunWorkerAsync()
End If
End Sub
Public Sub ThreadPMRefreshRun()
@@ -127,20 +122,24 @@ Public Class DDWDResultHandler
Protected Overrides Sub OnStop()
Try
' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen.
Logger.Warn("WindreamResultHandler wurde gestoppt!")
'LoggerPMR.Warn("WindreamResultHandler has been stopped!")
_database.Execute_non_Query("Update TBWMRH_PROFIL SET Running = 1 WHERE GUID = " & _PROFIL_ID)
Logger.Info("WindreamResultHandler wurde gestoppt!")
Catch ex As Exception
EventLog.WriteEntry("DDWMResultHandler", "Unexpected error in OnStop: " & ex.ToString(), EventLogEntryType.Error)
End Try
End Sub
Public Sub RUN_THREAD(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
Public Sub RUN_RESULTHANDLER(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
Try
MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"))
Logger = MyLogger.GetLogger()
_database = New clsDatabase(MyLogger)
If My.Settings.SQLSERVER_CS_RH = "" Then
Logger.Debug("RESULT HANDLER ConString not configured... No Run")
Exit Sub
End If
Dim notcompleted As Boolean = False
'clsLogger.Init(My.Application.Info.DirectoryPath & "\Log", "_SERVICEResultHandler")
Logger.Debug("RUN_THREAD WMResulthandler started..")
@@ -148,9 +147,10 @@ Public Class DDWDResultHandler
_windream = New clsWindream_allgemein(MyLogger)
'windream initialisieren
If _windream.Init() = True Then
clsCURRENT.TEMP_FILES.Clear()
Logger.Debug("windream vollumfänglich initialisiert!")
'Zur sicherheit die DB nochmal initialiseren
If _database.Init(My.Settings.SQLSERVER_CS, True) = True Then
If _database.Init(My.Settings.SQLSERVER_CS_RH, True) = True Then
Dim DT As DataTable = _database.Return_Datatable("select * from TBWMRH_KONFIGURATION where GUID = 1")
If DT.Rows.Count = 1 Then
clsCURRENT.DT_TBWMRH_KONFIGURATION = DT
@@ -188,6 +188,17 @@ Public Class DDWDResultHandler
Logger.Info("Keine aktiven Profile WMResulthandler vorhanden")
notcompleted = True
End If
Try
For Each _file In clsCURRENT.TEMP_FILES
'Dim oFile As New FileInfo(_file)
'If (DateTime.UtcNow - oFile.CreationTimeUtc > TimeSpan.FromDays(1)) Then
System.IO.File.Delete(_file)
'End If
Next
Catch ex As Exception
End Try
_database.Execute_non_Query("UPDATE TBWMRH_KONFIGURATION SET LAST_TICK = GETDATE() WHERE GUID = 1")
If oFirstRun = True Then
oFirstRun = False
@@ -275,8 +286,8 @@ Public Class DDWDResultHandler
End Sub
Public Function Thread_Abbrechen()
Try
If DDWDResultHandler.threadRunner.IsBusy Then
DDWDResultHandler.threadRunner.CancelAsync()
If DDWDResultHandler.threadResultHandler.IsBusy Then
DDWDResultHandler.threadResultHandler.CancelAsync()
End If
Return True
Catch ex As Exception

View File

@@ -58,21 +58,32 @@ Namespace My
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_RENOLIT;Persist Security In"& _
"fo=True;User ID=sa;Password=dd")> _
Public ReadOnly Property SQLSERVER_CS() As String
Public ReadOnly Property SQLSERVER_CS_RH() As String
Get
Return CType(Me("SQLSERVER_CS"),String)
Return CType(Me("SQLSERVER_CS_RH"),String)
End Get
End Property
<Global.System.Configuration.ApplicationScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info="& _
"True;User ID=sa;Password=dd")> _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public ReadOnly Property SQLSERVER_CS_PMRefresh() As String
Get
Return CType(Me("SQLSERVER_CS_PMRefresh"),String)
End Get
End Property
<Global.System.Configuration.UserScopedSettingAttribute(), _
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
Global.System.Configuration.DefaultSettingValueAttribute("")> _
Public Property PMREFRESH_INTERVALL() As String
Get
Return CType(Me("PMREFRESH_INTERVALL"),String)
End Get
Set
Me("PMREFRESH_INTERVALL") = value
End Set
End Property
End Class
End Namespace

View File

@@ -2,11 +2,11 @@
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="My" GeneratedClassName="MySettings" UseMySettingsClassName="true">
<Profiles />
<Settings>
<Setting Name="SQLSERVER_CS" Type="System.String" Scope="Application">
<Setting Name="SQLSERVER_CS_RH" Type="System.String" Scope="Application">
<Value Profile="(Default)">Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_RENOLIT;Persist Security Info=True;User ID=sa;Password=dd</Value>
</Setting>
<Setting Name="SQLSERVER_CS_PMRefresh" Type="System.String" Scope="Application">
<Value Profile="(Default)">Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd</Value>
<Value Profile="(Default)" />
</Setting>
</Settings>
</SettingsFile>

View File

@@ -9,7 +9,7 @@ Public Class clsPMRefresh
Private oConfigschedule
Private oConfigIDXName_DocID
Private oConfigIDXName_Created
Private oConfigWMDrive
'Private oConfigWMDrive
Private oConfigLOGERRONLY As Boolean
Sub New(theLogger As LogConfig)
MyLogger = theLogger
@@ -31,7 +31,7 @@ Public Class clsPMRefresh
oConfigschedule = oDTPM_CONFIG.Rows(0).Item("SERVICE_SCHEDULE").ToString
oConfigIDXName_DocID = oDTPM_CONFIG.Rows(0).Item("SERVICE_IDXNAME_DOCID").ToString
oConfigIDXName_Created = oDTPM_CONFIG.Rows(0).Item("SERVICE_IDXNAME_CREATED").ToString
oConfigWMDrive = oDTPM_CONFIG.Rows(0).Item("SERVICE_WMDRIVE_LETTER").ToString
'oConfigWMDrive = oDTPM_CONFIG.Rows(0).Item("SERVICE_WMDRIVE_LETTER").ToString
oConfigLOGERRONLY = oDTPM_CONFIG.Rows(0).Item("SERVICE_LOG_ERRORS_ONLY")
Dim oSplit As String()
oSplit = oConfigschedule.Split(";")
@@ -125,7 +125,6 @@ Public Class clsPMRefresh
'---------------------- für jedes Profil die Dateien überprüfen ------------------------
For Each Profile_Row In oDTPROFILES.Rows
oStep = "4a"
Console.WriteLine(">> Dateien für Profil '" & Profile_Row.Item("NAME") & "' eintragen")
Logger.Debug("Add info for profile '" & Profile_Row.Item("NAME") & "'")
Dim oPROFILE_ID As Integer = Profile_Row.Item("GUID")
WD_Search = Nothing
@@ -139,6 +138,7 @@ Public Class clsPMRefresh
oStep = "4d"
Dim oDocCount As Integer = 0
If IsNothing(oDTWM_Results) Then
Logger.Warn("ATTENTION: oDTWM_Results is NOTHING")
Continue For
End If
'Die aktuellen Files auf refreshed = 0 setzten
@@ -151,7 +151,7 @@ Public Class clsPMRefresh
Dim Profil_Docs(oDTWM_Results.Rows.Count - 1, 2) As String
For Each oRow As DataRow In oDTWM_Results.Rows
Dim oDOC_ID = oRow.Item(0)
Dim oWMFilePath As String = oConfigWMDrive & ":" & oRow.Item(1)
Dim oWMFilePath As String = oRow.Item(1)
Profil_Docs(oDocCount, 0) = oRow.Item(0)
Profil_Docs(oDocCount, 1) = oWMFilePath
'------DMS Erstell-Datum holen --------
@@ -215,6 +215,8 @@ Public Class clsPMRefresh
Else
Logger.Warn("ATTENTION: Refresh could not be executed " & oSQLCommand)
End If
Else
Logger.Warn("ATTENTION: WM-Search is nothing.. ")
End If
Next
oStep = "4i"