From 701cce5dffccd3ae98fef3bb2f5c29ffc08bd3de Mon Sep 17 00:00:00 2001 From: Digital Data - Marlon Schreiber Date: Tue, 18 Apr 2017 16:08:05 +0200 Subject: [PATCH] MS --- Global_Indexer/ClassFolderWatcher.vb | 23 +++++++++-- Global_Indexer/ClassHelper.vb | 27 ++++++++++++- Global_Indexer/ClassInit.vb | 10 ++++- Global_Indexer/My Project/AssemblyInfo.vb | 2 +- Global_Indexer/frmConfig_Basic.vb | 18 ++++++++- Global_Indexer/frmIndex.vb | 44 ++++++++++++++------- Global_Indexer/frmSQLSuggestion.Designer.vb | 7 ++-- Global_Indexer/frmSQLSuggestion.resx | 43 ++++++++++++++------ SetupWix/Product.wxs | 2 +- 9 files changed, 137 insertions(+), 39 deletions(-) diff --git a/Global_Indexer/ClassFolderWatcher.vb b/Global_Indexer/ClassFolderWatcher.vb index e5420f3..2a97bec 100644 --- a/Global_Indexer/ClassFolderWatcher.vb +++ b/Global_Indexer/ClassFolderWatcher.vb @@ -38,7 +38,7 @@ Public Class ClassFolderWatcher Public Shared Function StartStop_FolderWatch() Try If CURRENT_FOLDERWATCH = "" Then - MsgBox("Bitte definieren Sie einen Überwachungsordner:", MsgBoxStyle.Exclamation) + 'MsgBox("Bitte definieren Sie einen Überwachungsordner:", MsgBoxStyle.Exclamation) Return False End If If FolderWatcher Is Nothing Then @@ -90,8 +90,13 @@ Public Class ClassFolderWatcher Public Shared Function StartStop_FolderWatchSCAN() Try If CURRENT_SCAN_FOLDERWATCH = "" Then - MsgBox("Bitte definieren Sie einen Überwachungsordner für Scan-Eingänge:", MsgBoxStyle.Exclamation) - Return False + If FolderWatcher.EnableRaisingEvents = True Then + Stop_FWSCAN() + Return 0 + Else + MsgBox("Bitte definieren Sie einen Überwachungsordner für Scan-Eingänge:", MsgBoxStyle.Exclamation) + Return False + End If End If If FolderWatcher_SCAN Is Nothing Then FolderWatcher_SCAN = New System.IO.FileSystemWatcher(CURRENT_SCAN_FOLDERWATCH, "*.*") @@ -128,6 +133,18 @@ Public Class ClassFolderWatcher Return 99 End Try End Function + Public Shared Function Stop_FWSCAN() + If FolderWatcher.EnableRaisingEvents = True Then + 'Gestartet also Stoppen + FolderWatcher.EnableRaisingEvents = False + FW_started = False + ClassLogger.Add(" >> FolderWatch gestoppt", False) + SaveConfigValue("FW_started", "False") + Return True + Else + Return False + End If + End Function Private Shared Sub OnCreated(source As Object, e As FileSystemEventArgs) Try For Each row As DataRow In DTEXCLUDE_FILES.Rows diff --git a/Global_Indexer/ClassHelper.vb b/Global_Indexer/ClassHelper.vb index d1c9663..3cc410a 100644 --- a/Global_Indexer/ClassHelper.vb +++ b/Global_Indexer/ClassHelper.vb @@ -1,4 +1,5 @@ Imports System.Text +Imports System.Text.RegularExpressions Public Class ClassHelper Public Shared Function encode_utf8(ByVal str As String) As String @@ -9,7 +10,7 @@ Public Class ClassHelper Dim utf8Encoding As New System.Text.UTF8Encoding(True) Dim encodedString() As Byte encodedString = utf8Encoding.GetBytes(str) - If LogErrorsOnly = False Then ClassLogger.Add(String.Format(" >> String {0} was encoded via utf8 to {1}", str, utf8Encoding.GetString(encodedString))) + If LogErrorsOnly = False Then ClassLogger.Add(String.Format(" >> String {0} was encoded via utf8 to {1}", str, utf8Encoding.GetString(encodedString)), False) Return utf8Encoding.GetString(encodedString) Catch ex As Exception ClassLogger.Add("Unexpected error in encode_utf8: " & ex.Message) @@ -17,4 +18,28 @@ Public Class ClassHelper End Try End Function + Public Shared Function StringAsUtf8Bytes(ByVal strData As String) As Byte() + Try + Dim bytes() As Byte + ' get unicode string as bytes + bytes = Encoding.UTF8.GetBytes(strData) + ' return byte data + Return bytes + Catch ex As Exception + ClassLogger.Add("Unexpected error in StringAsUtf8Bytes: " & ex.Message) + Return Nothing + End Try + + End Function + Public Shared Function CheckSpecialSigns(ByVal str As String) + Try + Dim pattern As String = "[!""#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\s]" + Dim matches As MatchCollection = Regex.Matches(str, pattern) + Return matches.Count + Catch ex As Exception + ClassLogger.Add("Unexpected error in CheckSpecialSigns: " & ex.Message) + Return 0 + End Try + End Function + End Class diff --git a/Global_Indexer/ClassInit.vb b/Global_Indexer/ClassInit.vb index 00a5a94..52aa0e6 100644 --- a/Global_Indexer/ClassInit.vb +++ b/Global_Indexer/ClassInit.vb @@ -59,8 +59,14 @@ Public Class ClassInit If Not folderwatch Is Nothing Then CURRENT_FOLDERWATCH = folderwatch If FW_started = True Then - FW_ISSTARTED = True - ClassFolderWatcher.StartStop_FolderWatch() + If CURRENT_FOLDERWATCH = "" Then + FW_started = False + SaveConfigValue("FW_started", "False") + Else + FW_ISSTARTED = True + ClassFolderWatcher.StartStop_FolderWatch() + End If + End If End If If Not folderwatch_SCAN Is Nothing Then diff --git a/Global_Indexer/My Project/AssemblyInfo.vb b/Global_Indexer/My Project/AssemblyInfo.vb index 4ae4c70..3cd5093 100644 --- a/Global_Indexer/My Project/AssemblyInfo.vb +++ b/Global_Indexer/My Project/AssemblyInfo.vb @@ -33,7 +33,7 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - + \ No newline at end of file diff --git a/Global_Indexer/frmConfig_Basic.vb b/Global_Indexer/frmConfig_Basic.vb index e4f1e95..cd1432b 100644 --- a/Global_Indexer/frmConfig_Basic.vb +++ b/Global_Indexer/frmConfig_Basic.vb @@ -253,15 +253,29 @@ Public Class frmConfig_Basic End Sub Sub CheckFolder(mypath As String, FOLDER_TYPE As String) Try + If mypath = "" Then + ClassDatabase.Execute_non_Query("DELETE FROM TBGI_FOLDERWATCH_USER WHERE USER_ID = " & CURRENT_USERID & " AND FOLDER_TYPE = '" & FOLDER_TYPE & "'", True) + If FOLDER_TYPE = "SCAN" Then + CURRENT_SCAN_FOLDERWATCH = "" + SaveConfigValue("FWSCAN_started", "False") + FWSCAN_started = False + Else + FW_started = False + SaveConfigValue("FW_started", "False") + CURRENT_FOLDERWATCH = "" + End If + + Exit Sub + End If Try If (Not System.IO.Directory.Exists(mypath)) Then System.IO.Directory.CreateDirectory(mypath) End If Catch ex As Exception - ClassLogger.Add(" >> Unexpected error inm Erstellen des Folderwatchordners: " & mypath, False) + ClassLogger.Add(" >> Unexpected error in CheckFolder: " & mypath, False) ClassLogger.Add(" >> " & ex.Message, False) If USER_LANGUAGE = "de-DE" Then - MsgBox("Unexpected error inm Erstellen des Folderwatchordners: " & mypath & vbNewLine & "Bitte überprüfen Sie die Rechte!" & vbNewLine & ex.Message, MsgBoxStyle.Critical) + MsgBox("Unexpected error in ECheckFolder: " & mypath & vbNewLine & "Bitte überprüfen Sie die Rechte!" & vbNewLine & ex.Message, MsgBoxStyle.Critical) Else MsgBox("Error in creating Hotfolder: " & mypath & vbNewLine & "Please check the rights!" & vbNewLine & ex.Message, MsgBoxStyle.Critical) End If diff --git a/Global_Indexer/frmIndex.vb b/Global_Indexer/frmIndex.vb index 250c20a..e3c7221 100644 --- a/Global_Indexer/frmIndex.vb +++ b/Global_Indexer/frmIndex.vb @@ -1788,8 +1788,8 @@ Public Class frmIndex 'Me.VWINDEX_AUTOMTableAdapter.Connection.ConnectionString = My.Settings.MyConnectionString 'Me.VWINDEX_MANTableAdapter.Connection.ConnectionString = My.Settings.MyConnectionString Catch ex As Exception - ClassLogger.Add(" - Unexpected error inm Speichern der Verbindung - Fehler: " & vbNewLine & ex.Message) - MsgBox("Unexpected error inm Speichern der Verbindung: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation) + ClassLogger.Add(" - Unexpected error in Speichern der Verbindung - Fehler: " & vbNewLine & ex.Message) + MsgBox("Unexpected error in Speichern der Verbindung: " & vbNewLine & ex.Message, MsgBoxStyle.Exclamation) End Try End Sub @@ -2164,37 +2164,53 @@ Public Class frmIndex Else Dim tempFilename = My.Computer.FileSystem.GetTempFileName() + Dim tempFilename1 = My.Computer.FileSystem.GetTempFileName() Try - Me.grpBetreff.Dock = DockStyle.Top Me.grpbxMailBody.Dock = DockStyle.Fill Dim msg_email As New Msg.Message(CURRENT_WORKFILE) + msg_email.Encoding = Encoding.Unicode + + Dim headers As String = ClassEmailHeaderExtractor.getMessageHeaders(msg_email) + If LogErrorsOnly = False Then ClassLogger.Add(" EMAIL-HEADER: " & headers, False) 'Eine tempfile generieren Dim name = Path.GetFileNameWithoutExtension(tempFilename) tempFilename = Path.Combine(Path.GetDirectoryName(tempFilename), name & ".html") + name = Path.GetFileNameWithoutExtension(tempFilename1) + tempFilename1 = Path.Combine(Path.GetDirectoryName(tempFilename1), name & ".msg") + msg_email.Save(tempFilename1) + Dim msg_email_unicode As New Msg.Message(tempFilename1) TEMP_FILES.Add(tempFilename) + TEMP_FILES.Add(tempFilename1) + If LogErrorsOnly = False Then ClassLogger.Add(" ...tempFilename: " & tempFilename, False) + If LogErrorsOnly = False Then ClassLogger.Add(" ...tempFilename1: " & tempFilename1, False) 'tempfile löschen If My.Computer.FileSystem.FileExists(tempFilename) Then My.Computer.FileSystem.DeleteFile(tempFilename) End If - - If msg_email.Subject = "" Then - Me.txtBetreff.Text = "!! No subject in email !!" + If msg_email_unicode.Subject = "" Then + Me.txtBetreff.Text = "!!No subject in email!!" Else - Dim betreff = ClassHelper.encode_utf8(msg_email.Subject) + If LogErrorsOnly = False Then ClassLogger.Add(" ...subject before converting: '" & msg_email_unicode.Subject & "'", False) + Dim betreff = ClassHelper.encode_utf8(msg_email_unicode.Subject) If Not IsNothing(betreff) Then + If ClassHelper.CheckSpecialSigns(betreff) > 0 Then + + End If + + If LogErrorsOnly = False Then ClassLogger.Add(" ...subject after converting: " & betreff, False) Me.txtBetreff.Text = betreff Else - Me.txtBetreff.Text = msg_email.Subject + ClassLogger.Add(" ...subject could not be converted to utf8!", False) + Me.txtBetreff.Text = msg_email_unicode.Subject End If - End If - + 'Try Dim wFile As System.IO.FileStream Dim byteData() As Byte - byteData = msg_email.BodyHtml + byteData = msg_email_unicode.BodyHtml If LogErrorsOnly = False Then ClassLogger.Add(" ...byteData HTML finished", False) ' MsgBox(msg_email.InternetCodePage) ' wFile = New FileStream(tempFilename, FileMode.Append) @@ -2203,10 +2219,10 @@ Public Class frmIndex 'Catch ex As IOException ' MsgBox(ex.ToString) 'End Try - If IsNothing(msg_email.BodyHtml) Then - File.WriteAllText(tempFilename, msg_email.Body, System.Text.Encoding.UTF8) + If IsNothing(msg_email_unicode.BodyHtml) Then + File.WriteAllText(tempFilename, msg_email_unicode.Body, System.Text.Encoding.UTF8) Else - Dim vOut As String = System.Text.Encoding.UTF8.GetString(msg_email.BodyHtml) + Dim vOut As String = System.Text.Encoding.UTF8.GetString(msg_email_unicode.BodyHtml) File.WriteAllText(tempFilename, vOut, System.Text.Encoding.UTF8) End If diff --git a/Global_Indexer/frmSQLSuggestion.Designer.vb b/Global_Indexer/frmSQLSuggestion.Designer.vb index 8727e63..29b1ab0 100644 --- a/Global_Indexer/frmSQLSuggestion.Designer.vb +++ b/Global_Indexer/frmSQLSuggestion.Designer.vb @@ -60,10 +60,10 @@ Partial Class frmSQLSuggestion ' 'GroupBox1 ' + resources.ApplyResources(Me.GroupBox1, "GroupBox1") Me.GroupBox1.Controls.Add(Me.btnTestNachbearbeitung) Me.GroupBox1.Controls.Add(Me.txtTest_idxMan) Me.GroupBox1.Controls.Add(Me.Label2) - resources.ApplyResources(Me.GroupBox1, "GroupBox1") Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.TabStop = False ' @@ -86,8 +86,8 @@ Partial Class frmSQLSuggestion ' 'btnVorschlag ' - Me.btnVorschlag.Image = Global.Global_Indexer.My.Resources.Resources.database_go resources.ApplyResources(Me.btnVorschlag, "btnVorschlag") + Me.btnVorschlag.Image = Global.Global_Indexer.My.Resources.Resources.database_go Me.btnVorschlag.Name = "btnVorschlag" Me.btnVorschlag.UseVisualStyleBackColor = True ' @@ -153,8 +153,8 @@ Partial Class frmSQLSuggestion ' 'Button2 ' - Me.Button2.Image = Global.Global_Indexer.My.Resources.Resources.save_16xLG resources.ApplyResources(Me.Button2, "Button2") + Me.Button2.Image = Global.Global_Indexer.My.Resources.Resources.save_16xLG Me.Button2.Name = "Button2" Me.Button2.UseVisualStyleBackColor = True ' @@ -178,7 +178,6 @@ Partial Class frmSQLSuggestion Me.Controls.Add(Me.SQL_ERGEBNISTextBox) Me.Controls.Add(SQL_UEBERPRUEFUNGLabel) Me.Controls.Add(Me.SQL_UEBERPRUEFUNGTextBox) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.MaximizeBox = False Me.MinimizeBox = False Me.Name = "frmSQLSuggestion" diff --git a/Global_Indexer/frmSQLSuggestion.resx b/Global_Indexer/frmSQLSuggestion.resx index 3ce3fb4..bee939a 100644 --- a/Global_Indexer/frmSQLSuggestion.resx +++ b/Global_Indexer/frmSQLSuggestion.resx @@ -152,11 +152,15 @@ False + + + Top, Right + True - 533, 66 + 683, 66 437, 39 @@ -181,6 +185,9 @@ Definieren Sie hier einen SQL-Befehl der die Auswahl auf VORHANDEN überprüft. 8 + + Bottom, Left + MiddleLeft @@ -262,7 +269,7 @@ Ergebniswert angezeigt. 2 - 15, 229 + 15, 367 351, 93 @@ -285,14 +292,17 @@ Ergebniswert angezeigt. 4 + + Top, Right + MiddleLeft - 372, 82 + 536, 54 - 151, 25 + 89, 25 48 @@ -315,6 +325,9 @@ Ergebniswert angezeigt. 5 + + Top, Bottom, Left, Right + Consolas, 8.25pt @@ -324,12 +337,11 @@ Ergebniswert angezeigt. True - Both - 351, 136 + 610, 279 47 @@ -346,17 +358,20 @@ Ergebniswert angezeigt. 7 + + Top, Right + Consolas, 8.25pt - 536, 112 + 686, 108 True - 434, 106 + 483, 106 49 @@ -430,11 +445,14 @@ Ergebniswert angezeigt. 2 + + Bottom, Right + MiddleLeft - 880, 229 + 1070, 407 90, 31 @@ -460,6 +478,9 @@ Ergebniswert angezeigt. 1 + + Bottom, Right + True @@ -467,7 +488,7 @@ Ergebniswert angezeigt. Segoe UI Semibold, 9pt, style=Bold, Italic - 679, 237 + 905, 441 195, 15 @@ -500,7 +521,7 @@ Ergebniswert angezeigt. 6, 13 - 973, 326 + 1172, 489 Segoe UI, 8.25pt diff --git a/SetupWix/Product.wxs b/SetupWix/Product.wxs index 17b0696..b92e988 100644 --- a/SetupWix/Product.wxs +++ b/SetupWix/Product.wxs @@ -157,7 +157,7 @@ - +