|
|
|
|
@ -261,30 +261,33 @@ Public Class Service1
|
|
|
|
|
'''<param name="e"></param>
|
|
|
|
|
Private Sub OnFileEvent(ByVal source As Object, ByVal e As FileSystemEventArgs)
|
|
|
|
|
If EventStopped = True Then Exit Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If UCase(Microsoft.VisualBasic.Right(e.FullPath, 4)) = ".IND" Or UCase(Microsoft.VisualBasic.Right(e.FullPath, 4)) = ".XML" Then
|
|
|
|
|
FileWatch.EnableRaisingEvents = False
|
|
|
|
|
EventStopped = True
|
|
|
|
|
If UCase(Microsoft.VisualBasic.Right(e.FullPath, 4)) = ".XML" Then
|
|
|
|
|
IntSleep(1)
|
|
|
|
|
Rename(e.FullPath, e.FullPath + ".ind")
|
|
|
|
|
End If
|
|
|
|
|
PrintTempJournal("Fileevent raised: " + e.FullPath)
|
|
|
|
|
'IntSleep(Params.WaitAfterFileevent)
|
|
|
|
|
'If UCase(Microsoft.VisualBasic.Right(e.FullPath, 4)) = ".XML" Then
|
|
|
|
|
' IntSleep(Params.Wait_before_xmlind_ren)
|
|
|
|
|
' Rename(e.FullPath, e.FullPath + ".ind")
|
|
|
|
|
' PrintTempJournal("Fileevent Rename XML: " + e.FullPath + " -> " + e.FullPath + ".ind")
|
|
|
|
|
'End If
|
|
|
|
|
PrintOut("Neue Datei " + e.FullPath)
|
|
|
|
|
'ServiceIcon.Text = "Working..."
|
|
|
|
|
Verarbeiten()
|
|
|
|
|
' ServiceThread = New Thread(AddressOf Verarbeiten)
|
|
|
|
|
' ServiceThread.Start()
|
|
|
|
|
FileWatch.EnableRaisingEvents = True
|
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Sub OnFileEventRename(ByVal source As Object, ByVal e As RenamedEventArgs)
|
|
|
|
|
If Params.UseFileEventRename = False Then Exit Sub
|
|
|
|
|
If EventStopped = True Then Exit Sub
|
|
|
|
|
If UCase(Microsoft.VisualBasic.Right(e.FullPath, 4)) = ".IND" Then
|
|
|
|
|
FileWatch.EnableRaisingEvents = False
|
|
|
|
|
EventStopped = True
|
|
|
|
|
PrintOut("Neue Datei " + e.FullPath)
|
|
|
|
|
'20130131 - Sleep von 1000 auf 3000 geändert, damit bei FinFox-Dokumente die Verarbeitung nicht aussteigt, sofern die Datei noch nicht angeliefert wurde
|
|
|
|
|
Threading.Thread.CurrentThread.Sleep(3000)
|
|
|
|
|
IntSleep(3)
|
|
|
|
|
Verarbeiten()
|
|
|
|
|
FileWatch.EnableRaisingEvents = True
|
|
|
|
|
End If
|
|
|
|
|
@ -312,13 +315,6 @@ Public Class Service1
|
|
|
|
|
Private Function CompareFileInfos(file1 As FileInfo, file2 As FileInfo) As Integer
|
|
|
|
|
Dim result = 0
|
|
|
|
|
|
|
|
|
|
'Select Case nameDirection
|
|
|
|
|
' Case SortOrder.Ascending
|
|
|
|
|
' result = file1.Name.CompareTo(file2.Name)
|
|
|
|
|
' Case SortOrder.Descending
|
|
|
|
|
' result = file2.Name.CompareTo(file1.Name)
|
|
|
|
|
'End Select
|
|
|
|
|
|
|
|
|
|
If result = 0 Then
|
|
|
|
|
Select Case dateDirection
|
|
|
|
|
Case SortOrder.Ascending
|
|
|
|
|
@ -331,26 +327,32 @@ Public Class Service1
|
|
|
|
|
Return result
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Private Sub PrintTempJournal(s As String)
|
|
|
|
|
If Params.Logpath = "" Then Exit Sub
|
|
|
|
|
FileOpen(14, Params.Logpath, OpenMode.Append)
|
|
|
|
|
WriteLine(14, Now.ToString("yyyy-MM-dd hh:mm:ss:hs") + " " + s)
|
|
|
|
|
FileClose(14)
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Private Sub Verarbeiten()
|
|
|
|
|
Dim gsffilename As String = ""
|
|
|
|
|
Try
|
|
|
|
|
Printout("Bei Verarbeiten() zuerst 5000ms warten", EventLogEntryType.Information)
|
|
|
|
|
IntSleep(5)
|
|
|
|
|
'Thread.Sleep(5000) 'hallo, wieder aktivieren
|
|
|
|
|
|
|
|
|
|
'Dim bmp As New Bitmap(Me.ImageList1.Images(0))
|
|
|
|
|
'ServiceIcon.Icon = Icon.FromHandle(bmp.GetHicon())
|
|
|
|
|
'Printout("Bei Verarbeiten() zuerst 5000ms warten", EventLogEntryType.Information)
|
|
|
|
|
PrintTempJournal("Verarbeitung Wait before start " + Params.WaitBeforeProcess.ToString + " Sekunden")
|
|
|
|
|
IntSleep(Params.WaitBeforeProcess)
|
|
|
|
|
Dim looper As Boolean = True
|
|
|
|
|
While looper = True
|
|
|
|
|
'Alle .IND-Dateien im Verzeichnis auslesen
|
|
|
|
|
|
|
|
|
|
PrintTempJournal("Read Directory .ind")
|
|
|
|
|
Dim clsindex As New clsIndexData()
|
|
|
|
|
Dim di As New IO.DirectoryInfo(Watch_Directory)
|
|
|
|
|
IntSleep(2)
|
|
|
|
|
IntSleep(Params.Wait_before_readdir)
|
|
|
|
|
Dim diar1 As IO.FileInfo() = di.GetFiles("*.ind")
|
|
|
|
|
Dim dra As IO.FileInfo
|
|
|
|
|
Array.Sort(diar1, AddressOf CompareFileInfos)
|
|
|
|
|
If diar1.Length = 0 Then
|
|
|
|
|
PrintTempJournal("Read Directory .xml")
|
|
|
|
|
diar1 = di.GetFiles("*.xml")
|
|
|
|
|
Array.Sort(diar1, AddressOf CompareFileInfos)
|
|
|
|
|
If diar1.Length = 0 Then
|
|
|
|
|
@ -358,11 +360,8 @@ Public Class Service1
|
|
|
|
|
clsindex = Nothing
|
|
|
|
|
di = Nothing
|
|
|
|
|
diar1 = Nothing
|
|
|
|
|
'Globals.Journal.Delete_Entry()
|
|
|
|
|
'Dim bmp1 As New Bitmap(Me.ImageList1.Images(1))
|
|
|
|
|
'ServiceIcon.Icon = Icon.FromHandle(bmp1.GetHicon())
|
|
|
|
|
'ServiceIcon.Text = "Waiting..."
|
|
|
|
|
EventStopped = False
|
|
|
|
|
PrintTempJournal("----------------------------------------------")
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
@ -370,18 +369,22 @@ Public Class Service1
|
|
|
|
|
For Each dra In diar1
|
|
|
|
|
Dim fullname As String = ""
|
|
|
|
|
Globals.Fehlermeldung = ""
|
|
|
|
|
|
|
|
|
|
IntSleep(Params.Wait_Before_Fileprocess)
|
|
|
|
|
PrintTempJournal("Verarbeitung " + dra.FullName)
|
|
|
|
|
fullname = dra.FullName
|
|
|
|
|
If UCase(System.IO.Path.GetExtension(dra.Name)) = ".XML" Then
|
|
|
|
|
PrintTempJournal(" Rename " + dra.FullName + " -> " + dra.FullName + ".ind")
|
|
|
|
|
IntSleep(Params.Wait_before_xmlind_ren)
|
|
|
|
|
Rename(dra.FullName, dra.FullName + ".ind")
|
|
|
|
|
fullname = dra.FullName + ".ind"
|
|
|
|
|
'IntSleep(1)
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
gsffilename = dra.Name.Substring(0, dra.Name.IndexOf("."))
|
|
|
|
|
PrintTempJournal(" Journal " + fullname)
|
|
|
|
|
PrintOut("File: " + fullname)
|
|
|
|
|
Globals.Journal.Open_Journal()
|
|
|
|
|
Globals.Journal.Insert_Journal("", "", "", fullname, "", "Start der Verarbeitung", "", "")
|
|
|
|
|
|
|
|
|
|
DivFnkt.Save_Indexdata(Journal.JournalNr, fullname)
|
|
|
|
|
clsindex.IndexFileName = fullname
|
|
|
|
|
If clsindex.getindexdata Then
|
|
|
|
|
@ -393,20 +396,16 @@ Public Class Service1
|
|
|
|
|
Journal.Insert_Journal("", "", "", fullname, "16", "Zuordnung zur Herkunftsapplikation fehlt.", "", "")
|
|
|
|
|
Else
|
|
|
|
|
If check_and_import.Herkunftsapplikationen_auslesen Then
|
|
|
|
|
'Sofern die Herkunftsapplikation erruiert werden konnte, wird die Journaltabelle mit der Applikationsid nachgeführt
|
|
|
|
|
Globals.Journal.Update_Journal()
|
|
|
|
|
'PrintOut("test", EventLogEntryType.Error)
|
|
|
|
|
'Verarbeitung der Daten
|
|
|
|
|
check_and_import.CheckandImport()
|
|
|
|
|
check_and_import = Nothing
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Journal.Insert_Journal("", "", "", fullname, "", "Total Index-Datensätze: " + LTrim(Str(indexdata.Rows.Count)), "", "")
|
|
|
|
|
Journal.Insert_Journal("", "", "", fullname, "", "Verarbeitung abgeschlossen.", "", "")
|
|
|
|
|
Try
|
|
|
|
|
'20200509_Keine Logdatei erstellen
|
|
|
|
|
'Logdatei_Erstellen()
|
|
|
|
|
Catch
|
|
|
|
|
End Try
|
|
|
|
|
Try
|
|
|
|
|
@ -432,8 +431,8 @@ Public Class Service1
|
|
|
|
|
IntSleep(3)
|
|
|
|
|
End If
|
|
|
|
|
PrintOut("Ende File: " + fullname)
|
|
|
|
|
|
|
|
|
|
IntSleep(5)
|
|
|
|
|
PrintTempJournal(" Abschluss " + fullname)
|
|
|
|
|
IntSleep(Params.wait_After_Fileprocess)
|
|
|
|
|
If Fehler <> 0 Then
|
|
|
|
|
send_error_mail()
|
|
|
|
|
End If
|
|
|
|
|
@ -467,6 +466,7 @@ Public Class Service1
|
|
|
|
|
End While
|
|
|
|
|
FileWatch.EnableRaisingEvents = True
|
|
|
|
|
EventStopped = False
|
|
|
|
|
PrintTempJournal("----------------------------------------------")
|
|
|
|
|
Exit Sub
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
Try
|
|
|
|
|
|