This commit is contained in:
SchreiberM 2020-01-09 14:47:13 +01:00
parent 2304214073
commit 0a7cdaa903
5 changed files with 50 additions and 40 deletions

View File

@ -117,20 +117,20 @@ Public Class ThreadRunner
If Not IsNothing(_mssql) Then If Not IsNothing(_mssql) Then
'Checking if documents have bee´n rejected 'Checking if documents have bee´n rejected
Dim oSQL As String = "Select * from TBEDMI_DOC_REJECTED WHERE MD5_UPDATE = 0" Dim oSQL As String = "Select * from TBEDMI_DOC_REJECTED WHERE MD5_UPDATE = 0"
Dim oDT As DataTable = _mssql.GetDatatable(oSQL) 'Dim oDT As DataTable = _mssql.GetDatatable(oSQL)
If Not IsNothing(oDT) Then 'If Not IsNothing(oDT) Then
For Each oRow As DataRow In oDT.Rows ' For Each oRow As DataRow In oDT.Rows
oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET REJECTED = TRUE WHERE MESSAGE_ID = '{oRow.Item("MESSAGE_ID")}'" ' oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET REJECTED = TRUE WHERE MESSAGE_ID = '{oRow.Item("MESSAGE_ID")}'"
If _firebird.ExecuteNonQuery(oSQL) = True Then ' If _firebird.ExecuteNonQuery(oSQL) = True Then
oSQL = $"UPDATE TBEDMI_DOC_REJECTED SET MD5_UPDATE = 1 WHERE GUID = '{oRow.Item("GUID")}'" ' oSQL = $"UPDATE TBEDMI_DOC_REJECTED SET MD5_UPDATE = 1 WHERE GUID = '{oRow.Item("GUID")}'"
If _mssql.ExecuteNonQuery(oSQL) = True Then ' If _mssql.ExecuteNonQuery(oSQL) = True Then
_logger.Debug($"Refreshed the Rejected Info for messageid [{oRow.Item("MESSAGE_ID")}]") ' _logger.Debug($"Refreshed the Rejected Info for messageid [{oRow.Item("MESSAGE_ID")}]")
End If ' End If
End If ' End If
Next ' Next
Else 'Else
_logger.Warn("oDTTBEDMI_DOC_REJECTED is nothing...") ' _logger.Warn("oDTTBEDMI_DOC_REJECTED is nothing...")
End If 'End If
End If End If
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql) Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql)
job.Start(args) job.Start(args)

View File

@ -2,6 +2,7 @@
Imports DigitalData.Modules.Logging Imports DigitalData.Modules.Logging
Public Class Form3 Public Class Form3
Private _frm4 As Form4
Public FilePath As String Public FilePath As String
Private Key As String Private Key As String
Private LogConfig As LogConfig Private LogConfig As LogConfig
@ -14,6 +15,7 @@ Public Class Form3
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
Me.LogConfig = LogConfig Me.LogConfig = LogConfig
Me.Key = Key Me.Key = Key
_frm4 = New Form4(LogConfig, Key)
End Sub End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
@ -32,9 +34,14 @@ Public Class Form3
DocumentViewer1.Done() DocumentViewer1.Done()
Logger.Info("Form closing") Logger.Info("Form closing")
_frm4.Close()
End Sub End Sub
Private Sub Form3_Shown(sender As Object, e As EventArgs) Handles Me.Shown
_frm4.FilePath = FilePath
_frm4.Show()
End Sub
End Class End Class

View File

@ -53,7 +53,8 @@
<Reference Include="GdPicture.NET.14"> <Reference Include="GdPicture.NET.14">
<HintPath>D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll</HintPath> <HintPath>D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll</HintPath>
</Reference> </Reference>
<Reference Include="Independentsoft.Msg"> <Reference Include="Independentsoft.Msg, Version=2.0.570.21482, Culture=neutral, PublicKeyToken=76be97fe952f1ec7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>P:\Visual Studio Projekte\Bibliotheken\MSG .NET\Bin\14_11_19_MIME_UTF_ENCODING\Independentsoft.Msg.dll</HintPath> <HintPath>P:\Visual Studio Projekte\Bibliotheken\MSG .NET\Bin\14_11_19_MIME_UTF_ENCODING\Independentsoft.Msg.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -205,8 +205,8 @@ Public Class Firebird
oCommand.ExecuteNonQuery() oCommand.ExecuteNonQuery()
_Logger.Debug("Command executed!") _Logger.Debug("Command executed!")
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: '{SqlCommand}'") _Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: [{SqlCommand}]")
_Logger.Warn($"Unexpected error in ExecuteNonQueryWithConnection: '{SqlCommand}'") _Logger.Warn($"Unexpected error in ExecuteNonQueryWithConnection: [{SqlCommand}]")
Throw ex Throw ex
Finally Finally
MaybeCommitTransaction(oTransaction, TransactionMode) MaybeCommitTransaction(oTransaction, TransactionMode)
@ -253,7 +253,7 @@ Public Class Firebird
} }
oResult = oCommand.ExecuteScalar() oResult = oCommand.ExecuteScalar()
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex, $"Error in ReturnScalar while executing command: '{SqlQuery}'") _Logger.Error(ex, $"Error in ReturnScalar while executing command: [{SqlQuery}]")
Throw ex Throw ex
Finally Finally
MaybeCommitTransaction(oTransaction, TransactionMode) MaybeCommitTransaction(oTransaction, TransactionMode)
@ -304,7 +304,7 @@ Public Class Firebird
oAdapter.Fill(oDatatable) oAdapter.Fill(oDatatable)
Catch ex As Exception Catch ex As Exception
_Logger.Error(ex) _Logger.Error(ex)
_Logger.Warn("Error in GetDatatableWithConnection while executing command: '{0}'", SqlQuery) _Logger.Warn("Error in GetDatatableWithConnection while executing command: [{0}]", SqlQuery)
Throw ex Throw ex
Finally Finally
MaybeCommitTransaction(oTransaction, TransactionMode) MaybeCommitTransaction(oTransaction, TransactionMode)

View File

@ -25,12 +25,10 @@ Public Class ImportZUGFeRDFiles
Public Const ZUGFERD_ATTACHMENTS = "ZUGFeRD Attachments" Public Const ZUGFERD_ATTACHMENTS = "ZUGFeRD Attachments"
Public HISTORY_ID As Integer Public HISTORY_ID As Integer
Private Const EMAIL_WRAPPING_TEXT = """ Private Const EMAIL_WRAPPING_TEXT = "<html><body style=''font-family:""Arial"";font-size:10.0pt''>Sehr geehrte Damen und Herren,<br>
<html><body style='font-family:""Arial"";font-size:10.0pt'>Sehr geehrte Damen und Herren,<br>
das WISAG-Portal zur Verarbeitung der Eingangsrechnungen im ZUGFeRD-Format konnte die von Ihnen gesandte Rechnung das WISAG-Portal zur Verarbeitung der Eingangsrechnungen im ZUGFeRD-Format konnte die von Ihnen gesandte Rechnung
leider nicht verarbeiten! <br><br> Grund: {0}<p>Bitte prüfen Sie die Datei und nehmen Sie bei Bedarf mit uns Kontakt auf.<p> leider nicht verarbeiten! <br><br> Grund: {0}<p>Bitte prüfen Sie die Datei und nehmen Sie bei Bedarf mit uns Kontakt auf.<p>
Vielen Dank für Ihr Verständnis.<br>Mit freundlichen Grüßen<br>Ihre IT-Abteilung</body></html> Vielen Dank für Ihr Verständnis.<br>Mit freundlichen Grüßen<br>Ihre IT-Abteilung</body></html>"
"""
Private Const EMAIL_SUBJECT = "WISAG ZUGFeRD Portal: Beleg abgelehnt" Private Const EMAIL_SUBJECT = "WISAG ZUGFeRD Portal: Beleg abgelehnt"
Private Const EMAIL_MISSINGPROPERTIES_1 = "<p>Die angehängte Datei entspricht nicht dem WISAG ZUGFeRD-Format: {0}</p>" Private Const EMAIL_MISSINGPROPERTIES_1 = "<p>Die angehängte Datei entspricht nicht dem WISAG ZUGFeRD-Format: {0}</p>"
Private Const EMAIL_MISSINGPROPERTIES_2 = "<p>Die folgenden Eigenschaften wurden als ERFORDERLICH eingestuft, wurden aber nicht gefunden:<p/>" Private Const EMAIL_MISSINGPROPERTIES_2 = "<p>Die folgenden Eigenschaften wurden als ERFORDERLICH eingestuft, wurden aber nicht gefunden:<p/>"
@ -196,7 +194,7 @@ Public Class ImportZUGFeRDFiles
If oDTResult.Rows.Count = 0 Then If oDTResult.Rows.Count = 0 Then
Dim oSQLInsert = $"INSERT INTO TBEDM_EMAIL_QUEUE " Dim oSQLInsert = $"INSERT INTO TBEDM_EMAIL_QUEUE "
oSQLInsert &= "(JOB_ID, REFERENCE1, EMAIL_ACCOUNT_ID, EMAIL_TO, EMAIL_SUBJ, EMAIL_BODY, CREATEDWHO, EMAIL_ATTMT1) VALUES " oSQLInsert &= "(JOB_ID, REFERENCE1, EMAIL_ACCOUNT_ID, EMAIL_TO, EMAIL_SUBJ, EMAIL_BODY, CREATEDWHO, EMAIL_ATTMT1) VALUES "
oSQLInsert &= $"({oJobId}, '{oReference}', {oAccountId}, '{oEmailTo}', '{oSubject}', '{oFinalBodyText}', '{oCreatedWho}', '{oAttachment}')" oSQLInsert &= $"({oJobId}, '{oReference}', {oAccountId}, '{oEmailTo}', '{oSubject}', '{oFinalBodyText.Replace("'", "''")}', '{oCreatedWho}', '{oAttachment}')"
_firebird.ExecuteNonQuery(oSQLInsert) _firebird.ExecuteNonQuery(oSQLInsert)
_logger.Debug("Email Queue updated for MessageId {0}.", MessageId, oEmailTo) _logger.Debug("Email Queue updated for MessageId {0}.", MessageId, oEmailTo)
Else Else
@ -235,39 +233,43 @@ Public Class ImportZUGFeRDFiles
_logger.Debug("To: {0}", oEmailTo) _logger.Debug("To: {0}", oEmailTo)
_logger.Debug("Subject: {0}", oSubject) _logger.Debug("Subject: {0}", oSubject)
_logger.Debug("Body {0}", oFinalBodyText) _logger.Debug("Body {0}", oFinalBodyText)
Dim osql = $"Select MAX(GUID) FROM TBEMLP_HSITORY WHERE EMAIL_MSG_ID = '{MessageId}'" Dim osql = $"Select MAX(GUID) FROM TBEMLP_HISTORY WHERE EMAIL_MSGID = '{MessageId}'"
Dim oHistoryID = _mssql.GetScalarValue(osql) Dim oHistoryID = _mssql.GetScalarValue(osql)
osql = $"select * from TBEDM_EMAIL_QUEUE where REFERENCE_ID = {oHistoryID} and EMAIL_ADRESS = '{oEmailTo}' and EMAIL_SUBJ = '{oSubject}'" 'osql = $"select * from TBEMLP_EMAIL_OUT where REFERENCE_ID = {oHistoryID} and EMAIL_ADRESS = '{oEmailTo}' and EMAIL_SUBJ = '{oSubject}'"
Dim oDTResult As DataTable = _mssql.GetDatatable(osql) 'Dim oDTResult As DataTable = _mssql.GetDatatable(osql)
If IsNumeric(oHistoryID) And oDTResult.Rows.Count = 0 Then If IsNumeric(oHistoryID) Then
Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] ([REMINDER_TYPE_ID],[SENDING_PROFILE], Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] (
[REMINDER_TYPE_ID]
,[SENDING_PROFILE]
,[REFERENCE_ID] ,[REFERENCE_ID]
,[REFERENCE_STRING] ,[REFERENCE_STRING]
,[WF_ID]
,[EMAIL_ADRESS] ,[EMAIL_ADRESS]
,[EMAIL_SUBJ] ,[EMAIL_SUBJ]
,[EMAIL_BODY] ,[EMAIL_BODY]
,[COMMENT] ,[COMMENT]
,[ADDED_WHO]) ,[ADDED_WHO])
VALUES VALUES
(99 (77
,{oAccountId} ,{oAccountId}
,{oHistoryID} ,{oHistoryID}
,'{MessageId}' ,'{MessageId}'
,77
,'{oEmailTo}' ,'{oEmailTo}'
,'{oSubject}' ,'{oSubject}'
,'{oFinalBodyText}' ,'{oFinalBodyText}'
,'{SourceProcedure}' ,'{SourceProcedure}'
,'{oCreatedWho}'" ,'{oCreatedWho}')"
_mssql.ExecuteNonQuery(oInsert) _mssql.ExecuteNonQuery(oInsert)
Else Else
If oDTResult.Rows.Count = 0 Then 'If oDTResult.Rows.Count = 0 Then
_logger.Debug("Email has already been sent!!") ' _logger.Debug("Email has already been sent!!")
Else 'Else
_logger.Debug("Could not get oHistoryID!!") _logger.Warn("Could not get oHistoryID in AddToEmailQueueMSSQL!!")
End If ' End If
End If End If
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
@ -317,13 +319,13 @@ Public Class ImportZUGFeRDFiles
Dim oArgs As WorkerArgs = Arguments Dim oArgs As WorkerArgs = Arguments
Dim oPropertyExtractor = New PropertyValues(_logConfig) Dim oPropertyExtractor = New PropertyValues(_logConfig)
_logger.Info("Starting Job {0}", [GetType].Name) _logger.Debug("Starting Job {0}", [GetType].Name)
Try Try
For Each oPath As String In oArgs.WatchDirectories For Each oPath As String In oArgs.WatchDirectories
Dim oDirInfo As New DirectoryInfo(oPath) Dim oDirInfo As New DirectoryInfo(oPath)
_logger.Info($"Start processing directory {oDirInfo.FullName}") _logger.Debug($"Start processing directory {oDirInfo.FullName}")
If oDirInfo.Exists Then If oDirInfo.Exists Then
' Filter out *.lock files ' Filter out *.lock files
@ -335,7 +337,7 @@ Public Class ImportZUGFeRDFiles
Dim oCurrentFileCount = 0 Dim oCurrentFileCount = 0
If oFileCount = 0 Then If oFileCount = 0 Then
_logger.Info("No files to process.") _logger.Debug("No files to process.")
Continue For Continue For
Else Else
_logger.Info("Found {0} files", oFileCount) _logger.Info("Found {0} files", oFileCount)
@ -713,7 +715,7 @@ Public Class ImportZUGFeRDFiles
End If End If
Next Next
_logger.Info("Finishing Job {0}", Me.GetType.Name) _logger.Debug("Finishing Job {0}", Me.GetType.Name)
Catch ex As Exception Catch ex As Exception
_logger.Error(ex) _logger.Error(ex)
_logger.Info("Job Failed! See error log for details") _logger.Info("Job Failed! See error log for details")