MS Log erweitert
This commit is contained in:
parent
22bdb96d42
commit
418df6f817
@ -9,7 +9,7 @@
|
||||
<add name="EB_Creator.My.MySettings.MyConnectionString" connectionString="Data Source=SDD-VMP04-SQL17\DD_DEVELOP01;Initial Catalog=DD_ECM_TEST;Persist Security Info=True;User ID=sa;Password=dd" providerName="System.Data.SqlClient"/>
|
||||
</connectionStrings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
<applicationSettings>
|
||||
<EB_Creator.My.MySettings>
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<AssemblyName>EB_Creator</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Console</MyType>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
|
||||
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
|
||||
' indem Sie "*" wie unten gezeigt eingeben:
|
||||
' <Assembly: AssemblyVersion("1.0.*")>
|
||||
|
||||
<Assembly: AssemblyVersion("1.3.0.0")>
|
||||
<Assembly: AssemblyFileVersion("1.3.0.0")>
|
||||
<Assembly: AssemblyVersion("2.0.0.0")>
|
||||
<Assembly: AssemblyFileVersion("2.0.0.0")>
|
||||
|
||||
@ -7,6 +7,8 @@ Imports GdPicture14
|
||||
Imports System.Drawing
|
||||
Imports DigitalData.Modules.Windream
|
||||
Imports System.Threading
|
||||
Imports DevExpress.XtraRichEdit
|
||||
Imports DevExpress.Pdf.Native
|
||||
|
||||
Public Class MyService
|
||||
#Region "+++++ variables +++++"
|
||||
@ -113,14 +115,14 @@ Public Class MyService
|
||||
If Not _threadRunner1.IsBusy Then
|
||||
_threadRunner1.RunWorkerAsync()
|
||||
Else
|
||||
Logger.Info("##### THREAD 1 Is STILL RUNNING #####")
|
||||
Logger.Info("##### Thread 1 IsBusy #####")
|
||||
End If
|
||||
End Sub
|
||||
Public Sub Thread_Run2()
|
||||
If Not _threadRunner2.IsBusy Then
|
||||
_threadRunner2.RunWorkerAsync()
|
||||
Else
|
||||
Logger.Info("##### THREAD 2 Is STILL RUNNING #####")
|
||||
Logger.Info("##### Thread 2 IsBusy #####")
|
||||
End If
|
||||
End Sub
|
||||
Public Sub RUN_THREAD1(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
|
||||
@ -128,7 +130,7 @@ Public Class MyService
|
||||
If My.Computer.Clock.LocalTime.Hour <> 4 And My.Computer.Clock.LocalTime.Hour <> 5 Then
|
||||
Generator_Run("01", My.Settings.oSQLThread1)
|
||||
Else
|
||||
Logger.Debug($"In Sleep Mode 04-05h: {Now.ToString}")
|
||||
Logger.Debug($"In Sleep Mode 04-05h: {Now.ToString}")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
@ -147,6 +149,7 @@ Public Class MyService
|
||||
Logger.Info($"##### THREAD for Generator {GeneratorID} has [{oDTEB_Workload.Rows.Count}] results 2Bworked #####")
|
||||
For Each oRow As DataRow In oDTEB_Workload.Rows
|
||||
oDocID = oRow.Item(0).ToString
|
||||
Logger.Debug($"WORKING ON DOCID - {oDocID.ToString}")
|
||||
Try
|
||||
oOutputfilename = oRow.Item("Outputfilename").ToString
|
||||
Catch ex As Exception
|
||||
@ -195,7 +198,7 @@ Public Class MyService
|
||||
Dim oError = False
|
||||
If My.Settings.PROC_BEFORE_POS = True Then
|
||||
oSQL = $"EXEC PRCUST_CREATE_RPTERGEBNISBERICHT_POS {oDocID.ToString}"
|
||||
Logger.Debug($"Now executing [{oSQL}]")
|
||||
Logger.Debug($"DocID - {oDocID.ToString} Now executing [{oSQL}]")
|
||||
If MyDatabase.ExecuteNonQuery(oSQL, 500) = False Then
|
||||
Delete_EB2bCreated(oDocID)
|
||||
oError = True
|
||||
@ -206,11 +209,13 @@ Public Class MyService
|
||||
Dim oDTEB = MyDatabase.GetDatatable(oSQL)
|
||||
If oDTEB.Rows.Count > 0 Then
|
||||
Create_EB_Report(oDocID.ToString, GeneratorID, oOutputfilename, OutputFolder, oReRun)
|
||||
|
||||
Else
|
||||
Logger.Warn($"No EB-Rows [{oSQL}]")
|
||||
Logger.Warn($"DocID - {oDocID.ToString} - No EB-Rows [{oSQL}]")
|
||||
Delete_EB2bCreated(oDocID)
|
||||
End If
|
||||
End If
|
||||
Logger.Debug($"")
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
@ -235,7 +240,7 @@ Public Class MyService
|
||||
End Sub
|
||||
Protected Overrides Sub OnStop()
|
||||
' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen.
|
||||
Logger.Info("## Service has been stopped manually. ##")
|
||||
Logger.Info("## Service stopped manually. ##")
|
||||
Try
|
||||
If UsedTempFile = True Then
|
||||
Try
|
||||
@ -297,30 +302,30 @@ Public Class MyService
|
||||
End If
|
||||
|
||||
|
||||
Logger.Info($"#### Trying to Create_EB_Report (EB-Protokoll) for DocID: {pDocID} - GENID: {GENID}... ####")
|
||||
Logger.Info($"#### Starting Create_EB_Report (EB-Protokoll) for DocID: {pDocID} - GENID: {GENID}... ####")
|
||||
Dim errortext As String
|
||||
Dim oStep As String
|
||||
Try
|
||||
Dim oReport As New XtraReportSR()
|
||||
Dim oReport As New RptErgebnisbericht()
|
||||
Dim oDatasource As SqlDataSource = oReport.DataSource
|
||||
'Parameter für 1.Query
|
||||
Dim oSelectQuery As CustomSqlQuery = oDatasource.Queries(0)
|
||||
'-------
|
||||
If oSelectQuery.Parameters.Count = 1 Then
|
||||
Logger.Debug($"Exactly [{oSelectQuery.Parameters.Count}] Parameter in Query 1!")
|
||||
Logger.Debug($"DocID: {pDocID} - Exactly [{oSelectQuery.Parameters.Count}] Parameter in Query 1!")
|
||||
Else
|
||||
Delete_EB2bCreated(pDocID)
|
||||
Logger.Warn($"There is no parameter in Query 1 - Check the parameters for Query1")
|
||||
Logger.Warn($"DocID: {pDocID} - There is no parameter in Query 1 - Check the parameters for Query1")
|
||||
DocID = 0
|
||||
Exit Sub
|
||||
End If
|
||||
'-------
|
||||
Logger.Debug($"Now passing the value [{pDocID}] to parameter 0 of Query 1...")
|
||||
oStep = $"Now passing the value [{pDocID}] to parameter 0 of Query 1..."
|
||||
Logger.Debug($"DocID: {pDocID} - Now passing the value [{pDocID}] to parameter 0 of Query 1...")
|
||||
oStep = $"DocID: {pDocID} - Now passing the value [{pDocID}] to parameter 0 of Query 1..."
|
||||
Dim oParameter As QueryParameter = oSelectQuery.Parameters(0)
|
||||
oParameter.Value = pDocID
|
||||
'---------
|
||||
Logger.Debug($"Parameter passed successfully!")
|
||||
Logger.Debug($"DocID: {pDocID} - Parameter passed successfully!")
|
||||
oStep = $"Parameter passed successfully!"
|
||||
'---------
|
||||
'Parameter für 2.Query
|
||||
@ -344,12 +349,12 @@ Public Class MyService
|
||||
'----------
|
||||
oReport.ReportPrintOptions.PrintOnEmptyDataSource = False
|
||||
|
||||
oStep = $"Trying to create the report-document.."
|
||||
oStep = $"DocID: {pDocID} - Trying to create the report-document.."
|
||||
oReport.CreateDocument(False)
|
||||
Dim filePath As String = $"C:\Temp\{DocID}.prnx"
|
||||
|
||||
|
||||
Logger.Debug($"oReport successfully created!")
|
||||
Logger.Debug($"DocID: {pDocID} - oReport successfully created!")
|
||||
Catch ex As Exception
|
||||
Delete_EB2bCreated(pDocID)
|
||||
Logger.Error(ex)
|
||||
@ -424,7 +429,7 @@ Public Class MyService
|
||||
MyDatabase.ExecuteNonQuery(oInsert)
|
||||
End If
|
||||
|
||||
Logger.Info($"#### Created Ergebnisbericht for DocID: {pDocID} - GENID: {GENID}! #####")
|
||||
Logger.Info($"#### DocID: {pDocID} - Created Ergebnisbericht - GENID: {GENID}! #####")
|
||||
If UsedTempFile = True Then
|
||||
Try
|
||||
File.Delete(TempFile)
|
||||
@ -435,16 +440,16 @@ Public Class MyService
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Logger.Info("ERROR: oFilewithStamp = False or """)
|
||||
Logger.Info($"DocID: {pDocID} - ERROR: oFilewithStamp = False or """)
|
||||
End If
|
||||
Else
|
||||
Logger.Warn("Create_MyStempel = False")
|
||||
Logger.Warn($"DocID: {pDocID} - Create_MyStempel = False")
|
||||
Delete_EB2bCreated(pDocID)
|
||||
DocID = 0
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
Logger.Warn("OriginFile is nothing!!")
|
||||
Logger.Warn($"DocID: {pDocID} - OriginFile is nothing!!")
|
||||
End If
|
||||
Else
|
||||
Logger.Warn($"Error in Create_EB_Report for DocID: {pDocID} - GENID: {GENID} - ERROR: EB_Reportfile {oMyErgebnisbericht} is not existing!!")
|
||||
@ -468,7 +473,8 @@ Public Class MyService
|
||||
|
||||
Dim errortext As String
|
||||
Try
|
||||
|
||||
Logger.Info($"### DocID: {pDocID} - Create_MyStempel starting - GENID {GENID} ###")
|
||||
Logger.Debug($"### DocID: {pDocID} - Create_MyStempel starting - GENID {GENID} ###")
|
||||
Dim oRptStampFirstPage As New RptStampIcon()
|
||||
Dim oDatasource As SqlDataSource = oRptStampFirstPage.DataSource
|
||||
Dim oSelectQuery As CustomSqlQuery = oDatasource.Queries(0)
|
||||
@ -505,7 +511,7 @@ Public Class MyService
|
||||
MyStempel1 = oTempStempel
|
||||
End If
|
||||
|
||||
Logger.Info($"...Stampreport created for DocID: {pDocID} - GENID {GENID}!")
|
||||
Logger.Info($"DocID: {pDocID} - Stampreport created - GENID {GENID}!")
|
||||
Return True
|
||||
Else
|
||||
If GENID = "02" Then
|
||||
@ -525,7 +531,9 @@ Public Class MyService
|
||||
End Function
|
||||
Private Function CreateStampedPDF(oOriginFile As String, pDocID As Integer, GENID As String)
|
||||
Try
|
||||
Logger.Info($"Trying to CreateStampedPDF for DocID: {pDocID} - GENID {GENID}...")
|
||||
|
||||
Logger.Info($"### DocID: {pDocID} - CreateStampedPDF starting - GENID {GENID} ###")
|
||||
Logger.Debug($"### DocID: {pDocID} - CreateStampedPDF starting - GENID {GENID} ###")
|
||||
Dim MyLocalStempel As String
|
||||
If GENID = "01" Then
|
||||
MyLocalStempel = MyStempel1
|
||||
@ -542,17 +550,17 @@ Public Class MyService
|
||||
Dim oGdPictureImaging As New GdPictureImaging()
|
||||
'Creating a new empty PDF document.
|
||||
If oGdPicturePDF.LoadFromFile(oOriginFile, False) = GdPictureStatus.OK Then
|
||||
Logger.Debug($"{pDocID}..oGdPicturePDF Created")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - ..oGdPicturePDF Created")
|
||||
Dim oYDistance = oGdPicturePDF.GetPageHeight
|
||||
'Just to remind you that units are set to points and the origin is set to bottom left by default.
|
||||
'Loading an image from a file.
|
||||
Dim imageID As Integer = oGdPictureImaging.CreateGdPictureImageFromFile(MyLocalStempel)
|
||||
|
||||
If oGdPictureImaging.GetStat() = GdPictureStatus.OK Then
|
||||
Logger.Debug($"{pDocID}..GdPictureImaging.GetStat")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - ..GdPictureImaging.GetStat")
|
||||
'Adding an image as a resource into the PDF document - we decided not to draw the image in this moment.
|
||||
Dim imageResName As String = oGdPicturePDF.AddImageFromGdPictureImage(imageID, False, False)
|
||||
Logger.Debug($"{pDocID}..oGdPicturePDF.AddImageFromGdPictureImage")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - ..oGdPicturePDF.AddImageFromGdPictureImage")
|
||||
|
||||
Dim oStempelHEight = oGdPictureImaging.GetHeight(imageID) / 5
|
||||
oYDistance = (oYDistance - oStempelHEight) - 10
|
||||
@ -564,19 +572,19 @@ Public Class MyService
|
||||
'MessageBox.Show("The example has NOT been followed successfully. Error: " + oGdPicturePDF.GetStat().ToString(), "Adding an image Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return ""
|
||||
End If
|
||||
Logger.Debug($"{pDocID}..oGdPicturePDF.SaveToFile")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - ..oGdPicturePDF.SaveToFile")
|
||||
'Releasing the image.
|
||||
oGdPictureImaging.ReleaseGdPictureImage(imageID)
|
||||
|
||||
|
||||
Else
|
||||
Logger.Warn($"The image [{MyLocalStempel}] can't be loaded. Error: " + oGdPictureImaging.GetStat().ToString())
|
||||
Logger.Warn($"CreateStampedPDF - DocID: {pDocID} - The image [{MyLocalStempel}] can't be loaded. Error: " + oGdPictureImaging.GetStat().ToString())
|
||||
Return ""
|
||||
'MessageBox.Show("The image can't be loaded. Error: " + oGdPictureImaging.GetStat().ToString(), "Adding an image Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
End If
|
||||
oGdPicturePDF.CloseDocument()
|
||||
Else
|
||||
Logger.Warn("The new PDF document can't be created. Error: " + oGdPicturePDF.GetStat().ToString())
|
||||
Logger.Warn($"CreateStampedPDF - DocID: {pDocID} - The new PDF document can't be created. Error: {oGdPicturePDF.GetStat().ToString()}")
|
||||
'MessageBox.Show("The new PDF document can't be created. Error: " + oGdPicturePDF.GetStat().ToString(), "Adding an image Example", MessageBoxButtons.OK, MessageBoxIcon.Error)
|
||||
Return ""
|
||||
End If
|
||||
@ -587,13 +595,15 @@ Public Class MyService
|
||||
Dim sw As Stopwatch = New Stopwatch()
|
||||
Dim oSuccess As Boolean = True
|
||||
sw.Start()
|
||||
Logger.Debug("Waiting for file: " & oStampedOriginWithPicture)
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - Waiting for file: {oStampedOriginWithPicture}")
|
||||
|
||||
Do While File.Exists(oStampedOriginWithPicture) = False
|
||||
If sw.Elapsed.TotalSeconds = 30 Then
|
||||
Logger.Info("ATTENTION: Still waiting (30 sec) for file: " & oStampedOriginWithPicture)
|
||||
Logger.Info($"CreateStampedPDF - DocID: {pDocID} - ATTENTION: Still waiting (30 sec) for file: {oStampedOriginWithPicture}")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - ATTENTION: Still waiting (30 sec) for file: {oStampedOriginWithPicture}")
|
||||
ElseIf sw.Elapsed.TotalMinutes = 1 Then
|
||||
Logger.Info("ATTENTION: Still waiting (60 sec) for file: " & oStampedOriginWithPicture)
|
||||
Logger.Info($"CreateStampedPDF - DocID: {pDocID} - ATTENTION: Still waiting (60 sec) for file: {oStampedOriginWithPicture}")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - ATTENTION: Still waiting (60 sec) for file: {oStampedOriginWithPicture}")
|
||||
oSuccess = False
|
||||
Exit Do
|
||||
End If
|
||||
@ -602,9 +612,9 @@ Public Class MyService
|
||||
sw.Stop()
|
||||
Try
|
||||
File.Delete(MyLocalStempel)
|
||||
Logger.Debug($"Deleted StempelFile [{MyLocalStempel}]!")
|
||||
Logger.Debug($"CreateStampedPDF - DocID: {pDocID} - Deleted StempelFile [{MyLocalStempel}]!")
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Could not delete reportfile {MyLocalStempel} after creating concatted file: {ex.Message}")
|
||||
Logger.Warn($"CreateStampedPDF - DocID: {pDocID} - Could not delete reportfile {MyLocalStempel} after creating concatted file: {ex.Message}")
|
||||
End Try
|
||||
If oSuccess = True Then
|
||||
Return oStampedOriginWithPicture
|
||||
@ -618,10 +628,11 @@ Public Class MyService
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Private Function Concat_Files(DocID As String, oOriginFile As String, GENID As String, Outputfilename As String, pOutputFolder As String, pFilewithStamp As String, MyFreigabebericht As String)
|
||||
Private Function Concat_Files(pDocID As String, oOriginFile As String, GENID As String, Outputfilename As String, pOutputFolder As String, pFilewithStamp As String, MyFreigabebericht As String)
|
||||
Dim oConcatSuccessfull As Boolean = True
|
||||
Dim MyFile2Concat As String
|
||||
Try
|
||||
Logger.Debug($"######### Function Concat_Files - DocID {pDocID} #############")
|
||||
If Outputfilename = "STANDARD" Then
|
||||
Outputfilename = Path.GetFileNameWithoutExtension(oOriginFile) & My.Settings.Concatted_File_Suffix + ".pdf"
|
||||
End If
|
||||
@ -634,7 +645,7 @@ Public Class MyService
|
||||
Try
|
||||
File.Delete(MyFile2Concat)
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Could not delete ConcattedFile {MyFile2Concat}: {ex.Message}")
|
||||
Logger.Warn($"Concat_Files - DocID {pDocID} - Could not delete ConcattedFile {MyFile2Concat}: {ex.Message}")
|
||||
Return False
|
||||
End Try
|
||||
|
||||
@ -648,7 +659,7 @@ Public Class MyService
|
||||
Dim _argument As String = $"""{pFilewithStamp}"" ""{MyFreigabebericht}"" cat output ""{MyFile2Concat}"""
|
||||
|
||||
oPDFTKProcess.StartInfo.Arguments = _argument
|
||||
Logger.Debug("Arguments: " & _argument)
|
||||
Logger.Debug($"Concat_Files - DocID {pDocID} - Arguments: [{_argument}]")
|
||||
oPDFTKProcess.Start()
|
||||
ProcID = oPDFTKProcess.Id
|
||||
|
||||
@ -671,13 +682,13 @@ Public Class MyService
|
||||
'Logger.Debug("...process has exited: ")
|
||||
'sw.Stop()
|
||||
Thread.Sleep(500)
|
||||
Logger.Debug("Now waiting for final concatted file [" & MyFile2Concat & "] ...")
|
||||
Logger.Debug($"Concat_Files - DocID {pDocID} - Now waiting for final concatted file [{MyFile2Concat}] ...")
|
||||
sw.Start()
|
||||
Do While File.Exists(MyFile2Concat) = False
|
||||
If sw.Elapsed.TotalSeconds = 30 Then
|
||||
Logger.Info("ATTENTION: Still waiting (30 sec) for file: " & MyFile2Concat)
|
||||
Logger.Info($"Concat_Files - DocID {pDocID} - ATTENTION: Still waiting (30 sec) for file: {MyFile2Concat}")
|
||||
ElseIf sw.Elapsed.TotalMinutes = 1 Then
|
||||
Logger.Info("ATTENTION: waiting (60 sec) for file: " & MyFile2Concat)
|
||||
Logger.Info($"Concat_Files - DocID {pDocID} - ATTENTION: waiting (60 sec) for file: {MyFile2Concat}")
|
||||
oConcatSuccessfull = False
|
||||
Exit Do
|
||||
End If
|
||||
@ -687,11 +698,11 @@ Public Class MyService
|
||||
|
||||
Try
|
||||
File.Delete(pFilewithStamp)
|
||||
Logger.Debug($"Deleted file [{pFilewithStamp}]!")
|
||||
Logger.Debug($"Concat_Files - DocID {pDocID} - Deleted file [{pFilewithStamp}]!")
|
||||
File.Delete(MyFreigabebericht)
|
||||
Logger.Debug($"Deleted file [{MyFreigabebericht}]!")
|
||||
Logger.Debug($"Concat_Files - DocID {pDocID} - Deleted file [{MyFreigabebericht}]!")
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Could not delete reportfile after creating concatted file: {ex.Message}")
|
||||
Logger.Warn($"Concat_Files - DocID {pDocID} - Could not delete reportfile after creating concatted file: {ex.Message}")
|
||||
End Try
|
||||
Return oConcatSuccessfull
|
||||
|
||||
@ -702,11 +713,13 @@ Public Class MyService
|
||||
|
||||
|
||||
Else
|
||||
Logger.Warn("pdftk is not existing")
|
||||
Logger.Warn($"Concat_Files - DocID {pDocID} - pdftk is not existing")
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"Concat_Files - DocID {pDocID} - Unexpected Error: {ex.Message}")
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Sub Delete_EB2bCreated(pDocID As Long)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user