MS HTTPS, Log,
This commit is contained in:
@@ -4,22 +4,23 @@ Imports DigitalData.Modules.Logging
|
||||
Public Class clsDatabase
|
||||
Private Shared MSSQL_inited As Boolean = False
|
||||
Dim Logger As Logger
|
||||
Sub New(MyLogger As LogConfig, ConStr As String)
|
||||
Sub New(MyLogger As LogConfig)
|
||||
Logger = MyLogger.GetLogger()
|
||||
Init(ConStr)
|
||||
End Sub
|
||||
Public Function Init(CONSTRING As String)
|
||||
Public Function Init(CONSTRING As String, pSaveCS As Boolean)
|
||||
Try
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
SQLconnect.ConnectionString = CONSTRING
|
||||
SQLconnect.Open()
|
||||
SQLconnect.Close()
|
||||
clsCURRENT.SQLSERVER_CS = CONSTRING
|
||||
MSSQL_inited = True
|
||||
If pSaveCS = True Then
|
||||
clsCURRENT.SQLSERVER_CS = CONSTRING
|
||||
|
||||
End If
|
||||
MSSQL_inited = True
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"CONSTRING: {CONSTRING}")
|
||||
'clsLogger.Add("Error in DatabaseInit: " & ex.Message, True)
|
||||
Return False
|
||||
End Try
|
||||
@@ -219,15 +220,19 @@ Public Class clsDatabase
|
||||
End Function
|
||||
|
||||
|
||||
Public Function Return_Datatable(Select_anweisung As String)
|
||||
Public Function Return_Datatable(Select_anweisung As String, Optional pSQLConnection As String = "")
|
||||
Try
|
||||
Logger.Debug("Select_anweisung: " & Select_anweisung)
|
||||
If MSSQL_inited = False Then Return Nothing
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
SQLcommand.CommandText = Select_anweisung
|
||||
@@ -240,20 +245,30 @@ Public Class clsDatabase
|
||||
|
||||
Return dt
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"SQL: {Select_anweisung}")
|
||||
'clsLogger.Add("Error in Return_Datatable: " & ex.Message, True)
|
||||
'clsLogger.Add(">> SQL: " & Select_anweisung, False)
|
||||
|
||||
Return Nothing
|
||||
End Try
|
||||
End Function
|
||||
Public Function Execute_non_Query(ExecuteCMD As String)
|
||||
Public Function Execute_non_Query(ExecuteCMD As String, Optional pSQLConnection As String = "")
|
||||
If MSSQL_inited = False Then Return False
|
||||
Dim oSQLCON As String
|
||||
Try
|
||||
Logger.Debug("ExecuteCMD: " & ExecuteCMD)
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
oSQLCON = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
oSQLCON = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
SQLconnect.ConnectionString = oSQLCON
|
||||
|
||||
SQLconnect.Open()
|
||||
SQLcommand = SQLconnect.CreateCommand
|
||||
@@ -268,7 +283,10 @@ Public Class clsDatabase
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Dim msg = $"Unexpected error in Execute_non_Query: SQL: {ExecuteCMD}, oSQLCON: {oSQLCON}"
|
||||
Logger.Error(ex)
|
||||
Logger.Debug(msg)
|
||||
Logger.Info(msg)
|
||||
'clsLogger.Add("Error in Execute_non_Query: " & ex.Message, True)
|
||||
'clsLogger.Add("SQL: " & ExecuteCMD, False)
|
||||
|
||||
@@ -276,7 +294,7 @@ Public Class clsDatabase
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Execute_Scalar(cmdscalar As String)
|
||||
Public Function Execute_Scalar(cmdscalar As String, Optional pSQLConnection As String = "")
|
||||
If MSSQL_inited = False Then Return Nothing
|
||||
Dim result
|
||||
Try
|
||||
@@ -285,7 +303,11 @@ Public Class clsDatabase
|
||||
Dim SQLconnect As New SqlClient.SqlConnection
|
||||
Dim SQLcommand As SqlClient.SqlCommand
|
||||
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
If pSQLConnection <> "" Then
|
||||
SQLconnect.ConnectionString = pSQLConnection
|
||||
Else
|
||||
SQLconnect.ConnectionString = clsCURRENT.SQLSERVER_CS
|
||||
End If
|
||||
|
||||
|
||||
SQLconnect.Open()
|
||||
@@ -300,7 +322,7 @@ Public Class clsDatabase
|
||||
|
||||
Return result
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Error(ex, $"SQL: {cmdscalar}")
|
||||
'clsLogger.Add("Error in Execute_Scalar: " & ex.Message, True)
|
||||
'clsLogger.Add("SQL: " & cmdscalar, False)
|
||||
Return Nothing
|
||||
|
||||
@@ -33,7 +33,7 @@ Public Class clsDateiverarbeitung
|
||||
MyLoggerConf = MyLogger
|
||||
Logger = MyLogger.GetLogger()
|
||||
_windream = New clsWindream_allgemein(MyLogger)
|
||||
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
End Sub
|
||||
Public Function InitProfilData()
|
||||
Try
|
||||
@@ -319,6 +319,7 @@ Public Class clsDateiverarbeitung
|
||||
''' <param name="WMFile">Das WMObject, dass das aktuelle Dokument repräsentiert</param>
|
||||
''' <param name="userId">Die eindeutige Benutzer Kennung für die Authentifizierung in Windream</param>
|
||||
Public Function BNSjsonDownload(WMFile As WMObject, userId As String, apiAddress As String)
|
||||
Dim url As String
|
||||
Try
|
||||
Logger.Info("handling BNSjsonDownload.....")
|
||||
' Indizes für das aktuelle Dokument auslesen
|
||||
@@ -352,42 +353,62 @@ Public Class clsDateiverarbeitung
|
||||
Dim geschaeftsObjekt = "Sendung"
|
||||
' Für Tests wird hier die Sendungsnummer verwendet, später hängt der verwendete Index von 'geschaeftsObjekt' ab
|
||||
Dim geschaeftsId = SENDUNGNR
|
||||
Dim url As String = $"http://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
|
||||
url = $"https://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
|
||||
|
||||
' Logger.Debug($">> Generiertes JSON: {json}")
|
||||
Logger.Debug($">> Creating WebRequest for {url}")
|
||||
Dim req As HttpWebRequest
|
||||
Try
|
||||
req = WebRequest.Create(url)
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Unhandled Exception in BNSjsonDownload - CreatingWebRequest ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Dim req As HttpWebRequest = WebRequest.CreateHttp(url)
|
||||
|
||||
req.Method = "POST"
|
||||
req.ContentType = "application/json"
|
||||
req.ContentLength = bytes.Length
|
||||
req.Timeout = 3000
|
||||
req.ServicePoint.Expect100Continue = False
|
||||
Dim reqStream As Stream
|
||||
Try
|
||||
reqStream = req.GetRequestStream()
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Unhandled Exception in BNSjsonDownload - GetRequestStream ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
Dim reqStream As Stream = req.GetRequestStream()
|
||||
reqStream.Write(bytes, 0, bytes.Length)
|
||||
reqStream.Close()
|
||||
|
||||
'Logger.Debug($">> Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
|
||||
'Logger.Debug($">> Upload URL: {url}")
|
||||
Try
|
||||
Using res As HttpWebResponse = req.GetResponse()
|
||||
Dim code As HttpStatusCode = res.StatusCode
|
||||
Dim text As String = res.StatusDescription
|
||||
|
||||
Using res As HttpWebResponse = req.GetResponse()
|
||||
Dim code As HttpStatusCode = res.StatusCode
|
||||
Dim text As String = res.StatusDescription
|
||||
' Status 201 Created bedeutet: Alles okay!
|
||||
If code = HttpStatusCode.Created Then
|
||||
Logger.Info($"File has been uploaded: docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
|
||||
Else
|
||||
Logger.Warn($"Server Error (HTTP {code}: {text})")
|
||||
End If
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Unhandled Exception in BNSjsonDownload - GetResponse ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
|
||||
' Status 201 Created bedeutet: Alles okay!
|
||||
If code = HttpStatusCode.Created Then
|
||||
Logger.Info($"File has been uploaded: docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
|
||||
Else
|
||||
Logger.Warn($"Server Error (HTTP {code}: {text})")
|
||||
End If
|
||||
End Using
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
Logger.Warn($"Unhandled Exception in BNSjsonDownload - Profile ({clsCURRENT._Profilname}) {ex.Message}")
|
||||
Logger.Warn($"Unhandled Exception in BNSjsonDownload - Url ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
|
||||
Logger.Error(ex)
|
||||
Return True
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
Public Function RUN_ORACLE_COMMAND(WMFile As WMObject, OracleCS As String, OracleCommandRAW As String)
|
||||
|
||||
@@ -39,14 +39,9 @@ Public Class clsJob_Work
|
||||
|
||||
Dim oPWPlain = owrapper.DecryptData(oMAIL_USER_PW)
|
||||
If Not IsNothing(oPWPlain) Then
|
||||
If oPWPlain <> "" Then
|
||||
oMAIL_USER_PW = oPWPlain
|
||||
Else
|
||||
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort 42")
|
||||
Return False
|
||||
End If
|
||||
oMAIL_USER_PW = oPWPlain
|
||||
Else
|
||||
Logger.Warn("PWPlain is string.empty - Could not decrypt passwort 46")
|
||||
Logger.Warn("PWPlain is Nothing - Could not decrypt passwort 44")
|
||||
Return False
|
||||
End If
|
||||
If _mail.Email_Send_Independentsoft(Email_subject, Email_Body, Email_receipiants, oMAILFROM, oMAILSMTP, oMAIL_PORT, oMAIL_USER, oMAIL_USER_PW, oMAIL_AUTH_TYPE, Attachment_Filename) = True Then
|
||||
|
||||
@@ -21,7 +21,7 @@ Public Class clsProfil
|
||||
Logger = MyLogger.GetLogger()
|
||||
windream = New clsWindream_allgemein(MyLogger)
|
||||
windream_index = New clsWindream_Index(MyLogger)
|
||||
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS)
|
||||
_database = New clsDatabase(MyLogger)
|
||||
_dateiverarbeitung = New clsDateiverarbeitung(MyLogger)
|
||||
_email = New clsEmail(MyLogger)
|
||||
_JobWork = New clsJob_Work(MyLogger, _email)
|
||||
@@ -115,7 +115,7 @@ Public Class clsProfil
|
||||
'Den Durchlauf erlauben
|
||||
Run_Profile = True
|
||||
Else
|
||||
Logger.Info("No run as DiffMin (" & DiffMin & ") <= Intervall(" & arr(1) & ")")
|
||||
Logger.Debug("No run as DiffMin (" & DiffMin & ") <= Intervall(" & arr(1) & ")")
|
||||
End If
|
||||
Case Else
|
||||
Logger.Warn("_profRunType konnte nicht ausgewertet werden - " & arr(0))
|
||||
@@ -305,7 +305,7 @@ Public Class clsProfil
|
||||
'Für jeden File-Job
|
||||
For Each DR_PR_FILE_JOB As DataRow In DT_PROFIL_FILE_JOB.Rows
|
||||
If FileJobSuccessful = False Then
|
||||
Logger.Info("AUSSTIEG FOR SCHLEIFE...")
|
||||
Logger.Info("AUSSTIEG FOR SCHLEIFE cause FileJobSuccessful = False...")
|
||||
Exit For
|
||||
End If
|
||||
Select Case DR_PR_FILE_JOB.Item("TYP").ToString.ToLower
|
||||
@@ -607,7 +607,8 @@ Public Class clsProfil
|
||||
End Try
|
||||
Next
|
||||
Case "Send InfoMail with WM-Search".ToUpper
|
||||
Dim oWMResults As WMObjects = windream.GetSearchDocuments(_profwdSuche)
|
||||
Logger.Info("Working on CASE Send InfoMail with WM-Search.... ")
|
||||
Dim oWMResults As WMObjects = windream.GetSearchDocuments(DR_PR_JB.Item("STRING5"))
|
||||
If oWMResults Is Nothing Then
|
||||
Logger.Warn("windreamSucheErgebnisse is nothing ( Send InfoMail with WM-Search)!", True, "clsProfil.Profil_Durchlauf")
|
||||
Return False
|
||||
@@ -625,6 +626,8 @@ Public Class clsProfil
|
||||
End If
|
||||
|
||||
End If
|
||||
Else
|
||||
Logger.Info("Send InfoMail with WM-Search - oWMResults.Count = 0")
|
||||
End If
|
||||
|
||||
End Select
|
||||
@@ -640,7 +643,7 @@ Public Class clsProfil
|
||||
End If
|
||||
Else
|
||||
' keine Dateien zum Importieren
|
||||
Logger.Info("Keine windream-Dokumente für Profil '" & _Profilname & "' vorhanden/gefunden.")
|
||||
Logger.Debug("Keine windream-Dokumente für Profil '" & _Profilname & "' vorhanden/gefunden.")
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
@@ -34,7 +34,12 @@ Public Class clsWindream_allgemein
|
||||
''' </summary>
|
||||
''' <remarks></remarks>
|
||||
Sub New(MyLogger As LogConfig)
|
||||
Logger = MyLogger.GetLogger()
|
||||
Try
|
||||
Logger = MyLogger.GetLogger()
|
||||
Catch ex As Exception
|
||||
|
||||
End Try
|
||||
|
||||
' wenn ein Fehler bei der Initialisierung auftrat
|
||||
If Not Init() Then
|
||||
' Nachricht ausgeben
|
||||
@@ -474,20 +479,26 @@ Public Class clsWindream_allgemein
|
||||
Return oSearch.execute
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"WM-SEARCH ({wdfLocation})")
|
||||
Return Nothing
|
||||
End Try
|
||||
|
||||
End Function
|
||||
Public Function GetSearchDocumentsDT(ByVal wdfLocation As String, NameIndexDocID As String, NameIndexCreated As String) As DataTable
|
||||
Public Function GetSearchDocumentsDT(ByVal wdfLocation As String, NameIndexDocID As String, NameIndexCreated As String, WMSearchLocal As Boolean) As DataTable
|
||||
Dim dtresult As New DataTable
|
||||
dtresult.Columns.Add("DOC_ID", GetType(Integer))
|
||||
dtresult.Columns.Add("PATH", GetType(String))
|
||||
dtresult.Columns.Add("CREATED", GetType(DateAndTime))
|
||||
dtresult.Columns.Add("CREATED", GetType(String))
|
||||
Logger.Debug($"Executing WMSearch: {wdfLocation}...")
|
||||
Try
|
||||
Dim SearchName = wdfLocation.Substring(wdfLocation.LastIndexOf("\") + 1)
|
||||
Dim SearchPath = wdfLocation.Substring(0, wdfLocation.Length - SearchName.Length)
|
||||
Dim oWMSZPath = wdfLocation.Substring(2).ToLower
|
||||
Dim oWMSZPath
|
||||
If WMSearchLocal = False Then
|
||||
oWMSZPath = wdfLocation.Substring(2).ToLower
|
||||
Else
|
||||
oWMSZPath = wdfLocation.ToLower
|
||||
End If
|
||||
|
||||
Logger.Debug("oWMSZPath: " & oWMSZPath)
|
||||
Try
|
||||
@@ -495,6 +506,11 @@ Public Class clsWindream_allgemein
|
||||
Catch ex As Exception
|
||||
Dim msg As String = ex.Message
|
||||
Try
|
||||
If WMSearchLocal = True Then
|
||||
Logger.Error(ex)
|
||||
Return dtresult
|
||||
End If
|
||||
|
||||
Logger.Debug("Unexpected Error in Creating oController: " & msg)
|
||||
Logger.Debug("...NOW trying to implement \\windream\Objects ...")
|
||||
Dim WmSearch_wmobject = "\\windream\Objects" & oWMSZPath
|
||||
@@ -559,18 +575,18 @@ Public Class clsWindream_allgemein
|
||||
If WMObjects.Count > 0 Then
|
||||
|
||||
For Each dok As WMObject In WMObjects
|
||||
Dim path As String = dok.aPath
|
||||
Dim DOC_ID = dok.GetVariableValue(NameIndexDocID)
|
||||
Logger.Debug("Adding DocInfo for DocID: " & DOC_ID.ToString)
|
||||
dtresult.Rows.Add(DOC_ID, path, dok.GetVariableValue(NameIndexCreated))
|
||||
Dim oPath As String = dok.aPath
|
||||
Dim oDOC_ID = dok.GetVariableValue(NameIndexDocID)
|
||||
Dim oCreated = dok.GetVariableValue(NameIndexCreated)
|
||||
Logger.Debug($"Adding DocInfo {oDOC_ID.ToString}|{oPath}|{oCreated}")
|
||||
dtresult.Rows.Add(oDOC_ID, oPath, oCreated)
|
||||
Next
|
||||
dtresult.AcceptChanges()
|
||||
Else
|
||||
Logger.Info($"No results for WMSearch: {wdfLocation}!!")
|
||||
End If
|
||||
Return dtresult
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Logger.Warn($"WM-SEARCH ({wdfLocation})")
|
||||
Return dtresult
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Reference in New Issue
Block a user