MS GerneratorID

This commit is contained in:
2020-08-24 14:11:45 +02:00
parent f803b39d0c
commit c075475cdc
7 changed files with 73 additions and 69 deletions

View File

@@ -40,6 +40,7 @@ Public Class Form1
Next
Me.TimerMinute.Start()
txtDocID.Text = My.Settings.MyDocID
tsiGENKey.Text = "Generator-ID: " & My.Settings.GEN_ID
End Sub
Dim Run_Active As Boolean = False
Private Sub TimerMinute_Tick(sender As Object, e As EventArgs) Handles TimerMinute.Tick
@@ -50,14 +51,25 @@ Public Class Form1
Try
Dim oDT As DataTable = MySQLSDB.GetDatatable(My.Settings.oSQLGetDocId)
If Not IsNothing(oDT) Then
Dim oDocID As Long
If oDT.Rows.Count > 0 Then
For Each oRow As DataRow In oDT.Rows
oDocID = oRow.Item(0).ToString
Dim oInsert = $"INSERT INTO TBCUST_PM_RPT_2BCREATED (DocID,GEN_ID) VALUES ({oDocID},'{My.Settings.GEN_ID}')"
MySQLSDB.ExecuteNonQuery(oInsert)
Next
Run_Active = True
For Each oRow As DataRow In oDT.Rows
Dim oSQL = $"select count(*) from VWCUST_RPTPM_INV_RPT_STAMP_CHECK WHERE docID = {oRow.Item(0).ToString}"
oDocID = oRow.Item(0).ToString
Dim oSQL = $"select count(*) from VWCUST_RPTPM_INV_RPT_STAMP_CHECK WHERE docID = {oDocID.ToString}"
If MySQLSDB.GetScalarValue(oSQL) >= 1 Then
Create_Report(oRow.Item(0).ToString, 0)
Create_Report(oDocID.ToString, 0)
Else
Logger.Info($"ATTENTION - No FinalFreigabe for DocID: {oRow.Item(0).ToString}")
Logger.Info($"ATTENTION - No FinalFreigabe for DocID: {oDocID.ToString}")
Dim oDELETE = $"DELETE FROM TBCUST_PM_RPT_2BCREATED WHERE DocID = {oDocID} AND GEN_ID = '{My.Settings.GEN_ID}'"
MySQLSDB.ExecuteNonQuery(oDELETE)
End If
Next
End If
@@ -74,62 +86,17 @@ Public Class Form1
End Sub
Sub Create_Report(DocID As String, ReportOption As Integer)
Sub Create_Report(pDocID As String, ReportOption As Integer)
MyFreigabebericht = ""
MyStempel = ""
MyOriginStamped = ""
Logger.Info($"Trying to create report for DocID: {DocID}...")
Logger.Info($"Trying to create report for DocID: {pDocID}...")
Dim errortext As String
Try
If DEBUG = True Then
DocumentViewer1.DocumentSource = Nothing
End If
' Me.MyDataset.VWCUST_RPTPM_UNION.Clear()
' VWCUST_RPTPM_UNIONTableAdapter.Connection.ConnectionString = My.Settings.CONF_SQLSERVER
' Me.VWCUST_RPTPM_UNIONTableAdapter.Fill(Me.MyDataset.VWCUST_RPTPM_UNION, DocID)
' Logger.Debug($"---VWCUST_RPTPM_UNION.Rows.Count = [{MyDataset.VWCUST_RPTPM_UNION.Rows.Count}]!---")
' If Me.MyDataset.VWCUST_RPTPM_UNION.Rows.Count = 0 Then
' Logger.Debug($"no rows for UnionView VWCUST_RPTPM_UNION for DocID {DocID}")
' Logger.Debug("My.Settings.CONF_SQLSERVER: " & My.Settings.CONF_SQLSERVER)
' Dim oSQL = $"SELECT GroupTypeID, GroupType, DOC_ID, KreditorNummer, KreditorName_Lang, KreditorName, RechnungNr, Referenz, Nettobetrag, Bruttobetrag, Zahlungsziel, Mandant, [Mandant Name], Kostenstelle, [Erhalten wann], Belegdatum,
' FG_Email, FG_Freigabe, FG_Wann, WHO, [WHEN], DELEGATION
'FROM VWCUST_RPTPM_UNION
'WHERE (DOC_ID = {DocID}) AND (LEN(RechnungNr) > 0)"
' Dim oCHECKDT As DataTable = MySQLSDB.GetDatatable(oSQL)
' Dim oMsg
' If oCHECKDT.Rows.Count <> 0 Then
' Logger.Debug("Now trying to add rows from regular select row by row...")
' Try
' For Each oRow As DataRow In oCHECKDT.Rows
' MyDataset.VWCUST_RPTPM_UNION.ImportRow(oRow)
' Next
' MyDataset.VWCUST_RPTPM_UNION.AcceptChanges()
' Logger.Debug($"Added {MyDataset.VWCUST_RPTPM_UNION.Rows.Count} rows!!")
' Catch ex As Exception
' Logger.Debug($"Ups: Unexpected error in Adding rows row by row: {ex.Message}")
' Logger.Warn($"Unexpected error in Adding rows row by row: {ex.Message}")
' End Try
' If Me.MyDataset.VWCUST_RPTPM_UNION.Rows.Count <> 0 Then
' oMsg = $"...BUT REGULAR SELECT [{oSQL}] returned {oCHECKDT.Rows.Count} rows!!!!"
' Logger.Warn(oMsg)
' End If
' Else
' Logger.Warn($"no rows for UnionView VWCUST_RPTPM_UNION for DocID {DocID}")
' Logger.Debug("My.Settings.CONF_SQLSERVER: " & My.Settings.CONF_SQLSERVER)
' End If
' If DEBUG = True And Me.MyDataset.VWCUST_RPTPM_UNION.Rows.Count = 0 Then
' If oCHECKDT.Rows.Count <> 0 Then
' MsgBox($"No rows for UnionView VWCUST_RPTPM_UNION for DocID {DocID}! " & vbNewLine & oMsg)
' Else
' MsgBox($"No rows for UnionView VWCUST_RPTPM_UNION for DocID {DocID}")
' End If
' Exit Sub
' End If
'End If
Catch ex As Exception
If DEBUG = True Then
MsgBox(ex.Message, MsgBoxStyle.Critical, "Error in 1:")
@@ -140,14 +107,14 @@ Public Class Form1
Try
Dim report As New XtraReport2()
report.ReportPrintOptions.PrintOnEmptyDataSource = False
report.FilterString = "DocID = " + DocID
report.FilterString = "DocID = " + pDocID
'report.ObjectDataSource1.Parameters(0).Value = Convert.ToInt64(TextBox1.Text)
report.CreateDocument(False)
If DEBUG = True Then
DocumentViewer1.DocumentSource = report
End If
Dim oMyErgebnisbericht As String = Path.Combine(My.Settings.CONCAT_TEMPFolder, DocID & "_ERPT.pdf")
Dim oMyErgebnisbericht As String = Path.Combine(My.Settings.CONCAT_TEMPFolder, pDocID & "_ERPT.pdf")
If File.Exists(oMyErgebnisbericht) Then
Try
File.Delete(oMyErgebnisbericht)
@@ -166,7 +133,7 @@ Public Class Form1
End If
MyFreigabebericht = oMyErgebnisbericht
Dim oOriginFile As String
Dim osql = $"select dbo.FNDD_GET_WINDREAM_FILE_PATH ({DocID},1)"
Dim osql = $"select dbo.FNDD_GET_WINDREAM_FILE_PATH ({pDocID},1)"
oOriginFile = MySQLSDB.GetScalarValue(osql)
If File.Exists(oOriginFile) = False Then
Logger.Warn($"File {oOriginFile} is not existing. Check the pathconfiguration!")
@@ -176,17 +143,17 @@ Public Class Form1
If Not IsNothing(oOriginFile) Then
If File.Exists(My.Settings.Path2PDFTK) Then
If Create_MyStempel(DEBUG, DocID) = True Then
If Create_MyStempel(DEBUG, pDocID) = True Then
'Jetzt Stempeln des OriginakBeleges mit dem Stamp-Report
Dim oStampedResult = CreateStampedPDF(oOriginFile, DocID)
Dim oStampedResult = CreateStampedPDF(oOriginFile, pDocID)
If oStampedResult <> "" Then
If Concat_Files(DocID, oOriginFile) = True Then
If Concat_Files(pDocID, oOriginFile) = True Then
If DEBUG Then
MsgBox($"The ResultReport has been created: {MyEndResult}", MsgBoxStyle.Information)
End If
If DEBUG = False Then
Dim oInsert = $"INSERT INTO TBCUST_PM_RPT_CREATED (DocID) VALUES ({Convert.ToInt64(DocID)})"
Dim oInsert = $"INSERT INTO TBCUST_PM_RPT_CREATED (DocID) VALUES ({Convert.ToInt64(pDocID)})"
MySQLSDB.ExecuteNonQuery(oInsert)
End If
Logger.Info($"Concatted file [{oStampedResult}] created!")
@@ -208,6 +175,8 @@ Public Class Form1
End If
Catch ex As Exception
Dim oUpdate = $"DELETE FROM TBCUST_PM_RPT_2BCREATED WHERE DocID = {pDocID} AND GEN_ID = '{My.Settings.GEN_ID}'"
MySQLSDB.ExecuteNonQuery(oUpdate)
errortext = "ex.message: " & ex.Message & vbNewLine & "ex.StackTrace: " & ex.StackTrace.ToString & vbNewLine & "ex.InnerException: " & ex.InnerException.Message
If DEBUG = True Then
MsgBox(errortext, MsgBoxStyle.Critical, "Error in 2:")
@@ -216,9 +185,9 @@ Public Class Form1
Logger.Error(ex)
End Try
End Sub
Private Function Create_MyStempel(istest As Boolean, DocID As String)
Private Function Create_MyStempel(istest As Boolean, pDocID As String)
MyStempel = ""
Logger.Info($"Trying to create Stampreport for DocID: {DocID}...")
Logger.Info($"Trying to create Stampreport for DocID: {pDocID}...")
Dim errortext As String
Try
If istest = True Then
@@ -236,14 +205,14 @@ Public Class Form1
Try
Dim myReport As New RptStampIcon()
myReport.ReportPrintOptions.PrintOnEmptyDataSource = False
myReport.FilterString = "DocID = " + DocID
myReport.FilterString = "DocID = " + pDocID
'report.ObjectDataSource1.Parameters(0).Value = Convert.ToInt64(TextBox1.Text)
myReport.CreateDocument(False)
If istest = True Then
DocumentViewer1.DocumentSource = myReport
End If
Dim oTempStempel As String = Path.Combine(My.Settings.CONCAT_TEMPFolder, DocID & "_Stamp.jpg")
Dim oTempStempel As String = Path.Combine(My.Settings.CONCAT_TEMPFolder, pDocID & "_Stamp.jpg")
If File.Exists(oTempStempel) Then
Try
File.Delete(oTempStempel)
@@ -264,9 +233,9 @@ Public Class Form1
If File.Exists(oTempStempel) Then
MyStempel = oTempStempel
Logger.Info($"Stampreport created for DocID: {DocID}!")
Logger.Info($"Stampreport created for DocID: {pDocID}!")
If istest = True Then
MsgBox($"Stampreport [{oTempStempel}] created for DocID [{DocID}]!", MsgBoxStyle.Information)
MsgBox($"Stampreport [{oTempStempel}] created for DocID [{pDocID}]!", MsgBoxStyle.Information)
End If
Return True
Else
@@ -276,6 +245,8 @@ Public Class Form1
Catch ex As Exception
errortext = "ex.message: " & ex.Message & vbNewLine & "ex.StackTrace: " & ex.StackTrace.ToString & vbNewLine & "ex.InnerException: " & ex.InnerException.Message
Dim oUpdate = $"DELETE FROM TBCUST_PM_RPT_2BCREATED WHERE DocID = {pDocID} AND GEN_ID = '{My.Settings.GEN_ID}'"
MySQLSDB.ExecuteNonQuery(oUpdate)
If istest = True Then
MsgBox(errortext, MsgBoxStyle.Critical, "Error in Create_StampReport:")
Clipboard.SetText(errortext)
@@ -284,9 +255,9 @@ Public Class Form1
Return False
End Try
End Function
Private Function CreateStampedPDF(oOriginFile As String, DocID As Integer)
Private Function CreateStampedPDF(oOriginFile As String, pDocID As Integer)
Try
Logger.Info($"Trying to create stamp on OriginWMFile for DocID: {DocID}...")
Logger.Info($"Trying to create stamp on OriginWMFile for DocID: {pDocID}...")
Logger.Debug($"Now in CreateStampedPDF")
Dim myProcess As New Process
Dim ProcID