diff --git a/GUIs.ZooFlow/Globix/ClassValidator.vb b/GUIs.ZooFlow/Globix/ClassValidator.vb
index f4eccc27..5b8248d9 100644
--- a/GUIs.ZooFlow/Globix/ClassValidator.vb
+++ b/GUIs.ZooFlow/Globix/ClassValidator.vb
@@ -2,6 +2,7 @@
Imports DigitalData.GUIs.ZooFlow.Base
Imports DigitalData.GUIs.ZooFlow.frmGlobix_Index
Imports DigitalData.Modules.EDMI.API
+Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Imports DigitalData.Modules.Logging
Public Class ClassValidator
@@ -14,30 +15,18 @@ Public Class ClassValidator
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
+ Function ValidateControls(pPanel As Panel, pDocType As DocType) As Boolean
Try
Logger.Debug("Starting [ValidateControls]")
Dim result As Boolean = True
- For Each oControl As Control In pControls
+ For Each oControl As Control In pPanel.Controls
' ========================= 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 oIndexName = GetIndexName(oTextBox, "txt")
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
If oOptional = False Then
@@ -54,7 +43,7 @@ Public Class ClassValidator
Dim oValues As List(Of String) = oLookup.Properties.SelectedValues
If oValues.Count = 0 Then
- Dim oIndexName = Replace(oLookup.Name, "cmbMulti", "")
+ Dim oIndexName = GetIndexName(oLookup, "cmbMulti")
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
If oOptional = False Then
@@ -70,7 +59,7 @@ Public Class ClassValidator
Dim cmbSingle As TextBox = oControl
If cmbSingle.Text = "" Then
- Dim oIndexName = Replace(cmbSingle.Name, "cmbSingle", "")
+ Dim oIndexName = GetIndexName(cmbSingle, "cmbSingle")
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
If oOptional = False Then
@@ -84,7 +73,7 @@ Public Class ClassValidator
If oControl.Name.StartsWith("cmb") Then
Dim cmb As ComboBox = oControl
If cmb.Text = "" Then
- Dim oIndexName = Replace(cmb.Name, "cmb", "")
+ Dim oIndexName = GetIndexName(cmb, "cmb")
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
If oOptional = False Then
@@ -98,7 +87,7 @@ Public Class ClassValidator
' ========================= DATE PICKER =========================
If oControl.Name.StartsWith("dtp") Then
Dim dtp As DevExpress.XtraEditors.DateEdit = oControl
- Dim oIndexName As String = Replace(dtp.Name, "dtp", "")
+ Dim oIndexName As String = GetIndexName(dtp, "dtp")
If dtp.Text = String.Empty Then
Dim oOptional = TestIsIndexOptional(pDocType, oIndexName)
@@ -134,4 +123,124 @@ Public Class ClassValidator
Return False
End Try
End Function
+
+ Function GetControlValues(pPanel As Panel)
+ Dim oAttributeValues As New List(Of UserAttributeValue)
+
+ For Each oControl As Control In pPanel.Controls
+
+ ' ========================= TEXTBOX =========================
+ If oControl.Name.StartsWith("txt") Then
+ Dim oTextBox As DevExpress.XtraEditors.TextEdit = oControl
+ Dim oIndexName = GetIndexName(oTextBox, "txt")
+
+ ' TODO: What to do when value is emmpty? send an empty value or skip the control?
+ 'If oTextBox.Text = "" Then
+ 'End If
+
+ oAttributeValues.Add(New UserAttributeValue With {
+ .AttributeName = oIndexName,
+ .AttributeValues = WrapIndexValue(oTextBox.Text),
+ .ControlName = oTextBox.Name
+ })
+ End If
+
+ ' ========================= LOOKUP =========================
+ If oControl.Name.StartsWith("cmbMulti") Then
+ Dim oLookup = DirectCast(oControl, LookupControl3)
+ Dim oValues As List(Of String) = oLookup.Properties.SelectedValues
+ Dim oIndexName = GetIndexName(oLookup, "cmbMulti")
+
+ If oValues.Count = 0 Then
+ End If
+
+ oAttributeValues.Add(New UserAttributeValue With {
+ .AttributeName = oIndexName,
+ .AttributeValues = WrapIndexValue(oValues),
+ .ControlName = oLookup.Name
+ })
+ End If
+
+ ' ========================= COMBO BOX =========================
+ If oControl.Name.StartsWith("cmbSingle") Then
+ Dim cmbSingle As TextBox = oControl
+ Dim oIndexName = GetIndexName(cmbSingle, "cmbSingle")
+
+ If cmbSingle.Text = "" Then
+ End If
+
+ oAttributeValues.Add(New UserAttributeValue With {
+ .AttributeName = oIndexName,
+ .AttributeValues = WrapIndexValue(cmbSingle.Text),
+ .ControlName = cmbSingle.Name
+ })
+ End If
+
+ If oControl.Name.StartsWith("cmb") Then
+ Dim cmb As ComboBox = oControl
+ Dim oIndexName = GetIndexName(cmb, "cmb")
+
+ If cmb.Text = "" Then
+ End If
+
+ oAttributeValues.Add(New UserAttributeValue With {
+ .AttributeName = oIndexName,
+ .AttributeValues = WrapIndexValue(cmb.Text),
+ .ControlName = cmb.Name
+ })
+ End If
+
+ ' ========================= DATE PICKER =========================
+ If oControl.Name.StartsWith("dtp") Then
+ Dim dtp As DevExpress.XtraEditors.DateEdit = oControl
+ Dim oIndexName As String = GetIndexName(dtp, "dtp")
+
+ oAttributeValues.Add(New UserAttributeValue With {
+ .AttributeName = oIndexName,
+ .AttributeValues = WrapIndexValue(dtp.EditValue.ToString),
+ .ControlName = dtp.Name
+ })
+ End If
+
+ ' ========================= CHECK BOX =========================
+ If oControl.Name.StartsWith("chk") Then
+ Dim chk As CheckBox = oControl
+ Dim oIndexName As String = GetIndexName(chk, "chk")
+
+
+ oAttributeValues.Add(New UserAttributeValue With {
+ .AttributeName = oIndexName,
+ .AttributeValues = WrapIndexValue(chk.Checked.ToString),
+ .ControlName = chk.Name
+ })
+ End If
+ Next
+
+ Return oAttributeValues
+ End Function
+
+ Private Function GetIndexName(pControl As Control, pPrefix As String) As String
+ Dim oIndexName = Replace(pControl.Name, pPrefix, "")
+ Return oIndexName
+ End Function
+
+ Private Function WrapIndexValue(pValue As String) As String()
+ Return New List(Of String) From {pValue}.ToArray
+ End Function
+
+ Private Function WrapIndexValue(pValues As List(Of String)) As String()
+ Return pValues.ToArray
+ End Function
+
+ 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
End Class
diff --git a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb
index 411f61c0..0352f2d2 100644
--- a/GUIs.ZooFlow/Globix/frmGlobix_Index.vb
+++ b/GUIs.ZooFlow/Globix/frmGlobix_Index.vb
@@ -305,9 +305,9 @@ Public Class frmGlobix_Index
End Sub
Sub Refresh_Dokart()
Try
- Dim oSql = String.Format("select * from VWGI_DOCTYPE where UPPER(USERNAME) = UPPER('{0}') ORDER BY SEQUENCE", My.Application.User.UserName)
- Dim oFilter = $"USERNAME = '{My.Application.User.UserName}'"
- DT_VWGI_DOCTYPE = _DataASorDB.GetDatatable("DD_ECM", oSql, "VWGI_DOCTYPE", oFilter, "SEQUENCE")
+ Dim oSql = String.Format("select * from VWGI_DOCTYPE_IDB where UPPER(USERNAME) = UPPER('{0}') ORDER BY SEQUENCE", My.Application.User.UserName)
+ 'Dim oFilter = $"USERNAME = '{My.Application.User.UserName}'"
+ DT_VWGI_DOCTYPE = _DataASorDB.GetDatatable("DD_ECM", oSql, "VWGI_DOCTYPE_IDB", "", "SEQUENCE")
For Each oRow As DataRow In DT_VWGI_DOCTYPE.Rows
cmbDocType.Properties.Items.Add(New DocType With {
@@ -2415,7 +2415,11 @@ Public Class frmGlobix_Index
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oDokart As DocType = cmbDocType.SelectedItem
- Await GlobixFlowNew(oDokart)
+ Dim oResult = Await GlobixFlowNew(oDokart)
+ If oResult = True Then
+ CancelAttempts = MaxCancelAttempts
+ Close()
+ End If
End Sub
Private Async Function GlobixFlowNew(pDocType As DocType) As Threading.Tasks.Task(Of Boolean)
@@ -2425,26 +2429,29 @@ Public Class frmGlobix_Index
Cursor = Cursors.WaitCursor
Dim oValidator As New ClassValidator(My.LogConfig, My.Application.Service.Client)
- If oValidator.ValidateControls(pnlIndex.Controls, pDocType) = False Then
+ If oValidator.ValidateControls(pnlIndex, pDocType) = False Then
Return False
End If
- 'TODO: Globix File Import
+ Dim oValues = oValidator.GetControlValues(pnlIndex)
- 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 oFileName As String = My.Application.Globix.CURRENT_WORKFILE
+ Dim oObjectStore As String = "WORK"
+ Dim oObjectKind As String = "DOC"
+ Dim oBusinessEntity As String = "DEFAULT"
+ Dim oProfileId As Integer = My.Application.Globix.CURRENT_DOCTYPE_ID
+ Dim oAttributes As List(Of UserAttributeValue) = oValues
Dim oOptions As New Modules.EDMI.API.Options.ImportFileOptions
- Await My.Application.Service.Client.ImportFileAsync(oFileName, oProfileId, oAttributes, oObjectStore, oObjectKind, oBusinessENtity, oOptions)
+ Await My.Application.Service.Client.ImportFileAsync(oFileName, oProfileId, oAttributes, oObjectStore, oObjectKind, oBusinessEntity, oOptions)
+
+ MsgBox("Die Datei wurde erfolgreich verarbeitet!", MsgBoxStyle.Information, Text)
Return True
Catch ex As Exception
_Logger.Error(ex)
MsgBox("Indexierung fehlgeschlagen!", MsgBoxStyle.Critical, Text)
+ Return False
Finally
Cursor = Cursors.Default
diff --git a/GUIs.ZooFlow/frmtest.vb b/GUIs.ZooFlow/frmtest.vb
index d067e120..59000de3 100644
--- a/GUIs.ZooFlow/frmtest.vb
+++ b/GUIs.ZooFlow/frmtest.vb
@@ -39,7 +39,12 @@ Public Class frmtest
Dim oObjectId As Long = Await My.Application.Service.Client.ImportFileAsync(
txtFile2Import.Text,
txtProfileId.Text,
- New List(Of EDMIServiceReference.UserAttributeValue),
+ New List(Of EDMIServiceReference.UserAttributeValue) From {
+ New EDMIServiceReference.UserAttributeValue With {
+ .AttributeName = "Attribut String1",
+ .AttributeValues = New List(Of String) From {"SchreiberM"}.ToArray
+ }
+ },
"WORK",
"DOC",
"DEFAULT"
diff --git a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
index f7595dbe..8ec03ba6 100644
--- a/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
+++ b/Modules.EDMIAPI/Connected Services/EDMIServiceReference/Reference.vb
@@ -933,7 +933,7 @@ Namespace EDMIServiceReference
End Property
Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
-
+
Protected Sub RaisePropertyChanged(ByVal propertyName As String)
Dim propertyChanged As System.ComponentModel.PropertyChangedEventHandler = Me.PropertyChangedEvent
If (Not (propertyChanged) Is Nothing) Then
diff --git a/Modules.Patterns/IModule.vb b/Modules.Patterns/IModule.vb
index 91bcf20e..5caaa4cd 100644
--- a/Modules.Patterns/IModule.vb
+++ b/Modules.Patterns/IModule.vb
@@ -10,10 +10,4 @@
'''
'''
Property IsComplex As Boolean
-
- '''
- ''' Main Replace Function
- '''
- ''' The replaced string
- Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String
End Interface
diff --git a/Modules.Patterns/Modules/Clipboard.vb b/Modules.Patterns/Modules/Clipboard.vb
index ef9bba94..43cc729b 100644
--- a/Modules.Patterns/Modules/Clipboard.vb
+++ b/Modules.Patterns/Modules/Clipboard.vb
@@ -17,24 +17,23 @@ Namespace Modules
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String, pClipboardContents As String) As String
Dim oResult = pInput
Dim oCounter = 0
- Dim oClipboardContents = pReplaceMap.Item(CLIP_VALUE_BOARD)
Try
' LEGACY: Replace Clipboard Contents
- oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToLower, oClipboardContents)
- oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToUpper, oClipboardContents)
- oResult = oResult.Replace(CLIPBOARD_VALUE_DE, oClipboardContents)
+ oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToLower, pClipboardContents)
+ oResult = oResult.Replace(CLIPBOARD_VALUE_DE.ToUpper, pClipboardContents)
+ oResult = oResult.Replace(CLIPBOARD_VALUE_DE, pClipboardContents)
- oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToLower, oClipboardContents)
- oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToUpper, oClipboardContents)
- oResult = oResult.Replace(CLIPBOARD_VALUE_EN, oClipboardContents)
+ oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToLower, pClipboardContents)
+ oResult = oResult.Replace(CLIPBOARD_VALUE_EN.ToUpper, pClipboardContents)
+ oResult = oResult.Replace(CLIPBOARD_VALUE_EN, pClipboardContents)
' Replace Clipboard Contents
While ContainsPatternAndValue(oResult, PatternIdentifier, CLIP_VALUE_BOARD)
- oResult = ReplacePattern(oResult, PatternIdentifier, oClipboardContents)
+ oResult = ReplacePattern(oResult, PatternIdentifier, pClipboardContents)
IncrementCounterOrThrow(oCounter)
End While
diff --git a/Modules.Patterns/Modules/Controls.vb b/Modules.Patterns/Modules/Controls.vb
index 874c1cc9..35e341d9 100644
--- a/Modules.Patterns/Modules/Controls.vb
+++ b/Modules.Patterns/Modules/Controls.vb
@@ -19,15 +19,14 @@ Namespace Modules
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String, pPanel As Panel) As String
Dim oResult = pInput
Dim oCounter = 0
- Dim oPanel As Panel = pReplaceMap.Item(CTRL_VALUE_PANEL)
While ContainsPattern(oResult, PatternIdentifier)
Try
Dim oControlName As String = GetNextPattern(oResult, PatternIdentifier).Value
- Dim oControl As Control = oPanel.Controls.Find(oControlName, False).FirstOrDefault()
+ Dim oControl As Control = pPanel.Controls.Find(oControlName, False).FirstOrDefault()
If oControl IsNot Nothing Then
Dim oReplaceValue As String
diff --git a/Modules.Patterns/Modules/FileInformation.vb b/Modules.Patterns/Modules/FileInformation.vb
index b0e8bf5e..8022dfd8 100644
--- a/Modules.Patterns/Modules/FileInformation.vb
+++ b/Modules.Patterns/Modules/FileInformation.vb
@@ -20,42 +20,41 @@ Namespace Modules
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String, pFileInfo As FileInfo) As String
Dim oResult = pInput
Dim oCounter = 0
- Dim oFileInfo As FileInfo = pReplaceMap.Item(FILE_VALUE_FILEINFO)
' Replace Filename without extension
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME)
- Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(oFileInfo.Name)
+ Dim oFilenameWithoutExtension = Path.GetFileNameWithoutExtension(pFileInfo.Name)
oResult = ReplacePattern(oResult, PatternIdentifier, oFilenameWithoutExtension)
IncrementCounterOrThrow(oCounter)
End While
' Replace Filename with extension
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME_EXT)
- Dim oFilename As String = oFileInfo.Name
+ Dim oFilename As String = pFileInfo.Name
oResult = ReplacePattern(oResult, PatternIdentifier, oFilename)
IncrementCounterOrThrow(oCounter)
End While
' Replace Extension
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_FILENAME_EXT)
- Dim oExtension As String = oFileInfo.Extension.Substring(1)
+ Dim oExtension As String = pFileInfo.Extension.Substring(1)
oResult = ReplacePattern(oResult, PatternIdentifier, oExtension)
IncrementCounterOrThrow(oCounter)
End While
' Replace creation date
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_DATE_CREATED)
- Dim oDateCreated = oFileInfo.CreationTime.ToString("yyyy-MM-dd")
+ Dim oDateCreated = pFileInfo.CreationTime.ToString("yyyy-MM-dd")
oResult = ReplacePattern(oResult, PatternIdentifier, oDateCreated)
IncrementCounterOrThrow(oCounter)
End While
' Replace last modification date
While ContainsPatternAndValue(oResult, PatternIdentifier, FILE_VALUE_DATE_CREATED)
- Dim oDateModified = oFileInfo.LastWriteTime.ToString("yyyy-MM-dd")
+ Dim oDateModified = pFileInfo.LastWriteTime.ToString("yyyy-MM-dd")
oResult = ReplacePattern(oResult, PatternIdentifier, oDateModified)
IncrementCounterOrThrow(oCounter)
End While
diff --git a/Modules.Patterns/Modules/Globix.vb b/Modules.Patterns/Modules/Globix/GlobixAutomatic.vb
similarity index 78%
rename from Modules.Patterns/Modules/Globix.vb
rename to Modules.Patterns/Modules/Globix/GlobixAutomatic.vb
index edda84bc..38a6950b 100644
--- a/Modules.Patterns/Modules/Globix.vb
+++ b/Modules.Patterns/Modules/Globix/GlobixAutomatic.vb
@@ -1,26 +1,29 @@
Imports DigitalData.Modules.Logging
-Namespace Modules
+Namespace Modules.Globix
'''
''' Patterns for Generating a Filename in Global Indexer
'''
- Public Class Globix
+ Public Class GlobixAutomatic
Inherits BaseModule
Implements IModule
- Public Const GBX_VALUE_INDICIES = "GLOBIX_INDICIES"
-
- Public Property PatternIdentifier As String = "GBX" Implements IModule.PatternIdentifier
+ Public Property PatternIdentifier As String = "ATTR_A" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String, pIndexes As Dictionary(Of String, List(Of String))) As String
Dim oResult = pInput
Dim oCounter = 0
- Dim pIndexes As Dictionary(Of String, List(Of String)) = pReplaceMap.Item(GBX_VALUE_INDICIES)
+
+ If pIndexes Is Nothing Then
+ Throw New ArgumentNullException("pIndexes")
+ End If
+
+ Logger.Debug("Replacing Automatic Indexes. [{0}] Indexes loaded.", pIndexes?.Count)
While ContainsPattern(oResult, PatternIdentifier)
Try
diff --git a/Modules.Patterns/Modules/Globix/GlobixManual.vb b/Modules.Patterns/Modules/Globix/GlobixManual.vb
new file mode 100644
index 00000000..4652a151
--- /dev/null
+++ b/Modules.Patterns/Modules/Globix/GlobixManual.vb
@@ -0,0 +1,59 @@
+Imports DigitalData.Modules.Logging
+
+Namespace Modules.Globix
+ '''
+ ''' Patterns for Generating a Filename in Global Indexer
+ '''
+ Public Class GlobixManual
+ Inherits BaseModule
+ Implements IModule
+
+ Public Property PatternIdentifier As String = "ATTR_M" Implements IModule.PatternIdentifier
+ Public Property IsComplex As Boolean = True Implements IModule.IsComplex
+
+ Public Sub New(pLogConfig As LogConfig)
+ MyBase.New(pLogConfig)
+ End Sub
+
+ Public Function Replace(pInput As String, pIndexes As Dictionary(Of String, List(Of String))) As String
+ Dim oResult = pInput
+ Dim oCounter = 0
+
+ If pIndexes Is Nothing Then
+ Throw New ArgumentNullException("pIndexes")
+ End If
+
+ Logger.Debug("Replacing Manual Indexes. [{0}] Indexes loaded.", pIndexes?.Count)
+
+ While ContainsPattern(oResult, PatternIdentifier)
+ Try
+ Dim oIndexName As String = GetNextPattern(oResult, PatternIdentifier).Value
+
+ If pIndexes.ContainsKey(oIndexName) = False Then
+ Logger.Warn("Value for Index [{0}] does not exist and will not be used for replacing. Exiting.", oIndexName)
+ Return oResult
+ End If
+
+ ' TODO: If Index contains multiple values, only the first value will be used as value
+ Dim oIndexValues As List(Of String) = pIndexes.Item(oIndexName)
+ Dim oFirstValue As String = oIndexValues.FirstOrDefault()
+
+ If oFirstValue Is Nothing Then
+ Logger.Warn("Value for Index [{0}] is empty and will not be used for replacing. Exiting.")
+ Return oResult
+ End If
+
+ oResult = ReplacePattern(oResult, PatternIdentifier, oFirstValue)
+
+ Catch ex As Exception
+ Logger.Error(ex)
+ Return oResult
+ Finally
+ IncrementCounterOrThrow(oCounter)
+ End Try
+ End While
+
+ Return oResult
+ End Function
+ End Class
+End Namespace
diff --git a/Modules.Patterns/Modules/IDB.vb b/Modules.Patterns/Modules/IDB.vb
index d9a2472d..e22a12c4 100644
--- a/Modules.Patterns/Modules/IDB.vb
+++ b/Modules.Patterns/Modules/IDB.vb
@@ -4,7 +4,7 @@ Imports DigitalData.Modules.Logging
Namespace Modules
'''
- ''' Patterns for Windream Indicies
+ ''' Patterns for IDB Attributes
'''
Public Class IDB
Inherits BaseModule
@@ -12,14 +12,14 @@ Namespace Modules
Public Const IDB_OBJECT_ID = "IDB_OBJECT_ID"
- Public Property PatternIdentifier As String = "IDB" Implements IModule.PatternIdentifier
+ Public Property PatternIdentifier As String = "ATTR" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = True Implements IModule.IsComplex
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String) As String
'TODO: Implement, depends on IDB Data, which is not in monorepo yet
Return pInput
diff --git a/Modules.Patterns/Modules/Internal.vb b/Modules.Patterns/Modules/Internal.vb
index 5394746a..ab26eb9e 100644
--- a/Modules.Patterns/Modules/Internal.vb
+++ b/Modules.Patterns/Modules/Internal.vb
@@ -23,7 +23,7 @@ Namespace Modules
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String) As String
Dim oResult = pInput
Dim oCounter = 0
Dim oNow As Date = Now
diff --git a/Modules.Patterns/Modules/User.vb b/Modules.Patterns/Modules/User.vb
index 74315b94..d5ddca22 100644
--- a/Modules.Patterns/Modules/User.vb
+++ b/Modules.Patterns/Modules/User.vb
@@ -1,4 +1,5 @@
Imports DigitalData.Modules.Logging
+Imports DigitalData.Modules.ZooFlow
Namespace Modules
Public Class User
@@ -20,37 +21,37 @@ Namespace Modules
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String, pUser As State.UserState) As String
Dim oResult = pInput
Dim oCounter = 0
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_PRENAME)
- oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_PRENAME))
+ oResult = ReplacePattern(oResult, PatternIdentifier, pUser.GivenName)
IncrementCounterOrThrow(oCounter)
End While
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_SURNAME)
- oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_SURNAME))
+ oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Surname)
IncrementCounterOrThrow(oCounter)
End While
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_EMAIL)
- oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_EMAIL))
+ oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Email)
IncrementCounterOrThrow(oCounter)
End While
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_SHORTNAME)
- oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_SHORTNAME))
+ oResult = ReplacePattern(oResult, PatternIdentifier, pUser.ShortName)
IncrementCounterOrThrow(oCounter)
End While
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_LANGUAGE)
- oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_LANGUAGE))
+ oResult = ReplacePattern(oResult, PatternIdentifier, pUser.Language)
IncrementCounterOrThrow(oCounter)
End While
While ContainsPatternAndValue(oResult, PatternIdentifier, USER_VALUE_USER_ID)
- oResult = ReplacePattern(oResult, PatternIdentifier, pReplaceMap.Item(USER_VALUE_USER_ID))
+ oResult = ReplacePattern(oResult, PatternIdentifier, pUser.UserId)
IncrementCounterOrThrow(oCounter)
End While
diff --git a/Modules.Patterns/Modules/Windream.vb b/Modules.Patterns/Modules/Windream.vb
index 3cae5fdd..98d14ebb 100644
--- a/Modules.Patterns/Modules/Windream.vb
+++ b/Modules.Patterns/Modules/Windream.vb
@@ -19,10 +19,9 @@ Namespace Modules
MyBase.New(pLogConfig)
End Sub
- Public Function Replace(pInput As String, pReplaceMap As Dictionary(Of String, Object)) As String Implements IModule.Replace
+ Public Function Replace(pInput As String, pWMObject As WINDREAMLib.WMObject) As String
Dim oResult = pInput
Dim oCounter = 0
- Dim pWMObject As WINDREAMLib.WMObject = pReplaceMap.Item(WM_VALUE_DOCUMENT)
While ContainsPattern(oResult, PatternIdentifier)
Try
diff --git a/Modules.Patterns/Patterns.vbproj b/Modules.Patterns/Patterns.vbproj
index 8fc6b49b..c22610ea 100644
--- a/Modules.Patterns/Patterns.vbproj
+++ b/Modules.Patterns/Patterns.vbproj
@@ -82,8 +82,9 @@
+
-
+
diff --git a/Modules.Patterns/Patterns2.vb b/Modules.Patterns/Patterns2.vb
index d5e20913..cc9b07d9 100644
--- a/Modules.Patterns/Patterns2.vb
+++ b/Modules.Patterns/Patterns2.vb
@@ -19,42 +19,9 @@ Imports WINDREAMLib
''' {#WMI#String 39}
'''
Public Class Patterns2
- '''
- ''' Complex patterns that rely on Windream
- '''
- Public Const PATTERN_WMI = "WMI"
-
- '''
- ''' Complex patterns that rely on IDB Attribute values
- '''
- Public Const PATTERN_IDBA = "IDBA"
-
- '''
- ''' Complex patterns that rely on Control Values
- '''
- Public Const PATTERN_CTRL = "CTRL"
-
- '''
- ''' Simple patterns that rely on Data from the TBDD_USER table
- '''
- Public Const PATTERN_USER = "USER"
-
- Public Const USER_VALUE_PRENAME = "PRENAME"
- Public Const USER_VALUE_SURNAME = "SURNAME"
- Public Const USER_VALUE_EMAIL = "EMAIL"
- Public Const USER_VALUE_SHORTNAME = "SHORTNAME"
- Public Const USER_VALUE_LANGUAGE = "LANGUAGE"
- Public Const USER_VALUE_USER_ID = "USER_ID"
- Public Const VALUE_PROFILE_ID = "PROFILE_ID"
- Public Const VALUE_PROFILE_TITLE = "PROFILE_TITLE"
-
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly Base As Modules.BaseModule
-
- Private ReadOnly ControlPanel As Panel
- Private ReadOnly IDBActive As Boolean
-
Private ReadOnly Modules As New List(Of IModule)
Public Sub New(pLogConfig As LogConfig)
@@ -67,192 +34,97 @@ Public Class Patterns2
New Modules.Clipboard(LogConfig),
New Modules.Controls(LogConfig),
New Modules.User(LogConfig),
- New Modules.FileInformation(LogConfig)
+ New Modules.FileInformation(LogConfig),
+ New Modules.IDB(LogConfig),
+ New Modules.Globix.GlobixAutomatic(LogConfig),
+ New Modules.Globix.GlobixManual(LogConfig)
})
End Sub
- Public Sub New(pLogConfig As LogConfig, pControlPanel As Panel, pIDBActive As Boolean)
- MyClass.New(pLogConfig)
- ControlPanel = pControlPanel
- IDBActive = pIDBActive
- End Sub
-
- Public Function ReplaceAllValues(pInput As String, pPanel As Panel, pUser As State.UserState, pFIleinfo As FileInfo) As String
- Dim oResult = pInput
-
- For Each oModule In Modules
- Try
- Dim oArgs = GetReplaceMapForModule(oModule, pPanel:=pPanel, pUser:=pUser, pFileInfo:=pFIleinfo)
- oResult = oModule.Replace(oResult, oArgs)
- Catch ex As Exception
- Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, oModule.GetType.Name)
- Logger.Error(ex)
- End Try
- Next
-
- Return oResult
- 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)()
- Dim oArgs = GetReplaceMapForModule(oModule, pUser:=pUser)
- oResult = DoReplaceForModule(oResult, oModule, oArgs)
-
- Return oResult
+ Try
+ Logger.Debug("Replacing User Values")
+ Dim oModule = New Modules.User(LogConfig)
+ Return oModule.Replace(pInput, pUser)
+ Catch ex As Exception
+ Logger.Warn("Error occurred while replacing User Values")
+ Logger.Error(ex)
+ Return pInput
+ End Try
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.FileInformation)()
- Dim oArgs = GetReplaceMapForModule(oModule, pFileInfo:=pFileInfo)
- oResult = DoReplaceForModule(oResult, oModule, oArgs)
-
- Return oResult
+ Try
+ Logger.Debug("Replacing File Values")
+ Dim oModule = New Modules.FileInformation(LogConfig)
+ Return oModule.Replace(pInput, pFileInfo)
+ Catch ex As Exception
+ Logger.Warn("Error occurred while replacing File Values")
+ Logger.Error(ex)
+ Return pInput
+ End Try
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)()
- Dim oArgs = GetReplaceMapForModule(oModule, pPanel:=pPanel)
- oResult = DoReplaceForModule(oResult, oModule, oArgs)
-
- Return oResult
+ Try
+ Logger.Debug("Replacing Control Values")
+ Dim oModule = New Modules.Controls(LogConfig)
+ Return oModule.Replace(pInput, pPanel)
+ Catch ex As Exception
+ Logger.Warn("Error occurred while replacing Control Values")
+ Logger.Error(ex)
+ Return pInput
+ End Try
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)()
- Dim oArgs = GetReplaceMapForModule(oModule, pWMObject:=pWMObject)
- oResult = DoReplaceForModule(oResult, oModule, oArgs)
-
- Return oResult
+ Try
+ Logger.Debug("Replacing Windream Values")
+ Dim oModule = New Modules.Windream(LogConfig)
+ Return oModule.Replace(pInput, pWMObject)
+ Catch ex As Exception
+ Logger.Warn("Error occurred while replacing Windream Values")
+ Logger.Error(ex)
+ Return pInput
+ End Try
End Function
- Public Function ReplaceInternalValues(pInput As String) As String
+ Public Function ReplaceInternalValues(pInput As String, Optional pClipboardContents As String = "") As String
Logger.Debug("Replacing Internal Values")
Dim oResult = pInput
- Dim oInternalModule = GetModule(Of Modules.Internal)()
- Dim oInternalArgs = GetReplaceMapForModule(oInternalModule)
- oResult = DoReplaceForModule(oResult, oInternalModule, oInternalArgs)
+ Try
+ Dim oInternal = New Modules.Internal(LogConfig)
+ Dim oClipboard = New Modules.Clipboard(LogConfig)
- Dim oClipboardModule = GetModule(Of Modules.Clipboard)()
- Dim oClipboardArgs = GetReplaceMapForModule(oClipboardModule)
- oResult = DoReplaceForModule(oResult, oClipboardModule, oClipboardArgs)
+ oResult = oInternal.Replace(oResult)
+ oResult = oClipboard.Replace(oResult, pClipboardContents)
- Return oResult
+ Return oResult
+ Catch ex As Exception
+ Logger.Warn("Error occurred while replacing Internal Values")
+ Logger.Error(ex)
+ Return oResult
+ End Try
End Function
- Public Function ReplaceGlobixValues(pInput As String, pGlobixIndexes As Dictionary(Of String, List(Of String))) As String
+ Public Function ReplaceGlobixValues(pInput As String, pManualIndexes As Dictionary(Of String, List(Of String)), pAutomaticIndexes As Dictionary(Of String, List(Of String))) As String
Logger.Debug("Replacing Globix Values")
Dim oResult = pInput
- Dim oGlobixModule = GetModule(Of Modules.Globix)()
- Dim oGlobixArgs = GetReplaceMapForModule(oGlobixModule, pGlobixIndexes:=pGlobixIndexes)
- oResult = DoReplaceForModule(oResult, oGlobixModule, oGlobixArgs)
-
- Return oResult
- End Function
-
-
-
- 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
+ Dim oAutomatic = New Modules.Globix.GlobixAutomatic(LogConfig)
+ Dim oManual = New Modules.Globix.GlobixManual(LogConfig)
- Logger.Debug("Calling Replace for Input String [{0}]", pInput)
+ oResult = oAutomatic.Replace(oResult, pAutomaticIndexes)
+ oResult = oManual.Replace(oResult, pManualIndexes)
- pInput = pModule.Replace(pInput, pArgs)
+ Return oResult
Catch ex As Exception
- Logger.Warn("Placeholders for String [{0}] could not be replaced completely in Module [{1}]. Skipping.", pInput, pModule.GetType.Name)
+ Logger.Warn("Error occurred while replacing Globix Values")
Logger.Error(ex)
+ Return oResult
End Try
-
- Return pInput
- End Function
-
- Private Function GetModule(Of ModuleT)() As IModule
- Return Modules.
- Where(Function(m) TypeOf m Is ModuleT).
- SingleOrDefault()
- End Function
-
- Private Function GetReplaceMapForModule(pModule As IModule,
- Optional pPanel As Panel = Nothing,
- Optional pUser As State.UserState = Nothing,
- Optional pWMObject As WMObject = Nothing,
- Optional pGlobixIndexes As Dictionary(Of String, List(Of String)) = Nothing,
- Optional pFileInfo As FileInfo = Nothing
- ) As Dictionary(Of String, Object)
- 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
- Logger.Error(ex)
- 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
- Logger.Error(ex)
- 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)
- oArgs.Add(Patterns.Modules.User.USER_VALUE_PRENAME, pUser.GivenName)
- oArgs.Add(Patterns.Modules.User.USER_VALUE_SHORTNAME, pUser.ShortName)
- oArgs.Add(Patterns.Modules.User.USER_VALUE_SURNAME, pUser.Surname)
- oArgs.Add(Patterns.Modules.User.USER_VALUE_USER_ID, pUser.UserId)
- oArgs.Add(Patterns.Modules.User.USER_VALUE_USER_NAME, pUser.UserName)
- Catch ex As Exception
- Logger.Error(ex)
- 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
- Logger.Error(ex)
- 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
- Logger.Error(ex)
- 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
- Logger.Error(ex)
- End Try
- End If
-
- Return oArgs
End Function
#Region "Helper Functions"
diff --git a/Service.EDMIService/BaseClass.vb b/Service.EDMIService/BaseClass.vb
index b574765e..6823af2d 100644
--- a/Service.EDMIService/BaseClass.vb
+++ b/Service.EDMIService/BaseClass.vb
@@ -1,12 +1,14 @@
Imports DigitalData.Modules.Logging
+Imports DigitalData.Services.EDMIService.IDB
Public Class BaseClass
Friend LogConfig As LogConfig
Friend Logger As Logger
Public Sub New(pLogConfig As LogConfig)
+ Dim oClassName = [GetType]().Name
LogConfig = pLogConfig
- Logger = pLogConfig.GetLogger()
+ Logger = pLogConfig.GetLogger(oClassName)
End Sub
Public Sub LogAndThrow(pMessage As String)
diff --git a/Service.EDMIService/GlobalState.vb b/Service.EDMIService/GlobalState.vb
index 8897fc96..fd1a32dc 100644
--- a/Service.EDMIService/GlobalState.vb
+++ b/Service.EDMIService/GlobalState.vb
@@ -39,10 +39,10 @@ Public Class GlobalState
.DataSource = oConnection.Server,
.InitialCatalog = oConnection.Database,
.UserID = oConnection.Username,
- .Password = MSSQLServer.DecryptConnectionString(oConnection.Password)
+ .Password = oConnection.Password
}
- Return oBuilder.ToString
+ Return MSSQLServer.DecryptConnectionString(oBuilder.ToString)
End Function
diff --git a/Service.EDMIService/IDB/Helpers.vb b/Service.EDMIService/IDB/Helpers.vb
index 5186b2a9..af19315a 100644
--- a/Service.EDMIService/IDB/Helpers.vb
+++ b/Service.EDMIService/IDB/Helpers.vb
@@ -3,18 +3,45 @@ Imports DigitalData.Modules.Language
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.EDMI.API.Client
Imports System.Data.SqlClient
+Imports System.IO
+Imports DigitalData.Modules.ZooFlow.State
+Imports DigitalData.Modules.Patterns
+Imports DigitalData.Services.EDMIService.Methods
Namespace IDB
Public Class Helpers
Inherits BaseClass
- Private Database As MSSQLServer
+ Private ReadOnly Patterns As Patterns2
+ Private ReadOnly Database As MSSQLServer
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer)
MyBase.New(pLogConfig)
+ Patterns = New Patterns2(pLogConfig)
Database = pMSSQLServer
End Sub
+ Public Function GetPlaceholderValue(pValue As String,
+ pFileInfo As FileInfo,
+ pUserState As UserState,
+ pUserAttributes As Dictionary(Of String, List(Of String)),
+ pAutoAttributes 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)
+ oResult = Patterns.ReplaceGlobixValues(oResult, pUserAttributes, pAutoAttributes)
+
+ Return oResult
+ End Function
+
+ Public Function UserAttributesToDictionary(pUserAttributes As List(Of UserAttributeValue)) As Dictionary(Of String, List(Of String))
+ Return pUserAttributes.ToDictionary(
+ Function(attr) attr.AttributeName,
+ Function(attr) attr.AttributeValues)
+ End Function
+
Public Function TestObjectIdExists(pObjectId As Long, Optional ByRef IsDeleted As Boolean = False, Optional ByRef IsActive As Boolean = False) As Boolean
Try
Dim oSQL As String = $"SELECT IDB_OBJ_ID, ACTIVE, DELETED FROM TBIDB_OBJECT WHERE IDB_OBJ_ID = {pObjectId}"
diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb
index 2b2574e3..423c5dce 100644
--- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb
+++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/ImportFileMethod.vb
@@ -3,6 +3,8 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Patterns
Imports DigitalData.Modules.Language
Imports DigitalData.Services.EDMIService.Methods.GetDatatableFromCache
+Imports System.IO
+Imports DigitalData.Modules.ZooFlow.State
Namespace Methods.GlobalIndexer.ImportFile
Public Class ImportFileMethod
@@ -10,7 +12,10 @@ Namespace Methods.GlobalIndexer.ImportFile
Private ReadOnly Patterns As Patterns2
Private ReadOnly GetDatatable As GetDatatableFromCacheMethod
+ Private ReadOnly Connection As SqlClient.SqlConnection
+ Private ReadOnly Transaction As SqlClient.SqlTransaction
+ Private User As UserState
Private Profile As DataRow
Private Const VIEW_PROFILE = "VWGI_DOCTYPE_IDB"
@@ -23,6 +28,8 @@ Namespace Methods.GlobalIndexer.ImportFile
Patterns = New Patterns2(pLogConfig)
GetDatatable = New GetDatatableFromCacheMethod(LogConfig, Database, GlobalState)
+ Connection = Database.GetConnection()
+ Transaction = Connection.BeginTransaction()
End Sub
'''
@@ -35,6 +42,8 @@ Namespace Methods.GlobalIndexer.ImportFile
'''
Public Function Run(pData As ImportFileRequest)
Try
+ User = pData.User
+
' TODO: Add missing user properties in UserState from TBDD_USER
'pData.User = ResolveUserFromUserName(pData.User.UserName)
@@ -43,17 +52,16 @@ Namespace Methods.GlobalIndexer.ImportFile
Dim oPostProcessingSteps As DataTable = LoadPostProcessingSteps(oManualIndexes)
LoadProfile(pData.ProfileId)
-
- Dim oFinalAttributes = pData.AttributeValues
- Dim oFileName As String = GetFilenameByNameconvention(pData.File.FileName, Profile.Item("NAMENKONVENTION"))
+ Dim oUserAttributes = pData.AttributeValues
+ Dim oAutoAttributes As List(Of UserAttributeValue) = Nothing
' Apply post processing
Dim oPostProcessing = New Steps.PostProcessing(LogConfig, oPostProcessingSteps)
- oFinalAttributes = oPostProcessing.ApplyManualPostprocessing(oFinalAttributes)
+ oUserAttributes = oPostProcessing.ApplyManualPostprocessing(oUserAttributes)
' Apply automatic attributes
Dim oAutomaticIndexing = New Steps.AutomaticIndexing(LogConfig, Database, oAutomaticIndexes, GlobalState)
- oFinalAttributes = oAutomaticIndexing.ApplyAutomaticeAttributes(oFinalAttributes, pData.File.FileInfoRaw, pData.User)
+ oAutoAttributes = oAutomaticIndexing.ApplyAutomaticeAttributes(oUserAttributes, pData.File.FileInfoRaw, User)
' Import the file
Dim oNewFile As New NewFileMethod(LogConfig, Database, GlobalState)
@@ -62,29 +70,87 @@ Namespace Methods.GlobalIndexer.ImportFile
.BusinessEntity = pData.BusinessEntity,
.KindType = pData.KindType,
.StoreName = pData.StoreName,
- .User = pData.User
+ .User = User
})
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)
End If
+ Logger.Info("Generating display filename for file [{0}]", pData.File.FileName)
+
+ Dim oNameconvention As String = Profile.ItemEx(Of String)("NAMENKONVENTION")
+ Dim oDisplayFilename = GetFilenameByNameconvention(pData.File.FileInfoRaw, oNameconvention, User, oUserAttributes, oAutoAttributes)
+
+ Logger.Info("Collecting Attributes for ObjectId [{0}]", oResponse.ObjectId)
+
+ Dim oFinalAttributes As New Dictionary(Of String, List(Of String)) From {
+ {"DisplayFileName", New List(Of String) From {oDisplayFilename}}
+ }
+ oFinalAttributes = oFinalAttributes.
+ Concat(Helpers.UserAttributesToDictionary(oUserAttributes)).
+ Concat(Helpers.UserAttributesToDictionary(oAutoAttributes)).
+ ToDictionary(Function(kv) kv.Key, Function(kv) kv.Value)
+
+ Logger.Info("Writing [{0}] Attributes for ObjectId [{0}] ", oResponse.ObjectId)
+ WriteAttributeValues(oResponse.ObjectId, oFinalAttributes)
+
+ ' Finally, commit the transaction
+ Transaction?.Commit()
+
+ Return New ImportFileResponse(oResponse.ObjectId)
+
Catch ex As Exception
+ Logger.Warn("Error occurred while importing file!")
+ Logger.Error(ex)
+
+ Logger.Info("Rolling back transaction.")
+ Transaction?.Rollback()
+
Return New ImportFileResponse(ex)
End Try
End Function
+ Private Function GetFilenameByNameconvention(pFileInfo As FileInfo, pNameconvention As String, pUser As UserState, pAttributes As List(Of UserAttributeValue), pAutoAttributes As List(Of UserAttributeValue)) As String
+ Dim oAttributeDict = Helpers.UserAttributesToDictionary(pAttributes)
+ Dim oAutoAttributeDict = Helpers.UserAttributesToDictionary(pAutoAttributes)
+ If pNameconvention Is Nothing OrElse pNameconvention = String.Empty Then
+ Logger.Warn("Nameconvention for File [{0}] was empty. Returning original filename.", pFileInfo.Name)
+ Return pFileInfo.Name
+ End If
-
- Private Function GetFilenameByNameconvention(pFileName As String, pNameconvention As String) As String
- Return pFileName
+ Dim oFileName As String = Helpers.GetPlaceholderValue(pNameconvention, pFileInfo, pUser, oAttributeDict, oAutoAttributeDict)
+ Return oFileName & pFileInfo.Extension
End Function
+ Private Sub WriteAttributeValues(pObjectId As Long, pAttributes As Dictionary(Of String, List(Of String)))
+ For Each oAttribute As KeyValuePair(Of String, List(Of String)) In pAttributes
+ Try
+ ' TODO: This works only for simple attributes for now!!!
+ Dim oValue = oAttribute.Value.FirstOrDefault()
+
+ ' Dont write empty attributes
+ If oValue Is Nothing Then
+ Continue For
+ End If
+
+ ' Now make the call to the database
+ Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, pObjectId, oAttribute.Key, oValue, User.Language, User.UserName)
+ If oSuccess Then
+ Logger.Info("Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value)
+ Else
+ Logger.Warn("Attribute value could not be written")
+ End If
+ Catch ex As Exception
+ LogAndThrow(ex, $"Attribute [{oAttribute.Key}] could not be written!")
+ End Try
+ Next
+ End Sub
+
'''
''' Load Profiles for this Import
'''
@@ -142,7 +208,7 @@ Namespace Methods.GlobalIndexer.ImportFile
oIndexes.Add(oAutomaticIndex)
Next
- Logger.Info("[{0}] automatic indexes loaded.", oIndexes)
+ Logger.Info("Automatic indexes loaded: [{0}]", oIndexes.Count)
Return oIndexes
Catch ex As Exception
@@ -186,6 +252,8 @@ Namespace Methods.GlobalIndexer.ImportFile
oIndexes.Add(oManualIndex)
Next
+ Logger.Info("Manual indexes loaded: [{0}]", oIndexes.Count)
+
Return oIndexes
Catch ex As Exception
diff --git a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb
index 2753617a..2143a26a 100644
--- a/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb
+++ b/Service.EDMIService/Methods/GlobalIndexer/ImportFile/Steps/AutomaticIndexing.vb
@@ -3,7 +3,7 @@ Imports DigitalData.Modules.Database
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Patterns
Imports DigitalData.Modules.ZooFlow.State
-Imports DigitalData.Services.EDMIService.GlobalState
+Imports DigitalData.Services.EDMIService.IDB
Namespace Methods.GlobalIndexer.ImportFile.Steps
Public Class AutomaticIndexing
@@ -12,6 +12,7 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
Private ReadOnly GlobalState As GlobalState
Private ReadOnly AutomaticIndexes As List(Of AutomaticIndex)
Private ReadOnly Patterns As Patterns2
+ Private ReadOnly Helpers As Helpers
Private ReadOnly Database As MSSQLServer
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pAutomaticIndexes As List(Of AutomaticIndex), pGlobalState As GlobalState)
@@ -20,41 +21,49 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
GlobalState = pGlobalState
AutomaticIndexes = pAutomaticIndexes
Patterns = New Patterns2(pLogConfig)
+ Helpers = New Helpers(pLogConfig, pDatabase)
Logger.Info("Starting Automatic Indexing")
End Sub
+ '''
+ ''' Generates a new list of Auto Attributes from the Auto Index configuration and External Data (like User, FileInfo and UserAttributes)
+ '''
+ ''' A new list of Automatic Attributes. This list may be empty.
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
+ Return New List(Of UserAttributeValue)
End If
Logger.Info("Processing [{0}] automatic indexes", AutomaticIndexes.Count)
- Dim oAttributes As List(Of UserAttributeValue) = pUserAttributes
+ Dim oUserAttributes As List(Of UserAttributeValue) = pUserAttributes
+ Dim oAutoAttributes As New List(Of UserAttributeValue)
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)
+ Dim oAttribute = ApplyAutomaticIndex(oAutomaticIndex, pFileInfo, pUserState, oUserAttributes, oAutoAttributes)
If oAttribute IsNot Nothing Then
- Logger.Info("Adding Attribute [{0}]", oAttribute)
- oAttributes.Add(oAttribute)
+ Logger.Debug("Adding Attribute [{0}]", oAttribute)
+ oAutoAttributes.Add(oAttribute)
End If
Next
- Return oAttributes
+ Return oAutoAttributes
End Function
-
- Private Function ApplyAutomaticIndex(pAutomaticIndex As AutomaticIndex, pFileInfo As FileInfo, pUserState As UserState, pAttributes As List(Of UserAttributeValue)) As UserAttributeValue
+ Private Function ApplyAutomaticIndex(pAutomaticIndex As AutomaticIndex,
+ pFileInfo As FileInfo,
+ pUserState As UserState,
+ pAttributes As List(Of UserAttributeValue),
+ pAutoAttributes As List(Of UserAttributeValue)) As UserAttributeValue
Try
- Dim oAttributeDict = pAttributes.ToDictionary(
- Function(attr) attr.AttributeName,
- Function(attr) attr.AttributeValues)
+ Dim oAttributeDict = Helpers.UserAttributesToDictionary(pAttributes)
+ Dim oAutoAttributeDict = Helpers.UserAttributesToDictionary(pAutoAttributes)
Logger.Info("Applying Automatic Index [{0}]", pAutomaticIndex.Name)
@@ -64,7 +73,8 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
' 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)
+ Dim oResult As String = Helpers.GetPlaceholderValue(
+ pAutomaticIndex.Value, pFileInfo, pUserState, oAttributeDict, oAutoAttributeDict)
Return New UserAttributeValue With {
.AttributeValues = New List(Of String) From {oResult},
@@ -77,9 +87,12 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
Dim oConnectionString As String = GlobalState.GetConnectionString(pAutomaticIndex.SQLConnectionId)
Dim oFinalSQLCommand = pAutomaticIndex.SQLCommand
+ ' TODO: Dont show the unmasked conn string
+ Logger.Debug("SQL Connection String is: [{0}]", oConnectionString)
Logger.Debug("SQL Command is: [{0}]", oFinalSQLCommand)
- oFinalSQLCommand = GetPlaceholderValue(oFinalSQLCommand, pFileInfo, pUserState, oAttributeDict)
+ oFinalSQLCommand = Helpers.GetPlaceholderValue(
+ oFinalSQLCommand, pFileInfo, pUserState, oAttributeDict, oAutoAttributeDict)
' Now we have a SQL command which only contains vector placeholders
' Next, we execute the command to get our result
@@ -106,17 +119,7 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
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)
- oResult = Patterns.ReplaceGlobixValues(oResult, pAttributes)
-
- Return oResult
- End Function
End Class
End Namespace
\ No newline at end of file
diff --git a/Service.EDMIService/Methods/NewFile/NewFileMethod.vb b/Service.EDMIService/Methods/NewFile/NewFileMethod.vb
index 00324f53..3d21fae3 100644
--- a/Service.EDMIService/Methods/NewFile/NewFileMethod.vb
+++ b/Service.EDMIService/Methods/NewFile/NewFileMethod.vb
@@ -127,13 +127,13 @@ Public Class NewFileMethod
'TODO: File dates in try catch
- Dim oDefaultAttributes As New Dictionary(Of String, Object) From {
+ Dim oSystemAttributes As New Dictionary(Of String, Object) From {
{"OriginFileName", pData.File.FileName},
{"OriginCreationDatetime", pData.File.FileCreatedAt},
{"OriginChangedDatetime", pData.File.FileChangedAt}
}
- For Each oAttribute As KeyValuePair(Of String, Object) In oDefaultAttributes
+ For Each oAttribute As KeyValuePair(Of String, Object) In oSystemAttributes
Try
' Dont write empty attributes
If oAttribute.Value Is Nothing Then
@@ -142,9 +142,9 @@ Public Class NewFileMethod
Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, oObjectId, oAttribute.Key, oAttribute.Value, pData.User.Language, pData.User.UserName)
If oSuccess Then
- Logger.Debug("Default Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value)
+ Logger.Debug("System Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value)
Else
- Logger.Warn("Default attribute value could not be written")
+ Logger.Warn("System attribute value could not be written")
End If
Catch ex As Exception
LogAndThrow(ex, $"System attribute [{oAttribute.Key}] could not be written!")
@@ -158,7 +158,7 @@ Public Class NewFileMethod
Return New NewFile.NewFileResponse(oObjectId)
Catch ex As Exception
- Logger.Warn("Error occurred while importing file!")
+ Logger.Warn("Error occurred while creating file!")
Logger.Error(ex)
Logger.Info("Cleaning up files.")
diff --git a/Service.EDMIService/Scheduler/DatatableJob.vb b/Service.EDMIService/Scheduler/DatatableJob.vb
index b0c01c96..8614a9dc 100644
--- a/Service.EDMIService/Scheduler/DatatableJob.vb
+++ b/Service.EDMIService/Scheduler/DatatableJob.vb
@@ -18,7 +18,7 @@ Public Class DatatableJob
Dim oLogConfig As LogConfig = oJobData.Item("LogConfig")
Dim oCronJobId As Integer = oJobData.Item("CronJobId")
Dim oCronJobTitle As String = oJobData.Item("CronJobTitle")
- Dim oLogger As Logger = oLogConfig.GetLoggerFor("Scheduler")
+ Dim oLogger As Logger = oLogConfig.GetLogger()
Dim oResult As New JobResult()
diff --git a/Service.EDMIService/Scheduler/JobListener.vb b/Service.EDMIService/Scheduler/JobListener.vb
index e982a6e2..9fabc4bf 100644
--- a/Service.EDMIService/Scheduler/JobListener.vb
+++ b/Service.EDMIService/Scheduler/JobListener.vb
@@ -21,7 +21,7 @@ Public Class JobListener
MyBase.New()
_LogConfig = LogConfig
- _Logger = LogConfig.GetLoggerFor("Scheduler")
+ _Logger = LogConfig.GetLogger()
_MSSQL = MSSQL
Dataset = ResultDataSet
End Sub
diff --git a/Service.EDMIService/WindowsService.vb b/Service.EDMIService/WindowsService.vb
index 4f1c73e2..c2d4b424 100644
--- a/Service.EDMIService/WindowsService.vb
+++ b/Service.EDMIService/WindowsService.vb
@@ -10,22 +10,21 @@ Imports System.ServiceModel.Channels
Public Class WindowsService
Inherits ServiceBase
- Private _ServiceHost As ServiceHost(Of EDMIService)
- Private _LogConfig As LogConfig
- Private _LogConfigScheduler As LogConfig
- Private _Logger As Logger
+ Private ServiceHost As ServiceHost(Of EDMIService)
+ Private LogConfig As LogConfig
+ Private LogConfigScheduler As LogConfig
+ Private Logger As Logger
- Private _Firebird As Firebird
- Private _MSSQL_ECM As MSSQLServer
- Private _MSSQL_IDB As MSSQLServer
+ Private Firebird As Firebird
+ Private MSSQL_ECM As MSSQLServer
+ Private MSSQL_IDB As MSSQLServer
- Private _ConfigManager As ConfigManager(Of Config)
- Private _Config As Config
- Private _Path As EDMI.File.Path
- Private _Archive As EDMI.File.Archive
- Private _Filesystem As Filesystem.File
- Private _Global As GlobalState
- Private _Scheduler As Scheduler
+ Private ConfigManager As ConfigManager(Of Config)
+ Private Config As Config
+ Private Archive As EDMI.File.Archive
+ Private Filesystem As Filesystem.File
+ Private GlobalState As GlobalState
+ Private Scheduler As Scheduler
Public Sub New()
ServiceName = SERVICE_NAME
@@ -39,123 +38,127 @@ Public Class WindowsService
Try
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()
+ 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)
- _Logger.Info("ServiceDirectory: {0}", oServicePath)
+ Logger.Info("Service {0} is starting...", SERVICE_DISPLAY_NAME)
+ Logger.Info("ServiceDirectory: {0}", oServicePath)
- _Logger.Info("Loading Config")
- _ConfigManager = New ConfigManager(Of Config)(_LogConfig, oServicePath)
- _Config = _ConfigManager.Config
- _LogConfig.Debug = _ConfigManager.Config.Debug
+ Logger.Info("Loading Config")
+ ConfigManager = New ConfigManager(Of Config)(LogConfig, oServicePath)
+ Config = ConfigManager.Config
+ LogConfig.Debug = ConfigManager.Config.Debug
Dim oTimer As New Timers.Timer(60000)
- AddHandler oTimer.Elapsed, Sub()
- _Logger.Debug("Reloading config..")
- _ConfigManager.Reload()
- _Config = _ConfigManager.Config
- _LogConfig.Debug = _ConfigManager.Config.Debug
-
- 'UpdateTraceLogging()
- End Sub
+ AddHandler oTimer.Elapsed, AddressOf ReloadTimer_Tick
oTimer.Start()
- _Logger.Debug("Connecting to Databases")
+ Logger.Debug("Connecting to Databases")
- _Firebird = StartFirebird()
- _MSSQL_ECM = StartMSSQL_ECM()
- _MSSQL_IDB = StartMSSQL_IDB()
+ Firebird = StartFirebird()
+ MSSQL_ECM = GetMSSQL_ECM(LogConfig)
+ MSSQL_IDB = GetMSSQL_IDB(LogConfig)
- _Logger.Debug("Initializing EDMI Functions")
+ Logger.Debug("Initializing EDMI Functions")
- _Archive = New EDMI.File.Archive(_LogConfig)
- _Filesystem = New Filesystem.File(_LogConfig)
- _Global = New GlobalState(_LogConfig, _MSSQL_IDB, _MSSQL_ECM)
- _Scheduler = New Scheduler(_LogConfigScheduler, _MSSQL_ECM, _Global.TableStore)
+ Archive = New EDMI.File.Archive(LogConfig)
+ Filesystem = New Filesystem.File(LogConfig)
+ GlobalState = New GlobalState(LogConfig, MSSQL_IDB, MSSQL_ECM)
- _Logger.Debug("Loading Global Data")
- _Global.LoadObjectStores()
- _Global.LoadConnections()
+ Dim oMSSQLServer = GetMSSQL_ECM(LogConfigScheduler)
+ Scheduler = New Scheduler(LogConfigScheduler, oMSSQLServer, GlobalState.TableStore)
- _Logger.Debug("Starting Scheduler")
- _Scheduler.Start()
+ Logger.Debug("Loading Global Data")
+ GlobalState.LoadObjectStores()
+ GlobalState.LoadConnections()
- _Logger.Debug("Preparing WCF ServiceHost")
- EDMIService.MSSQL_ECM = _MSSQL_ECM
- EDMIService.MSSQL_IDB = _MSSQL_IDB
- EDMIService.Firebird = _Firebird
- EDMIService.LogConfig = _LogConfig
- EDMIService.AppConfig = _Config
- EDMIService.EDMIArchive = _Archive
- EDMIService.Filesystem = _Filesystem
- EDMIService.GlobalState = _Global
- EDMIService.Scheduler = _Scheduler
+ Logger.Debug("Starting Scheduler")
+ Scheduler.Start()
- _Logger.Debug("Starting WCF ServiceHost")
+ Logger.Debug("Preparing WCF ServiceHost")
+ EDMIService.MSSQL_ECM = MSSQL_ECM
+ EDMIService.MSSQL_IDB = MSSQL_IDB
+ EDMIService.Firebird = Firebird
+ EDMIService.LogConfig = LogConfig
+ EDMIService.AppConfig = Config
+ EDMIService.EDMIArchive = Archive
+ EDMIService.Filesystem = Filesystem
+ EDMIService.GlobalState = GlobalState
+ EDMIService.Scheduler = Scheduler
+
+ Logger.Debug("Starting WCF ServiceHost")
Dim oBaseAddresses() As Uri = {New Uri(SERVICE_BASE_ADDRESS)}
- _ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
- _ServiceHost.EnableMetadataExchange(False)
+ ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
+ ServiceHost.EnableMetadataExchange(False)
- _Logger.Debug("Listing Endpoints:")
- For Each oEndpoint In _ServiceHost.Description.Endpoints
- _Logger.Debug("Name: {0}", oEndpoint.Name)
- _Logger.Debug("Address: {0}", oEndpoint.Address.ToString)
- _Logger.Debug("Listen Uri: {0}", oEndpoint.ListenUri.AbsoluteUri)
- _Logger.Debug("Binding: {0}", oEndpoint.Binding.Name)
- _Logger.Debug("Contract: {0}", oEndpoint.Contract.Name)
+ Logger.Debug("Listing Endpoints:")
+ For Each oEndpoint In ServiceHost.Description.Endpoints
+ Logger.Debug("Name: {0}", oEndpoint.Name)
+ Logger.Debug("Address: {0}", oEndpoint.Address.ToString)
+ Logger.Debug("Listen Uri: {0}", oEndpoint.ListenUri.AbsoluteUri)
+ Logger.Debug("Binding: {0}", oEndpoint.Binding.Name)
+ Logger.Debug("Contract: {0}", oEndpoint.Contract.Name)
Next
- _ServiceHost.Open()
+ ServiceHost.Open()
- _Logger.Info("WCF ServiceHost started")
- _Logger.Info("Service {0} successfully started", SERVICE_DISPLAY_NAME)
+ Logger.Info("WCF ServiceHost started")
+ Logger.Info("Service {0} successfully started", SERVICE_DISPLAY_NAME)
Catch ex As Exception
- _Logger.Warn("Unexpected Error while starting the service: {0}", ex.Message)
- _Logger.Error(ex)
+ Logger.Warn("Unexpected Error while starting the service: {0}", ex.Message)
+ Logger.Error(ex)
GracefullyStop()
End Try
End Sub
- Private Function StartFirebird() As Firebird
- _Logger.Debug("Connecting to Firebird")
+ Private Sub ReloadTimer_Tick()
+ If ConfigManager.Reload() = False Then
+ Logger.Warn("Could not reload config, check the service and config file.")
+ End If
- If _Config.Firebird_Datasource = String.Empty Then
- _Logger.Info("Firebird database not configured. Skipping.")
+ Config = ConfigManager.Config
+ LogConfig.Debug = ConfigManager.Config.Debug
+ End Sub
+
+ Private Function StartFirebird() As Firebird
+ Logger.Debug("Connecting to Firebird")
+
+ If Config.Firebird_Datasource = String.Empty Then
+ Logger.Info("Firebird database not configured. Skipping.")
Return Nothing
End If
Try
Dim oFirebird = New Firebird(
- _LogConfig,
- _Config.Firebird_Datasource,
- _Config.Firebird_DatabaseName,
- _Config.Firebird_DatabaseUser,
- _Config.Firebird_DatabasePassword
+ LogConfig,
+ Config.Firebird_Datasource,
+ Config.Firebird_DatabaseName,
+ Config.Firebird_DatabaseUser,
+ Config.Firebird_DatabasePassword
)
- _Logger.Info("Database connection established.")
+ Logger.Info("Database connection established.")
Return oFirebird
Catch ex As Exception
- _Logger.Warn("StartFirebird: Could not connect to firebird database.")
- _Logger.Error(ex)
+ Logger.Warn("StartFirebird: Could not connect to firebird database.")
+ Logger.Error(ex)
Return Nothing
End Try
End Function
- Private Function StartMSSQL_ECM() As MSSQLServer
- _Logger.Debug("Connecting to ECM MSSQL")
- Dim oMSSQL = New MSSQLServer(_LogConfig, _Config.ConnectionString_ECM)
- _Logger.Info("Database connection to ECM Database established.")
+ Private Function GetMSSQL_ECM(pLogConfig As LogConfig) As MSSQLServer
+ Logger.Debug("Connecting to ECM MSSQL")
+ Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_ECM)
+ Logger.Info("Database connection to ECM Database established.")
Return oMSSQL
End Function
- Private Function StartMSSQL_IDB() As MSSQLServer
- _Logger.Debug("Connecting to IDB MSSQL")
- Dim oMSSQL = New MSSQLServer(_LogConfig, _Config.ConnectionString_IDB)
- _Logger.Info("Database connection to IDB Database established.")
+ Private Function GetMSSQL_IDB(pLogConfig As LogConfig) As MSSQLServer
+ Logger.Debug("Connecting to IDB MSSQL")
+ Dim oMSSQL = New MSSQLServer(pLogConfig, Config.ConnectionString_IDB)
+ Logger.Info("Database connection to IDB Database established.")
Return oMSSQL
End Function
@@ -164,13 +167,13 @@ Public Class WindowsService
End Sub
Private Sub GracefullyStop()
- _Logger.Info("Service {0} is stopping!", SERVICE_DISPLAY_NAME)
- If _ServiceHost IsNot Nothing Then
- _ServiceHost.Close()
- _ServiceHost = Nothing
+ Logger.Info("Service {0} is stopping!", SERVICE_DISPLAY_NAME)
+ If ServiceHost IsNot Nothing Then
+ ServiceHost.Close()
+ ServiceHost = Nothing
End If
- _Scheduler.Stop()
+ Scheduler.Stop()
End Sub
End Class