diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb index bca8fff7..476aa40c 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.Designer.vb @@ -81,7 +81,7 @@ Partial Class frmDocumentResultList Me.RibbonControl.Name = "RibbonControl" Me.RibbonControl.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1}) Me.RibbonControl.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.[False] - Me.RibbonControl.Size = New System.Drawing.Size(1189, 159) + Me.RibbonControl.Size = New System.Drawing.Size(1189, 158) Me.RibbonControl.StatusBar = Me.RibbonStatusBar ' 'SwitchMainContainerHorizontal @@ -146,8 +146,8 @@ Partial Class frmDocumentResultList ' Me.BarButtonBack.Caption = "Zurück" Me.BarButtonBack.Id = 9 - Me.BarButtonBack.ImageOptions.Image = CType(resources.GetObject("BarButtonItem4.ImageOptions.Image"), System.Drawing.Image) - Me.BarButtonBack.ImageOptions.LargeImage = CType(resources.GetObject("BarButtonItem4.ImageOptions.LargeImage"), System.Drawing.Image) + Me.BarButtonBack.ImageOptions.Image = CType(resources.GetObject("BarButtonBack.ImageOptions.Image"), System.Drawing.Image) + Me.BarButtonBack.ImageOptions.LargeImage = CType(resources.GetObject("BarButtonBack.ImageOptions.LargeImage"), System.Drawing.Image) Me.BarButtonBack.Name = "BarButtonBack" ' 'BarButtonItem5 @@ -187,10 +187,10 @@ Partial Class frmDocumentResultList 'RibbonStatusBar ' Me.RibbonStatusBar.ItemLinks.Add(Me.labelResultCount) - Me.RibbonStatusBar.Location = New System.Drawing.Point(0, 649) + Me.RibbonStatusBar.Location = New System.Drawing.Point(0, 647) Me.RibbonStatusBar.Name = "RibbonStatusBar" Me.RibbonStatusBar.Ribbon = Me.RibbonControl - Me.RibbonStatusBar.Size = New System.Drawing.Size(1189, 22) + Me.RibbonStatusBar.Size = New System.Drawing.Size(1189, 24) ' 'SplitContainerControl1 ' @@ -202,7 +202,7 @@ Partial Class frmDocumentResultList Me.SplitContainerControl1.Panel1.Text = "Panel1" Me.SplitContainerControl1.Panel2.Controls.Add(Me.SplitContainerControl2) Me.SplitContainerControl1.Panel2.Text = "Panel2" - Me.SplitContainerControl1.Size = New System.Drawing.Size(762, 490) + Me.SplitContainerControl1.Size = New System.Drawing.Size(762, 489) Me.SplitContainerControl1.SplitterPosition = 382 Me.SplitContainerControl1.TabIndex = 2 Me.SplitContainerControl1.Text = "SplitContainerControl1" @@ -214,15 +214,20 @@ Partial Class frmDocumentResultList Me.GridControl1.MainView = Me.GridView1 Me.GridControl1.MenuManager = Me.RibbonControl Me.GridControl1.Name = "GridControl1" - Me.GridControl1.Size = New System.Drawing.Size(382, 490) + Me.GridControl1.Size = New System.Drawing.Size(382, 489) Me.GridControl1.TabIndex = 0 Me.GridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView1}) ' 'GridView1 ' + Me.GridView1.Appearance.EvenRow.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(214, Byte), Integer), CType(CType(49, Byte), Integer)) + Me.GridView1.Appearance.EvenRow.Options.UseBackColor = True + Me.GridView1.Appearance.FocusedRow.BackColor = System.Drawing.Color.FromArgb(CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer), CType(CType(224, Byte), Integer)) + Me.GridView1.Appearance.FocusedRow.Options.UseBackColor = True Me.GridView1.Bands.AddRange(New DevExpress.XtraGrid.Views.BandedGrid.GridBand() {Me.GridBand1}) Me.GridView1.GridControl = Me.GridControl1 Me.GridView1.Name = "GridView1" + Me.GridView1.OptionsView.EnableAppearanceEvenRow = True Me.GridView1.OptionsView.ShowAutoFilterRow = True ' 'GridBand1 @@ -249,7 +254,7 @@ Partial Class frmDocumentResultList Me.SplitContainerControl2.Panel1.Text = "Panel1" Me.SplitContainerControl2.Panel2.Controls.Add(Me.GridControl3) Me.SplitContainerControl2.Panel2.Text = "Panel2" - Me.SplitContainerControl2.Size = New System.Drawing.Size(370, 490) + Me.SplitContainerControl2.Size = New System.Drawing.Size(370, 489) Me.SplitContainerControl2.SplitterPosition = 223 Me.SplitContainerControl2.TabIndex = 0 Me.SplitContainerControl2.Text = "SplitContainerControl2" @@ -301,9 +306,12 @@ Partial Class frmDocumentResultList ' 'GridView2 ' + Me.GridView2.Appearance.EvenRow.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(214, Byte), Integer), CType(CType(49, Byte), Integer)) + Me.GridView2.Appearance.EvenRow.Options.UseBackColor = True Me.GridView2.Bands.AddRange(New DevExpress.XtraGrid.Views.BandedGrid.GridBand() {Me.GridBand2}) Me.GridView2.GridControl = Me.GridControl2 Me.GridView2.Name = "GridView2" + Me.GridView2.OptionsView.EnableAppearanceEvenRow = True Me.GridView2.OptionsView.ShowAutoFilterRow = True ' 'GridBand2 @@ -326,15 +334,18 @@ Partial Class frmDocumentResultList Me.GridControl3.MainView = Me.GridView3 Me.GridControl3.MenuManager = Me.RibbonControl Me.GridControl3.Name = "GridControl3" - Me.GridControl3.Size = New System.Drawing.Size(370, 257) + Me.GridControl3.Size = New System.Drawing.Size(370, 256) Me.GridControl3.TabIndex = 0 Me.GridControl3.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() {Me.GridView3}) ' 'GridView3 ' + Me.GridView3.Appearance.EvenRow.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(214, Byte), Integer), CType(CType(49, Byte), Integer)) + Me.GridView3.Appearance.EvenRow.Options.UseBackColor = True Me.GridView3.Bands.AddRange(New DevExpress.XtraGrid.Views.BandedGrid.GridBand() {Me.GridBand3}) Me.GridView3.GridControl = Me.GridControl3 Me.GridView3.Name = "GridView3" + Me.GridView3.OptionsView.EnableAppearanceEvenRow = True Me.GridView3.OptionsView.ShowAutoFilterRow = True ' 'GridBand3 @@ -352,13 +363,13 @@ Partial Class frmDocumentResultList 'SplitContainerControl3 ' Me.SplitContainerControl3.Dock = System.Windows.Forms.DockStyle.Fill - Me.SplitContainerControl3.Location = New System.Drawing.Point(0, 159) + Me.SplitContainerControl3.Location = New System.Drawing.Point(0, 158) Me.SplitContainerControl3.Name = "SplitContainerControl3" Me.SplitContainerControl3.Panel1.Controls.Add(Me.SplitContainerControl1) Me.SplitContainerControl3.Panel1.Text = "Panel1" Me.SplitContainerControl3.Panel2.Controls.Add(Me.DocumentViewer1) Me.SplitContainerControl3.Panel2.Text = "Panel2" - Me.SplitContainerControl3.Size = New System.Drawing.Size(1189, 490) + Me.SplitContainerControl3.Size = New System.Drawing.Size(1189, 489) Me.SplitContainerControl3.SplitterPosition = 762 Me.SplitContainerControl3.TabIndex = 5 Me.SplitContainerControl3.Text = "SplitContainerControl3" @@ -368,7 +379,7 @@ Partial Class frmDocumentResultList Me.DocumentViewer1.Dock = System.Windows.Forms.DockStyle.Fill Me.DocumentViewer1.Location = New System.Drawing.Point(0, 0) Me.DocumentViewer1.Name = "DocumentViewer1" - Me.DocumentViewer1.Size = New System.Drawing.Size(417, 490) + Me.DocumentViewer1.Size = New System.Drawing.Size(417, 489) Me.DocumentViewer1.TabIndex = 0 ' 'XtraSaveFileDialog diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.resx b/GUIs.Common/DocumentResultList/frmDocumentResultList.resx index 74f243d4..cbea546c 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.resx +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.resx @@ -245,7 +245,7 @@ nFnvtqI2y4WaO7s+m1CnlB8XAAAAAElFTkSuQmCC - + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAPdEVYdFRpdGxlAEJhY2s7UHJldj1cl8kAAAEJSURB @@ -256,7 +256,7 @@ a4S/HhL8/ZQrE1w52s8/k+WH37lI3sUnQlO0bha7AAAAAElFTkSuQmCC - + iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAPdEVYdFRpdGxlAEJhY2s7UHJldj1cl8kAAAJwSURB diff --git a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb index f8156760..0590ab5e 100644 --- a/GUIs.Common/DocumentResultList/frmDocumentResultList.vb +++ b/GUIs.Common/DocumentResultList/frmDocumentResultList.vb @@ -77,7 +77,7 @@ Public Class frmDocumentResultList SwitchDetailContainerHorizontal.Visibility = DevExpress.XtraBars.BarItemVisibility.Never End If - RibbonControl.Minimized = True + 'RibbonControl.Minimized = True ' Initialize Viewer with GDPicture.NET License DocumentViewer1.Init(_LogConfig, _Environment.Settings.GdPictureKey) diff --git a/GUIs.ZooFlow/ClassInit.vb b/GUIs.ZooFlow/ClassInit.vb index a7500bca..1ca42bc1 100644 --- a/GUIs.ZooFlow/ClassInit.vb +++ b/GUIs.ZooFlow/ClassInit.vb @@ -123,6 +123,7 @@ Public Class ClassInit MyApplication.Settings.GdPictureKey = NotNull(oRow.Item("LICENSE"), String.Empty) My.Application.Settings.GdPictureKey = NotNull(oRow.Item("LICENSE"), String.Empty) + My.Application.GDPictureLicense = My.Application.Settings.GdPictureKey Catch ex As Exception _Logger.Error(ex) Throw New InitException("Error initializing3rdParty!") diff --git a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb index 627cda00..6442ec86 100644 --- a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb +++ b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb @@ -609,476 +609,1201 @@ Public Class frmGlobix_Index End Sub Private Sub BarButtonItem1_ItemClick_1(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem1.ItemClick - 'ClearError() - 'ClearNotice() - 'Me.Cursor = Cursors.WaitCursor - 'Refresh_RegexTable() - 'For Each rowregex As DataRow In My.Application.BASE_DATA_DT_REGEX.Rows - ' If rowregex.Item("FUNCTION_NAME") = "CLEAN_FILENAME" Then - ' My.Application.Globix.REGEX_CLEAN_FILENAME = rowregex.Item("REGEX") - ' End If - 'Next - 'If chkMultiindexing.Visibility = DevExpress.XtraBars.BarItemVisibility.Always And chkMultiindexing.Checked = True Then - ' 'Die erste Datei indexieren - ' If WORK_FILE() = True Then - ' 'Und nun die folgenden - ' Dim DTFiles2Work As DataTable = My.Database.GetDatatable("SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND GUID <> " & My.Application.Globix.CURRENT_WORKFILE_GUID & " AND UPPER(USER@WORK) = UPPER('" & My.Application.User.UserName & "')") - ' If Not DTFiles2Work Is Nothing Then - ' Dim err = False - ' For Each filerow As DataRow In DTFiles2Work.Rows - ' My.Application.Globix.CURRENT_WORKFILE_GUID = filerow.Item("GUID") - ' My.Application.Globix.CURRENT_WORKFILE = filerow.Item("FILENAME2WORK") - ' DropType = filerow.Item("HANDLE_TYPE") + ClearError() + ClearNotice() + Me.Cursor = Cursors.WaitCursor + Refresh_RegexTable() + For Each rowregex As DataRow In My.Application.BASE_DATA_DT_REGEX.Rows + If rowregex.Item("FUNCTION_NAME") = "CLEAN_FILENAME" Then + My.Application.Globix.REGEX_CLEAN_FILENAME = rowregex.Item("REGEX") + End If + Next + If chkMultiindexing.Visibility = DevExpress.XtraBars.BarItemVisibility.Always And chkMultiindexing.Checked = True Then + 'Die erste Datei indexieren + If WORK_FILE() = True Then + 'Und nun die folgenden + Dim DTFiles2Work As DataTable = My.Database.GetDatatable("SELECT * FROM TBGI_FILES_USER WHERE WORKED = 0 AND GUID <> " & My.Application.Globix.CURRENT_WORKFILE_GUID & " AND UPPER(USER@WORK) = UPPER('" & My.Application.User.UserName & "')") + If Not DTFiles2Work Is Nothing Then + Dim err = False + For Each filerow As DataRow In DTFiles2Work.Rows + My.Application.Globix.CURRENT_WORKFILE_GUID = filerow.Item("GUID") + My.Application.Globix.CURRENT_WORKFILE = filerow.Item("FILENAME2WORK") + DropType = filerow.Item("HANDLE_TYPE") - ' If WORK_FILE() = False Then - ' err = True - ' Exit For - ' End If - ' Next - ' Me.Cursor = Cursors.Default - ' If err = False Then - ' If My.Application.User.Language = "de-DE" Then - ' MsgBox("Alle Dateien wurden mit Multiindexing erfolgreich verarbeitet!", MsgBoxStyle.Information, "Erfolgsmeldung:") - ' Else - ' MsgBox("All files were successfully processed through Multiindexing", MsgBoxStyle.Information, "Success") - ' End If + If WORK_FILE() = False Then + err = True + Exit For + End If + Next + Me.Cursor = Cursors.Default + If err = False Then + If My.Application.User.Language = "de-DE" Then + MsgBox("Alle Dateien wurden mit Multiindexing erfolgreich verarbeitet!", MsgBoxStyle.Information, "Erfolgsmeldung:") + Else + MsgBox("All files were successfully processed through Multiindexing", MsgBoxStyle.Information, "Success") + End If - ' 'DTACTUAL_FILES.Clear() + 'DTACTUAL_FILES.Clear() - ' DocumentViewer1.CloseDocument() - ' DocumentViewer1.Done() + DocumentViewer1.CloseDocument() + DocumentViewer1.Done() - ' CancelAttempts = 2 - ' Me.Close() - ' End If - ' End If - ' End If - 'Else - ' If WORK_FILE() = True Then - ' Me.Cursor = Cursors.Default - ' If My.UIConfig.Globix.ShowIndexResult = True Then - ' If My.Application.User.Language = "de-DE" Then - ' MsgBox("Die Datei wurde erfolgreich verarbeitet!" & vbNewLine & "Ablagepfad:" & vbNewLine & My.Application.Globix.CURRENT_NEWFILENAME, MsgBoxStyle.Information, "Erfolgsmeldung") - ' Else - ' MsgBox("File sucessfully processed!" & vbNewLine & "Path:" & vbNewLine & My.Application.Globix.CURRENT_NEWFILENAME, MsgBoxStyle.Information, "Success") - ' End If - ' End If + CancelAttempts = 2 + Me.Close() + End If + End If + End If + Else + If WORK_FILE() = True Then + Me.Cursor = Cursors.Default + If My.UIConfig.Globix.ShowIndexResult = True Then + If My.Application.User.Language = "de-DE" Then + MsgBox("Die Datei wurde erfolgreich verarbeitet!" & vbNewLine & "Ablagepfad:" & vbNewLine & My.Application.Globix.CURRENT_NEWFILENAME, MsgBoxStyle.Information, "Erfolgsmeldung") + Else + MsgBox("File sucessfully processed!" & vbNewLine & "Path:" & vbNewLine & My.Application.Globix.CURRENT_NEWFILENAME, MsgBoxStyle.Information, "Success") + End If + End If - ' DocumentViewer1.CloseDocument() - ' DocumentViewer1.Done() + DocumentViewer1.CloseDocument() + DocumentViewer1.Done() - ' CancelAttempts = 2 - ' Me.Close() - ' End If - 'End If - 'Me.Cursor = Cursors.Default + CancelAttempts = 2 + Me.Close() + End If + End If + Me.Cursor = Cursors.Default End Sub - 'Private Function WORK_FILE() - ' Try - ' Dim oSQL = $"SELECT * FROM VWDDINDEX_MAN WHERE DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID}" - ' My.Application.Globix.CURR_DT_MAN_INDEXE = My.Database.GetDatatable(oSQL) + Private Function WORK_FILE() + Try + Dim oSQL = $"SELECT * FROM VWDDINDEX_MAN WHERE DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID}" + My.Application.Globix.CURR_DT_MAN_INDEXE = My.Database.GetDatatable(oSQL) - ' _Logger.Debug("Manuelle Indexe geladen") + _Logger.Debug("Manuelle Indexe geladen") - ' If My.Application.Globix.CURR_DT_MAN_INDEXE.Rows.Count > 0 Then - ' My.Application.Globix.CURRENT_DOCTYPE_ID = Me.cmbDoctype.SelectedValue - ' If CheckWrite_IndexeMan(Me.cmbDoctype.SelectedValue) = True Then - ' '##### Manuelle Indexe indexiert ##### - ' _Logger.Info("Datei [" & My.Application.Globix.CURRENT_WORKFILE & "] wird nun indexiert...") - ' If FillIndexe_Autom(Me.cmbDoctype.SelectedValue) = True Then - ' _Logger.Debug(" ...FillIndexe_Autom durchlaufen") + If My.Application.Globix.CURR_DT_MAN_INDEXE.Rows.Count > 0 Then + My.Application.Globix.CURRENT_DOCTYPE_ID = Me.cmbDoctype.SelectedValue + If CheckWrite_IndexeMan(Me.cmbDoctype.SelectedValue) = True Then + '##### Manuelle Indexe indexiert ##### + _Logger.Info("Datei [" & My.Application.Globix.CURRENT_WORKFILE & "] wird nun indexiert...") + If FillIndexe_Autom(Me.cmbDoctype.SelectedValue) = True Then + _Logger.Debug(" ...FillIndexe_Autom durchlaufen") - ' 'Den Zielnamen zusammenbauen - ' If Name_Generieren() = True Then - ' 'Dokumentenviewer ausblenden um keinen Zugriffsfehler zu produzieren - ' DocumentViewer1.Done() - ' DocumentViewer1.CloseDocument() + 'Den Zielnamen zusammenbauen + If Name_Generieren() = True Then + 'Dokumentenviewer ausblenden um keinen Zugriffsfehler zu produzieren + DocumentViewer1.Done() + DocumentViewer1.CloseDocument() - ' _Logger.Debug(" ...Viewer geschlossen") - ' 'Die Datei verschieben - ' If Move_File2_Target() = True Then - ' _Logger.Debug(" ...Move_File2_Target durchlaufen") - ' My.Application.Globix.CURRENT_LASTDOCTYPE = cmbDoctype.Text - ' _Logger.Info("Datei '" & My.Application.Globix.CURRENT_NEWFILENAME & "' erfolgreich erzeugt.") - ' Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & My.Application.Globix.CURRENT_WORKFILE_GUID - ' My.Database.ExecuteNonQuery(oDEL) - ' Return True - ' End If + _Logger.Debug(" ...Viewer geschlossen") + 'Die Datei verschieben + If Move_File2_Target() = True Then + _Logger.Debug(" ...Move_File2_Target durchlaufen") + My.Application.Globix.CURRENT_LASTDOCTYPE = cmbDoctype.Text + _Logger.Info("Datei '" & My.Application.Globix.CURRENT_NEWFILENAME & "' erfolgreich erzeugt.") + Dim oDEL As String = "DELETE FROM TBGI_FILES_USER WHERE GUID = " & My.Application.Globix.CURRENT_WORKFILE_GUID + My.Database.ExecuteNonQuery(oDEL) + Return True + End If - ' Else - ' If My.Application.User.Language = "de-DE" Then - ' MsgBox("Unerwarteter Fehler in Name_Generieren - Bitte überprüfen sie die Logdatei", MsgBoxStyle.Critical) - ' Else - ' MsgBox("Unexpected error in Name_Generieren - Please check the Logfile", MsgBoxStyle.Critical) - ' End If - ' Return False - ' End If - ' Else - ' If My.Application.User.Language = "de-DE" Then - ' MsgBox("Unerwarteter Fehler in FillIndexe_Autom - Bitte überprüfen sie die Logdatei", MsgBoxStyle.Critical) - ' Else - ' MsgBox("Unexpected error in FillIndexe_Autom - Please check the Logfile", MsgBoxStyle.Critical) - ' End If - ' Return False - ' End If - ' '#### Automatische Werte indexieren #### - ' End If - ' Else - ' If My.Application.User.Language = "de-DE" Then - ' MsgBox("Bitte überprüfen Sie die Konfiguration dieser Dokumentart." & vbNewLine & "Es sind KEINE manuellen Indizes konfiguriert oder aktiv geschaltet!", MsgBoxStyle.Exclamation) - ' Else - ' MsgBox("Please check the configuration for this document-type." & vbNewLine & "There are NO manual indicies that are either configured or set to active!", MsgBoxStyle.Exclamation) - ' End If - ' Return False - ' End If - ' Catch ex As Exception - ' _Logger.Error(ex) - ' MsgBox("Unexpected Error in WORK_FILE:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) - ' Return False - ' End Try - 'End Function - 'Function CheckWrite_IndexeMan(dokartid As Integer) - ' '#### Zuerst manuelle Werte indexieren #### - ' Try - ' _Logger.Info("In CheckWrite_IndexeMan") - ' Dim result As Boolean = False - ' For Each oControl As Control In Me.pnlIndex.Controls - ' ' MsgBox(ctrl.Name) - ' If oControl.Name.StartsWith("txt") Then - ' Dim box As DevExpress.XtraEditors.TextEdit = oControl - ' If box.Text = "" Then - ' Dim oIndexName = Replace(box.Name, "txt", "") - ' Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) - ' 'My.Database.ExecuteNonQuery("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(box.Name, "txt", "") & "'", MyConnectionString, True) - ' If optional_index = False Then - ' MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, "Fehlende Eingabe:") - ' box.Focus() - ' Return False - ' Else - ' Indexwert_Postprocessing(Replace(box.Name, "txt", ""), "") - ' result = True - ' End If - ' Else - ' If Indexwert_checkValueDB(Replace(box.Name, "txt", ""), box.Text) = False Then - ' _Logger.Info(" - Der eingegebene Wert wurde nicht in der Datenbank gefunden") - ' MsgBox("Der eingegebene Wert wurde nicht in der Datenbank gefunden!", MsgBoxStyle.Exclamation, "Fehlerhafte Indexierung:") - ' box.Focus() - ' Return False - ' Else - ' Indexwert_Postprocessing(Replace(box.Name, "txt", ""), box.Text) - ' result = True - ' End If - ' End If - ' End If + Else + If My.Application.User.Language = "de-DE" Then + MsgBox("Unerwarteter Fehler in Name_Generieren - Bitte überprüfen sie die Logdatei", MsgBoxStyle.Critical) + Else + MsgBox("Unexpected error in Name_Generieren - Please check the Logfile", MsgBoxStyle.Critical) + End If + Return False + End If + Else + If My.Application.User.Language = "de-DE" Then + MsgBox("Unerwarteter Fehler in FillIndexe_Autom - Bitte überprüfen sie die Logdatei", MsgBoxStyle.Critical) + Else + MsgBox("Unexpected error in FillIndexe_Autom - Please check the Logfile", MsgBoxStyle.Critical) + End If + Return False + End If + '#### Automatische Werte indexieren #### + End If + Else + If My.Application.User.Language = "de-DE" Then + MsgBox("Bitte überprüfen Sie die Konfiguration dieser Dokumentart." & vbNewLine & "Es sind KEINE manuellen Indizes konfiguriert oder aktiv geschaltet!", MsgBoxStyle.Exclamation) + Else + MsgBox("Please check the configuration for this document-type." & vbNewLine & "There are NO manual indicies that are either configured or set to active!", MsgBoxStyle.Exclamation) + End If + Return False + End If + Catch ex As Exception + _Logger.Error(ex) + MsgBox("Unexpected Error in WORK_FILE:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) + Return False + End Try + End Function - ' If oControl.Name.StartsWith("cmbMulti") Then - ' Dim oLookup = DirectCast(oControl, DigitalData.Controls.LookupGrid.LookupControl2) - ' Dim values As List(Of String) = oLookup.SelectedValues + Function Name_Generieren() + Try + _Logger.Debug("#### Name_Generieren ####") + Dim sql As String = "select VERSION_DELIMITER, FILE_DELIMITER FROM TBDD_MODULES WHERE GUID = 1" + Dim oFilesystem As New DigitalData.Modules.Filesystem.File(_LogConfig) + Dim DT1 As DataTable = My.Database.GetDatatable(sql) + For Each row As DataRow In DT1.Rows + My.Application.Globix.FILE_DELIMITER = row.Item("FILE_DELIMITER") + My.Application.Globix.VERSION_DELIMITER = row.Item("VERSION_DELIMITER") + Next - ' If values.Count = 0 Then - ' Dim oIndexName = Replace(oLookup.Name, "cmbMulti", "") - ' Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) - ' 'ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(oLookup.Name, "cmbMulti", "") & "'", MyConnectionString, True) + Dim err As Boolean = False + Dim folder_Created As Boolean = False + Dim oRAWZielordner As String + Dim extension As String = System.IO.Path.GetExtension(My.Application.Globix.CURRENT_WORKFILE) - ' If optional_index = False Then - ' MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) - ' oLookup.Focus() - ' Return False - ' Else - ' Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), "") - ' result = True - ' End If - ' Else - ' Dim vectorValue = String.Join(ClassConstants.VECTORSEPARATOR, values) - ' Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), vectorValue) - ' result = True - ' End If - ' ElseIf oControl.Name.StartsWith("cmbSingle") Then - ' Dim cmbSingle As TextBox = oControl + sql_history_INSERT_INTO = "INSERT INTO TBGI_HISTORY (FILENAME_ORIGINAL,FILENAME_NEW" + sql_history_Index_Values = "" + Dim AnzahlIndexe As Integer = 1 + 'CURR_DOKART_OBJECTTYPE = DT.Rows(0).Item("OBJEKTTYP") + My.Application.Globix.CURRENT_WORKFILE_EXTENSION = extension - ' If cmbSingle.Text = "" Then - ' Dim oIndexName = Replace(cmbSingle.Name, "cmbSingle", "") - ' Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) - ' 'ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmbSingle.Name, "cmbSingle", "") & "'", MyConnectionString, True) + 'oRAWZielordner = WINDREAM.GetNormalizedPath(My.Application.Globix.CURR_DT_DOCTYPE.Rows(0).Item("ZIEL_PFAD")) + oRAWZielordner = Path.Combine("\\windream\objects", oRAWZielordner) - ' If optional_index = False Then - ' MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) - ' cmbSingle.Focus() - ' Return False - ' Else - ' Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbSingle", ""), "") - ' result = True - ' End If - ' Else - ' Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbSingle", ""), cmbSingle.Text) - ' result = True - ' End If - ' ElseIf oControl.Name.StartsWith("cmb") Then - ' Dim cmb As ComboBox = oControl - ' If cmb.Text = "" Then - ' Dim oIndexName = Replace(cmb.Name, "cmb", "") - ' Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) - ' 'Dim optional_index As Boolean = ClassDatabase.Execute_Scalar("SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = " & dokartid & " AND NAME = '" & Replace(cmb.Name, "cmb", "") & "'", MyConnectionString, True) - ' If optional_index = False Then - ' MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) - ' cmb.Focus() - ' Return False - ' Else - ' Indexwert_Postprocessing(Replace(cmb.Name, "cmb", ""), "") - ' result = True - ' End If - ' Else - ' Indexwert_Postprocessing(Replace(cmb.Name, "cmb", ""), cmb.Text) - ' result = True - ' End If - ' End If - ' If oControl.Name.StartsWith("dtp") Then - ' Dim dtp As DevExpress.XtraEditors.DateEdit = oControl - ' Dim oIndexName As String = Replace(dtp.Name, "dtp", "") + '#### + ' Regulären Ausdruck zum Auslesen der Indexe definieren + Dim preg As String = "\[%{1}[a-zA-Z0-9ß\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}" + 'schonmal den gesamten Pfad laden + Dim oNamenkonvention As String = FilterDatatable(My.Application.Globix.CURR_DT_DOCTYPE, $"", "NAMENKONVENTION", "", False).ToString & My.Application.Globix.CURRENT_WORKFILE_EXTENSION + NewFileString = oNamenkonvention + ' einen Regulären Ausdruck laden + Dim regulärerAusdruck As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(preg) + ' die Vorkommen im SQL-String auslesen + Dim oMatchelements As System.Text.RegularExpressions.MatchCollection = regulärerAusdruck.Matches(oNamenkonvention) + '#### + If oMatchelements.Count = 0 Then + _Logger.Debug("No RegularExpression Fileds on Nameconvention!") + End If + ' alle Vorkommen innerhalbd er Namenkonvention durchlaufen + For Each oElement As System.Text.RegularExpressions.Match In oMatchelements + Select Case oElement.Value.Substring(2, 1).ToUpper + 'Manueller Indexwert + Case "M" + _Logger.Debug("NameGenerieren: Manueller Index wird geprüft...") + Dim Indexname = oElement.Value.Substring(3, oElement.Value.Length - 4) - ' If dtp.Text = String.Empty Then - ' Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) - ' 'ClassDatabase.Execute_Scalar($"SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = {dokartid} AND NAME = '{oIndexName}'", MyConnectionString, True) + Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID} AND INDEXNAME = '{Indexname}'", "OPTIONAL", "", False) - ' If optional_index = False Then - ' MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) - ' dtp.Focus() - ' Return False - ' Else - ' Indexwert_Postprocessing(oIndexName, "") - ' result = True - ' End If - ' Else - ' Indexwert_Postprocessing(Replace(dtp.Name, "dtp", ""), dtp.Text) - ' result = True - ' End If - ' End If - ' If oControl.Name.StartsWith("chk") Then - ' Dim chk As CheckBox = oControl - ' Indexwert_Postprocessing(Replace(chk.Name, "chk", ""), chk.Checked) - ' result = True - ' End If - ' If TypeOf (oControl) Is Button Then - ' Continue For - ' End If - ' If oControl.Name.StartsWith("lbl") = False And result = False Then - ' _Logger.Info("Die Überprüfung der manuellen Indices ist fehlerhaft. Bitte informieren Sie den Systembetreuer") - ' Return False - ' End If - ' Next + Dim oManValue As String = GetManIndex_Value(Indexname, "FILE", optional_index) + If oManValue <> String.Empty Then + Dim firstVectorValue = oManValue.Split(ClassConstants.VECTORSEPARATOR).First() - ' Return True - ' Catch ex As Exception - ' _Logger.Warn(" - Unvorhergesehener Fehler in CheckWrite_IndexeMan - Fehler: " & vbNewLine & ex.Message) - ' _Logger.Error(ex.Message) - ' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unerwarteter Unexpected error in CheckWrite_IndexeMan:") - ' Return False - ' End Try - 'End Function - 'Function FillIndexe_Autom(dokart_id As Integer) - ' Try + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, firstVectorValue) + NewFileString = oNamenkonvention + sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString + AnzahlIndexe += 1 + sql_history_Index_Values = sql_history_Index_Values & ", '" & oManValue.Replace("'", "''") & "'" + Else - ' Dim oSQL = $"SELECT * FROM VWDDINDEX_AUTOM WHERE DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID}" - ' My.Application.Globix.CURR_DT_AUTO_INDEXE = My.Database.GetDatatable(oSQL) + If optional_index = True Then + oNamenkonvention = oNamenkonvention.Replace("-" & oElement.Value & "-", "-") + oNamenkonvention = oNamenkonvention.Replace("_" & oElement.Value & "_", "_") + oNamenkonvention = oNamenkonvention.Replace("_" & oElement.Value & "-", "_") + oNamenkonvention = oNamenkonvention.Replace("-" & oElement.Value & "_", "-") - ' Dim oRegex As New Regex("\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}") + oNamenkonvention = oNamenkonvention.Replace("-" & oElement.Value, "-") + oNamenkonvention = oNamenkonvention.Replace("_" & oElement.Value, "_") + oNamenkonvention = oNamenkonvention.Replace(oElement.Value & "-", "-") + oNamenkonvention = oNamenkonvention.Replace(oElement.Value & "_", "_") - ' If My.Application.Globix.CURR_DT_AUTO_INDEXE.Rows.Count = 0 Then - ' Return True - ' End If + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, oManValue) - ' ' 1. Schritt: Einfach-Indexe und Platzhalter ersetzen - ' For Each oAutoIndexRow As DataRow In My.Application.Globix.CURR_DT_AUTO_INDEXE.Rows - ' _Logger.Info("Working on AutomaticIndex: " & oAutoIndexRow.Item("INDEXNAME") & "...") - ' Dim oSqlResult As String = NotNull(oAutoIndexRow.Item("SQL_RESULT"), "") - ' Dim oSqlActive As Boolean = NotNull(oAutoIndexRow.Item("SQL_ACTIVE"), False) - ' Dim oSqlConnectionId As Integer = NotNull(oAutoIndexRow.Item("CONNECTION_ID"), -1) - ' Dim oSqlProvider As String = NotNull(oAutoIndexRow.Item("SQL_PROVIDER"), "") - ' Dim oEndResult As New List(Of String) + Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oNamenkonvention) + Dim oExtension = Path.GetExtension(oNamenkonvention) - ' ' Wenn kein SQL Befehl vorhanden oder aktiv ist, - ' ' versuchen wir, die Spalte VALUE zu ersetzen - ' If oSqlResult = String.Empty Or oSqlActive = 0 Then - ' Dim oPlaceholderResult As String - ' Dim oValue As String = NotNull(oAutoIndexRow.Item("VALUE"), "") + If oFilenameWithoutExtension.EndsWith("-") Or oFilenameWithoutExtension.EndsWith("_") Then + oFilenameWithoutExtension = oFilenameWithoutExtension.Substring(0, oFilenameWithoutExtension.Count - 1) + End If - ' oPlaceholderResult = GetPlaceholderValue(oValue, My.Application.Globix.CURRENT_WORKFILE, My.Application.User.ShortName) + NewFileString = oFilenameWithoutExtension & oExtension + sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString + AnzahlIndexe += 1 + sql_history_Index_Values = sql_history_Index_Values & ", '" & oManValue.Replace("'", "''") & "'" + Else + _Logger.Debug("Der Indexvalue für Index '" & Indexname & "' ist String.Empty") + err = True + End If - ' If Not IsNothing(oPlaceholderResult) Then - ' oValue = oPlaceholderResult - ' End If + End If + Case "A" + Dim value As String = GetAutoIndex_Value(oElement.Value.Substring(3, oElement.Value.Length - 4)) + If value <> String.Empty Then + If value = "EMPTY_OI" Then + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, "") + NewFileString = oNamenkonvention + Else + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, value) + NewFileString = oNamenkonvention + sql_history_INSERT_INTO = sql_history_INSERT_INTO & ", INDEX" & AnzahlIndexe.ToString + AnzahlIndexe += 1 + sql_history_Index_Values = sql_history_Index_Values & ", '" & value.Replace("'", "''") & "'" + End If + Else + err = True + End If + Case "V" + Dim datetemp As String + Dim _Month As String = My.Computer.Clock.LocalTime.Month + If _Month.Length = 1 Then + _Month = "0" & _Month + End If + Dim _day As String = My.Computer.Clock.LocalTime.Day + If _day.Length = 1 Then + _day = "0" & _day + End If + Dim type = oElement.Value '.ToUpper.Replace("[v%", "") + type = type.Replace("[%v_", "") + type = type.Replace("[%v", "") + type = type.Replace("]", "") + Select Case type + Case "YY_MM_DD" + datetemp = My.Computer.Clock.LocalTime.Year.ToString.Substring(2) & "_" & _Month & "_" & _day + Case "YYYY_MM_DD" + datetemp = My.Computer.Clock.LocalTime.Year & "_" & _Month & "_" & _day + Case "DD_MM_YY" + datetemp = _day & "_" & _Month & "_" & My.Computer.Clock.LocalTime.Year.ToString.Substring(2) + Case "DD_MM_YYYY" + datetemp = _day & "_" & _Month & "_" & My.Computer.Clock.LocalTime.Year + Case "YYMMDD" + datetemp = My.Computer.Clock.LocalTime.Year.ToString.Substring(2) & _Month & _day + Case "YYYYMMDD" + datetemp = My.Computer.Clock.LocalTime.Year & _Month & _day + Case "DDMMYY" + datetemp = _day & _Month & My.Computer.Clock.LocalTime.Year.ToString.Substring(2) + Case "DDMMYYYY" + datetemp = _day & _Month & My.Computer.Clock.LocalTime.Year + Case "OFilename" + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, System.IO.Path.GetFileNameWithoutExtension(My.Application.Globix.CURRENT_WORKFILE)) + Case "Username".ToUpper + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, Environment.UserName) + Case "Usercode".ToUpper + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, My.Application.User.ShortName) + Case "" + End Select + If datetemp <> "" Then + oNamenkonvention = oNamenkonvention.Replace(oElement.Value, datetemp) + End If + NewFileString = oNamenkonvention + Case "[%Version]".ToUpper + Try + Dim version As Integer = 1 + Dim Stammname As String = oRAWZielordner & "\" & oNamenkonvention.Replace(oElement.Value, "") + Dim _neuername As String = oRAWZielordner & "\" & oNamenkonvention.Replace(oElement.Value, "") + Stammname = _neuername.Replace(My.Application.Globix.VERSION_DELIMITER, "") + _neuername = _neuername.Replace(My.Application.Globix.VERSION_DELIMITER, "") + 'Dim MoveFilename As String = DATEINAME.Replace(element.Value, "") + 'Überprüfen ob File existiert + If File.Exists(_neuername) = False Then + NewFileString = _neuername + Else + Do While File.Exists(_neuername) + version = version + 1 + _neuername = Stammname.Replace(extension, "") & My.Application.Globix.VERSION_DELIMITER & version & extension + NewFileString = _neuername + Loop + End If + Catch ex As Exception + _Logger.Warn(" - Unexpected error in NameGenerieren - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Umbenennnen der Datei:") + err = True + End Try + Case Else + _Logger.Info(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oElement.Value.ToUpper) + MsgBox("Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oElement.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:") + End Select + Next - ' oAutoIndexRow.Item("Indexiert") = True - ' oAutoIndexRow.Item("Indexwert") = oValue + My.Application.Globix.CURRENT_NEWFILENAME = oFilesystem.GetCleanFilename(NewFileString) + 'CURRENT_NEWFILENAME = ClassFilehandle.CleanFilename(NewFileString, "") + My.Application.Globix.CURRENT_NEWFILENAME = Path.Combine(oRAWZielordner, My.Application.Globix.CURRENT_NEWFILENAME) - ' Continue For - ' End If + _Logger.Debug("#### ENDE Name_Generieren ####") + _Logger.Debug("") + If err = False Then + Return True + Else + Return False + End If - ' ' Wenn ein SQL Befehl vorhanden und aktiv ist - ' ' Alle Platzhalter finden - ' Dim oMatches As MatchCollection = oRegex.Matches(oSqlResult) + Catch ex As Exception + _Logger.Warn(" - Unvorhergesehener Unexpected error in Name_Generieren - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox(ex.Message, MsgBoxStyle.Critical, "Allgemeiner Unexpected error in Name_Generieren:") + Return False + End Try - ' For Each oMatch As Match In oMatches - ' Dim oIndexValue As String = StripPlaceholder(oMatch.Value) - ' Dim oOptionalIndex = False - ' Dim oPlaceholderResult As String = Nothing - ' Dim oManualIndexResult As String = Nothing + End Function + Private Function Move_File2_Target() + Dim oError As Boolean + Try + Dim oFolderForIndex = FilterDatatable(My.Application.Globix.CURR_DT_DOCTYPE, $"", "FOLDER_FOR_INDEX", "", False) - ' ' Einfachen Platzhalter Wert erzeugen - ' oPlaceholderResult = GetPlaceholderValue(oIndexValue, My.Application.Globix.CURRENT_WORKFILE, My.Application.User.ShortName) - - ' ' Einfachen Platzhalter ersetzen - ' If Not IsNothing(oPlaceholderResult) Then - ' oSqlResult = oSqlResult.Replace(oMatch.Value, oPlaceholderResult) - ' End If - - ' oOptionalIndex = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID} AND INDEXNAME = '{oIndexValue}'", "OPTIONAL", "", False) - - ' 'ClassDatabase.Execute_Scalar($"SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = {CURRENT_DOKART_ID} AND UPPER(NAME) = UPPER('{oIndexValue}')", MyConnectionString, True) - ' oManualIndexResult = GetManIndex_Value(oIndexValue, "IDX_AUTO", oOptionalIndex) - - ' ' Wenn Ergebnis den VektorPlatzhalter enthält, soll nichts ersetzt werden. - ' ' Werden im nächsten Schritt ersetzt. - ' If oManualIndexResult.Contains(ClassConstants.VECTORSEPARATOR) Then - ' oManualIndexResult = Nothing - ' End If - - ' If Not IsNothing(oManualIndexResult) Then - ' oSqlResult = oSqlResult.Replace(oMatch.Value, oManualIndexResult) - ' End If - ' Next + If Not IsDBNull(oFolderForIndex) Then + CreateFolderForIndex(oFolderForIndex) + Else + CreateFolderForIndex(String.Empty) + End If - ' 'TODO: Replace Windream Patterns? - ' oSqlResult = clsPatterns.ReplaceControlValues(oSqlResult, pnlIndex) - ' oSqlResult = clsPatterns.ReplaceInternalValues(oSqlResult) - ' If oSqlResult <> String.Empty Then - ' _Logger.Debug("oSqlResult after Replace [" & oSqlResult & "]") - ' End If - ' ' Ergebnis: Es wurden alle einfachen Platzhalter ersetzt, jetzt haben wir einen SQL Befehl, - ' ' der nur noch vektorfelder-platzhalter enthält + Dim oExportSuccessful As Boolean = False + 'Variable Folder + If DropType = "|DROPFROMFSYSTEM|" Or DropType = "|OUTLOOK_ATTACHMENT|" Or DropType = "|ATTMNTEXTRACTED|" Or DropType = "|FW_SIMPLEINDEXER|" Then + ' oExportSuccessful = SINGLEFILE_2_WINDREAM(My.Application.Globix.CURR_D) + ElseIf DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Or DropType = "|MSGONLY|" Or DropType = "|FW_OUTLOOK_MESSAGE|" Then + ' oExportSuccessful = SINGLEFILE_2_WINDREAM(CURR_DOKART_OBJECTTYPE) + End If + If oExportSuccessful = True Then + 'Kein Fehler in Export2windream + oError = False + If Write_Indizes() = True Then + 'Kein Fehler in Setzen der windream-Indizes + Dim Insert_String As String + Try + Dim tempCur_WF = My.Application.Globix.CURRENT_WORKFILE.Replace("'", "''") + Dim tempCur_New_FN = My.Application.Globix.CURRENT_NEWFILENAME.Replace("'", "''") + Insert_String = sql_history_INSERT_INTO & ",ADDED_WHO) VALUES ('" & tempCur_WF & "','" & tempCur_New_FN & "'" & sql_history_Index_Values & ",'" & Environment.UserDomainName & "\" & Environment.UserName & "')" + My.Database.GetScalarValue(Insert_String) + If DropType.Contains("MSG") Or DropType = "|ATTMNTEXTRACTED|" Or DropType = "|OUTLOOK_ATTACHMENT|" Then + If My.Application.Globix.CURRENT_MESSAGEID <> "" Then + Dim max As String = "SELECT MAX(GUID) FROM TBGI_HISTORY" + Dim GUID = My.Database.GetScalarValue(max) + Try + If GUID > 0 Then + Dim sqlUpdate As String + If DropType = "|ATTMNTEXTRACTED|" Or DropType = "|OUTLOOK_ATTACHMENT|" Then + sqlUpdate = "Update TBGI_HISTORY SET ATTACHMENT = 1, MSG_ID = '" & My.Application.Globix.CURRENT_MESSAGEID & "' WHERE GUID = " & GUID + My.Database.ExecuteNonQuery(sqlUpdate) + Else + sqlUpdate = "Update TBGI_HISTORY SET ATTACHMENT = 0, MSG_ID = '" & My.Application.Globix.CURRENT_MESSAGEID & "' WHERE GUID = " & GUID + My.Database.ExecuteNonQuery(sqlUpdate) + End If + End If + Catch ex As Exception + _Logger.Error(ex) + End Try + End If + End If - ' ' 2. Schritt: Vektorfelder ersetzen - ' Dim oVectorMatches As MatchCollection = oRegex.Matches(oSqlResult) - ' If oVectorMatches.Count > 0 Then - ' _Logger.Info(" There are " & oVectorMatches.Count & " matches for vectors!") - ' Dim oIsFirstMatch = True + Catch ex As Exception + _Logger.Error(ex) + MsgBox("Error in Insert-History - View logfile: " & ex.Message, MsgBoxStyle.Critical) + _Logger.Warn(" - Unexpected error in Insert-History - Fehler: " & vbNewLine & ex.Message) + _Logger.Warn(" - Unexpected error in Insert-History - SQL: " & Insert_String) + oError = True + End Try + Else + oError = True + End If + Else + oError = True - ' For Each oVectorMatch As Match In oVectorMatches - ' Dim oIndexValue As String = StripPlaceholder(oVectorMatch.Value) - ' Dim oOptionalIndex = False - ' Dim oManualIndexResult As String = Nothing + If My.Application.User.Language = "de-DE" Then + MsgBox("Der Export nach windream war nicht erfolgreich - Check LogFile", MsgBoxStyle.Exclamation) + Else + MsgBox("Export to windream was unsucessful - Check LogFile", MsgBoxStyle.Exclamation) + End If + End If - ' oOptionalIndex = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID} AND INDEXNAME = '{oIndexValue}'", "OPTIONAL", "", False) - ' ' ClassDatabase.Execute_Scalar($"SELECT OPTIONAL FROM TBDD_INDEX_MAN WHERE DOK_ID = {CURRENT_DOKART_ID} AND UPPER(NAME) = UPPER('{oIndexValue}')", MyConnectionString, True) - ' oManualIndexResult = GetManIndex_Value(oIndexValue, "IDX_AUTO", oOptionalIndex) + 'False oder True zurückgeben + 'Kein Fehler aufgetreten + If oError = False Then + Return True + Else + 'Fehler aufgetreten + Return False + End If + Catch ex As Exception + _Logger.Error(ex) + MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected Error in Move File2Target:") + Return False + End Try + End Function + Private Function Write_Indizes() + Try + Dim indexierung_erfolgreich As Boolean = False + ' 'Manuelle Indexe Indexieren + ' Dim DTMan As DataTable = MyDataset.VWDDINDEX_MAN + ' If DTMan.Rows.Count > 0 Then + ' Dim Count As Integer = 0 + ' For Each row As DataRow In DTMan.Rows + ' Dim idxvalue = row.Item("Indexwert") + ' Dim indexname = row.Item("WD_INDEX").ToString + ' _Logger.Debug($"Write_Indizes - Index [{indexname}]...") + ' Dim optional_Index = CBool(row.Item("OPTIONAL")) + ' Dim indexiert = CBool(row.Item("Indexiert")) + ' If indexiert And idxvalue.ToString <> "" And idxvalue <> "EMPTY_OI" Then + ' If indexname <> String.Empty Then + ' If row.Item("SAVE_VALUE") = True Then + ' 'Den Indexwert zwischenspeichern + ' Dim DTTemp As DataTable = MyDataset.TBTEMP_INDEXRESULTS + ' Dim rowexists As Boolean = False + ' For Each rowTemp As DataRow In DTTemp.Rows + ' 'Wenn bereits ein Eintrag existiert..... + ' If rowTemp.Item("Dokumentart") = row.Item("DOKUMENTART") And rowTemp.Item("Indexname") = row.Item("INDEXNAME") Then + ' rowexists = True + ' '......überschreiben + ' rowTemp.Item("Value") = row.Item("Indexwert") + ' End If + ' Next + ' '.....ansonsten neu anlegen + ' If rowexists = False Then + ' Dim newRow As DataRow = DTTemp.NewRow() + ' newRow("Dokumentart") = row.Item("DOKUMENTART").ToString + ' newRow("Indexname") = row.Item("INDEXNAME").ToString + ' newRow("Value") = row.Item("Indexwert") + ' DTTemp.Rows.Add(newRow) + ' End If + ' End If - ' Dim oVectorIndexValues = oManualIndexResult.Split(ClassConstants.VECTORSEPARATOR).ToList() - - ' For Each oVectorIndexValue In oVectorIndexValues - ' Dim oTempSql = oSqlResult.Replace(oVectorMatch.Value, oVectorIndexValue) - ' Dim oResult = GetAutomaticIndexSQLValue(oTempSql, oSqlConnectionId, oSqlProvider) - ' oEndResult.Add(oResult) - ' Next - - ' ' Verhindert, dass die Schleife mehrmals durchlaufen wird - ' If oIsFirstMatch Then - ' Exit For - ' End If - ' oAutoIndexRow.Item("Indexiert") = True - ' oAutoIndexRow.Item("Indexwert") = String.Join(ClassConstants.VECTORSEPARATOR, oEndResult.ToArray) - ' Next - ' Else - ' Dim oResult = GetAutomaticIndexSQLValue(oSqlResult, oSqlConnectionId, oSqlProvider) - ' _Logger.Info("Got a simple SQLResult: " & oResult.ToString) - ' oAutoIndexRow.Item("Indexiert") = True - ' oAutoIndexRow.Item("Indexwert") = oResult - - ' End If - ' Next - - ' Return True - ' Catch ex As Exception - ' _Logger.Error(ex) - ' MsgBox(ex.Message) - ' Return False - ' End Try - 'End Function - 'Function GetAutomaticIndexSQLValue(SQLCommand As String, vconnectionID As Integer, vProvider As String) As String - ' Try - ' Dim oConnectionString As String - ' oConnectionString = My.Database.Get_ConnectionStringforID(vconnectionID) - ' If oConnectionString <> "" Then - ' 'NEU - ' Dim oErgebnis - ' 'Welcher Provider? - ' 'If vProvider.ToLower = "oracle" Then - ' 'oErgebnis = My.Database.leExecute_Scalar(SQLCommand, oConnectionString) - ' 'Else 'im Moment nur SQL-Server - ' oErgebnis = My.Database.GetScalarValueConStr(SQLCommand, oConnectionString) - ' 'End If + ' _Logger.Debug($"Manueller Indexvalue [{idxvalue.ToString}]...NOW THE INDEXING...") + ' Count += 1 - ' _Logger.Debug("SQL-ConnectionString: " & oConnectionString.Substring(0, oConnectionString.LastIndexOf("="))) + ' ' den Typ des Zielindexes auslesen + ' Dim oIndexType As Integer = WINDREAM.GetIndexType(indexname) + ' _Logger.Debug($"oIndexType [{oIndexType.ToString}]...") + ' If oIndexType < WINDREAM.WMObjectVariableValueTypeVector Then + ' _Logger.Debug($"Indexing oIndexType < WINDREAM.WMObjectVariableValueTypeVector...") + ' indexierung_erfolgreich = WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, indexname, idxvalue, CURR_DOKART_OBJECTTYPE) + ' Else + ' Dim oSplitArray = Split(idxvalue, ClassConstants.VECTORSEPARATOR) + ' Dim oListofString As New List(Of String) + ' If oSplitArray.Count = 0 Then + ' oListofString.Add(idxvalue) + ' Else + ' For Each oStr In oSplitArray + ' oListofString.Add(oStr) + ' Next + ' End If - ' If oErgebnis Is Nothing Then - ' 'showlblhinweis("Kein Ergebnis für automatisches SQL: " & vsqlstatement) - ' Return "" - ' Else - ' Return oErgebnis - ' End If - ' End If + ' indexierung_erfolgreich = WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, indexname, oListofString, CURR_DOKART_OBJECTTYPE) + ' End If - ' Catch ex As Exception - ' _Logger.Warn(" - Unexpected error in Get_AutomatischerIndex_SQL - Fehler: " & vbNewLine & ex.Message) - ' _Logger.Error(ex.Message) - ' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Get_AutomatischerIndex_SQL:") - ' Return "" - ' End Try - 'End Function - 'Sub Indexwert_Postprocessing(indexname As String, wert_in As String) - ' Try + ' 'indexierung_erfolgreich = ClassWindream.DateiIndexieren(CURRENT_NEWFILENAME, indexname, idxvalue) + ' If indexierung_erfolgreich = False Then + ' MsgBox("Error in Indexing file - See log", MsgBoxStyle.Critical) + ' Return False + ' Exit For + ' End If + ' Else - ' Dim value_post As String = "" - ' For Each oDataRow As DataRow In My.Application.Globix.CURR_DT_MAN_INDEXE.Rows - ' If oDataRow.Item("INDEXNAME") = indexname Then - ' Dim idxid As Integer = oDataRow.Item("GUID") - ' If idxid > 0 Then - ' ' In jedem Fall schon mal den Wert einfügen - ' oDataRow.Item("Indexwert") = wert_in - ' 'Die Nachbearbeitungsschritte laden - ' 'FILE AND INDEX - ' 'Zuerst nur die Fälle für die Variante ONLY FILE/FOLDER - ' Dim DTNB As DataTable = FilterDatatable(My.Application.Globix.CURR_INDEX_MAN_POSTPROCESSING, "IDXMAN_ID = " & idxid & " AND VARIANT = 'ONLY FILE/FOLDER'", "", "SEQUENCE", True) - ' 'ClassDatabase.Return_Datatable("SELECT * FROM TBDD_INDEX_MAN_POSTPROCESSING WHERE IDXMAN_ID = " & idxid & " AND VARIANT = 'ONLY FILE/FOLDER' ORDER BY SEQUENCE") - ' If DTNB Is Nothing = False Then - ' If DTNB.Rows.Count > 0 Then - ' value_post = clsPostProcessing.Get_Nachbearbeitung_Wert(wert_in, DTNB) - ' oDataRow.Item("Indexwert") = wert_in - ' oDataRow.Item("Indexwert_File") = value_post - ' End If - ' End If - ' 'Jetzt die Fälle für die Variante FILE AND INDEX - ' DTNB = Nothing + ' _Logger.Debug("No Indexing: indexname: " & indexname) + ' _Logger.Debug("No Indexing: is optional? " & optional_Index.ToString) + ' End If + ' Else + ' _Logger.Debug("Indexvalue is empty or field is not indexed - Indexname: " & indexname) + ' _Logger.Info("Indexvalue is empty or field is not indexed - Indexname: " & indexname) + ' End If + ' Next - ' DTNB = FilterDatatable(My.Application.Globix.CURR_INDEX_MAN_POSTPROCESSING, "IDXMAN_ID = " & idxid & " AND VARIANT = 'FILE AND INDEX'", "", "SEQUENCE", True) - ' 'ClassDatabase.Return_Datatable("SELECT * FROM TBDD_INDEX_MAN_POSTPROCESSING WHERE IDXMAN_ID = " & idxid & " AND VARIANT = 'FILE AND INDEX' ORDER BY SEQUENCE") - ' If DTNB Is Nothing = False Then - ' If DTNB.Rows.Count > 0 Then - ' value_post = clsPostProcessing.Get_Nachbearbeitung_Wert(wert_in, DTNB) - ' oDataRow.Item("Indexwert") = value_post - ' End If - ' End If - ' End If - ' oDataRow.Item("Indexiert") = True - ' End If - ' Next - ' Catch ex As Exception - ' _Logger.Warn(" - Unvorhergesehener Unexpected error in Indexwert_Postprocessing - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message) - ' _Logger.Error(ex.Message) - ' MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Indexwert_Postprocessing:") - ' End Try - 'End Sub + ' End If + ' 'Automatische Indexe Indexieren + ' Dim DTAut As DataTable = MyDataset.VWDDINDEX_AUTOM + ' If DTAut.Rows.Count > 0 Then + ' Dim Count As Integer = 0 + ' For Each row As DataRow In DTAut.Rows + ' Dim indexiert = CBool(row.Item("Indexiert")) + ' Dim Indexvalue = row.Item("Indexwert").ToString + ' Dim indexname = row.Item("INDEXNAME").ToString + ' If indexiert = True And Indexvalue <> "" Then + ' If Indexvalue <> "EMPTY_OI" Then + ' _Logger.Info("Auto Indexname: " & indexname.ToString) + ' _Logger.Info("Indexvalue: " & Indexvalue.ToString) + ' Count += 1 + + ' ' den Typ des Zielindexes auslesen + ' Dim indexType As Integer = WINDREAM.GetIndexType(indexname) + + ' If indexType < WINDREAM.WMObjectVariableValueTypeVector Then + ' indexierung_erfolgreich = WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, indexname, Indexvalue, CURR_DOKART_OBJECTTYPE) + ' Else + ' Dim oSplitArray = Split(Indexvalue, ClassConstants.VECTORSEPARATOR) + ' Dim oListofString As New List(Of String) + ' If oSplitArray.Count = 0 Then + ' oListofString.Add(Indexvalue) + ' Else + ' For Each oStr In oSplitArray + ' oListofString.Add(oStr) + ' Next + ' End If + ' indexierung_erfolgreich = WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, indexname, oListofString, CURR_DOKART_OBJECTTYPE) + ' End If + + ' 'indexierung_erfolgreich = WINDREAM.SetFileIndex(CURRENT_NEWFILENAME, indexname, Indexvalue, CURR_DOKART_OBJECTTYPE) + ' If indexierung_erfolgreich = False Then + ' MsgBox("Error in indexing file - See log", MsgBoxStyle.Critical) + ' Return False + ' Exit For + ' End If + ' End If + ' End If + ' Next + ' End If + ' If DropType = "|OUTLOOK_MESSAGE|" Or DropType = "|FW_MSGONLY|" Or DropType = "|MSGONLY|" Or CURRENT_NEWFILENAME.EndsWith(".msg") Then + ' indexierung_erfolgreich = SetEmailIndices() + ' If indexierung_erfolgreich = False Then + ' MsgBox("Error in SetEmailIndices - See log", MsgBoxStyle.Critical) + ' Return False + ' End If + ' ElseIf DropType = "|ATTMNTEXTRACTED|" Or DropType = "|OUTLOOK_ATTACHMENT|" Then + ' indexierung_erfolgreich = SetAttachmentIndices() + ' If indexierung_erfolgreich = False Then + ' MsgBox("Error in SetEmailIndices - See log", MsgBoxStyle.Critical) + ' Return False + ' End If + ' End If + Return True + Catch ex As Exception + _Logger.Warn("Unexpected error in Write_Indizes - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox("Error in Write_Indizes:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) + Return False + End Try + + End Function + Private Function CreateFolderForIndex(DynamicFolderConfig As String) + Try + Dim oRootFolder As String = Path.GetDirectoryName(My.Application.Globix.CURRENT_NEWFILENAME) + Dim oFilesystem As New DigitalData.Modules.Filesystem.File(_LogConfig) + + + If DynamicFolderConfig <> String.Empty Then + '###### + Dim oRegexString As String = "\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}" + ' einen Regulären Ausdruck laden + Dim oRegex As Regex = New Regex(oRegexString) + ' die Vorkommen im Folder-String auslesen + Dim oMatches As MatchCollection = oRegex.Matches(DynamicFolderConfig) + '#### + + ' alle Vorkommen innerhalb des Ordnerstrings durchlaufen + For Each oMatch As Match In oMatches + _Logger.Info("Elementname in FolderString: '" & oMatch.ToString & "'") + Select Case oMatch.Value.Substring(2, 1).ToUpper + + 'Manueller Indexwert + Case "M" + Dim oManIndexName = oMatch.Value.Substring(3, oMatch.Value.Length - 4) + Dim oIsOptional As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID} AND INDEXNAME = '{oManIndexName}'", "OPTIONAL", "", False) + + _Logger.Info("Versuch den Indexwert aus '" & oManIndexName & "' auszulesen.") + Dim oManIndexValue As String = GetManIndex_Value(oManIndexName, "FILE", oIsOptional) + _Logger.Info("Ergebnis/Wert für neuen Ordner: '" & oManIndexName & "'") + If Not oManIndexValue = String.Empty Then + If IsDate(oManIndexValue) Then + oManIndexValue = CDate(oManIndexValue).ToString("yyyyMMdd") + End If + + oManIndexValue = oFilesystem.GetCleanPath(oManIndexValue) + 'oManIndexValue = ClassFilehandle.CleanFilename(oManIndexValue, "") + DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oManIndexValue) + + _Logger.Info("FolderPattern: '" & DynamicFolderConfig & "'") + Else + + If oIsOptional = True Then + _Logger.Info("Optionaler Indexwert ist NICHT gefüllt") + DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, String.Empty) + Else + _Logger.Info(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!") + Return True + End If + End If + Case "A" + Dim oAutoIndexName = oMatch.Value.Substring(3, oMatch.Value.Length - 4) + _Logger.Info("Versuch den Auto-Indexwert aus '" & oAutoIndexName & "' auszulesen.") + Dim oAutoIndexValue As String = GetAutoIndex_Value(oAutoIndexName) + _Logger.Info("Ergebnis/Wert für neuen Ordner: '" & oAutoIndexName & "'") + If Not oAutoIndexValue = String.Empty Then + + oAutoIndexValue = oFilesystem.GetCleanPath(oAutoIndexValue) + 'oAutoIndexValue = ClassFilehandle.CleanFilename(oAutoIndexValue, "") + If oAutoIndexValue = "EMPTY_OI" Then + DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, "") + Else + DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oAutoIndexValue) + _Logger.Info("FolderPattern: '" & DynamicFolderConfig & "'") + End If + + Else + _Logger.Info(" - Achtung Ausnahme in 'CrFolderForIndex': der Index ist leer!") + End If + Case "V" + Dim oElementTemp As String + Dim _Month As String = My.Computer.Clock.LocalTime.Month + If _Month.Length = 1 Then + _Month = "0" & _Month + End If + Dim _day As String = My.Computer.Clock.LocalTime.Day + If _day.Length = 1 Then + _day = "0" & _day + End If + Dim type = oMatch.Value.Substring(3, oMatch.Value.Length - 4) + If type.StartsWith("_") Then + type = type.Replace("_", "") + End If + Select Case type + Case "YYYY/MM/DD" + oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month & "\" & _day + Case "YYYY/MM" + oElementTemp = My.Computer.Clock.LocalTime.Year & "\" & _Month + Case "YYYY" + oElementTemp = My.Computer.Clock.LocalTime.Year + Case "YYYY-MM" + oElementTemp = My.Computer.Clock.LocalTime.Year & "-" & _Month + End Select + DynamicFolderConfig = DynamicFolderConfig.Replace(oMatch.ToString, oElementTemp) + _Logger.Info("FolderPatter nach V-Element: '" & DynamicFolderConfig & "'") + Case Else + _Logger.Warn(" - Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper) + + If My.Application.User.Language = "de-DE" Then + MsgBox("Achtung - in der Namenkonvention wurde ein Element gefunden welches nicht zugeordnet werden kann!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:") + Else + MsgBox("Attention - One element in Namingconvention could not be matched!" & vbNewLine & "Elementname: " & oMatch.Value.ToUpper, MsgBoxStyle.Exclamation, "Unexpected error in Name generieren:") + End If + End Select + Next + End If + + + + + _Logger.Info("Den Root-Folder zusammenfügen>> ") + + Dim oNewFullPath As String = System.IO.Path.Combine(oRootFolder, DynamicFolderConfig) + + _Logger.Info("Fullpath (mit evtl. Sonderzeichen (SZ)) '" & oNewFullPath & "'") + Dim invalidPathChars() As Char = Path.GetInvalidPathChars() + For Each sonderChar As Char In invalidPathChars + 'Sonderzeichen ausser Whitespace entfernen + If Char.IsWhiteSpace(sonderChar) = False Then + If oNewFullPath.Contains(sonderChar) Then + oNewFullPath = oNewFullPath.Replace(sonderChar, "") + End If + End If + Next sonderChar + ' oNewFullPath = WINDREAM.GetCleanedPath(oNewFullPath) + + _Logger.Info("Fullpath (ohne SZ) '" & oNewFullPath & "'") + If Directory.Exists(oNewFullPath) = False Then + Try + Dim oCreatedPath = Directory.CreateDirectory(oNewFullPath) + oNewFullPath = oCreatedPath.FullName + _Logger.Info("Folder '" & oNewFullPath & "' wurde angelegt") + Catch ex As Exception + _Logger.Info("Error in CreateFolderforIndex-Method - Root Folder '" & oNewFullPath & "' could not be created. " & ex.Message) + _Logger.Error(ex.Message) + MsgBox("Attention: Root Folder '" & oNewFullPath & "' could not be created." & vbNewLine & ex.Message, MsgBoxStyle.Critical) + Return False + End Try + End If + + My.Application.Globix.CURRENT_NEWFILENAME = Path.Combine(oNewFullPath, Path.GetFileName(My.Application.Globix.CURRENT_NEWFILENAME)) + + Return True + Catch ex As Exception + MsgBox("Unexpected Error in CreateFolderforIndex-Method:" & vbNewLine & ex.Message, MsgBoxStyle.Critical) + _Logger.Warn("Fehler in CrFolderForIndex: " & ex.Message) + _Logger.Error(ex) + Return False + End Try + End Function + Function GetAutoIndex_Value(indexname As String) + Try + + For Each oDataRow As DataRow In My.Application.Globix.CURR_DT_MAN_INDEXE.Rows + If oDataRow.Item("INDEXNAME").ToString.ToLower = indexname.ToLower Then + Dim oIndexWert = oDataRow.Item("Indexwert") + Dim oIsIndexed = oDataRow.Item("Indexiert") + + If oIsIndexed = True Then + If oIndexWert.ToString <> String.Empty Then + oIndexWert = oIndexWert.ToString + + ' If Index is a vectorfield (read: Value contains the VECTORSEPARATOR character), use the first value + If oIndexWert.Contains(ClassConstants.VECTORSEPARATOR) Then + Return oIndexWert.ToString.Split(ClassConstants.VECTORSEPARATOR).FirstOrDefault() + Else + ' Else just return the normal value + Return oIndexWert + End If + Else + ShowNotice("Der Automatische Index: " & oDataRow.Item("INDEXNAME") & " wurde nicht ordnungsgemäss indexiert!") + Return "" + End If + Else + ShowNotice("Der Automatische Index: " & oDataRow.Item("INDEXNAME") & " wurde nicht ordnungsgemäss indexiert!") + Return "" + End If + Exit For + End If + Next + Catch ex As Exception + _Logger.Warn(" - Unvorhergesehener Unexpected error in GetAutoIndex_Value - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox("Indexname: " & indexname & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Unexpected error in GetAutoIndex_Value:") + Return "" + End Try + End Function + Function GetManIndex_Value(indexname As String, RequestFor As String, opt As Boolean) + Try + + For Each DR As DataRow In DT_INDEXEMAN.Rows + If DR.Item("INDEXNAME").ToString.ToLower = indexname.ToLower Then + If DR.Item("Indexiert") = True Then + _Logger.Info("## Manueller Index: " & indexname) + Select Case RequestFor + Case "FILE" + If DR.Item("Indexwert_File").ToString <> String.Empty Then + _Logger.Info(" >>Es liegt ein separater nachbearbeiteter Wert für die Dateibenennung vor: " & DR.Item("Indexwert_File").ToString) + _Logger.Info(" >>Zurückgegebener NachbearbeitungsWert: " & DR.Item("Indexwert_File")) + Return DR.Item("Indexwert_File") + Else + If DR.Item("Indexwert").ToString <> String.Empty Then + _Logger.Info("Zurückgegebener manueller Indexwert: " & DR.Item("Indexwert")) + Return DR.Item("Indexwert") + Else + If opt = False Then + _Logger.Info("Achtung, der Indexwert des manuellen Indexes '" & indexname & "' ist String.empty!") + ShowNotice("Indexiert = True - Der Index: " & DR.Item("INDEXNAME") & " wurde nicht ordnungsgemäss indexiert! - Automatischer Index konnte nicht gesetzt werden!") + Return Nothing + Else + Return "" + End If + + End If + End If + Case Else + If DR.Item("Indexwert").ToString <> String.Empty Then + _Logger.Info(" >>Zurückgegebener manueller Indexwert: " & DR.Item("Indexwert")) + Return DR.Item("Indexwert") + Else + + If opt = False Then + _Logger.Info("Achtung, der Indexwert des manuellen Indexes '" & indexname & "' ist String.empty!") + ShowNotice("Indexiert = True - Der Index: " & DR.Item("INDEXNAME") & " wurde nicht ordnungsgemäss indexiert! - Automatischer Index konnte nicht gesetzt werden!") + Return Nothing + Else + Return "" + End If + End If + End Select + Else + ShowNotice("Der Index: " & DR.Item("INDEXNAME") & " wurde nicht ordnungsgemäss indexiert! - Automatischer Index konnte nicht gesetzt werden!") + Return Nothing + End If + Exit For + End If + Next + Catch ex As Exception + _Logger.Warn(" - Unvorhergesehener Unexpected error in GetManIndex_Value - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox("Indexname: " & indexname & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Unexpected error in GetManIndex_Value:") + Return Nothing + End Try + End Function + Function CheckWrite_IndexeMan(dokartid As Integer) + '#### Zuerst manuelle Werte indexieren #### + Try + _Logger.Info("In CheckWrite_IndexeMan") + Dim result As Boolean = False + For Each oControl As Control In Me.pnlIndex.Controls + ' MsgBox(ctrl.Name) + If oControl.Name.StartsWith("txt") Then + Dim box As DevExpress.XtraEditors.TextEdit = oControl + If box.Text = "" Then + Dim oIndexName = Replace(box.Name, "txt", "") + Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {dokartid} AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) + + If optional_index = False Then + MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, "Fehlende Eingabe:") + box.Focus() + Return False + Else + Indexwert_Postprocessing(Replace(box.Name, "txt", ""), "") + result = True + End If + Else + If Indexwert_checkValueDB(Replace(box.Name, "txt", ""), box.Text) = False Then + _Logger.Info(" - Der eingegebene Wert wurde nicht in der Datenbank gefunden") + MsgBox("Der eingegebene Wert wurde nicht in der Datenbank gefunden!", MsgBoxStyle.Exclamation, "Fehlerhafte Indexierung:") + box.Focus() + Return False + Else + Indexwert_Postprocessing(Replace(box.Name, "txt", ""), box.Text) + result = True + End If + End If + End If + + If oControl.Name.StartsWith("cmbMulti") Then + Dim oLookup = DirectCast(oControl, DigitalData.Controls.LookupGrid.LookupControl2) + Dim values As List(Of String) = oLookup.SelectedValues + + If values.Count = 0 Then + Dim oIndexName = Replace(oLookup.Name, "cmbMulti", "") + Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {dokartid} AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) + + + If optional_index = False Then + MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) + oLookup.Focus() + Return False + Else + Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), "") + result = True + End If + Else + Dim vectorValue = String.Join(ClassConstants.VECTORSEPARATOR, values) + Indexwert_Postprocessing(Replace(oLookup.Name, "cmbMulti", ""), vectorValue) + result = True + End If + ElseIf oControl.Name.StartsWith("cmbSingle") Then + Dim cmbSingle As TextBox = oControl + + If cmbSingle.Text = "" Then + Dim oIndexName = Replace(cmbSingle.Name, "cmbSingle", "") + Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) + + + If optional_index = False Then + MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) + cmbSingle.Focus() + Return False + Else + Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbSingle", ""), "") + result = True + End If + Else + Indexwert_Postprocessing(Replace(cmbSingle.Name, "cmbSingle", ""), cmbSingle.Text) + result = True + End If + ElseIf oControl.Name.StartsWith("cmb") Then + Dim cmb As ComboBox = oControl + If cmb.Text = "" Then + Dim oIndexName = Replace(cmb.Name, "cmb", "") + Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) + + If optional_index = False Then + MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) + cmb.Focus() + Return False + Else + Indexwert_Postprocessing(Replace(cmb.Name, "cmb", ""), "") + result = True + End If + Else + Indexwert_Postprocessing(Replace(cmb.Name, "cmb", ""), cmb.Text) + result = True + End If + End If + If oControl.Name.StartsWith("dtp") Then + Dim dtp As DevExpress.XtraEditors.DateEdit = oControl + Dim oIndexName As String = Replace(dtp.Name, "dtp", "") + + If dtp.Text = String.Empty Then + Dim optional_index As Boolean = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = dokartid AND INDEXNAME = '{oIndexName}'", "OPTIONAL", "", False) + + + If optional_index = False Then + MsgBox(TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, Text) + dtp.Focus() + Return False + Else + Indexwert_Postprocessing(oIndexName, "") + result = True + End If + Else + Indexwert_Postprocessing(Replace(dtp.Name, "dtp", ""), dtp.Text) + result = True + End If + End If + If oControl.Name.StartsWith("chk") Then + Dim chk As CheckBox = oControl + Indexwert_Postprocessing(Replace(chk.Name, "chk", ""), chk.Checked) + result = True + End If + If TypeOf (oControl) Is Button Then + Continue For + End If + If oControl.Name.StartsWith("lbl") = False And result = False Then + _Logger.Info("Die Überprüfung der manuellen Indices ist fehlerhaft. Bitte informieren Sie den Systembetreuer") + Return False + End If + Next + + Return True + Catch ex As Exception + _Logger.Warn(" - Unvorhergesehener Fehler in CheckWrite_IndexeMan - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox(ex.Message, MsgBoxStyle.Critical, "Unerwarteter Unexpected error in CheckWrite_IndexeMan:") + Return False + End Try + End Function + + Function Indexwert_checkValueDB(indexname As String, wert As String) + Try + Dim DR As DataRow + 'DT = DD_DMSLiteDataSet.VWINDEX_MAN + For Each DR In DT_INDEXEMAN.Rows + If DR.Item("NAME") = indexname Then + If DR.Item("SQL_CHECK").ToString <> String.Empty Then + Dim connectionString As String + Dim sql As String + connectionString = My.Database.Get_ConnectionStringforID(DR.Item("CONNECTION_ID")) + If connectionString <> "" Then + Dim sqlscalar = DR.Item("SQL_CHECK") + Select Case DR.Item("DATENTYP") + Case "INTEGER" + sqlscalar = sqlscalar.ToString.Replace("@manValue", wert) + Case Else + sqlscalar = sqlscalar.ToString.Replace("@manValue", "'" & wert & "'") + End Select + + sql = sqlscalar + Dim ergebnis As Integer + 'If DR.Item("SQL_PROVIDER") = "Oracle" Then + ' ergebnis = ClassDatabase.OracleExecute_Scalar(sql, connectionString) + 'Else + 'MSQL + ergebnis = My.Database.GetScalarValueConStr(sql, connectionString) + ' End If + + Select Case ergebnis + Case 1 + Return True + Case 2 + ShowNotice("Indexwert nicht eindeutig: " & sql) + Return False + Case 99 + Return False + End Select + + End If + Else + Return True + End If + + End If + Next + Catch ex As Exception + MsgBox("Indexname: " & indexname & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Unexpected error in Indexwert_checkValue:") + _Logger.Info(" - Unvorhergesehener Unexpected error in Indexwert_checkValue - Fehler: " & vbNewLine & ex.Message) + Return False + End Try + End Function + Function FillIndexe_Autom(dokart_id As Integer) + Try + + Dim oSQL = $"SELECT * FROM VWDDINDEX_AUTOM WHERE DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID}" + My.Application.Globix.CURR_DT_AUTO_INDEXE = My.Database.GetDatatable(oSQL) + + Dim oRegex As New Regex("\[%{1}[a-zA-Z0-9\!\$\&\/\(\)\=\?\,\.\-\;\:_öÖüÜäÄ\#\'\+\*\~\{\}\@\€\<\>\ ]+]{1}") + + If My.Application.Globix.CURR_DT_AUTO_INDEXE.Rows.Count = 0 Then + Return True + End If + + ' 1. Schritt: Einfach-Indexe und Platzhalter ersetzen + For Each oAutoIndexRow As DataRow In My.Application.Globix.CURR_DT_AUTO_INDEXE.Rows + _Logger.Info("Working on AutomaticIndex: " & oAutoIndexRow.Item("INDEXNAME") & "...") + Dim oSqlResult As String = NotNull(oAutoIndexRow.Item("SQL_RESULT"), "") + Dim oSqlActive As Boolean = NotNull(oAutoIndexRow.Item("SQL_ACTIVE"), False) + Dim oSqlConnectionId As Integer = NotNull(oAutoIndexRow.Item("CONNECTION_ID"), -1) + Dim oSqlProvider As String = NotNull(oAutoIndexRow.Item("SQL_PROVIDER"), "") + Dim oEndResult As New List(Of String) + + ' Wenn kein SQL Befehl vorhanden oder aktiv ist, + ' versuchen wir, die Spalte VALUE zu ersetzen + If oSqlResult = String.Empty Or oSqlActive = 0 Then + Dim oPlaceholderResult As String + Dim oValue As String = NotNull(oAutoIndexRow.Item("VALUE"), "") + + oPlaceholderResult = GetPlaceholderValue(oValue, My.Application.Globix.CURRENT_WORKFILE, My.Application.User.ShortName) + + If Not IsNothing(oPlaceholderResult) Then + oValue = oPlaceholderResult + End If + + oAutoIndexRow.Item("Indexiert") = True + oAutoIndexRow.Item("Indexwert") = oValue + + Continue For + End If + + ' Wenn ein SQL Befehl vorhanden und aktiv ist + ' Alle Platzhalter finden + Dim oMatches As MatchCollection = oRegex.Matches(oSqlResult) + + For Each oMatch As Match In oMatches + Dim oIndexValue As String = StripPlaceholder(oMatch.Value) + Dim oOptionalIndex = False + Dim oPlaceholderResult As String = Nothing + Dim oManualIndexResult As String = Nothing + + ' Einfachen Platzhalter Wert erzeugen + oPlaceholderResult = GetPlaceholderValue(oIndexValue, My.Application.Globix.CURRENT_WORKFILE, My.Application.User.ShortName) + + ' Einfachen Platzhalter ersetzen + If Not IsNothing(oPlaceholderResult) Then + oSqlResult = oSqlResult.Replace(oMatch.Value, oPlaceholderResult) + End If + + oOptionalIndex = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID} AND INDEXNAME = '{oIndexValue}'", "OPTIONAL", "", False) + + + oManualIndexResult = GetManIndex_Value(oIndexValue, "IDX_AUTO", oOptionalIndex) + + ' Wenn Ergebnis den VektorPlatzhalter enthält, soll nichts ersetzt werden. + ' Werden im nächsten Schritt ersetzt. + If oManualIndexResult.Contains(ClassConstants.VECTORSEPARATOR) Then + oManualIndexResult = Nothing + End If + + If Not IsNothing(oManualIndexResult) Then + oSqlResult = oSqlResult.Replace(oMatch.Value, oManualIndexResult) + End If + Next + + + 'TODO: Replace Windream Patterns? + oSqlResult = clsPatterns.ReplaceControlValues(oSqlResult, pnlIndex) + oSqlResult = clsPatterns.ReplaceInternalValues(oSqlResult) + If oSqlResult <> String.Empty Then + _Logger.Debug("oSqlResult after Replace [" & oSqlResult & "]") + End If + ' Ergebnis: Es wurden alle einfachen Platzhalter ersetzt, jetzt haben wir einen SQL Befehl, + ' der nur noch vektorfelder-platzhalter enthält + + ' 2. Schritt: Vektorfelder ersetzen + Dim oVectorMatches As MatchCollection = oRegex.Matches(oSqlResult) + If oVectorMatches.Count > 0 Then + _Logger.Info(" There are " & oVectorMatches.Count & " matches for vectors!") + Dim oIsFirstMatch = True + + For Each oVectorMatch As Match In oVectorMatches + Dim oIndexValue As String = StripPlaceholder(oVectorMatch.Value) + Dim oOptionalIndex = False + Dim oManualIndexResult As String = Nothing + + oOptionalIndex = FilterDatatable(My.Application.Globix.CURR_DT_MAN_INDEXE, $"DOK_ID = {My.Application.Globix.CURRENT_DOCTYPE_ID} AND INDEXNAME = '{oIndexValue}'", "OPTIONAL", "", False) + + oManualIndexResult = GetManIndex_Value(oIndexValue, "IDX_AUTO", oOptionalIndex) + + Dim oVectorIndexValues = oManualIndexResult.Split(ClassConstants.VECTORSEPARATOR).ToList() + + For Each oVectorIndexValue In oVectorIndexValues + Dim oTempSql = oSqlResult.Replace(oVectorMatch.Value, oVectorIndexValue) + Dim oResult = GetAutomaticIndexSQLValue(oTempSql, oSqlConnectionId, oSqlProvider) + oEndResult.Add(oResult) + Next + + ' Verhindert, dass die Schleife mehrmals durchlaufen wird + If oIsFirstMatch Then + Exit For + End If + oAutoIndexRow.Item("Indexiert") = True + oAutoIndexRow.Item("Indexwert") = String.Join(ClassConstants.VECTORSEPARATOR, oEndResult.ToArray) + Next + Else + Dim oResult = GetAutomaticIndexSQLValue(oSqlResult, oSqlConnectionId, oSqlProvider) + _Logger.Info("Got a simple SQLResult: " & oResult.ToString) + oAutoIndexRow.Item("Indexiert") = True + oAutoIndexRow.Item("Indexwert") = oResult + + End If + Next + + Return True + Catch ex As Exception + _Logger.Error(ex) + MsgBox(ex.Message) + Return False + End Try + End Function + Function StripPlaceholder(Placeholder As String) As String + Dim oResult = Placeholder + oResult = Regex.Replace(oResult, "^\[%", "") + oResult = Regex.Replace(oResult, "\]$", "") + Return oResult + End Function + Function GetAutomaticIndexSQLValue(SQLCommand As String, vconnectionID As Integer, vProvider As String) As String + Try + Dim oConnectionString As String + oConnectionString = My.Database.Get_ConnectionStringforID(vconnectionID) + If oConnectionString <> "" Then + 'NEU + Dim oErgebnis + 'Welcher Provider? + 'If vProvider.ToLower = "oracle" Then + 'oErgebnis = My.Database.leExecute_Scalar(SQLCommand, oConnectionString) + 'Else 'im Moment nur SQL-Server + oErgebnis = My.Database.GetScalarValueConStr(SQLCommand, oConnectionString) + 'End If + _Logger.Debug("SQL-ConnectionString: " & oConnectionString.Substring(0, oConnectionString.LastIndexOf("="))) + If oErgebnis Is Nothing Then + 'showlblhinweis("Kein Ergebnis für automatisches SQL: " & vsqlstatement) + Return "" + Else + Return oErgebnis + End If + End If + + Catch ex As Exception + _Logger.Warn(" - Unexpected error in Get_AutomatischerIndex_SQL - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Get_AutomatischerIndex_SQL:") + Return "" + End Try + End Function + Sub Indexwert_Postprocessing(indexname As String, wert_in As String) + Try + + Dim value_post As String = "" + For Each oDataRow As DataRow In My.Application.Globix.CURR_DT_MAN_INDEXE.Rows + If oDataRow.Item("INDEXNAME") = indexname Then + Dim idxid As Integer = oDataRow.Item("GUID") + If idxid > 0 Then + ' In jedem Fall schon mal den Wert einfügen + oDataRow.Item("Indexwert") = wert_in + 'Die Nachbearbeitungsschritte laden + 'FILE AND INDEX + 'Zuerst nur die Fälle für die Variante ONLY FILE/FOLDER + Dim DTNB As DataTable = FilterDatatable(My.Application.Globix.CURR_INDEX_MAN_POSTPROCESSING, "IDXMAN_ID = " & idxid & " AND VARIANT = 'ONLY FILE/FOLDER'", "", "SEQUENCE", True) + 'ClassDatabase.Return_Datatable("SELECT * FROM TBDD_INDEX_MAN_POSTPROCESSING WHERE IDXMAN_ID = " & idxid & " AND VARIANT = 'ONLY FILE/FOLDER' ORDER BY SEQUENCE") + If DTNB Is Nothing = False Then + If DTNB.Rows.Count > 0 Then + value_post = clsPostProcessing.Get_Nachbearbeitung_Wert(wert_in, DTNB) + oDataRow.Item("Indexwert") = wert_in + oDataRow.Item("Indexwert_File") = value_post + End If + End If + 'Jetzt die Fälle für die Variante FILE AND INDEX + DTNB = Nothing + + DTNB = FilterDatatable(My.Application.Globix.CURR_INDEX_MAN_POSTPROCESSING, "IDXMAN_ID = " & idxid & " AND VARIANT = 'FILE AND INDEX'", "", "SEQUENCE", True) + 'ClassDatabase.Return_Datatable("SELECT * FROM TBDD_INDEX_MAN_POSTPROCESSING WHERE IDXMAN_ID = " & idxid & " AND VARIANT = 'FILE AND INDEX' ORDER BY SEQUENCE") + If DTNB Is Nothing = False Then + If DTNB.Rows.Count > 0 Then + value_post = clsPostProcessing.Get_Nachbearbeitung_Wert(wert_in, DTNB) + oDataRow.Item("Indexwert") = value_post + End If + End If + End If + oDataRow.Item("Indexiert") = True + End If + Next + Catch ex As Exception + _Logger.Warn(" - Unvorhergesehener Unexpected error in Indexwert_Postprocessing - Indexname: " & indexname & " - Fehler: " & vbNewLine & ex.Message) + _Logger.Error(ex.Message) + MsgBox(ex.Message, MsgBoxStyle.Critical, "Unexpected error in Indexwert_Postprocessing:") + End Try + End Sub End Class diff --git a/Modules.Config/ConfigAttributes.vb b/Modules.Config/ConfigAttributes.vb index 4a2614b5..09f5d278 100644 --- a/Modules.Config/ConfigAttributes.vb +++ b/Modules.Config/ConfigAttributes.vb @@ -15,6 +15,9 @@ Public Class ConnectionStringAppServer Inherits Attribute End Class + Public Class AppServerConfig + Inherits Attribute + End Class ''' ''' Global setting. Will not be saved to userconfig. ''' diff --git a/Modules.Config/My Project/AssemblyInfo.vb b/Modules.Config/My Project/AssemblyInfo.vb index 1ae5ba01..db174181 100644 --- a/Modules.Config/My Project/AssemblyInfo.vb +++ b/Modules.Config/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + +