Initial
This commit is contained in:
991
Service1.vb
Normal file
991
Service1.vb
Normal file
@@ -0,0 +1,991 @@
|
||||
Imports System.ServiceProcess
|
||||
Imports System.Threading
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports System.IO.File
|
||||
Imports System.Data.SqlClient
|
||||
Imports System.Data.SqlTypes
|
||||
Imports System.ComponentModel
|
||||
Imports System
|
||||
Imports System.SystemException
|
||||
Imports System.Web.Mail
|
||||
Imports System.Timers
|
||||
Imports System.Collections.Generic
|
||||
|
||||
'''<summary></summary>
|
||||
Public Class Service1
|
||||
Inherits System.ServiceProcess.ServiceBase
|
||||
|
||||
#Region " Vom Component Designer generierter Code "
|
||||
|
||||
Public Sub New()
|
||||
MyBase.New()
|
||||
|
||||
' Dieser Aufruf wird vom Komponenten-Designer benötigt.
|
||||
InitializeComponent()
|
||||
|
||||
|
||||
' Fügen Sie Initialisierungscode hinter dem InitializeComponent()-Aufruf ein
|
||||
|
||||
End Sub
|
||||
|
||||
'UserService überschreibt den Löschvorgang zum Bereinigen der Komponentenliste.
|
||||
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
If disposing Then
|
||||
If Not (components Is Nothing) Then
|
||||
components.Dispose()
|
||||
End If
|
||||
End If
|
||||
MyBase.Dispose(disposing)
|
||||
End Sub
|
||||
|
||||
' Der Haupteinstiegspunkt für den Vorgang
|
||||
<MTAThread()>
|
||||
Shared Sub Main()
|
||||
|
||||
#If CONFIG = "Release" Then
|
||||
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
||||
ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()}
|
||||
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
||||
#Else
|
||||
|
||||
Dim myServ As New Service1
|
||||
myServ.OnStart({""})
|
||||
While (True)
|
||||
System.Threading.Thread.Sleep(2000)
|
||||
End While
|
||||
#End If
|
||||
'#If DEBUG Then
|
||||
' Dim myServ As New Service1()
|
||||
' myServ.OnStart({""})
|
||||
' While (True)
|
||||
' System.Threading.Thread.Sleep(2000)
|
||||
' End While
|
||||
|
||||
'#Else
|
||||
' Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
||||
' ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()}
|
||||
' System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
||||
'#End If
|
||||
|
||||
'Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
||||
|
||||
'ServicesToRun = New System.ServiceProcess.ServiceBase() {New Service1()}
|
||||
|
||||
'System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
' Für Komponenten-Designer erforderlich
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
' HINWEIS: Die folgende Prozedur wird vom Komponenten-Designer benötigt.
|
||||
' Sie kann mit dem Komponenten-Designer modifiziert werden. Verwenden Sie nicht
|
||||
' den Code-Editor zur Bearbeitung.
|
||||
'Friend WithEvents ServiceIcon As System.Windows.Forms.NotifyIcon
|
||||
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
|
||||
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
|
||||
Me.components = New System.ComponentModel.Container()
|
||||
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Service1))
|
||||
'Me.ServiceIcon = New System.Windows.Forms.NotifyIcon(Me.components)
|
||||
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
|
||||
'
|
||||
'ServiceIcon
|
||||
'
|
||||
'Me.ServiceIcon.Icon = CType(resources.GetObject("ServiceIcon.Icon"), System.Drawing.Icon)
|
||||
'Me.ServiceIcon.Text = "EDKB08WS"
|
||||
'Me.ServiceIcon.Visible = True
|
||||
'
|
||||
'ImageList1
|
||||
'
|
||||
Me.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit
|
||||
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)
|
||||
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
|
||||
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
|
||||
'
|
||||
'Service1
|
||||
'
|
||||
Me.ServiceName = "Service1"
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Deklarationen"
|
||||
Private StopThread As Boolean = False
|
||||
'''<summary>Variable mit dem Namen des zu überwachenden Verzeichnises</summary>
|
||||
Dim Watch_Directory As String
|
||||
'''<summary>FileSystemWatcher</summary>
|
||||
'''<remarks>Dieser Reagiert auf das Ereignis OnCreate im angegebenen Verzeichnis
|
||||
'''(Watch_Directory)</remarks>
|
||||
Dim FileWatch As New FileSystemWatcher()
|
||||
|
||||
'''<summary>Varaible zum Zwischenspeichern der Indexdaten einer
|
||||
'''Indexdaten-Datei</summary>
|
||||
Dim indexdata As DataTable
|
||||
|
||||
'''<summary>Timer zur Auslösung der täglichen Journalaufbereitung</summary>
|
||||
Dim WithEvents JournalTimer As New Timers.Timer()
|
||||
|
||||
'Anpassungen GSF
|
||||
Dim WithEvents GSF_Timer As New Timers.Timer()
|
||||
|
||||
Dim WithEvents DirectoryTimer As New Timers.Timer()
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Hauptverarbeitung"
|
||||
|
||||
'''<summary>Start des Dienstes EDKB08WS</summary>
|
||||
'''<remarks>Beim Start des Dienstes werden neben dem Einlesen der Parameter der
|
||||
'''Journaltimer sowie der Systemfilewatcher zur Verzeichnisüberwachung
|
||||
'''initialisiert.</remarks>
|
||||
'''<param name="args"></param>
|
||||
Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
Try
|
||||
'Dim bmp As New Bitmap(Me.ImageList1.Images(2))
|
||||
'ServiceIcon.Icon = Icon.FromHandle(bmp.GetHicon())
|
||||
'ServiceIcon.Visible = True
|
||||
'ServiceIcon.Text = "Starting ..."
|
||||
|
||||
PrintOut("Start EDKB08")
|
||||
|
||||
'Parameter auslesen
|
||||
If Params.Loadparameters = False Then
|
||||
PrintOut(Params.Meldung)
|
||||
PrintOut("Verarbeitung abgebrochen")
|
||||
Exit Sub
|
||||
Else
|
||||
GSF_Timer.Interval = Params.Prop_gsf_TimerInterval
|
||||
#If CONFIG = "Release" Then
|
||||
|
||||
GSF_Timer.Enabled = GSF_Timer.Interval > 60000
|
||||
#Else
|
||||
GSF_Timer.Enabled = GSF_Timer.Interval > 60000
|
||||
#End If
|
||||
|
||||
DirectoryTimer.Interval = Params.DirectoryTimer_Intervall
|
||||
DirectoryTimer.Enabled = True
|
||||
Watch_Directory = Params.Inputverzeichnis
|
||||
PrintOut(Params.Meldung)
|
||||
PrintOut("Parameter:")
|
||||
PrintOut("Überwachtes Verzeichnis: " + Params.Inputverzeichnis)
|
||||
PrintOut("E-Mail OK: " + Params.MailAdresseOK)
|
||||
PrintOut("E-Mail NOK:" + Params.MailAdresseNOK)
|
||||
PrintOut("GSF_Timer:" + Params.Prop_gsf_TimerInterval.ToString)
|
||||
PrintOut("GSF_ConfigPath:" + Params.Prop_gsf_ConfigPath)
|
||||
End If
|
||||
'Datenbank initialisieren
|
||||
Dim db_conn As New edokadb.DB_Connection()
|
||||
JournalTimer.Interval = Params.JournalTimer_Time
|
||||
#If CONFIG = "Release" Then
|
||||
JournalTimer.Enabled = True
|
||||
|
||||
#Else
|
||||
Dim a As Integer = 1
|
||||
JournalTimer.Enabled = True
|
||||
#End If
|
||||
|
||||
|
||||
PrintOut("Journaltimer initialisiert. Eventhalndler alle " + LTrim(Str(JournalTimer.Interval / (1000 * 60))) + " Minuten")
|
||||
|
||||
'Verzeichnis-Überwachung initialisieren und starten
|
||||
If Not Init_Filewatcher() Then
|
||||
Printout("Verarbeitung gestoppt", EventLogEntryType.Error)
|
||||
End If
|
||||
If Not Start_Watching() Then
|
||||
Printout("Verarbeitung gestoppt", EventLogEntryType.Error)
|
||||
Exit Sub
|
||||
End If
|
||||
'Dim bmp1 As New Bitmap(Me.ImageList1.Images(1))
|
||||
'ServiceIcon.Icon = Icon.FromHandle(bmp1.GetHicon())
|
||||
'ServiceIcon.Text = "Waiting ..."
|
||||
Catch ex As Exception
|
||||
' Dim bmp1 As New Bitmap(Me.ImageList1.Images(2))
|
||||
'ServiceIcon.Icon = Icon.FromHandle(bmp1.GetHicon())
|
||||
Printout("Fehler beim Start von EDKB08" + ex.Message, EventLogEntryType.Error)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnStop()
|
||||
' Dim bmp1 As New Bitmap(Me.ImageList1.Images(2))
|
||||
'ServiceIcon.Icon = Icon.FromHandle(bmp1.GetHicon())
|
||||
'ServiceIcon.Text = "Stopping..."
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "FileWatcher"
|
||||
|
||||
'''<summary>Initialisierung des Filewacher-Objektes</summary>
|
||||
'''<remarks>Das Filewacher-Objekt wird mit den entpsrechenden Pfad- sowie
|
||||
'''Dateifilter-Angaben initialisiert.</remarks>
|
||||
Private Function Init_Filewatcher() As Boolean
|
||||
Try
|
||||
FileWatch.Path = Watch_Directory
|
||||
FileWatch.IncludeSubdirectories = False
|
||||
FileWatch.Filter = "*.*"
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Printout("Fehler bei der Initialisierung des Filewacherobjekts auf " + Watch_Directory + ex.Message, EventLogEntryType.Error)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'''<summary>Eventhandler des FileWatching-Objektes aktivieren</summary>
|
||||
Private Function Start_Watching() As Boolean
|
||||
Try
|
||||
AddHandler FileWatch.Created, New FileSystemEventHandler(AddressOf OnFileEvent)
|
||||
AddHandler FileWatch.Renamed, AddressOf OnFileEventRename
|
||||
FileWatch.EnableRaisingEvents = True
|
||||
PrintOut("Filewatch Event-Handler initialisiert: " + Me.Watch_Directory)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Printout("Fehler bei der Event-Initialisierung " + ex.Message, EventLogEntryType.Error)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Dim EventStopped As Boolean = False
|
||||
'''<summary>Aktivitäten im Inputverzeichnis verarbeiten</summary>
|
||||
'''<remarks>Wird eine Datei mit der Endung .IND angeliefert, wird der Eventhandler
|
||||
'''gestoppt und die anstehenden Dokumente verarbeitet.
|
||||
'''
|
||||
'''Nach abgeschlossener Verarbeitung wird der Eventhandler wieder
|
||||
'''eingeschaltet</remarks>
|
||||
'''<param name="source"></param>
|
||||
'''<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
|
||||
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)
|
||||
Verarbeiten()
|
||||
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
|
||||
IntSleep(3)
|
||||
Verarbeiten()
|
||||
FileWatch.EnableRaisingEvents = True
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Verarbeitung"
|
||||
|
||||
'''<summary>Verarbeiten von angelieferten Daten</summary>
|
||||
'''<remarks>In dieser Methode werden angelieferte Indexdateien verarbeitet.
|
||||
'''<para></para>
|
||||
'''<para>Bevor die Verarbeitung startet, wird der Systemfilewacher
|
||||
'''ausgeschaltet.</para>
|
||||
'''<para>Die Verarbeitung wird solange durchgeführt, bis alle anstehenden
|
||||
'''Indexdaten und Dokumente abgearbeitet sind.</para>
|
||||
'''<para>Am Schluss der Verarbeitung wird der Systemfilewacher wieder
|
||||
'''gestartet.</para></remarks>
|
||||
'''
|
||||
'''
|
||||
Private nameDirection As SortOrder = SortOrder.Ascending
|
||||
Private dateDirection As SortOrder = SortOrder.Ascending
|
||||
Private Function CompareFileInfos(file1 As FileInfo, file2 As FileInfo) As Integer
|
||||
Dim result = 0
|
||||
|
||||
If result = 0 Then
|
||||
Select Case dateDirection
|
||||
Case SortOrder.Ascending
|
||||
result = file1.LastWriteTime.CompareTo(file2.LastWriteTime)
|
||||
Case SortOrder.Descending
|
||||
result = file2.LastWriteTime.CompareTo(file1.LastWriteTime)
|
||||
End Select
|
||||
End If
|
||||
|
||||
Return result
|
||||
End Function
|
||||
|
||||
Private Sub PrintTempJournal(s As String)
|
||||
If Params.Logpath = "" Then Exit Sub
|
||||
Dim fn As String = Params.Logpath + "\" + Now.ToString("yyyyMMdd") + "_log.txt"
|
||||
FileOpen(14, fn, 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)
|
||||
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(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
|
||||
looper = False
|
||||
clsindex = Nothing
|
||||
di = Nothing
|
||||
diar1 = Nothing
|
||||
EventStopped = False
|
||||
PrintTempJournal("----------------------------------------------")
|
||||
Exit Sub
|
||||
End If
|
||||
End If
|
||||
Try
|
||||
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"
|
||||
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
|
||||
indexdata = clsindex.Indexdata
|
||||
Dim check_and_import As New clsCheckandImport()
|
||||
check_and_import.IndexData = indexdata
|
||||
|
||||
If check_and_import.Herkunftsapplikationen_auslesen = False Then
|
||||
Journal.Insert_Journal("", "", "", fullname, "16", "Zuordnung zur Herkunftsapplikation fehlt.", "", "")
|
||||
Else
|
||||
If check_and_import.Herkunftsapplikationen_auslesen Then
|
||||
Globals.Journal.Update_Journal()
|
||||
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
|
||||
Catch
|
||||
End Try
|
||||
Try
|
||||
PrintOut("Journal Close: " + fullname)
|
||||
Globals.Journal.Close_Journal()
|
||||
Catch
|
||||
End Try
|
||||
|
||||
'Anpassungen EBES-LSV
|
||||
If GSF = True Then
|
||||
IntSleep(1)
|
||||
Dim a As Integer
|
||||
|
||||
If Fehler <> 0 Then
|
||||
PrintOut("Dokstatus Fehler Start: " + fullname)
|
||||
OBJ_GSF.Set_DokStatus(dra.Name.Substring(0, dra.Name.IndexOf(".")), EDKB08_GSF.Common.Enum_DokStatus.OK)
|
||||
PrintOut("Dokstatus Fehler Ende: " + fullname)
|
||||
Else
|
||||
PrintOut("Dokstatus Start: " + fullname)
|
||||
OBJ_GSF.Set_DokStatus(dra.Name.Substring(0, dra.Name.IndexOf(".")), EDKB08_GSF.Common.Enum_DokStatus.OK)
|
||||
PrintOut("Dokstatus Ende: " + fullname)
|
||||
End If
|
||||
IntSleep(3)
|
||||
End If
|
||||
PrintOut("Ende File: " + fullname)
|
||||
PrintTempJournal(" Abschluss " + fullname)
|
||||
IntSleep(Params.wait_After_Fileprocess)
|
||||
If Fehler <> 0 Then
|
||||
send_error_mail()
|
||||
End If
|
||||
Next
|
||||
Catch ex As Exception
|
||||
Try
|
||||
Globals.Journal.Close_Journal()
|
||||
Catch
|
||||
End Try
|
||||
|
||||
Printout(ex.Message, EventLogEntryType.Error)
|
||||
clsindex = Nothing
|
||||
di = Nothing
|
||||
diar1 = Nothing
|
||||
End Try
|
||||
clsindex = Nothing
|
||||
di = Nothing
|
||||
diar1 = Nothing
|
||||
|
||||
'20151225
|
||||
Try
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
Catch
|
||||
End Try
|
||||
Try
|
||||
Globals.conn_journale.CloseConnection(True)
|
||||
Catch
|
||||
End Try
|
||||
|
||||
|
||||
End While
|
||||
FileWatch.EnableRaisingEvents = True
|
||||
EventStopped = False
|
||||
PrintTempJournal("----------------------------------------------")
|
||||
Exit Sub
|
||||
Catch ex As Exception
|
||||
Try
|
||||
Globals.conn_edoka.CloseConnection(True)
|
||||
Catch
|
||||
End Try
|
||||
Try
|
||||
Globals.conn_journale.CloseConnection(True)
|
||||
Catch
|
||||
End Try
|
||||
Fehler = -16
|
||||
Try
|
||||
Journal.Insert_Journal("", "", "", "", "-16", ex.Message + ex.StackTrace, "", "")
|
||||
Catch
|
||||
End Try
|
||||
Try
|
||||
Journal.Insert_Journal("", "", "", "", "", "Verarbeitung abgebrochen", "", "")
|
||||
Catch
|
||||
End Try
|
||||
Try
|
||||
Journal.Close_Journal()
|
||||
Catch
|
||||
|
||||
End Try
|
||||
|
||||
Try
|
||||
OBJ_GSF.Set_DokStatus(gsffilename, EDKB08_GSF.Common.Enum_DokStatus.FehlerEDKB08)
|
||||
Catch
|
||||
End Try
|
||||
|
||||
Printout("Folgender Fehler ist in EDKB08 aufgetreten:" + ex.Message, EventLogEntryType.Error)
|
||||
FileWatch.EnableRaisingEvents = True
|
||||
'Dim bmp1 As New Bitmap(Me.ImageList1.Images(1))
|
||||
'ServiceIcon.Icon = Icon.FromHandle(bmp1.GetHicon())
|
||||
'ServiceIcon.Text = "Waiting ..."
|
||||
EventStopped = False
|
||||
End Try
|
||||
End Sub
|
||||
Sub send_error_mail()
|
||||
Dim subject As String
|
||||
Dim body As String
|
||||
subject = "EDKB08-Dokumentimport mit Fehlern " + Globals.Herkunftsapplikation.Rows(0).Item(1)
|
||||
body = "Fehler EDOKB08:" + vbCrLf + vbCrLf
|
||||
body = body + "Applikation: " + Globals.Herkunftsapplikation.Rows(0).Item(1).ToString + vbCrLf
|
||||
body = body + "Journal-Nr: " + Journal.JournalNr.ToString + vbCrLf + vbCrLf
|
||||
body = body + "Fehlermeldung: " + vbCrLf
|
||||
body = body + Globals.Fehlermeldung
|
||||
If Globals.Herkunftsapplikation.Rows(0).Item("Mail_Empfaneger").ToString = "" Then Exit Sub
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand
|
||||
scmCmdToExecute.CommandText = "dbo.SP_SendMail"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
Dim dtToReturn As DataTable = New DataTable
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@email", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Globals.Herkunftsapplikation.Rows(0).Item("Mail_Empfaneger").ToString))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@betreff", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, subject))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@meldung", SqlDbType.VarChar, 1024, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, body))
|
||||
scmCmdToExecute.Connection = conn_edoka.scoDBConnection
|
||||
Try
|
||||
conn_edoka.OpenConnection()
|
||||
Catch
|
||||
End Try
|
||||
Try
|
||||
scmCmdToExecute.ExecuteNonQuery()
|
||||
Catch ex As Exception
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
conn_edoka.CloseConnection(True)
|
||||
End Try
|
||||
End Sub
|
||||
Public Sub IntSleep(Seconds As Integer)
|
||||
Dim sleeptime As DateTime
|
||||
sleeptime = DateAdd(DateInterval.Second, Seconds, Now)
|
||||
While Now < sleeptime
|
||||
Thread.Sleep(10)
|
||||
End While
|
||||
|
||||
End Sub
|
||||
'''<summary>Journaldatei erstellen und je nach Applikationseinstellungen
|
||||
'''versenden</summary>
|
||||
'''<remarks>Erstellt eine Journaldatei mit den Journaldaten der Verarbeitung und
|
||||
'''sendet diese mittels Mail bzw. mittls DTO weiter</remarks>
|
||||
Private Sub Logdatei_Erstellen()
|
||||
Dim filename As String = ""
|
||||
Try
|
||||
If Globals.Herkunftsapplikation.Rows(0).Item("log_erstellung") <> 1 And Globals.Herkunftsapplikation.Rows(0).Item("log_erstellung") <> 2 Then Exit Sub
|
||||
If Globals.Herkunftsapplikation.Rows(0).Item("log_erstellung") = 1 And Globals.Herkunftsapplikation.Rows(0).Item("Mail_Periodizitaet") = 0 Then
|
||||
filename = Journal.Print_Log(Globals.Herkunftsapplikation.Rows(0).Item(0), Globals.Herkunftsapplikation.Rows(0).Item(1), Globals.Herkunftsapplikation.Rows(0).Item("outputformat"))
|
||||
PrintOut("Aufruf Sendmail")
|
||||
Send_Mail(filename, Globals.Herkunftsapplikation.Rows(0).Item("Mail_Empfaneger"))
|
||||
End If
|
||||
If Globals.Herkunftsapplikation.Rows(0).Item("log_erstellung") = 2 Then
|
||||
filename = Journal.Print_Log(Globals.Herkunftsapplikation.Rows(0).Item(0), Globals.Herkunftsapplikation.Rows(0).Item(1), Globals.Herkunftsapplikation.Rows(0).Item("outputformat"))
|
||||
Send_DTO(filename)
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Journal.Insert_Journal("", "", "", filename, "-16", "Das Journal " + filename + " konnte nicht erstellt werden." + ex.Message, "", "")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
'''<summary>DTO-Versand</summary>
|
||||
'''<param name="filename"></param>
|
||||
Private Function Send_DTO(ByVal filename As String) As Boolean
|
||||
Try
|
||||
Dim i As Integer
|
||||
Dim tw As TextWriter
|
||||
Dim s As String
|
||||
s = Herkunftsapplikation.Rows(0).Item(3)
|
||||
s = s.Replace("%1", filename)
|
||||
s = s.Replace("%2", filename)
|
||||
tw = New StreamWriter(New FileStream(Params.TempPfad + "dtotransfer.cmd", FileMode.Create))
|
||||
tw.WriteLine(s)
|
||||
tw.Flush()
|
||||
tw.Close()
|
||||
i = Microsoft.VisualBasic.Shell(Params.TempPfad + "dtotransfer.cmd", AppWinStyle.Hide, True)
|
||||
If i <> 0 Then
|
||||
Journal.Insert_Journal("", "", "", filename, "0", "DTO-Datei konnte nicht übermittelt werden. RC: " + LTrim(Str(i)), "", "")
|
||||
Else
|
||||
Journal.Insert_Journal("", "", "", filename, "0", "DTO-Datei konnte nicht übermittelt werden. RC: " + LTrim(Str(i)), "", "")
|
||||
End If
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Fehler = 4
|
||||
Journal.Insert_Journal("", "", "", filename, "-16", "DTO-Datei konnte nicht übermittelt werden. " + ex.Message, "", "")
|
||||
'PrintOut("Der Journalversand mittls DTO ist fehlgeschlagen. " + ex.Message, EventLogEntryType.Warning)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
'''<summary>Versand von Journaldaten mittels Email</summary>
|
||||
'''<param name="filename"></param>
|
||||
'''<param name="empfaenger"></param>
|
||||
Private Function Send_Mail(ByVal filename As String, ByVal empfaenger As String) As Boolean
|
||||
'Sofern ein SMTP-Server angegeben wird, wird vie SMTP Versendet
|
||||
If Params.Mailserver <> "" Then
|
||||
|
||||
Dim strArgs() As String = Command.Split(",")
|
||||
Dim blnSMTP As Boolean = False
|
||||
Dim blnCC As Boolean = False
|
||||
Dim blnAttachments As Boolean = False
|
||||
Try
|
||||
Dim insMail As New System.Net.Mail.MailMessage(Params.Mailabsender, empfaenger)
|
||||
With insMail
|
||||
.Subject = "EDKB08-Journal"
|
||||
'.BodyEndoding = System.Text.Encoding.Unicode
|
||||
.Body = "Dieses Email wurde automatisch von EDKB08 erstellt"
|
||||
' .Attachments.Add(New MailAttachment(filename))
|
||||
End With
|
||||
Dim myMail As New System.Net.Mail.SmtpClient
|
||||
myMail.Host = Params.Mailserver
|
||||
myMail.Send(insMail)
|
||||
''PrintOut("Journal erfolgreich versandt.", EventLogEntryType.Information)
|
||||
Journal.Insert_Journal("", "", "", filename, "0", "E-Mail mit Journal versandt.", "", "")
|
||||
Catch ex As Exception
|
||||
Fehler = 4
|
||||
Journal.Insert_Journal("", "", "", filename, "-10", "E-Mail konnte nicht versandt werden. " + ex.Message, "", "")
|
||||
'PrintOut("Journal konnte nicht versandt werden." + ex.Message, EventLogEntryType.Error)
|
||||
Return False
|
||||
End Try
|
||||
Else
|
||||
If Save_Report_To_DB(filename) Then
|
||||
If Fehler = 0 Then
|
||||
send_db_mail(empfaenger, "EDKB08-Dokumentimport erfolgreich: " + filename.Substring(filename.LastIndexOf("\") + 1), filename)
|
||||
Else
|
||||
send_db_mail(empfaenger, "EDKB08-Dokumentimport mit Fehlern: " + filename.Substring(filename.LastIndexOf("\") + 1), filename)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Function
|
||||
|
||||
Private Function send_db_mail(ByVal empfaenger As String, ByVal Subject As String, ByVal filename As String) As Boolean
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_send_mail"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn_journale_Mail.scoDBConnection
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@empfaenger", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, empfaenger))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@betreff", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Subject))
|
||||
filename = filename.Substring(filename.LastIndexOf("\") + 1)
|
||||
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@filename", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, filename))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@jobnr", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, Journal.JournalNr))
|
||||
scmCmdToExecute.Parameters.Add(New SqlParameter("@errorcode", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 9))
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
If scmCmdToExecute.Parameters("@errorcode").Value <> 0 Then
|
||||
'Journal.Insert_Journal("", "", "", filename, "20", "Mail konnte nicht versandt werden. " + scmCmdToExecute.Parameters("@errorcode").Value, "", "")
|
||||
PrintLog("Mail konnte nicht versandt werden. " + scmCmdToExecute.Parameters("@errorcode").Value, EventLogEntryType.Warning)
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
'Journal.Insert_Journal("", "", "", filename, "20", "Mail konnte nicht versandt werden." + ex.Message, "", "")
|
||||
PrintLog("Mail konnte nicht versandt werden." + ex.Message, EventLogEntryType.Warning)
|
||||
Return False
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
dtToReturn.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function Save_Report_To_DB(ByVal Filename As String) As Boolean
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From import_journaldatei where import_jobnr=" + Journal.JournalNr.ToString, connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Try
|
||||
'Connectionstring zur Datenbank
|
||||
connection.ConnectionString = Globals.sConnectionString_journale
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim fs As New FileStream(Filename, FileMode.Open, FileAccess.Read)
|
||||
Dim mydata(fs.Length) As Byte
|
||||
fs.Read(mydata, 0, fs.Length)
|
||||
fs.Close()
|
||||
Dim myRow As DataRow
|
||||
If ds.Tables(0).Rows.Count = 0 Then
|
||||
' Neues Dokument speichern
|
||||
myRow = ds.Tables(0).NewRow
|
||||
myRow.Item(0) = Journal.JournalNr
|
||||
myRow.Item(1) = mydata
|
||||
ds.Tables(0).Rows.Add(myRow)
|
||||
da.Update(ds, "docs")
|
||||
Else
|
||||
'Bestehendes Dokument sichenr
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
myRow.Item(1) = mydata
|
||||
da.Update(ds, "docs")
|
||||
End If
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
File.Delete(Filename)
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Journal.Insert_Journal("", "", "", Filename, "20", "Das Journal konnte nicht auf der Datenbank gespeichert werden." + vbNewLine + ex.Message, "", "")
|
||||
Return False
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
End Function
|
||||
|
||||
|
||||
|
||||
#End Region
|
||||
|
||||
#Region "Journaltimer Funktionen"
|
||||
|
||||
Public Sub JournalTimer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles JournalTimer.Elapsed
|
||||
If EventStopped = True Then Exit Sub
|
||||
Dim restartdok As New DataTable()
|
||||
Dim restartjob As New DataTable()
|
||||
restartdok = get_restartdok()
|
||||
restartjob = get_restartjob()
|
||||
Me.JournalTimer.Enabled = False
|
||||
Dim i As Integer
|
||||
Me.FileWatch.EnableRaisingEvents = False
|
||||
For i = 0 To restartdok.Rows.Count - 1
|
||||
Write_Restartfiles(restartdok.Rows(i).Item(0))
|
||||
Next
|
||||
For i = 0 To restartjob.Rows.Count - 1
|
||||
Write_Restartjobfiles(restartjob.Rows(i).Item(0))
|
||||
Next
|
||||
If restartdok.Rows.Count <> 0 Or restartjob.Rows.Count <> 0 Then
|
||||
Verarbeiten()
|
||||
End If
|
||||
'20120905 - SHU - Wenn IND-Dateien im Input-Verzeichnis vorhanden sind, diese verarbeiten
|
||||
Dim di As New IO.DirectoryInfo(Watch_Directory)
|
||||
Dim diar1 As IO.FileInfo() = di.GetFiles("*.ind")
|
||||
If diar1.Length > 0 Then Verarbeiten()
|
||||
restartjob.Dispose()
|
||||
restartdok.Dispose()
|
||||
|
||||
If Now.Hour > 0 And Now.Hour < 1 Then
|
||||
Dim filename As String
|
||||
Dim dt As DataTable
|
||||
PrintOut("Start Tägliche Journalerstellung")
|
||||
dt = get_applikationen()
|
||||
For i = 0 To dt.Rows.Count - 1
|
||||
filename = Journal.Print_Log_Batch(dt.Rows(i).Item(0), dt.Rows(i).Item(1), dt.Rows(i).Item(2))
|
||||
Send_Mail(filename, dt.Rows(i).Item(3))
|
||||
PrintOut(dt.Rows(i).Item(1) + ": " + "Journal gesendet")
|
||||
Next
|
||||
End If
|
||||
Me.JournalTimer.Enabled = True
|
||||
Me.FileWatch.EnableRaisingEvents = True
|
||||
End Sub
|
||||
|
||||
Private Sub Write_Restartfiles(ByVal itemid As Integer)
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From import_daten where import_data_nr=" + LTrim(Str(itemid)), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
Dim Dokumentfilename As String
|
||||
Dim XMLFilename As String
|
||||
Dim xmlstring As String
|
||||
Dim xmlds As New DataSet()
|
||||
|
||||
Try
|
||||
'Connectionstring zur Datenbank
|
||||
connection.ConnectionString = Globals.sConnectionString_journale
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
xmlstring = ds.Tables(0).Rows(0).Item(3)
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
|
||||
'Indexfile schreiben
|
||||
XMLFilename = Params.Inputverzeichnis + LTrim(Str(itemid)) + "_" + Format(Now, "yyyyMMddHHmmss") + ".ind"
|
||||
FileOpen(11, XMLFilename, OpenMode.Output)
|
||||
PrintLine(11, xmlstring)
|
||||
FileClose(11)
|
||||
xmlds.ReadXml(XMLFilename)
|
||||
Dokumentfilename = Params.Inputverzeichnis + xmlds.Tables(0).Rows(0).Item(12)
|
||||
xmlds.Dispose()
|
||||
'Dokumentdatei schreiben
|
||||
Dim MyData() As Byte
|
||||
MyData = myRow.Item(4)
|
||||
Dim K As Long
|
||||
K = UBound(MyData)
|
||||
Dim fs As New FileStream(Dokumentfilename, FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(MyData, 0, K)
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
Catch ex As Exception
|
||||
FileClose(11)
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
End Sub
|
||||
|
||||
Private Sub Write_Restartjobfiles(ByVal itemid As Integer)
|
||||
Dim connection As New SqlConnection()
|
||||
Dim da As New SqlDataAdapter("Select * From import_job where import_jobnr=" + LTrim(Str(itemid)), connection)
|
||||
Dim CB As SqlCommandBuilder = New SqlCommandBuilder(da)
|
||||
Dim ds As New DataSet()
|
||||
|
||||
Try
|
||||
'Connectionstring zur Datenbank
|
||||
connection.ConnectionString = Globals.sConnectionString_journale
|
||||
connection.Open()
|
||||
da.Fill(ds, "docs")
|
||||
Dim myRow As DataRow
|
||||
myRow = ds.Tables(0).Rows(0)
|
||||
|
||||
Dim MyData() As Byte
|
||||
MyData = myRow.Item(7)
|
||||
Dim K As Long
|
||||
K = UBound(MyData)
|
||||
Dim fs As New FileStream(Params.Inputverzeichnis + LTrim(Str(itemid)) + "_" + Format(Now, "yyyyMMddHHmmss") + ".ind", FileMode.OpenOrCreate, FileAccess.Write)
|
||||
fs.Write(MyData, 0, K)
|
||||
fs.Close()
|
||||
fs = Nothing
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
CB = Nothing
|
||||
ds = Nothing
|
||||
da = Nothing
|
||||
connection.Close()
|
||||
connection = Nothing
|
||||
End Sub
|
||||
|
||||
'''<summary></summary>
|
||||
Private Function get_applikationen() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_edoka_import_get_journalprotag"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn_edoka.scoDBConnection
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
Printout("Tägliche Journalerstellung fehlgeschlagen. " + ex.Message, EventLogEntryType.Error)
|
||||
Return dtToReturn
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
dtToReturn.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function get_restartdok() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_get_restartdok"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn_journale.scoDBConnection
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
Printout("Auslesen von erneut zu ladenden Dokumenten ist fehlgeschlagen. " + ex.Message, EventLogEntryType.Error)
|
||||
Return dtToReturn
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
dtToReturn.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function get_restartjob() As DataTable
|
||||
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
||||
Dim dtToReturn As DataTable = New DataTable()
|
||||
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
||||
scmCmdToExecute.CommandText = "dbo.sp_get_restartjob"
|
||||
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
||||
scmCmdToExecute.Connection = conn_journale.scoDBConnection
|
||||
Try
|
||||
sdaAdapter.Fill(dtToReturn)
|
||||
Return dtToReturn
|
||||
Catch ex As Exception
|
||||
Printout("Auslesen von erneut zu ladenden Dokumenten ist fehlgeschlagen. " + ex.Message, EventLogEntryType.Error)
|
||||
Return dtToReturn
|
||||
Finally
|
||||
scmCmdToExecute.Dispose()
|
||||
sdaAdapter.Dispose()
|
||||
dtToReturn.Dispose()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
#End Region
|
||||
|
||||
|
||||
#Region "GSF"
|
||||
|
||||
Dim WithEvents OBJ_GSF As New EDKB08_GSF.Common()
|
||||
|
||||
'Anpassungen EBES-LSV'
|
||||
Dim GSF As Boolean
|
||||
|
||||
Public Sub GSF_Verarbeitung(ByVal Startverzeichnis As String) Handles OBJ_GSF.StartVerarbeitung
|
||||
Dim savewatch_directory As String
|
||||
Dim saveInputVerzeichnis As String
|
||||
saveInputVerzeichnis = Params.Inputverzeichnis
|
||||
savewatch_directory = Watch_Directory
|
||||
Try
|
||||
Params.Inputverzeichnis = Startverzeichnis
|
||||
Watch_Directory = Startverzeichnis
|
||||
|
||||
GSF = True
|
||||
GSF_Timer.Enabled = False
|
||||
EventStopped = True
|
||||
IntSleep(5)
|
||||
Verarbeiten()
|
||||
EventStopped = False
|
||||
GSF = False
|
||||
GSF_Timer.Enabled = GSF_Timer.Interval > 60000
|
||||
Catch
|
||||
Finally
|
||||
Params.Inputverzeichnis = saveInputVerzeichnis
|
||||
Watch_Directory = savewatch_directory
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub GSF_Timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles GSF_Timer.Elapsed
|
||||
PrintLog("GSF_Timer elapsed")
|
||||
PrintOut("Event_Stopped:" + EventStopped.ToString)
|
||||
If EventStopped Then Exit Sub
|
||||
PrintLog("GSF_Timer elapsed")
|
||||
GSF_Timer.Enabled = False
|
||||
FileWatch.EnableRaisingEvents = False
|
||||
OBJ_GSF.Sub_Init(Params.Prop_gsf_ConfigPath, Params.Prop_gsf_ConfigDateiendung)
|
||||
OBJ_GSF.Start_Checking()
|
||||
OBJ_GSF.Sub_End()
|
||||
FileWatch.EnableRaisingEvents = True
|
||||
GSF_Timer.Enabled = GSF_Timer.Interval > 60000
|
||||
|
||||
'20201114 - Verarbeitung der während GSF-Verarbeitung angelieferten Daten
|
||||
DirectoryTimer_Elapsed(sender, e)
|
||||
'20201114 - Ende
|
||||
End Sub
|
||||
|
||||
Sub GSF_logging(ByVal logeintrag As String, ByVal itype As Integer) Handles OBJ_GSF.LogToBMS
|
||||
PrintOut(logeintrag + " " + itype.ToString)
|
||||
End Sub
|
||||
|
||||
Private Sub DirectoryTimer_Elapsed(sender As Object, e As ElapsedEventArgs) Handles DirectoryTimer.Elapsed
|
||||
PrintOut("Event_Stopped:" + EventStopped.ToString)
|
||||
If EventStopped Then Exit Sub
|
||||
GSF_Timer.Enabled = False
|
||||
FileWatch.EnableRaisingEvents = False
|
||||
FileOpen(99, Params.Directoryscanner, OpenMode.Input)
|
||||
While Not EOF(99)
|
||||
Dim s As String
|
||||
Input(99, s)
|
||||
Copyfiles(s, Params.Inputverzeichnis)
|
||||
End While
|
||||
Verarbeiten()
|
||||
FileClose(99)
|
||||
FileWatch.EnableRaisingEvents = True
|
||||
GSF_Timer.Enabled = GSF_Timer.Interval > 60000
|
||||
End Sub
|
||||
|
||||
Sub Copyfiles(inputdir As String, outputdir As String)
|
||||
Dim destextension As String
|
||||
For Each fi As FileInfo In New DirectoryInfo(inputdir).GetFiles
|
||||
If UCase(fi.Extension) = ".XML" Then
|
||||
destextension = ".ind"
|
||||
Else
|
||||
destextension = fi.Extension
|
||||
End If
|
||||
Try
|
||||
File.Move(fi.FullName, outputdir + "\" + Path.GetFileNameWithoutExtension(fi.Name) + destextension)
|
||||
Catch
|
||||
End Try
|
||||
|
||||
Next
|
||||
End Sub
|
||||
#End Region
|
||||
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user