You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
267 lines
11 KiB
267 lines
11 KiB
Option Explicit On
|
|
|
|
Imports System.Data.SqlClient
|
|
Imports System.Data.SqlTypes
|
|
Imports System.IO
|
|
|
|
|
|
'''<summary>Funktionen für die Journalisierung der einzelnen
|
|
'''Verarbeitungsschritte</summary>
|
|
Public Class clsJournal
|
|
|
|
#Region "Deklarationen"
|
|
'''<summary>Interne Variable für das Property JournalNr</summary>
|
|
Dim m_Journalnr As Integer
|
|
|
|
'''<summary>Property für die JournalNr</summary>
|
|
Property JournalNr() As Integer
|
|
Get
|
|
Return m_Journalnr
|
|
End Get
|
|
Set(ByVal Value As Integer)
|
|
m_Journalnr = Value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
'''<summary>Variable für die Datenbankklasse clsImport_Job</summary>
|
|
Dim Journal As New edokadb.clsImport_Job()
|
|
'''<summary>Variable für die Datenbankklasse clsimport_eintrag</summary>
|
|
Dim Journaleintrag As New edokadb.clsImport_Eintrag()
|
|
|
|
'''<summary>Interne Variable für das halten einer Datentabelle</summary>
|
|
Dim tmptbl As New DataTable()
|
|
|
|
#End Region
|
|
|
|
#Region "öffentliche Methoden"
|
|
'''<summary>Öffnet ein neuer Journaleintrag in der Tabelle Import_Job</summary>
|
|
'''<remarks>Für jede Indexdatei wird in der Verarbeitung ein neues Journal mit den
|
|
'''entsprechenden Einträgen erstellt</remarks>
|
|
'''<seealso cref="Main.Verarbeiten">Verarbeiten</seealso>
|
|
Public Function Open_Journal() As Boolean
|
|
Try
|
|
Journal.cpMainConnectionProvider = Globals.conn_journale
|
|
Journal.daStart_TS = New SqlDateTime(CType(Now, DateTime))
|
|
Journal.iFeherhaft = New SqlInt32(CType(0, Int32))
|
|
Journal.iJournal_Ausgeliefert = New SqlInt32(CType(0, Int32))
|
|
Try
|
|
Globals.conn_journale.OpenConnection()
|
|
Catch
|
|
End Try
|
|
|
|
Journal.Insert()
|
|
Try
|
|
Globals.conn_journale.CloseConnection(True)
|
|
Catch
|
|
End Try
|
|
|
|
Me.JournalNr = Journal.iImport_JobNr.Value
|
|
Journal.Dispose()
|
|
Catch
|
|
Try
|
|
Globals.conn_journale.CloseConnection(True)
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Try
|
|
|
|
End Function
|
|
|
|
'''<summary>Schliessen des aktuell geöffneten Verarbeitungsjournales</summary>
|
|
'''<remarks>Beim Abschluss eines Jobs wird der aktuelle Timestamp in der Tabelle
|
|
'''Import_Job nachgeführt</remarks>
|
|
'''<seealso cref="Main.Verarbeiten">Verarbeiten</seealso>
|
|
Public Function Close_Journal() As Boolean
|
|
Journal.cpMainConnectionProvider = Globals.conn_journale
|
|
Journal.iImport_JobNr = New SqlInt32(CType(Me.JournalNr, Int32))
|
|
Journal.SelectOne()
|
|
If Fehler <> 0 Then
|
|
Journal.iFeherhaft = New SqlInt32(CType(1, Integer))
|
|
End If
|
|
Journal.daEnde_TS = New SqlDateTime(CType(Now, DateTime))
|
|
Globals.conn_journale.OpenConnection()
|
|
Journal.Update()
|
|
Globals.conn_journale.CloseConnection(True)
|
|
End Function
|
|
|
|
'''<summary>Journaleintrag löschen</summary>
|
|
'''<remarks>Löscht den Journaleintrag aus der Variabel JournalNr</remarks>
|
|
Public Sub Delete_Entry()
|
|
Journal.cpMainConnectionProvider = Globals.conn_journale
|
|
Journal.iImport_JobNr = New SqlInt32(CType(Me.JournalNr, Int32))
|
|
Journal.SelectOne()
|
|
Journal.daEnde_TS = New SqlDateTime(CType(Now, DateTime))
|
|
Globals.conn_journale.OpenConnection()
|
|
Journal.Delete()
|
|
Globals.conn_journale.CloseConnection(True)
|
|
End Sub
|
|
'''<summary>Einfügen eines neuen Journaldatensatzes</summary>
|
|
'''<param name="RecNo">Recordnummer der Indexdaten bzw. "" für allgemeine
|
|
'''Journaleinträte</param>
|
|
'''<param name="Partnernr">Partnernr oder "" für allgemeine
|
|
'''Einträge</param>
|
|
'''<param name="dateityp">Dateityp der zu importierenden Datei bzw. ""
|
|
'''für allgemeine Einträge</param>
|
|
'''<param name="dateiname">Index-Dateiname oder Dateiname der zu importierenden
|
|
'''Datei</param>
|
|
'''<param name="Status">Status Nr</param>
|
|
'''<param name="Statustext">Bezeichnung zur Statusnr</param>
|
|
'''<param name="EDOKA_Dokumentid">Dokumentid des EDOKA-Dokumentes nach dem Import
|
|
'''oder ""</param>
|
|
'''<param name="Applikationnr">Fremdschlüssel zur Tabelle FA_APPL</param>
|
|
'''<seealso cref="edokadb.clsFA_APPL">edkb08.edokadb.clsFA_APPL</seealso>
|
|
Public Sub Insert_Journal(ByVal RecNo As String, ByVal Partnernr As String, ByVal dateityp As String, ByVal dateiname As String,
|
|
ByVal Status As String, ByVal Statustext As String, ByVal EDOKA_Dokumentid As String,
|
|
ByVal Applikationnr As String)
|
|
If Status <> "" And Status <> "0" Then
|
|
If Globals.Fehlermeldung <> "" Then Globals.Fehlermeldung = Globals.Fehlermeldung + vbCrLf
|
|
Globals.Fehlermeldung = Globals.Fehlermeldung + Statustext
|
|
End If
|
|
Me.Journaleintrag.cpMainConnectionProvider = Globals.conn_journale
|
|
Me.Journaleintrag.sRecordNo = New SqlString(CType(RecNo, String))
|
|
Me.Journaleintrag.sPartnernr = New SqlString(CType(Partnernr, String))
|
|
Me.Journaleintrag.sDateityp = New SqlString(CType(dateityp, String))
|
|
Me.Journaleintrag.sDateiname = New SqlString(CType(dateiname, String))
|
|
Me.Journaleintrag.sStatus = New SqlString(CType(Status, String))
|
|
Me.Journaleintrag.sStatustext = New SqlString(CType(Statustext, String))
|
|
Me.Journaleintrag.sEDOKA_Dokumentid = New SqlString(CType(EDOKA_Dokumentid, String))
|
|
Try
|
|
If Globals.Herkunftsapplikation.Rows.Count = 0 Then
|
|
Me.Journaleintrag.sApplikationsnr = New SqlString(CType(0, String))
|
|
Else
|
|
Me.Journaleintrag.sApplikationsnr = New SqlString(CType(Globals.Herkunftsapplikation.Rows(0).Item(0), String))
|
|
End If
|
|
Catch
|
|
Me.Journaleintrag.sApplikationsnr = New SqlString(CType(0, String))
|
|
End Try
|
|
Me.Journaleintrag.daTS = New SqlDateTime(CType(Now, DateTime))
|
|
Me.Journaleintrag.iImport_JobNr = New SqlInt32(CType(JournalNr, Int32))
|
|
Me.Journaleintrag.sEDOKA_Dokumenttyp = New SqlString(CType("", String))
|
|
If RecNo <> "" Then
|
|
Me.Journaleintrag.sIndexdaten = New SqlString(CType(get_indexdata(RecNo), String))
|
|
Else
|
|
Me.Journaleintrag.sIndexdaten = New SqlString(CType("", String))
|
|
End If
|
|
|
|
Globals.conn_journale.OpenConnection()
|
|
Me.Journaleintrag.Insert()
|
|
Globals.conn_journale.CloseConnection(True)
|
|
|
|
If Status <> "0" And Status <> "" Then
|
|
PrintLog(Str(Me.Journaleintrag.iImport_Eintragnr.Value) + " " + Status + " " + Statustext, EventLogEntryType.Error)
|
|
Else
|
|
PrintLog(Str(Me.Journaleintrag.iImport_Eintragnr.Value) + " " + Status + " " + Statustext, EventLogEntryType.Information)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function get_indexdata(ByVal Recno As Integer) As String
|
|
Try
|
|
Dim s As String = ""
|
|
Dim i As Integer
|
|
For i = 0 To Globals.temp_indexdaten.Columns.Count - 1
|
|
s = s + LTrim(Str(i + 1)) + ": " + Trim(Globals.temp_indexdaten.Rows(Recno).Item(i)) + " "
|
|
Next
|
|
Return s
|
|
Catch
|
|
Return ""
|
|
End Try
|
|
End Function
|
|
|
|
'''<summary>Ergänzt den Journaleintrag mit der zugehörenden
|
|
'''Herkunftsapplikation</summary>
|
|
'''<seealso cref="Globals.Herkunftsapplikation">edkb08.Globals</seealso>
|
|
Public Sub Update_Journal()
|
|
Try
|
|
Dim j As New edokadb.clsImport_Job()
|
|
j.iImport_JobNr = New SqlInt32(CType(Globals.Journal.JournalNr, Int32))
|
|
j.cpMainConnectionProvider = Globals.conn_journale
|
|
j.SelectOne()
|
|
j.iApplikationNr = New SqlInt32(CType(Globals.Herkunftsapplikation.Rows(0).Item(0), Int32))
|
|
Globals.conn_journale.OpenConnection()
|
|
j.Update()
|
|
Globals.conn_journale.CloseConnection(True)
|
|
Catch ex As Exception
|
|
PrintOut("clsJournal:Update_Journal:" + ex.Message + ex.StackTrace, EventLogEntryType.Error)
|
|
End Try
|
|
End Sub
|
|
|
|
#Region "Journal"
|
|
|
|
Public Function Print_Log(ByVal Applid As Integer, ByVal Applname As String, ByVal type As String) As String
|
|
Dim dt As New DataTable()
|
|
dt = Get_Journaldata(Applid)
|
|
Dim ds As New DataSet()
|
|
ds.Tables.Add(dt)
|
|
|
|
Dim x As New Export()
|
|
Return x.Create_Report(dt, UCase(type), Globals.Herkunftsapplikation.Rows(0).Item(1))
|
|
End Function
|
|
|
|
Public Function Print_Log_Batch(ByVal Applid As Integer, ByVal Applname As String, ByVal type As String) As String
|
|
Dim dt As New DataTable()
|
|
dt = Get_Journaldata(Applid)
|
|
Dim ds As New DataSet()
|
|
ds.Tables.Add(dt)
|
|
|
|
Dim x As New Export()
|
|
Return x.Create_Report(dt, UCase(type), Applname)
|
|
End Function
|
|
|
|
' Function table_to_csv(ByVal DT As DataTable) As String
|
|
' Dim zeile As String = ""
|
|
' Dim DR As DataRow
|
|
' Dim DC As DataColumn
|
|
|
|
' ' Spaltenüberschriften
|
|
' For Each DC In DT.Columns
|
|
' zeile += IIf(zeile <> "", ";", "").ToString
|
|
' zeile += DC.ColumnName
|
|
' Next
|
|
' table_to_csv += zeile & Chr(13)
|
|
|
|
' ' - Alle Zeillen ausgeben
|
|
' For Each DR In DT.Rows
|
|
' zeile = ""
|
|
' ' Schleife über alle Spalten
|
|
' For Each DC In DT.Columns
|
|
' zeile += IIf(zeile <> "", ";", "").ToString
|
|
' zeile += DR.Item(DC.ColumnName).ToString
|
|
|
|
' Next
|
|
' table_to_csv += zeile & Chr(13)
|
|
' Next
|
|
'End Function
|
|
|
|
Private Function Get_Journaldata(ByVal applid As Integer) As DataTable
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
scmCmdToExecute.CommandText = "import_journal"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
Dim dtToReturn As DataTable = New DataTable()
|
|
Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute)
|
|
Try
|
|
scmCmdToExecute.Connection = conn_journale.scoDBConnection
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@applid", SqlDbType.Int, 4, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, applid))
|
|
sdaAdapter.Fill(dtToReturn)
|
|
Return dtToReturn
|
|
Catch ex As Exception
|
|
Throw New Exception("Dokumenterstellung::Generic_Select::" & scmCmdToExecute.CommandText & "::Error occured." & ex.Message, ex)
|
|
Finally
|
|
scmCmdToExecute.Dispose()
|
|
sdaAdapter.Dispose()
|
|
End Try
|
|
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
|
|
|
|
End Class
|