MS JObs
This commit is contained in:
parent
2304214073
commit
0a7cdaa903
@ -117,20 +117,20 @@ Public Class ThreadRunner
|
||||
If Not IsNothing(_mssql) Then
|
||||
'Checking if documents have bee´n rejected
|
||||
Dim oSQL As String = "Select * from TBEDMI_DOC_REJECTED WHERE MD5_UPDATE = 0"
|
||||
Dim oDT As DataTable = _mssql.GetDatatable(oSQL)
|
||||
If Not IsNothing(oDT) Then
|
||||
For Each oRow As DataRow In oDT.Rows
|
||||
oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET REJECTED = TRUE WHERE MESSAGE_ID = '{oRow.Item("MESSAGE_ID")}'"
|
||||
If _firebird.ExecuteNonQuery(oSQL) = True Then
|
||||
oSQL = $"UPDATE TBEDMI_DOC_REJECTED SET MD5_UPDATE = 1 WHERE GUID = '{oRow.Item("GUID")}'"
|
||||
If _mssql.ExecuteNonQuery(oSQL) = True Then
|
||||
_logger.Debug($"Refreshed the Rejected Info for messageid [{oRow.Item("MESSAGE_ID")}]")
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
_logger.Warn("oDTTBEDMI_DOC_REJECTED is nothing...")
|
||||
End If
|
||||
'Dim oDT As DataTable = _mssql.GetDatatable(oSQL)
|
||||
'If Not IsNothing(oDT) Then
|
||||
' For Each oRow As DataRow In oDT.Rows
|
||||
' oSQL = $"UPDATE TBEDM_ZUGFERD_HISTORY_IN SET REJECTED = TRUE WHERE MESSAGE_ID = '{oRow.Item("MESSAGE_ID")}'"
|
||||
' If _firebird.ExecuteNonQuery(oSQL) = True Then
|
||||
' oSQL = $"UPDATE TBEDMI_DOC_REJECTED SET MD5_UPDATE = 1 WHERE GUID = '{oRow.Item("GUID")}'"
|
||||
' If _mssql.ExecuteNonQuery(oSQL) = True Then
|
||||
' _logger.Debug($"Refreshed the Rejected Info for messageid [{oRow.Item("MESSAGE_ID")}]")
|
||||
' End If
|
||||
' End If
|
||||
' Next
|
||||
'Else
|
||||
' _logger.Warn("oDTTBEDMI_DOC_REJECTED is nothing...")
|
||||
'End If
|
||||
End If
|
||||
Dim job As New ImportZUGFeRDFiles(_logConfig, _firebird, _mssql)
|
||||
job.Start(args)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Form3
|
||||
Private _frm4 As Form4
|
||||
Public FilePath As String
|
||||
Private Key As String
|
||||
Private LogConfig As LogConfig
|
||||
@ -14,6 +15,7 @@ Public Class Form3
|
||||
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
||||
Me.LogConfig = LogConfig
|
||||
Me.Key = Key
|
||||
_frm4 = New Form4(LogConfig, Key)
|
||||
End Sub
|
||||
|
||||
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
@ -32,9 +34,14 @@ Public Class Form3
|
||||
|
||||
DocumentViewer1.Done()
|
||||
Logger.Info("Form closing")
|
||||
_frm4.Close()
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Form3_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
_frm4.FilePath = FilePath
|
||||
_frm4.Show()
|
||||
|
||||
End Sub
|
||||
End Class
|
||||
@ -53,7 +53,8 @@
|
||||
<Reference Include="GdPicture.NET.14">
|
||||
<HintPath>D:\ProgramFiles\GdPicture.NET 14\Redist\GdPicture.NET (.NET Framework 4.5)\GdPicture.NET.14.dll</HintPath>
|
||||
</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>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
||||
@ -205,8 +205,8 @@ Public Class Firebird
|
||||
oCommand.ExecuteNonQuery()
|
||||
_Logger.Debug("Command executed!")
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: '{SqlCommand}'")
|
||||
_Logger.Warn($"Unexpected error in ExecuteNonQueryWithConnection: '{SqlCommand}'")
|
||||
_Logger.Error(ex, $"Error in ExecuteNonQuery while executing command: [{SqlCommand}]")
|
||||
_Logger.Warn($"Unexpected error in ExecuteNonQueryWithConnection: [{SqlCommand}]")
|
||||
Throw ex
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@ -253,7 +253,7 @@ Public Class Firebird
|
||||
}
|
||||
oResult = oCommand.ExecuteScalar()
|
||||
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
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
@ -304,7 +304,7 @@ Public Class Firebird
|
||||
oAdapter.Fill(oDatatable)
|
||||
Catch ex As Exception
|
||||
_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
|
||||
Finally
|
||||
MaybeCommitTransaction(oTransaction, TransactionMode)
|
||||
|
||||
@ -25,12 +25,10 @@ Public Class ImportZUGFeRDFiles
|
||||
Public Const ZUGFERD_ATTACHMENTS = "ZUGFeRD Attachments"
|
||||
Public HISTORY_ID As Integer
|
||||
|
||||
Private Const EMAIL_WRAPPING_TEXT = """
|
||||
<html><body style='font-family:""Arial"";font-size:10.0pt'>Sehr geehrte Damen und Herren,<br>
|
||||
Private Const EMAIL_WRAPPING_TEXT = "<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
|
||||
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_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/>"
|
||||
@ -196,7 +194,7 @@ Public Class ImportZUGFeRDFiles
|
||||
If oDTResult.Rows.Count = 0 Then
|
||||
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 &= $"({oJobId}, '{oReference}', {oAccountId}, '{oEmailTo}', '{oSubject}', '{oFinalBodyText}', '{oCreatedWho}', '{oAttachment}')"
|
||||
oSQLInsert &= $"({oJobId}, '{oReference}', {oAccountId}, '{oEmailTo}', '{oSubject}', '{oFinalBodyText.Replace("'", "''")}', '{oCreatedWho}', '{oAttachment}')"
|
||||
_firebird.ExecuteNonQuery(oSQLInsert)
|
||||
_logger.Debug("Email Queue updated for MessageId {0}.", MessageId, oEmailTo)
|
||||
Else
|
||||
@ -235,39 +233,43 @@ Public Class ImportZUGFeRDFiles
|
||||
_logger.Debug("To: {0}", oEmailTo)
|
||||
_logger.Debug("Subject: {0}", oSubject)
|
||||
_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)
|
||||
|
||||
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
|
||||
Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] ([REMINDER_TYPE_ID],[SENDING_PROFILE],
|
||||
If IsNumeric(oHistoryID) Then
|
||||
Dim oInsert = $"INSERT INTO [dbo].[TBEMLP_EMAIL_OUT] (
|
||||
[REMINDER_TYPE_ID]
|
||||
,[SENDING_PROFILE]
|
||||
,[REFERENCE_ID]
|
||||
,[REFERENCE_STRING]
|
||||
,[WF_ID]
|
||||
,[EMAIL_ADRESS]
|
||||
,[EMAIL_SUBJ]
|
||||
,[EMAIL_BODY]
|
||||
,[COMMENT]
|
||||
,[ADDED_WHO])
|
||||
VALUES
|
||||
(99
|
||||
(77
|
||||
,{oAccountId}
|
||||
,{oHistoryID}
|
||||
,'{MessageId}'
|
||||
,77
|
||||
,'{oEmailTo}'
|
||||
,'{oSubject}'
|
||||
,'{oFinalBodyText}'
|
||||
,'{SourceProcedure}'
|
||||
,'{oCreatedWho}'"
|
||||
,'{oCreatedWho}')"
|
||||
_mssql.ExecuteNonQuery(oInsert)
|
||||
Else
|
||||
If oDTResult.Rows.Count = 0 Then
|
||||
_logger.Debug("Email has already been sent!!")
|
||||
Else
|
||||
_logger.Debug("Could not get oHistoryID!!")
|
||||
End If
|
||||
'If oDTResult.Rows.Count = 0 Then
|
||||
' _logger.Debug("Email has already been sent!!")
|
||||
'Else
|
||||
_logger.Warn("Could not get oHistoryID in AddToEmailQueueMSSQL!!")
|
||||
' End If
|
||||
End If
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
@ -317,13 +319,13 @@ Public Class ImportZUGFeRDFiles
|
||||
Dim oArgs As WorkerArgs = Arguments
|
||||
Dim oPropertyExtractor = New PropertyValues(_logConfig)
|
||||
|
||||
_logger.Info("Starting Job {0}", [GetType].Name)
|
||||
_logger.Debug("Starting Job {0}", [GetType].Name)
|
||||
|
||||
Try
|
||||
For Each oPath As String In oArgs.WatchDirectories
|
||||
Dim oDirInfo As New DirectoryInfo(oPath)
|
||||
|
||||
_logger.Info($"Start processing directory {oDirInfo.FullName}")
|
||||
_logger.Debug($"Start processing directory {oDirInfo.FullName}")
|
||||
|
||||
If oDirInfo.Exists Then
|
||||
' Filter out *.lock files
|
||||
@ -335,7 +337,7 @@ Public Class ImportZUGFeRDFiles
|
||||
Dim oCurrentFileCount = 0
|
||||
|
||||
If oFileCount = 0 Then
|
||||
_logger.Info("No files to process.")
|
||||
_logger.Debug("No files to process.")
|
||||
Continue For
|
||||
Else
|
||||
_logger.Info("Found {0} files", oFileCount)
|
||||
@ -713,7 +715,7 @@ Public Class ImportZUGFeRDFiles
|
||||
End If
|
||||
Next
|
||||
|
||||
_logger.Info("Finishing Job {0}", Me.GetType.Name)
|
||||
_logger.Debug("Finishing Job {0}", Me.GetType.Name)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
_logger.Info("Job Failed! See error log for details")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user