MS V2.7 .Net Logger etc

This commit is contained in:
2021-06-15 16:28:55 +02:00
parent e2619eb3ad
commit e796ae91cb
109 changed files with 295499 additions and 8793 deletions

View File

@@ -4,20 +4,20 @@ Public Class ClassSAP
Public Shared SAP_CONNECTION As New R3Connection()
Public Shared Function ConnectionInit(Host As String, SysNumber As String, Username As String, PW As String, Client As String, Lang As String)
Try
If LogErrorsOnly = False Then ClassLogger.Add("", False)
If LogErrorsOnly = False Then ClassLogger.Add(" >> SAP Connect started:", False)
LOGGER.Debug("", False)
LOGGER.Debug("SAP Connect started:", False)
SAPConnectionString = String.Format("USER={0} LANG={1} CLIENT={2} SYSNR={3} ASHOST={4} PASSWD={5}", Username, Lang, Client, SysNumber, Host, PW)
Dim con As New R3Connection()
ERPConnect.LIC.SetLic("W86DWC992C")
If LogErrorsOnly = False Then ClassLogger.Add(" >> SAP Connectionstring: " & SAPConnectionString, False)
LOGGER.Debug("SAP Connectionstring: " & SAPConnectionString, False)
con.Open(SAPConnectionString)
SAP_CONNECTION.Open(SAPConnectionString)
If LogErrorsOnly = False Then ClassLogger.Add(" >> SAP-Connection created!", False)
If LogErrorsOnly = False Then ClassLogger.Add("", False)
LOGGER.Debug("SAP-Connection created!", False)
LOGGER.Debug("", False)
Return True
Catch ex As Exception
MsgBox("Error in SAP ConnectionInit: " & ex.Message, MsgBoxStyle.Critical)
ClassLogger.Add("Error in SAP ConnectionInit: " & ex.Message, True)
LOGGER.Warn("Error in SAP ConnectionInit: " & ex.Message)
Return False
End Try
End Function
@@ -25,29 +25,29 @@ Public Class ClassSAP
Try
Dim RESULT_TABLE As DataTable = New DataTable
If LogErrorsOnly = False Then ClassLogger.Add(" >> Get data from FuBa-Function", False)
LOGGER.Debug("Get data from FuBa-Function", False)
Dim func As RFCFunction
Try
func = SAP_CONNECTION.CreateFunction(FuBaName)
If LogErrorsOnly = False Then ClassLogger.Add(" >> func.Execute", False)
LOGGER.Debug("func.Execute", False)
func.Execute()
If LogErrorsOnly = False Then ClassLogger.Add(" >> function was executed", False)
LOGGER.Debug("function was executed", False)
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Create SAP Function: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in Create SAP Function: " & ex.Message, False)
MsgBox("Error in Create SAP Function: " & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
Dim FUNCT_ROW_COUNT As Integer = 1
Dim RowMaskresult As String = ""
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >> Checking FunctionExecute", False)
LOGGER.Debug("Checking FunctionExecute", False)
'Den ersten Wert ausgeben lassen um die Spalten zu splitten
For Each row As RFCStructure In func.Tables("T_INDEX").Rows
Try
If row.Item(1).ToString.Contains(SplitCharacter) Then
RowMaskresult = row.Item(1).ToString
If LogErrorsOnly = False Then ClassLogger.Add(" >> RowMask result: " & RowMaskresult, False)
LOGGER.Debug("RowMask result: " & RowMaskresult, False)
FUNCT_ROW_COUNT = 2
End If
Catch ex As Exception
@@ -56,7 +56,7 @@ Public Class ClassSAP
If FUNCT_ROW_COUNT = 2 Then Exit For
Next
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Checking FunctionExecute: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in Checking FunctionExecute: " & ex.Message, False)
MsgBox("Error in Checking FunctionExecute: " & ex.Message, MsgBoxStyle.Critical)
SAP_CONNECTION.Close()
Return Nothing
@@ -65,18 +65,18 @@ Public Class ClassSAP
Dim ColCount As Integer
If SplitCharacter <> "" And RowMaskresult.Contains(SplitCharacter) Then
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >> Define Datatable with SplitCharacter method", False)
LOGGER.Debug("Define Datatable with SplitCharacter method", False)
Dim split() = RowMaskresult.Split(SplitCharacter)
If split.Length > 0 Then
ColCount = split.Length - 1
CURRENT_COL_COUNT = ColCount
If LogErrorsOnly = False Then
ClassLogger.Add(" >> ColCount: " & ColCount.ToString, False)
ClassLogger.Add(" >> Split-Results: ", False)
LOGGER.Debug("ColCount: " & ColCount.ToString, False)
LOGGER.Debug("Split-Results: ", False)
For Each s As String In split
ClassLogger.Add(" # " & s, False)
LOGGER.Debug(" # " & s, False)
Next
End If
For x = 0 To ColCount
' Declare DataColumn and DataRow variables.
Dim column As DataColumn
@@ -86,14 +86,14 @@ Public Class ClassSAP
column.ColumnName = "Column " & x.ToString
RESULT_TABLE.Columns.Add(column)
Next
If LogErrorsOnly = False Then ClassLogger.Add(" >> Datatable Columns after Split created", False)
LOGGER.Debug("Datatable Columns after Split created", False)
' Create new DataRow objects and add to DataTable.
'Jetzt die Zeilen der Function durchlaufen
For Each row As RFCStructure In func.Tables("T_INDEX").Rows
Dim new_row As DataRow
If RowLimit <> 0 Then
If RowLimit = FUNCT_ROW_COUNT Then
If LogErrorsOnly = False Then ClassLogger.Add(" >> RowCount limited to" & RowLimit.ToString & " rows. Exit SAP Function", False)
LOGGER.Debug("RowCount limited to" & RowLimit.ToString & " rows. Exit SAP Function", False)
Exit For
End If
End If
@@ -110,13 +110,13 @@ Public Class ClassSAP
RESULT_TABLE.Rows.Add(new_row)
End If
Next
If LogErrorsOnly = False Then ClassLogger.Add(" >> RowCount FuBa: " & RESULT_TABLE.Rows.Count.ToString, False)
LOGGER.Debug("RowCount FuBa: " & RESULT_TABLE.Rows.Count.ToString, False)
Return RESULT_TABLE
Else
Return Nothing
End If
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Create Datatable with split-method: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in Create Datatable with split-method: " & ex.Message, False)
MsgBox("Unexpected Error in Create Datatable with split-method: " & ex.Message, MsgBoxStyle.Critical)
SAP_CONNECTION.Close()
Return Nothing
@@ -125,7 +125,7 @@ Public Class ClassSAP
Return Nothing
End If
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in Function FuBa_ReturnDatatable Seperated: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in Function FuBa_ReturnDatatable Seperated: " & ex.Message, False)
MsgBox("Unexpected Error in Function FuBa_ReturnDatatable Seperated: " & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
@@ -133,7 +133,7 @@ Public Class ClassSAP
Public Shared Function Return_Datatable_for_Table(tablename As String, where_clause As String, Optional RowLimit As Integer = 0)
Try
Dim RESULT_TABLE As DataTable = New DataTable
If LogErrorsOnly = False Then ClassLogger.Add(" >> Get data from SAP Table", False)
LOGGER.Debug("Get data from SAP Table", False)
Dim table As New ERPConnect.Utils.ReadTable(SAP_CONNECTION)
'Dim cWhereClause = "SAP_OBJECT EQ '<ObjectType>' AND AR_DATE GE '<AR_DATE>'"
'Dim sSearchDate1 = "20160101"
@@ -146,21 +146,21 @@ Public Class ClassSAP
If RowLimit <> 0 Then
table.RowCount = RowLimit
End If
If LogErrorsOnly = False Then ClassLogger.Add(" >>Table.Run executing.....", False)
LOGGER.Debug(" >>Table.Run executing.....", False)
table.Run()
If LogErrorsOnly = False Then ClassLogger.Add(" >>Table.Run executed", False)
LOGGER.Debug(" >>Table.Run executed", False)
RESULT_TABLE = table.Result
SAP_CONNECTION.Close()
Return RESULT_TABLE
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in SAP Table Result: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in SAP Table Result: " & ex.Message, False)
MsgBox("Unexpected Error in SAP Table Result: " & ex.Message, MsgBoxStyle.Critical)
Return Nothing
End Try
End Function
Public Shared Function LINK_ARC_OBJECT(table As String, barcode As String, contrep As String, docid As String, ardate As String, doctype As String)
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >> CREATE_ARC_OBJECT", False)
LOGGER.Debug("CREATE_ARC_OBJECT", False)
Dim sapfunc As RFCFunction = SAP_CONNECTION.CreateFunction("BAPI_BARCODE_SENDLIST")
'Create and fill the frist row
@@ -185,14 +185,14 @@ Public Class ClassSAP
End If
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in SAP Table Result: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in SAP Table Result: " & ex.Message, False)
MsgBox("Unexpected Error in CREATE_ARC_OBJECT: " & ex.Message, MsgBoxStyle.Critical)
Return ex.Message
End Try
End Function
Public Shared Function INSERT_ARCHIVE_OBJECT(ARCHIV_ID As String, ARC_DOC_ID As String, AR_OBJECT As String, OBJECT_ID As String, SAP_OBJECT As String, DOC_TYPE As String, table As String)
Try
If LogErrorsOnly = False Then ClassLogger.Add(" >> INSERT_ARCHIVE_OBJECT", False)
LOGGER.Debug("INSERT_ARCHIVE_OBJECT", False)
Dim sapfunc As RFCFunction = SAP_CONNECTION.CreateFunction("ARCHIV_CONNECTION_INSERT")
'Create and fill the frist row
@@ -222,7 +222,7 @@ Public Class ClassSAP
Return ""
Catch ex As Exception
ClassLogger.Add(">> Unexpected Error in INSERT_ARCHIVE_OBJECT: " & ex.Message, False)
LOGGER.Warn("Unexpected Error in INSERT_ARCHIVE_OBJECT: " & ex.Message, False)
MsgBox("Unexpected Error in INSERT_ARCHIVE_OBJECT: " & ex.Message, MsgBoxStyle.Critical)
Return ex.Message
End Try