diff --git a/GUIs.ZooFlow/App.config b/GUIs.ZooFlow/App.config index aba68645..d79df093 100644 --- a/GUIs.ZooFlow/App.config +++ b/GUIs.ZooFlow/App.config @@ -116,7 +116,7 @@ - 17255 + diff --git a/GUIs.ZooFlow/ClassStrings.vb b/GUIs.ZooFlow/ClassStrings.vb new file mode 100644 index 00000000..a64e92fc --- /dev/null +++ b/GUIs.ZooFlow/ClassStrings.vb @@ -0,0 +1,4 @@ +Public Class ClassStrings + Public Const TEXT_MISSING_INPUT = "Bitte vervollständigen Sie die Eingaben!" + Public Const TITLE_MISSING_INPUT = "Fehlende Eingaben" +End Class diff --git a/GUIs.ZooFlow/Globix/ClassValidator.vb b/GUIs.ZooFlow/Globix/ClassValidator.vb new file mode 100644 index 00000000..f4eccc27 --- /dev/null +++ b/GUIs.ZooFlow/Globix/ClassValidator.vb @@ -0,0 +1,137 @@ +Imports DigitalData.Controls.LookupGrid +Imports DigitalData.GUIs.ZooFlow.Base +Imports DigitalData.GUIs.ZooFlow.frmGlobix_Index +Imports DigitalData.Modules.EDMI.API +Imports DigitalData.Modules.Logging + +Public Class ClassValidator + Inherits BaseClass + + Private ReadOnly Client As Client + + Public Sub New(pLogConfig As LogConfig, pClient As Client) + MyBase.New(pLogConfig) + Client = pClient + End Sub + + Private Function TestIsIndexOptional(pDocType As DocType, pIndexName As String) As Boolean + Dim oIsOptional As Boolean = My.Helpers.GetValueFromDatatable( + My.Application.Globix.CURR_DT_MAN_INDEXE, + $"DOK_ID = {pDocType.Guid} AND INDEXNAME = '{pIndexName}'", "OPTIONAL", "") + + Return oIsOptional + End Function + + Private Sub ShowValidationMessage() + MsgBox(ClassStrings.TEXT_MISSING_INPUT, MsgBoxStyle.Exclamation, ClassStrings.TITLE_MISSING_INPUT) + End Sub + + Function ValidateControls(pControls As ControlCollection, pDocType As DocType) As Boolean + Try + Logger.Debug("Starting [ValidateControls]") + Dim result As Boolean = True + + For Each oControl As Control In pControls + + ' ========================= TEXT BOX ========================= + If oControl.Name.StartsWith("txt") Then + Dim oTextBox As DevExpress.XtraEditors.TextEdit = oControl + If oTextBox.Text = "" Then + Dim oIndexName = Replace(oTextBox.Name, "txt", "") + Dim oOptional = TestIsIndexOptional(pDocType, oIndexName) + + If oOptional = False Then + ShowValidationMessage() + oTextBox.Focus() + Return False + End If + End If + End If + + ' ========================= LOOKUP ========================= + If oControl.Name.StartsWith("cmbMulti") Then + Dim oLookup = DirectCast(oControl, LookupControl3) + Dim oValues As List(Of String) = oLookup.Properties.SelectedValues + + If oValues.Count = 0 Then + Dim oIndexName = Replace(oLookup.Name, "cmbMulti", "") + Dim oOptional = TestIsIndexOptional(pDocType, oIndexName) + + If oOptional = False Then + ShowValidationMessage() + oLookup.Focus() + Return False + End If + End If + End If + + ' ========================= COMBO BOX ========================= + If oControl.Name.StartsWith("cmbSingle") Then + Dim cmbSingle As TextBox = oControl + + If cmbSingle.Text = "" Then + Dim oIndexName = Replace(cmbSingle.Name, "cmbSingle", "") + Dim oOptional = TestIsIndexOptional(pDocType, oIndexName) + + If oOptional = False Then + ShowValidationMessage() + cmbSingle.Focus() + Return False + End If + End If + End If + + If oControl.Name.StartsWith("cmb") Then + Dim cmb As ComboBox = oControl + If cmb.Text = "" Then + Dim oIndexName = Replace(cmb.Name, "cmb", "") + Dim oOptional = TestIsIndexOptional(pDocType, oIndexName) + + If oOptional = False Then + ShowValidationMessage() + cmb.Focus() + Return False + End If + End If + End If + + ' ========================= DATE PICKER ========================= + 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 oOptional = TestIsIndexOptional(pDocType, oIndexName) + + If oOptional = False Then + ShowValidationMessage() + dtp.Focus() + Return False + End If + End If + End If + + ' ========================= CHECK BOX ========================= + If oControl.Name.StartsWith("chk") Then + Dim chk As CheckBox = oControl + '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 ValidateControls") + Logger.Error(ex.Message) + Return False + End Try + End Function +End Class diff --git a/GUIs.ZooFlow/Globix/frmGlobix_Index.Designer.vb b/GUIs.ZooFlow/Globix/frmGlobix_Index.Designer.vb index 10a20a6c..81ea97de 100644 --- a/GUIs.ZooFlow/Globix/frmGlobix_Index.Designer.vb +++ b/GUIs.ZooFlow/Globix/frmGlobix_Index.Designer.vb @@ -52,9 +52,10 @@ Partial Class frmGlobix_Index Me.SplitContainerControl1 = New DevExpress.XtraEditors.SplitContainerControl() Me.pnlIndex = New System.Windows.Forms.Panel() Me.Panel3 = New System.Windows.Forms.Panel() + Me.Button1 = New System.Windows.Forms.Button() Me.btnAblageFlow = New System.Windows.Forms.Button() Me.Panel1 = New System.Windows.Forms.Panel() - Me.ComboBoxEdit1 = New DevExpress.XtraEditors.ComboBoxEdit() + Me.cmbDocType = New DevExpress.XtraEditors.ComboBoxEdit() Me.DocumentViewer1 = New DigitalData.Controls.DocumentViewer.DocumentViewer() Me.GlobixDataset = New DigitalData.GUIs.ZooFlow.GlobixDataset() CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit() @@ -62,7 +63,7 @@ Partial Class frmGlobix_Index Me.SplitContainerControl1.SuspendLayout() Me.Panel3.SuspendLayout() Me.Panel1.SuspendLayout() - CType(Me.ComboBoxEdit1.Properties, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.cmbDocType.Properties, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.GlobixDataset, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' @@ -263,6 +264,7 @@ Partial Class frmGlobix_Index ' 'Panel3 ' + Me.Panel3.Controls.Add(Me.Button1) Me.Panel3.Controls.Add(Me.btnAblageFlow) Me.Panel3.Dock = System.Windows.Forms.DockStyle.Bottom Me.Panel3.Location = New System.Drawing.Point(0, 433) @@ -270,24 +272,35 @@ Partial Class frmGlobix_Index Me.Panel3.Size = New System.Drawing.Size(522, 75) Me.Panel3.TabIndex = 2 ' + 'Button1 + ' + Me.Button1.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight + Me.Button1.Location = New System.Drawing.Point(317, 15) + Me.Button1.Name = "Button1" + Me.Button1.Size = New System.Drawing.Size(186, 44) + Me.Button1.TabIndex = 1 + Me.Button1.Text = "Starte Ablage (Neu)" + Me.Button1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.Button1.UseVisualStyleBackColor = True + ' 'btnAblageFlow ' - Me.btnAblageFlow.Dock = System.Windows.Forms.DockStyle.Fill - Me.btnAblageFlow.Font = New System.Drawing.Font("Tahoma", 15.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.btnAblageFlow.Font = New System.Drawing.Font("Tahoma", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.btnAblageFlow.Image = Global.DigitalData.GUIs.ZooFlow.My.Resources.Resources.ZooFlow_g_64___Kopie Me.btnAblageFlow.ImageAlign = System.Drawing.ContentAlignment.MiddleRight - Me.btnAblageFlow.Location = New System.Drawing.Point(0, 0) + Me.btnAblageFlow.Location = New System.Drawing.Point(12, 6) Me.btnAblageFlow.Name = "btnAblageFlow" - Me.btnAblageFlow.Size = New System.Drawing.Size(522, 75) + Me.btnAblageFlow.Size = New System.Drawing.Size(185, 63) Me.btnAblageFlow.TabIndex = 1 - Me.btnAblageFlow.Text = "Starte Ablage" + Me.btnAblageFlow.Text = "Starte Ablage (Alt)" Me.btnAblageFlow.TextAlign = System.Drawing.ContentAlignment.MiddleLeft Me.btnAblageFlow.UseVisualStyleBackColor = True ' 'Panel1 ' Me.Panel1.BackColor = System.Drawing.Color.Silver - Me.Panel1.Controls.Add(Me.ComboBoxEdit1) + Me.Panel1.Controls.Add(Me.cmbDocType) Me.Panel1.Dock = System.Windows.Forms.DockStyle.Top Me.Panel1.Location = New System.Drawing.Point(0, 0) Me.Panel1.Name = "Panel1" @@ -296,18 +309,18 @@ Partial Class frmGlobix_Index ' 'ComboBoxEdit1 ' - Me.ComboBoxEdit1.Dock = System.Windows.Forms.DockStyle.Top - Me.ComboBoxEdit1.Location = New System.Drawing.Point(0, 0) - Me.ComboBoxEdit1.MenuManager = Me.RibbonControl1 - Me.ComboBoxEdit1.Name = "ComboBoxEdit1" + Me.cmbDocType.Dock = System.Windows.Forms.DockStyle.Top + Me.cmbDocType.Location = New System.Drawing.Point(0, 0) + Me.cmbDocType.MenuManager = Me.RibbonControl1 + Me.cmbDocType.Name = "ComboBoxEdit1" SerializableAppearanceObject1.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(214, Byte), Integer), CType(CType(49, Byte), Integer)) SerializableAppearanceObject1.Options.UseBackColor = True - Me.ComboBoxEdit1.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", 20, True, True, False, EditorButtonImageOptions1, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject1, SerializableAppearanceObject2, SerializableAppearanceObject3, SerializableAppearanceObject4, "", Nothing, Nothing, DevExpress.Utils.ToolTipAnchor.[Default])}) - Me.ComboBoxEdit1.Properties.ButtonsStyle = DevExpress.XtraEditors.Controls.BorderStyles.UltraFlat - Me.ComboBoxEdit1.Properties.NullText = "Bitte wählen Sie ein Profil" - Me.ComboBoxEdit1.Properties.Padding = New System.Windows.Forms.Padding(5) - Me.ComboBoxEdit1.Size = New System.Drawing.Size(522, 30) - Me.ComboBoxEdit1.TabIndex = 4 + Me.cmbDocType.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo, "", 20, True, True, False, EditorButtonImageOptions1, New DevExpress.Utils.KeyShortcut(System.Windows.Forms.Keys.None), SerializableAppearanceObject1, SerializableAppearanceObject2, SerializableAppearanceObject3, SerializableAppearanceObject4, "", Nothing, Nothing, DevExpress.Utils.ToolTipAnchor.[Default])}) + Me.cmbDocType.Properties.ButtonsStyle = DevExpress.XtraEditors.Controls.BorderStyles.UltraFlat + Me.cmbDocType.Properties.NullText = "Bitte wählen Sie ein Profil" + Me.cmbDocType.Properties.Padding = New System.Windows.Forms.Padding(5) + Me.cmbDocType.Size = New System.Drawing.Size(522, 30) + Me.cmbDocType.TabIndex = 4 ' 'DocumentViewer1 ' @@ -342,7 +355,7 @@ Partial Class frmGlobix_Index Me.SplitContainerControl1.ResumeLayout(False) Me.Panel3.ResumeLayout(False) Me.Panel1.ResumeLayout(False) - CType(Me.ComboBoxEdit1.Properties, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.cmbDocType.Properties, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.GlobixDataset, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() @@ -376,6 +389,7 @@ Partial Class frmGlobix_Index Friend WithEvents pnlIndex As Panel Friend WithEvents Panel3 As Panel Friend WithEvents GlobixDataset As GlobixDataset - Friend WithEvents ComboBoxEdit1 As DevExpress.XtraEditors.ComboBoxEdit + Friend WithEvents cmbDocType As DevExpress.XtraEditors.ComboBoxEdit Friend WithEvents btnAblageFlow As Button + Friend WithEvents Button1 As Button End Class diff --git a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb index 9d9593f5..411f61c0 100644 --- a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb +++ b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb @@ -11,6 +11,7 @@ Imports DigitalData.Modules.Language.Utils Imports DigitalData.Controls.LookupGrid Imports Independentsoft Imports DevExpress.XtraEditors.Controls +Imports DigitalData.Modules.EDMI.API.EDMIServiceReference Public Class frmGlobix_Index #Region "+++++ Variablen ++++++" @@ -51,11 +52,13 @@ Public Class frmGlobix_Index Return Name End Function End Class + Public Class ControlMeta Public Property IndexName As String Public Property IndexType As String Public Property MultipleValues As Boolean = False End Class + #End Region Public Sub New(LogConfig As LogConfig) @@ -260,12 +263,12 @@ Public Class frmGlobix_Index checkItemPreselection.Checked = True If My.Application.Globix.CURRENT_LASTDOCTYPE <> "" Then - Dim oFoundDocType = ComboBoxEdit1.Properties.Items. + Dim oFoundDocType = cmbDocType.Properties.Items. Cast(Of DocType)(). Where(Function(dt) dt.Name = My.Application.Globix.CURRENT_LASTDOCTYPE). FirstOrDefault() If oFoundDocType IsNot Nothing Then - ComboBoxEdit1.SelectedItem = oFoundDocType + cmbDocType.SelectedItem = oFoundDocType End If @@ -278,13 +281,13 @@ Public Class frmGlobix_Index _Logger.Debug("There is a match on REGEX_DOCTYPE: [{0}]", oRoW.Item("DOCTYPE")) _Logger.Debug("Regex: [{0}], FileName: [{1}]", oRoW.Item("Regex"), oOnlyFilename) - Dim oFoundDocType = ComboBoxEdit1.Properties.Items. + Dim oFoundDocType = cmbDocType.Properties.Items. Cast(Of DocType)(). Where(Function(dt) dt.Name = My.Application.Globix.CURRENT_LASTDOCTYPE). FirstOrDefault() If oFoundDocType IsNot Nothing Then - ComboBoxEdit1.SelectedItem = oFoundDocType + cmbDocType.SelectedItem = oFoundDocType End If Exit For End If @@ -307,7 +310,7 @@ Public Class frmGlobix_Index DT_VWGI_DOCTYPE = _DataASorDB.GetDatatable("DD_ECM", oSql, "VWGI_DOCTYPE", oFilter, "SEQUENCE") For Each oRow As DataRow In DT_VWGI_DOCTYPE.Rows - ComboBoxEdit1.Properties.Items.Add(New DocType With { + cmbDocType.Properties.Items.Add(New DocType With { .Guid = oRow.Item("DOCTYPE_ID"), .Name = oRow.Item("DOCTYPE") }) @@ -319,9 +322,9 @@ Public Class frmGlobix_Index End Sub - Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBoxEdit1.SelectedIndexChanged - If ComboBoxEdit1.SelectedIndex <> -1 And FormLoaded = True Then - Dim oSelectedItem As DocType = ComboBoxEdit1.SelectedItem + Private Sub ComboBoxEdit1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbDocType.SelectedIndexChanged + If cmbDocType.SelectedIndex <> -1 And FormLoaded = True Then + Dim oSelectedItem As DocType = cmbDocType.SelectedItem My.Application.Globix.CURRENT_DOCTYPE_ID = oSelectedItem.Guid @@ -393,8 +396,8 @@ Public Class frmGlobix_Index _Controls = oControls If DT_INDEXEMAN.Rows.Count = 0 Then - ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert") - _Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & ComboBoxEdit1.Text & " definiert") + ShowError("Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDocType.Text & " definiert") + _Logger.Info(" - Keine Manuellen Indizes für die " & vbNewLine & "Dokumentart " & cmbDocType.Text & " definiert") End If For Each oRow As DataRow In DT_INDEXEMAN.Rows @@ -778,13 +781,15 @@ Public Class frmGlobix_Index Private Sub GlobixFlow() ClearError() ClearNotice() - Me.Cursor = Cursors.WaitCursor + Cursor = Cursors.WaitCursor Refresh_RegexTable() + For Each rowregex As DataRow In My.Application.Globix.DT_FUNCTION_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 @@ -854,7 +859,7 @@ Public Class frmGlobix_Index _Logger.Debug("Manuelle Indexe geladen") If My.Application.Globix.CURR_DT_MAN_INDEXE.Rows.Count > 0 Then - Dim oDokart As DocType = ComboBoxEdit1.SelectedItem + Dim oDokart As DocType = cmbDocType.SelectedItem My.Application.Globix.CURRENT_DOCTYPE_ID = oDokart.Guid If CheckWrite_IndexeMan(oDokart.Guid) = True Then @@ -2404,11 +2409,48 @@ Public Class frmGlobix_Index End Function - Private Sub PictureEdit1_EditValueChanged(sender As Object, e As EventArgs) - - End Sub - Private Sub btnAblageFlow_Click(sender As Object, e As EventArgs) Handles btnAblageFlow.Click GlobixFlow() End Sub + + Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + Dim oDokart As DocType = cmbDocType.SelectedItem + Await GlobixFlowNew(oDokart) + End Sub + + Private Async Function GlobixFlowNew(pDocType As DocType) As Threading.Tasks.Task(Of Boolean) + Try + ClearError() + ClearNotice() + Cursor = Cursors.WaitCursor + + Dim oValidator As New ClassValidator(My.LogConfig, My.Application.Service.Client) + If oValidator.ValidateControls(pnlIndex.Controls, pDocType) = False Then + Return False + End If + + 'TODO: Globix File Import + + Dim oFileName As String + Dim oObjectStore As String + Dim oObjectKind As String + Dim oBusinessENtity As String + Dim oProfileId As Integer + Dim oAttributes As List(Of UserAttributeValue) + Dim oOptions As New Modules.EDMI.API.Options.ImportFileOptions + + Await My.Application.Service.Client.ImportFileAsync(oFileName, oProfileId, oAttributes, oObjectStore, oObjectKind, oBusinessENtity, oOptions) + + Return True + Catch ex As Exception + _Logger.Error(ex) + MsgBox("Indexierung fehlgeschlagen!", MsgBoxStyle.Critical, Text) + + Finally + Cursor = Cursors.Default + + End Try + End Function + + End Class diff --git a/GUIs.ZooFlow/My Project/Settings.Designer.vb b/GUIs.ZooFlow/My Project/Settings.Designer.vb index b2272aaf..3fa2f2eb 100644 --- a/GUIs.ZooFlow/My Project/Settings.Designer.vb +++ b/GUIs.ZooFlow/My Project/Settings.Designer.vb @@ -14,7 +14,7 @@ Option Explicit On _ Partial Friend NotInheritable Class Settings Inherits Global.System.Configuration.ApplicationSettingsBase @@ -97,7 +97,7 @@ Partial Friend NotInheritable Class Settings _ + Global.System.Configuration.DefaultSettingValueAttribute("")> _ Public Property IDBOBJID() As String Get Return CType(Me("IDBOBJID"),String) diff --git a/GUIs.ZooFlow/My Project/Settings.settings b/GUIs.ZooFlow/My Project/Settings.settings index 32a23f97..ca8890e2 100644 --- a/GUIs.ZooFlow/My Project/Settings.settings +++ b/GUIs.ZooFlow/My Project/Settings.settings @@ -29,7 +29,7 @@ Data Source=SDD-VMP04-SQL17\DD_DEVELOP01;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=dd - 17255 + \ No newline at end of file diff --git a/GUIs.ZooFlow/ZooFlow.vbproj b/GUIs.ZooFlow/ZooFlow.vbproj index 93aa7660..3a67a455 100644 --- a/GUIs.ZooFlow/ZooFlow.vbproj +++ b/GUIs.ZooFlow/ZooFlow.vbproj @@ -200,6 +200,7 @@ + @@ -235,6 +236,7 @@ + frmGlobixNameconvention.vb diff --git a/GUIs.ZooFlow/frmtest.Designer.vb b/GUIs.ZooFlow/frmtest.Designer.vb index 96cc9acc..b895a6e8 100644 --- a/GUIs.ZooFlow/frmtest.Designer.vb +++ b/GUIs.ZooFlow/frmtest.Designer.vb @@ -23,28 +23,19 @@ Partial Class frmtest _ Private Sub InitializeComponent() Me.Label2 = New System.Windows.Forms.Label() - Me.txtIDB_OBJ_ID = New System.Windows.Forms.TextBox() Me.txtFile2Import = New System.Windows.Forms.TextBox() - Me.Button4 = New System.Windows.Forms.Button() - Me.Button5 = New System.Windows.Forms.Button() - Me.CheckBoxKeepExtension = New System.Windows.Forms.CheckBox() - Me.Button6 = New System.Windows.Forms.Button() + Me.btnOpenFile = New System.Windows.Forms.Button() Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() - Me.Button7 = New System.Windows.Forms.Button() - Me.Button8 = New System.Windows.Forms.Button() + Me.btnNewFile = New System.Windows.Forms.Button() Me.Label4 = New System.Windows.Forms.Label() Me.Label5 = New System.Windows.Forms.Label() Me.cmbObjectStoreType = New System.Windows.Forms.ComboBox() Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker() Me.Label6 = New System.Windows.Forms.Label() - Me.TextBox1 = New System.Windows.Forms.TextBox() + Me.btnImportFile = New System.Windows.Forms.Button() Me.Label1 = New System.Windows.Forms.Label() - Me.GroupBox1 = New System.Windows.Forms.GroupBox() - Me.ListBox1 = New System.Windows.Forms.ListBox() - Me.txtAttributeName = New System.Windows.Forms.TextBox() - Me.Button2 = New System.Windows.Forms.Button() - Me.txtAttibuteValue = New System.Windows.Forms.TextBox() - Me.GroupBox1.SuspendLayout() + Me.txtProfileId = New System.Windows.Forms.TextBox() + Me.txtIDB_OBJ_ID = New System.Windows.Forms.TextBox() Me.SuspendLayout() ' 'Label2 @@ -56,15 +47,6 @@ Partial Class frmtest Me.Label2.TabIndex = 6 Me.Label2.Text = "FileStoreType" ' - 'txtIDB_OBJ_ID - ' - Me.txtIDB_OBJ_ID.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.DigitalData.GUIs.ZooFlow.Settings.Default, "IDBOBJID", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) - Me.txtIDB_OBJ_ID.Location = New System.Drawing.Point(137, 38) - Me.txtIDB_OBJ_ID.Name = "txtIDB_OBJ_ID" - Me.txtIDB_OBJ_ID.Size = New System.Drawing.Size(100, 20) - Me.txtIDB_OBJ_ID.TabIndex = 9 - Me.txtIDB_OBJ_ID.Text = Global.DigitalData.GUIs.ZooFlow.Settings.Default.IDBOBJID - ' 'txtFile2Import ' Me.txtFile2Import.Location = New System.Drawing.Point(137, 12) @@ -72,66 +54,27 @@ Partial Class frmtest Me.txtFile2Import.Size = New System.Drawing.Size(426, 20) Me.txtFile2Import.TabIndex = 11 ' - 'Button4 + 'btnOpenFile ' - Me.Button4.Location = New System.Drawing.Point(16, 345) - Me.Button4.Name = "Button4" - Me.Button4.Size = New System.Drawing.Size(286, 23) - Me.Button4.TabIndex = 13 - Me.Button4.Text = "4A. Reopen from AppServ" - Me.Button4.UseVisualStyleBackColor = True - ' - 'Button5 - ' - Me.Button5.Location = New System.Drawing.Point(16, 374) - Me.Button5.Name = "Button5" - Me.Button5.Size = New System.Drawing.Size(286, 23) - Me.Button5.TabIndex = 14 - Me.Button5.Text = "4B. Alternative stream/append" - Me.Button5.UseVisualStyleBackColor = True - ' - 'CheckBoxKeepExtension - ' - Me.CheckBoxKeepExtension.AutoSize = True - Me.CheckBoxKeepExtension.Checked = True - Me.CheckBoxKeepExtension.CheckState = System.Windows.Forms.CheckState.Checked - Me.CheckBoxKeepExtension.Location = New System.Drawing.Point(16, 19) - Me.CheckBoxKeepExtension.Name = "CheckBoxKeepExtension" - Me.CheckBoxKeepExtension.Size = New System.Drawing.Size(100, 17) - Me.CheckBoxKeepExtension.TabIndex = 15 - Me.CheckBoxKeepExtension.Text = "Keep Extension" - Me.CheckBoxKeepExtension.UseVisualStyleBackColor = True - ' - 'Button6 - ' - Me.Button6.Location = New System.Drawing.Point(569, 9) - Me.Button6.Name = "Button6" - Me.Button6.Size = New System.Drawing.Size(75, 23) - Me.Button6.TabIndex = 16 - Me.Button6.Text = "Select File" - Me.Button6.UseVisualStyleBackColor = True + Me.btnOpenFile.Location = New System.Drawing.Point(569, 9) + Me.btnOpenFile.Name = "btnOpenFile" + Me.btnOpenFile.Size = New System.Drawing.Size(75, 23) + Me.btnOpenFile.TabIndex = 16 + Me.btnOpenFile.Text = "Select File" + Me.btnOpenFile.UseVisualStyleBackColor = True ' 'OpenFileDialog1 ' Me.OpenFileDialog1.FileName = "OpenFileDialog1" ' - 'Button7 + 'btnNewFile ' - Me.Button7.Location = New System.Drawing.Point(16, 403) - Me.Button7.Name = "Button7" - Me.Button7.Size = New System.Drawing.Size(286, 23) - Me.Button7.TabIndex = 14 - Me.Button7.Text = "4C. Alternative" - Me.Button7.UseVisualStyleBackColor = True - ' - 'Button8 - ' - Me.Button8.Location = New System.Drawing.Point(12, 142) - Me.Button8.Name = "Button8" - Me.Button8.Size = New System.Drawing.Size(187, 23) - Me.Button8.TabIndex = 17 - Me.Button8.Text = "Import File" - Me.Button8.UseVisualStyleBackColor = True + Me.btnNewFile.Location = New System.Drawing.Point(12, 142) + Me.btnNewFile.Name = "btnNewFile" + Me.btnNewFile.Size = New System.Drawing.Size(187, 23) + Me.btnNewFile.TabIndex = 17 + Me.btnNewFile.Text = "NewFile" + Me.btnNewFile.UseVisualStyleBackColor = True ' 'Label4 ' @@ -177,93 +120,61 @@ Partial Class frmtest Me.Label6.TabIndex = 6 Me.Label6.Text = "Date" ' - 'TextBox1 + 'btnImportFile ' - Me.TextBox1.Location = New System.Drawing.Point(137, 183) - Me.TextBox1.Name = "TextBox1" - Me.TextBox1.Size = New System.Drawing.Size(426, 20) - Me.TextBox1.TabIndex = 21 + Me.btnImportFile.Location = New System.Drawing.Point(205, 142) + Me.btnImportFile.Name = "btnImportFile" + Me.btnImportFile.Size = New System.Drawing.Size(187, 23) + Me.btnImportFile.TabIndex = 17 + Me.btnImportFile.Text = "ImportFile (GLOBIX)" + Me.btnImportFile.UseVisualStyleBackColor = True ' 'Label1 ' Me.Label1.AutoSize = True - Me.Label1.Location = New System.Drawing.Point(9, 186) + Me.Label1.Location = New System.Drawing.Point(410, 44) Me.Label1.Name = "Label1" - Me.Label1.Size = New System.Drawing.Size(98, 13) + Me.Label1.Size = New System.Drawing.Size(45, 13) Me.Label1.TabIndex = 18 - Me.Label1.Text = "File Path (Imported)" + Me.Label1.Text = "ProfileId" ' - 'GroupBox1 + 'txtProfileId ' - Me.GroupBox1.Controls.Add(Me.CheckBoxKeepExtension) - Me.GroupBox1.Location = New System.Drawing.Point(653, 12) - Me.GroupBox1.Name = "GroupBox1" - Me.GroupBox1.Size = New System.Drawing.Size(200, 100) - Me.GroupBox1.TabIndex = 22 - Me.GroupBox1.TabStop = False - Me.GroupBox1.Text = "Import Options" + Me.txtProfileId.Location = New System.Drawing.Point(461, 41) + Me.txtProfileId.Name = "txtProfileId" + Me.txtProfileId.Size = New System.Drawing.Size(100, 20) + Me.txtProfileId.TabIndex = 21 + Me.txtProfileId.Text = "1" ' - 'ListBox1 + 'txtIDB_OBJ_ID ' - Me.ListBox1.FormattingEnabled = True - Me.ListBox1.Location = New System.Drawing.Point(653, 118) - Me.ListBox1.Name = "ListBox1" - Me.ListBox1.Size = New System.Drawing.Size(200, 329) - Me.ListBox1.TabIndex = 23 - ' - 'txtAttributeName - ' - Me.txtAttributeName.Location = New System.Drawing.Point(205, 236) - Me.txtAttributeName.Name = "txtAttributeName" - Me.txtAttributeName.Size = New System.Drawing.Size(115, 20) - Me.txtAttributeName.TabIndex = 24 - Me.txtAttributeName.Text = "InvoiceNr" - ' - 'Button2 - ' - Me.Button2.Location = New System.Drawing.Point(12, 234) - Me.Button2.Name = "Button2" - Me.Button2.Size = New System.Drawing.Size(187, 23) - Me.Button2.TabIndex = 17 - Me.Button2.Text = "GetAttribute" - Me.Button2.UseVisualStyleBackColor = True - ' - 'txtAttibuteValue - ' - Me.txtAttibuteValue.Location = New System.Drawing.Point(326, 236) - Me.txtAttibuteValue.Name = "txtAttibuteValue" - Me.txtAttibuteValue.Size = New System.Drawing.Size(100, 20) - Me.txtAttibuteValue.TabIndex = 25 + Me.txtIDB_OBJ_ID.DataBindings.Add(New System.Windows.Forms.Binding("Text", Global.DigitalData.GUIs.ZooFlow.Settings.Default, "IDBOBJID", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged)) + Me.txtIDB_OBJ_ID.Location = New System.Drawing.Point(137, 38) + Me.txtIDB_OBJ_ID.Name = "txtIDB_OBJ_ID" + Me.txtIDB_OBJ_ID.Size = New System.Drawing.Size(100, 20) + Me.txtIDB_OBJ_ID.TabIndex = 9 + Me.txtIDB_OBJ_ID.Text = Global.DigitalData.GUIs.ZooFlow.Settings.Default.IDBOBJID ' 'frmtest ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(865, 450) - Me.Controls.Add(Me.txtAttibuteValue) - Me.Controls.Add(Me.txtAttributeName) - Me.Controls.Add(Me.ListBox1) - Me.Controls.Add(Me.GroupBox1) - Me.Controls.Add(Me.TextBox1) + Me.Controls.Add(Me.txtProfileId) Me.Controls.Add(Me.DateTimePicker1) Me.Controls.Add(Me.cmbObjectStoreType) - Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.Label4) - Me.Controls.Add(Me.Button2) - Me.Controls.Add(Me.Button8) - Me.Controls.Add(Me.Button6) - Me.Controls.Add(Me.Button7) - Me.Controls.Add(Me.Button5) - Me.Controls.Add(Me.Button4) + Me.Controls.Add(Me.btnImportFile) + Me.Controls.Add(Me.btnNewFile) + Me.Controls.Add(Me.btnOpenFile) Me.Controls.Add(Me.txtFile2Import) Me.Controls.Add(Me.txtIDB_OBJ_ID) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.Label2) Me.Name = "frmtest" Me.Text = "frmtest" - Me.GroupBox1.ResumeLayout(False) - Me.GroupBox1.PerformLayout() Me.ResumeLayout(False) Me.PerformLayout() @@ -271,23 +182,15 @@ Partial Class frmtest Friend WithEvents Label2 As Label Friend WithEvents txtIDB_OBJ_ID As TextBox Friend WithEvents txtFile2Import As TextBox - Friend WithEvents Button4 As Button - Friend WithEvents Button5 As Button - Friend WithEvents CheckBoxKeepExtension As CheckBox - Friend WithEvents Button6 As Button + Friend WithEvents btnOpenFile As Button Friend WithEvents OpenFileDialog1 As OpenFileDialog - Friend WithEvents Button7 As Button - Friend WithEvents Button8 As Button + Friend WithEvents btnNewFile As Button Friend WithEvents Label4 As Label Friend WithEvents Label5 As Label Friend WithEvents cmbObjectStoreType As ComboBox Friend WithEvents DateTimePicker1 As DateTimePicker Friend WithEvents Label6 As Label - Friend WithEvents TextBox1 As TextBox + Friend WithEvents btnImportFile As Button Friend WithEvents Label1 As Label - Friend WithEvents GroupBox1 As GroupBox - Friend WithEvents ListBox1 As ListBox - Friend WithEvents txtAttributeName As TextBox - Friend WithEvents Button2 As Button - Friend WithEvents txtAttibuteValue As TextBox + Friend WithEvents txtProfileId As TextBox End Class diff --git a/GUIs.ZooFlow/frmtest.vb b/GUIs.ZooFlow/frmtest.vb index d82e116a..d067e120 100644 --- a/GUIs.ZooFlow/frmtest.vb +++ b/GUIs.ZooFlow/frmtest.vb @@ -6,96 +6,19 @@ Imports System.Text Imports DigitalData.Modules.EDMI.API.Client Public Class frmtest - 'Private Sub Button1_Click(sender As Object, e As EventArgs) - ' My.Settings.Save() - ' Dim oString As String - ' Dim oextension = "" - ' Dim oKeepExtension As Boolean = False - ' If CheckBoxKeepExtension.Checked Then - ' If txtFile2Import.Text <> String.Empty Then - ' oextension = Path.GetExtension(txtFile2Import.Text) - ' oKeepExtension = True - ' End If - ' End If - ' oString = My.Application.Service.Client.CreateFileStoreObject(txtIDB_OBJ_ID.Text, txtFilestoreType.Text, txtDate.Text, oextension, oKeepExtension) - ' txtIDBFOPath.Text = oString - 'End Sub - - 'Private Sub Button2_Click(sender As Object, e As EventArgs) - ' Dim oString As String - ' oString = My.Application.Service.Client.CreateObjectId("DOC", My.Application.User.UserName, "") - ' txtIDB_OBJ_ID.Text = oString - 'End Sub - - 'Private Async Sub Button3_Click(sender As Object, e As EventArgs) - ' Try - ' Dim oResult As Boolean = False - - ' Using oStream As New FileStream(txtFile2Import.Text, FileMode.Open, FileAccess.Read) - ' Using oMemoryStream As New MemoryStream - ' oStream.CopyTo(oMemoryStream) - ' Dim oContents As Byte() = oMemoryStream.ToArray() - ' oResult = Await My.Application.Service.Client.ImportFileObjectAsync(oContents, My.Application.User.UserName, txtIDB_OBJ_ID.Text, "WORK", txtIDBFOPath.Text) - ' End Using - ' End Using - - ' If oResult = False Then - ' MsgBox("Oh no error", MsgBoxStyle.Critical) - ' Else - ' MsgBox("#Nailedit") - ' End If - ' Catch ex As Exception - ' MsgBox(ex.Message) - ' End Try - 'End Sub - - Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click - Try - Dim oextension = Path.GetExtension(txtFile2Import.Text) - Dim oFile = $"E:\file{oextension}" - Using oInputStream As New FileStream(TextBox1.Text, FileMode.Open) - Using oFileStream As New FileStream(oFile, FileMode.Create, FileAccess.Write) - oInputStream.CopyTo(oFileStream) - End Using - End Using - Dim oPAth = Path.GetDirectoryName(oFile) - MsgBox($"File [{oFile}] created!", MsgBoxStyle.Information) - Process.Start(oPAth) - Catch ex As Exception - MsgBox(ex.Message, MsgBoxStyle.Critical) - End Try + Private Sub frmtest_Load(sender As Object, e As EventArgs) Handles MyBase.Load + cmbObjectStoreType.SelectedIndex = 0 End Sub - Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click - Try - Dim wFile As System.IO.FileStream - Dim byteData() As Byte - Dim oextension = Path.GetExtension(txtFile2Import.Text) - byteData = Encoding.ASCII.GetBytes(txtFile2Import.Text) - wFile = New FileStream($"E:\file{oextension}", FileMode.Append) - wFile.Write(byteData, 0, byteData.Length) - wFile.Close() - Catch ex As IOException - MsgBox(ex.ToString) - End Try - End Sub - - Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click + Private Sub btnOpenFile_Click(sender As Object, e As EventArgs) Handles btnOpenFile.Click If OpenFileDialog1.ShowDialog() = DialogResult.OK Then txtFile2Import.Text = OpenFileDialog1.FileName End If End Sub - Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click - Dim oExt = Path.GetExtension(txtFile2Import.Text) - Dim oFile = $"E:\file{oExt}" - - File.Copy(TextBox1.Text, oFile) - End Sub - - Private Async Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click + Private Async Sub btnNewFile_Click(sender As Object, e As EventArgs) Handles btnNewFile.Click Dim oObjectId As Long = Await My.Application.Service.Client.NewFileAsync( txtFile2Import.Text, "WORK", @@ -111,23 +34,22 @@ Public Class frmtest txtIDB_OBJ_ID.Text = oObjectId End Sub - Private Sub frmtest_Load(sender As Object, e As EventArgs) Handles MyBase.Load - cmbObjectStoreType.SelectedIndex = 0 - End Sub - Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button2.Click - Try - Dim oValue = My.Application.Service.Client.GetVariableValue(txtIDB_OBJ_ID.Text, txtAttributeName.Text) + Private Async Sub btnImportFile_Click_(sender As Object, e As EventArgs) Handles btnImportFile.Click + Dim oObjectId As Long = Await My.Application.Service.Client.ImportFileAsync( + txtFile2Import.Text, + txtProfileId.Text, + New List(Of EDMIServiceReference.UserAttributeValue), + "WORK", + "DOC", + "DEFAULT" + ) - If oValue.Type Is Nothing Then - ListBox1.Items.Add("Value is nothing") - Else - ListBox1.Items.Add(oValue.Value) - txtAttibuteValue.Text = oValue.Value - End If - - Catch ex As Exception - MsgBox(ex.ToString) - End Try + If oObjectId <> INVALID_OBEJCT_ID Then + MsgBox("File Imported!", MsgBoxStyle.Information, Text) + Else + MsgBox("File was not imported. Check the server logs!") + End If + txtIDB_OBJ_ID.Text = oObjectId End Sub End Class \ No newline at end of file diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index 3cb18c88..3db4c23f 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -179,11 +179,19 @@ Public Class Client End Try End Function - Public Async Function ImportFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As Options.NewFileOptions = Nothing) As Task(Of Long) + Public Async Function ImportFileAsync( + pFilePath As String, + pProfileId As Integer, + pAttributeValues As List(Of UserAttributeValue), + pObjectStoreName As String, + pObjectKind As String, + pBusinessEntity As String, + Optional pImportOptions As Options.ImportFileOptions = Nothing + ) As Task(Of Long) Try ' Set default options If pImportOptions Is Nothing Then - pImportOptions = New Options.NewFileOptions() + pImportOptions = New Options.ImportFileOptions() End If ' Check if file exists @@ -221,7 +229,9 @@ Public Class Client .User = New UserState() With { .UserName = pImportOptions.Username, .Language = pImportOptions.Language - } + }, + .ProfileId = pProfileId, + .AttributeValues = pAttributeValues.ToArray }) If oFileImportResponse.OK = False Then Throw New ApplicationException("Could not Import File Contents!") diff --git a/Modules.EDMIAPI/Client/Options.vb b/Modules.EDMIAPI/Client/Options.vb index 688e3725..df869eb9 100644 --- a/Modules.EDMIAPI/Client/Options.vb +++ b/Modules.EDMIAPI/Client/Options.vb @@ -25,6 +25,15 @@ Public Property DateImported As Date = Date.Now End Class + Public Class ImportFileOptions + Inherits BaseOptions + + ''' + ''' Date when the file was imported. Can be in the past. Defaults to now. + ''' + Public Property DateImported As Date = Date.Now + End Class + Public Class GetVariableValueOptions Inherits BaseOptions End Class diff --git a/Modules.Patterns/Patterns2.vb b/Modules.Patterns/Patterns2.vb index 8278c8de..d5e20913 100644 --- a/Modules.Patterns/Patterns2.vb +++ b/Modules.Patterns/Patterns2.vb @@ -94,6 +94,7 @@ Public Class Patterns2 End Function Public Function ReplaceUserValues(pInput As String, pUser As State.UserState) As String + Logger.Debug("Replacing User Values") Dim oResult = pInput Dim oModule = GetModule(Of Modules.User)() @@ -104,9 +105,10 @@ Public Class Patterns2 End Function Public Function ReplaceFileValues(pInput As String, pFileInfo As FileInfo) As String + Logger.Debug("Replacing File Values") Dim oResult = pInput - Dim oModule = GetModule(Of Modules.User)() + Dim oModule = GetModule(Of Modules.FileInformation)() Dim oArgs = GetReplaceMapForModule(oModule, pFileInfo:=pFileInfo) oResult = DoReplaceForModule(oResult, oModule, oArgs) @@ -114,6 +116,7 @@ Public Class Patterns2 End Function Public Function ReplaceControlValues(pInput As String, pPanel As Panel) As String + Logger.Debug("Replacing Control Values") Dim oResult = pInput Dim oModule = GetModule(Of Modules.Controls)() @@ -124,6 +127,7 @@ Public Class Patterns2 End Function Public Function ReplaceWindreamValues(pInput As String, pWMObject As WMObject) As String + Logger.Debug("Replacing Windream Values") Dim oResult = pInput Dim oModule = GetModule(Of Modules.Windream)() @@ -134,6 +138,7 @@ Public Class Patterns2 End Function Public Function ReplaceInternalValues(pInput As String) As String + Logger.Debug("Replacing Internal Values") Dim oResult = pInput Dim oInternalModule = GetModule(Of Modules.Internal)() @@ -148,6 +153,7 @@ Public Class Patterns2 End Function Public Function ReplaceGlobixValues(pInput As String, pGlobixIndexes As Dictionary(Of String, List(Of String))) As String + Logger.Debug("Replacing Globix Values") Dim oResult = pInput Dim oGlobixModule = GetModule(Of Modules.Globix)() @@ -161,6 +167,12 @@ Public Class Patterns2 Private Function DoReplaceForModule(pInput As String, pModule As IModule, pArgs As Dictionary(Of String, Object)) As String Try + If pModule IsNot Nothing AndAlso pModule?.GetType?.Name IsNot Nothing Then + Logger.Debug("Calling Replace for Module [{0}]", pModule.GetType.Name) + End If + + Logger.Debug("Calling Replace for Input String [{0}]", pInput) + pInput = pModule.Replace(pInput, pArgs) Catch ex As Exception Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, pModule.GetType.Name) @@ -186,6 +198,7 @@ Public Class Patterns2 Dim oArgs As New Dictionary(Of String, Object) If TypeOf pModule Is Modules.Clipboard Then + Logger.Debug("Adding Arguments for Clipboard Module") Try oArgs.Add(Patterns.Modules.Clipboard.CLIP_VALUE_BOARD, My.Computer.Clipboard.GetText()) Catch ex As Exception @@ -193,6 +206,7 @@ Public Class Patterns2 End Try ElseIf TypeOf pModule Is Modules.FileInformation Then + Logger.Debug("Adding Arguments for File Module") Try oArgs.Add(Patterns.Modules.FileInformation.FILE_VALUE_FILEINFO, pFileInfo) Catch ex As Exception @@ -200,6 +214,7 @@ Public Class Patterns2 End Try ElseIf TypeOf pModule Is Modules.User Then + Logger.Debug("Adding Arguments for User Module") Try oArgs.Add(Patterns.Modules.User.USER_VALUE_EMAIL, pUser.Email) oArgs.Add(Patterns.Modules.User.USER_VALUE_LANGUAGE, pUser.Language) @@ -213,6 +228,7 @@ Public Class Patterns2 End Try ElseIf TypeOf pModule Is Modules.Controls Then + Logger.Debug("Adding Arguments for Controls Module") Try oArgs.Add(Patterns.Modules.Controls.CTRL_VALUE_PANEL, pPanel) Catch ex As Exception @@ -220,6 +236,7 @@ Public Class Patterns2 End Try ElseIf TypeOf pModule Is Modules.Windream Then + Logger.Debug("Adding Arguments for Windream Module") Try oArgs.Add(Patterns.Modules.Windream.WM_VALUE_DOCUMENT, pWMObject) Catch ex As Exception @@ -227,6 +244,7 @@ Public Class Patterns2 End Try ElseIf TypeOf pModule Is Modules.Globix Then + Logger.Debug("Adding Arguments for Globix Module") Try oArgs.Add(Patterns.Modules.Globix.GBX_VALUE_INDICIES, pGlobixIndexes) Catch ex As Exception diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb index 1d6e98b0..2b2574e3 100644 --- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb @@ -12,9 +12,6 @@ Namespace Methods.GlobalIndexer.ImportFile Private ReadOnly GetDatatable As GetDatatableFromCacheMethod Private Profile As DataRow - Private ManualIndexes As List(Of ManualIndex) - Private AutomaticIndexes As List(Of AutomaticIndex) - Private ManualIndexesPostProcessing As DataTable Private Const VIEW_PROFILE = "VWGI_DOCTYPE_IDB" Private Const VIEW_INDEX_MANUAL = "VWDDINDEX_MAN" @@ -41,7 +38,9 @@ Namespace Methods.GlobalIndexer.ImportFile ' TODO: Add missing user properties in UserState from TBDD_USER 'pData.User = ResolveUserFromUserName(pData.User.UserName) - LoadIndexes(pData.ProfileId) + Dim oManualIndexes = LoadManualIndexes(pData.ProfileId) + Dim oAutomaticIndexes = LoadAutomaticIndexes(pData.ProfileId) + Dim oPostProcessingSteps As DataTable = LoadPostProcessingSteps(oManualIndexes) LoadProfile(pData.ProfileId) @@ -49,13 +48,11 @@ Namespace Methods.GlobalIndexer.ImportFile Dim oFileName As String = GetFilenameByNameconvention(pData.File.FileName, Profile.Item("NAMENKONVENTION")) ' Apply post processing - Dim oPostProcessing = New Steps.PostProcessing(LogConfig, ManualIndexesPostProcessing) + Dim oPostProcessing = New Steps.PostProcessing(LogConfig, oPostProcessingSteps) oFinalAttributes = oPostProcessing.ApplyManualPostprocessing(oFinalAttributes) ' Apply automatic attributes - Dim oAutomaticIndexing = New Steps.AutomaticIndexing(LogConfig, Database, AutomaticIndexes, GlobalState) - - + Dim oAutomaticIndexing = New Steps.AutomaticIndexing(LogConfig, Database, oAutomaticIndexes, GlobalState) oFinalAttributes = oAutomaticIndexing.ApplyAutomaticeAttributes(oFinalAttributes, pData.File.FileInfoRaw, pData.User) ' Import the file @@ -69,6 +66,7 @@ Namespace Methods.GlobalIndexer.ImportFile }) If oResponse.OK Then + Logger.Info("Import of file [{0}] under ObjectId [{1}] successful!", pData.File.FileName, oResponse.ObjectId) Return New ImportFileResponse(oResponse.ObjectId) Else Throw New ApplicationException(oResponse.ErrorMessage) @@ -87,14 +85,6 @@ Namespace Methods.GlobalIndexer.ImportFile Return pFileName End Function - Private Sub LoadIndexes(pProfileId As Integer) - Logger.Debug("Start of Method [LoadIndexes]") - - LoadManualIndexes(pProfileId) - LoadAutomaticIndexes(pProfileId) - LoadPostProcessingSteps() - End Sub - ''' ''' Load Profiles for this Import ''' @@ -118,15 +108,18 @@ Namespace Methods.GlobalIndexer.ImportFile End Try End Sub - Private Sub LoadAutomaticIndexes(pProfileId As Integer) + ''' + ''' Load automatic indexes for this Import + ''' + Private Function LoadAutomaticIndexes(pProfileId As Integer) As List(Of AutomaticIndex) Logger.Debug("Start of Method [LoadAutomaticIndexes]") Try ' Load automatic Indexes for this Import Dim oAutomaticIndexes = GetDatatable.Run( New GetDatatableFromCacheRequest With { - .DataTable = VIEW_INDEX_MANUAL, - .FilterExpression = $"DOK_ID = {pProfileId}" + .DataTable = VIEW_INDEX_AUTOMATIC, + .FilterExpression = $"DOCTYPE_ID = {pProfileId}" }) If oAutomaticIndexes.OK = False Then @@ -145,15 +138,22 @@ Namespace Methods.GlobalIndexer.ImportFile .Sequence = oRow.ItemEx(Of String)("SEQUENCE"), .Value = oRow.ItemEx(Of String)("VALUE") } + + oIndexes.Add(oAutomaticIndex) Next - AutomaticIndexes = oIndexes + Logger.Info("[{0}] automatic indexes loaded.", oIndexes) + + Return oIndexes Catch ex As Exception LogAndThrow(ex, "Error while automatic loading indexes!") End Try - End Sub + End Function - Private Sub LoadManualIndexes(pProfileId As Integer) + ''' + ''' Load manual indexes for this Import + ''' + Private Function LoadManualIndexes(pProfileId As Integer) As List(Of ManualIndex) Logger.Debug("Start of Method [LoadManualIndexes]") Try @@ -182,23 +182,32 @@ Namespace Methods.GlobalIndexer.ImportFile .DefaultValue = oRow.ItemEx(Of String)("DEFAULT_VALUE"), .DataType = oRow.ItemEx(Of String)("DATA_TYPE") } + + oIndexes.Add(oManualIndex) Next - ManualIndexes = oIndexes + Return oIndexes Catch ex As Exception LogAndThrow(ex, "Error while loading indexes!") End Try - End Sub + End Function - Private Sub LoadPostProcessingSteps() + Private Function LoadPostProcessingSteps(pManualIndexes As List(Of ManualIndex)) As DataTable Logger.Debug("Start of Method [LoadPostProcessingSteps]") Try ' Generate a string containing all index ids joined into a string - Dim oIndexIdList As List(Of Integer) = ManualIndexes.Select(Function(index) index.Id).ToList() + Dim oIndexIdList As List(Of Integer) = pManualIndexes. + Select(Function(index) index.Id). + ToList() Dim oIndexIds As String = String.Join(",", oIndexIdList) + If oIndexIdList.Count = 0 Then + Logger.Debug("No Postprocessing steps found for this profile. Exiting.") + Return Nothing + End If + ' Load all relevant postprocessing steps Dim oPostProcessingSteps = GetDatatable.Run( New GetDatatableFromCacheRequest With { @@ -210,11 +219,11 @@ Namespace Methods.GlobalIndexer.ImportFile LogAndThrow(oPostProcessingSteps.ErrorMessage) End If - ManualIndexesPostProcessing = oPostProcessingSteps.Table + Return oPostProcessingSteps.Table Catch ex As Exception LogAndThrow(ex, "Error while loading post processing steps!") End Try - End Sub + End Function End Class End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb index 1dac0f51..70b73c13 100644 --- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileRequest.vb @@ -40,7 +40,7 @@ Namespace Methods.GlobalIndexer.ImportFile ''' Attribute Name/Attribute Value/ControlName ''' - Public Property AttributeValues As List(Of UserAttributeValue) + Public Property AttributeValues As New List(Of UserAttributeValue) ''' ''' User Importing the file diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb index 44358440..2753617a 100644 --- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb @@ -20,17 +20,30 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps GlobalState = pGlobalState AutomaticIndexes = pAutomaticIndexes Patterns = New Patterns2(pLogConfig) + + Logger.Info("Starting Automatic Indexing") End Sub - Public Function ApplyAutomaticeAttributes(pManualAttributes As List(Of UserAttributeValue), pFileInfo As FileInfo, pUserState As UserState) As List(Of UserAttributeValue) - Logger.Debug("Start of Method [ApplyAutomaticeAttributes]") - Dim oAttributes = pManualAttributes + Public Function ApplyAutomaticeAttributes(pUserAttributes As List(Of UserAttributeValue), pFileInfo As FileInfo, pUserState As UserState) As List(Of UserAttributeValue) + Logger.Debug("Start of Method [ApplyAutomaticAttributes]") + + If AutomaticIndexes Is Nothing OrElse AutomaticIndexes.Count = 0 Then + Logger.Warn("No Automatix Indexes supplied. Exiting.") + Return pUserAttributes + End If + + Logger.Info("Processing [{0}] automatic indexes", AutomaticIndexes.Count) + Dim oAttributes As List(Of UserAttributeValue) = pUserAttributes For Each oAutomaticIndex In AutomaticIndexes ' We add oAttributes from the previous run into the current run so it is in theory possible to reference ' automatic attributes which have been set just before. Dim oAttribute = ApplyAutomaticIndex(oAutomaticIndex, pFileInfo, pUserState, oAttributes) - oAttributes.Add(oAttribute) + + If oAttribute IsNot Nothing Then + Logger.Info("Adding Attribute [{0}]", oAttribute) + oAttributes.Add(oAttribute) + End If Next Return oAttributes @@ -38,41 +51,65 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps Private Function ApplyAutomaticIndex(pAutomaticIndex As AutomaticIndex, pFileInfo As FileInfo, pUserState As UserState, pAttributes As List(Of UserAttributeValue)) As UserAttributeValue - Dim oAttributeDict = pAttributes.ToDictionary( - Function(attr) attr.AttributeName, - Function(attr) attr.AttributeValues) + Try + Dim oAttributeDict = pAttributes.ToDictionary( + Function(attr) attr.AttributeName, + Function(attr) attr.AttributeValues) - ' If there is no SQL command, we use the Value property and replace all placeholders in it. - If pAutomaticIndex.HasSqlCommand = False Then - Dim oResult As String = GetPlaceholderValue(pAutomaticIndex.Value, pFileInfo, pUserState, oAttributeDict) + Logger.Info("Applying Automatic Index [{0}]", pAutomaticIndex.Name) + Dim oHasSqlCommand As Boolean = pAutomaticIndex.HasSqlCommand + + Logger.Debug("Index has SQLCommand: [{0}]", oHasSqlCommand) + + ' If there is no SQL command, we use the Value property and replace all placeholders in it. + If oHasSqlCommand = False Then + Dim oResult As String = GetPlaceholderValue(pAutomaticIndex.Value, pFileInfo, pUserState, oAttributeDict) + + Return New UserAttributeValue With { + .AttributeValues = New List(Of String) From {oResult}, + .AttributeName = pAutomaticIndex.Name, + .AttributeId = pAutomaticIndex.Id + } + End If + + ' Otherwise we will replace placeholders in the SQL command and then execute it + Dim oConnectionString As String = GlobalState.GetConnectionString(pAutomaticIndex.SQLConnectionId) + Dim oFinalSQLCommand = pAutomaticIndex.SQLCommand + + Logger.Debug("SQL Command is: [{0}]", oFinalSQLCommand) + + oFinalSQLCommand = GetPlaceholderValue(oFinalSQLCommand, pFileInfo, pUserState, oAttributeDict) + + ' Now we have a SQL command which only contains vector placeholders + ' Next, we execute the command to get our result + Dim oValue = Database.GetScalarValueWithConnection(oFinalSQLCommand, oConnectionString) + + If oValue Is Nothing Then + Logger.Warn("SQL for Automatic Index [{0}] returned an error. Exiting.") + Return Nothing + End If + + Logger.Info("Value for Automatic Index [{0}] is [{1}]", pAutomaticIndex.Name, oValue.ToString) + + ' TODO: Return multiple values Return New UserAttributeValue With { - .AttributeValues = New List(Of String) From {oResult}, + .AttributeValues = New List(Of String) From {oValue}, .AttributeName = pAutomaticIndex.Name, .AttributeId = pAutomaticIndex.Id } - End If + Catch ex As Exception + Logger.Warn("Automatic Indexing for index failed.") + Logger.Error(ex) - ' Otherwise we will replace placeholders in the SQL command and then execute it - Dim oConnectionString As String = GlobalState.GetConnectionString(pAutomaticIndex.SQLConnectionId) - Dim oFinalSQLCommand = pAutomaticIndex.SQLCommand - oFinalSQLCommand = GetPlaceholderValue(oFinalSQLCommand, pFileInfo, pUserState, oAttributeDict) - - ' Now we have a SQL command which only contains vector placeholders - ' Next, we execute the command to get our result - Dim oValue = Database.GetScalarValueWithConnection(oFinalSQLCommand, oConnectionString) - - ' TODO: Return multiple values - Return New UserAttributeValue With { - .AttributeValues = New List(Of String) From {oValue}, - .AttributeName = pAutomaticIndex.Name, - .AttributeId = pAutomaticIndex.Id - } + Return Nothing + End Try End Function Private Function GetPlaceholderValue(pValue As String, pFileInfo As FileInfo, pUserState As UserState, pAttributes As Dictionary(Of String, List(Of String))) As String Dim oResult As String = pValue + oResult = Patterns.ReplaceInternalValues(oResult) oResult = Patterns.ReplaceFileValues(oResult, pFileInfo) oResult = Patterns.ReplaceUserValues(oResult, pUserState) diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb index 86930694..21563be3 100644 --- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb +++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/PostProcessing.vb @@ -14,33 +14,53 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps Public Sub New(pLogConfig As LogConfig, pPostProcessingSteps As DataTable) MyBase.New(pLogConfig) PostprocessingSteps = pPostProcessingSteps + + Logger.Info("Starting Postprocessing of Manual Indexes") End Sub Public Function ApplyManualPostprocessing(pManualAttributes As List(Of UserAttributeValue)) As List(Of UserAttributeValue) - Logger.Debug("Start of Method [ApplyManualPostprocessing]") Dim oAttributes = pManualAttributes - For Each oProcessingRow As DataRow In PostprocessingSteps.Rows + Try + Logger.Debug("Start of Method [ApplyManualPostprocessing]") - Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID") - Dim oIndex As UserAttributeValue = pManualAttributes. - Where(Function(attr) attr.AttributeId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")). - FirstOrDefault() + If PostprocessingSteps Is Nothing Then + Logger.Debug("No Postprocessing steps found. Exiting.") + Return oAttributes + End If - Dim oValue = GetPostprocessingValue(oIndex.AttributeValues, oProcessingRow) + For Each oProcessingRow As DataRow In PostprocessingSteps.Rows + Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID") + Dim oIndex As UserAttributeValue = pManualAttributes. + Where(Function(attr) attr.AttributeId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")). + FirstOrDefault() + Dim oIndexPosition = pManualAttributes.IndexOf(oIndex) - oAttributes.Add(New UserAttributeValue With { - .AttributeId = oIndexId, - .AttributeName = oIndex.AttributeName, - .AttributeValues = oIndex.AttributeValues, - .ControlName = oIndex.ControlName - }) - Next + Logger.Info("Postprocessing Index [{0}]", oIndex.AttributeName) - Return oAttributes + Dim oValues = GetPostprocessingValue(oIndex.AttributeValues, oProcessingRow) + + Logger.Info("New Value for Index [{0}] is [{1}]", oIndex.AttributeName, String.Join(",", oValues)) + + ' Replace the old AttributeValue with the new one + oAttributes.Item(oIndexPosition) = New UserAttributeValue With { + .AttributeId = oIndexId, + .AttributeName = oIndex.AttributeName, + .AttributeValues = oValues, + .ControlName = oIndex.ControlName + } + Next + + Return oAttributes + Catch ex As Exception + Logger.Warn("Postprocessing failed. Returning incomplete Attributes.") + Logger.Error(ex) + Return oAttributes + + End Try End Function - Public Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow) + Public Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow) As List(Of String) Logger.Debug("Start of Method [GetPostprocessingValue]") Dim oType = pRow.Item("TYPE") @@ -88,7 +108,8 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps Next Case Else - LogAndThrow($"Postprocessing type [{oType}] is not supported!") + Logger.Warn("Postprocessing type [{0}] is not supported!", oType) + End Select Return oResult diff --git a/Service.EDMIService/Methods/UserAttributeValue.vb b/Service.EDMIService/Methods/UserAttributeValue.vb index 2d385c83..4c5dfed8 100644 --- a/Service.EDMIService/Methods/UserAttributeValue.vb +++ b/Service.EDMIService/Methods/UserAttributeValue.vb @@ -5,6 +5,10 @@ Public Property AttributeName As String Public Property AttributeValues As List(Of String) Public Property ControlName As String + + Public Overrides Function ToString() As String + Return AttributeName + End Function End Class End Namespace \ No newline at end of file diff --git a/Service.EDMIService/Scheduler/Scheduler.vb b/Service.EDMIService/Scheduler/Scheduler.vb index 6ef93270..22b6f05b 100644 --- a/Service.EDMIService/Scheduler/Scheduler.vb +++ b/Service.EDMIService/Scheduler/Scheduler.vb @@ -22,7 +22,7 @@ Public Class Scheduler Public Sub New(LogConfig As LogConfig, MSSQL_ECM As MSSQLServer, TableStore As DataSet) _LogConfig = LogConfig - _Logger = LogConfig.GetLoggerFor("Scheduler") + _Logger = LogConfig.GetLogger() _Factory = New StdSchedulerFactory(_Props) _MSSQL = MSSQL_ECM diff --git a/Service.EDMIService/WindowsService.vb b/Service.EDMIService/WindowsService.vb index 47b0cf36..4f1c73e2 100644 --- a/Service.EDMIService/WindowsService.vb +++ b/Service.EDMIService/WindowsService.vb @@ -12,6 +12,7 @@ Public Class WindowsService Private _ServiceHost As ServiceHost(Of EDMIService) Private _LogConfig As LogConfig + Private _LogConfigScheduler As LogConfig Private _Logger As Logger Private _Firebird As Firebird @@ -39,6 +40,7 @@ Public Class WindowsService Dim oServicePath As String = AppDomain.CurrentDomain.BaseDirectory _LogConfig = New LogConfig(LogConfig.PathType.CustomPath, IO.Path.Combine(oServicePath, "Log"), FileKeepRangeInDays:=3) + _LogConfigScheduler = New LogConfig(LogConfig.PathType.CustomPath, IO.Path.Combine(oServicePath, "Log"), Suffix:="Scheduler", FileKeepRangeInDays:=3) _Logger = _LogConfig.GetLogger() _Logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME) @@ -71,7 +73,7 @@ Public Class WindowsService _Archive = New EDMI.File.Archive(_LogConfig) _Filesystem = New Filesystem.File(_LogConfig) _Global = New GlobalState(_LogConfig, _MSSQL_IDB, _MSSQL_ECM) - _Scheduler = New Scheduler(_LogConfig, _MSSQL_ECM, _Global.TableStore) + _Scheduler = New Scheduler(_LogConfigScheduler, _MSSQL_ECM, _Global.TableStore) _Logger.Debug("Loading Global Data") _Global.LoadObjectStores()