EDMIService: WIP

This commit is contained in:
Jonathan Jenne 2021-12-09 16:28:26 +01:00
parent a509842616
commit e6b3a53477
15 changed files with 147 additions and 108 deletions

View File

@ -136,8 +136,8 @@ Public Class ClassValidator
'End If
oAttributeValues.Add(New UserAttributeValue With {
.AttributeName = oIndexName,
.AttributeValues = WrapIndexValue(oTextBox.Text),
.Name = oIndexName,
.Values = WrapIndexValue(oTextBox.Text),
.ControlName = oTextBox.Name
})
End If
@ -152,8 +152,8 @@ Public Class ClassValidator
End If
oAttributeValues.Add(New UserAttributeValue With {
.AttributeName = oIndexName,
.AttributeValues = WrapIndexValue(oValues),
.Name = oIndexName,
.Values = WrapIndexValue(oValues),
.ControlName = oLookup.Name
})
@ -166,8 +166,8 @@ Public Class ClassValidator
End If
oAttributeValues.Add(New UserAttributeValue With {
.AttributeName = oIndexName,
.AttributeValues = WrapIndexValue(cmbSingle.Text),
.Name = oIndexName,
.Values = WrapIndexValue(cmbSingle.Text),
.ControlName = cmbSingle.Name
})
@ -179,8 +179,8 @@ Public Class ClassValidator
End If
oAttributeValues.Add(New UserAttributeValue With {
.AttributeName = oIndexName,
.AttributeValues = WrapIndexValue(cmb.Text),
.Name = oIndexName,
.Values = WrapIndexValue(cmb.Text),
.ControlName = cmb.Name
})
End If
@ -191,8 +191,8 @@ Public Class ClassValidator
Dim oIndexName As String = GetIndexName(dtp, "dtp")
oAttributeValues.Add(New UserAttributeValue With {
.AttributeName = oIndexName,
.AttributeValues = WrapIndexValue(dtp.EditValue.ToString),
.Name = oIndexName,
.Values = WrapIndexValue(dtp.EditValue.ToString),
.ControlName = dtp.Name
})
End If
@ -204,8 +204,8 @@ Public Class ClassValidator
oAttributeValues.Add(New UserAttributeValue With {
.AttributeName = oIndexName,
.AttributeValues = WrapIndexValue(chk.Checked.ToString),
.Name = oIndexName,
.Values = WrapIndexValue(chk.Checked.ToString),
.ControlName = chk.Name
})
End If

View File

@ -41,8 +41,8 @@ Public Class frmtest
txtProfileId.Text,
New List(Of EDMIServiceReference.UserAttributeValue) From {
New EDMIServiceReference.UserAttributeValue With {
.AttributeName = "Attribut String1",
.AttributeValues = New List(Of String) From {"SchreiberM"}.ToArray
.Name = "Attribut String1",
.Values = New List(Of String) From {"SchreiberM"}.ToArray
}
},
"WORK",

View File

@ -22,10 +22,10 @@
<xs:element name="ArrayOfUserAttributeValue" nillable="true" type="tns:ArrayOfUserAttributeValue" />
<xs:complexType name="UserAttributeValue">
<xs:sequence>
<xs:element minOccurs="0" name="AttributeId" type="xs:int" />
<xs:element minOccurs="0" name="AttributeName" nillable="true" type="xs:string" />
<xs:element xmlns:q2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="AttributeValues" nillable="true" type="q2:ArrayOfstring" />
<xs:element minOccurs="0" name="ControlName" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="Id" type="xs:int" />
<xs:element minOccurs="0" name="Name" nillable="true" type="xs:string" />
<xs:element xmlns:q2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="Values" nillable="true" type="q2:ArrayOfstring" />
</xs:sequence>
</xs:complexType>
<xs:element name="UserAttributeValue" nillable="true" type="tns:UserAttributeValue" />

View File

@ -635,18 +635,18 @@ Namespace EDMIServiceReference
<System.NonSerializedAttribute()> _
Private extensionDataField As System.Runtime.Serialization.ExtensionDataObject
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private AttributeIdField As Integer
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private AttributeNameField As String
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private AttributeValuesField() As String
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private ControlNameField As String
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private IdField As Integer
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private NameField As String
<System.Runtime.Serialization.OptionalFieldAttribute()> _
Private ValuesField() As String
<Global.System.ComponentModel.BrowsableAttribute(false)> _
Public Property ExtensionData() As System.Runtime.Serialization.ExtensionDataObject Implements System.Runtime.Serialization.IExtensibleDataObject.ExtensionData
Get
@ -657,45 +657,6 @@ Namespace EDMIServiceReference
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property AttributeId() As Integer
Get
Return Me.AttributeIdField
End Get
Set
If (Me.AttributeIdField.Equals(value) <> true) Then
Me.AttributeIdField = value
Me.RaisePropertyChanged("AttributeId")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property AttributeName() As String
Get
Return Me.AttributeNameField
End Get
Set
If (Object.ReferenceEquals(Me.AttributeNameField, value) <> true) Then
Me.AttributeNameField = value
Me.RaisePropertyChanged("AttributeName")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property AttributeValues() As String()
Get
Return Me.AttributeValuesField
End Get
Set
If (Object.ReferenceEquals(Me.AttributeValuesField, value) <> true) Then
Me.AttributeValuesField = value
Me.RaisePropertyChanged("AttributeValues")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property ControlName() As String
Get
@ -709,6 +670,45 @@ Namespace EDMIServiceReference
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property Id() As Integer
Get
Return Me.IdField
End Get
Set
If (Me.IdField.Equals(value) <> true) Then
Me.IdField = value
Me.RaisePropertyChanged("Id")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property Name() As String
Get
Return Me.NameField
End Get
Set
If (Object.ReferenceEquals(Me.NameField, value) <> true) Then
Me.NameField = value
Me.RaisePropertyChanged("Name")
End If
End Set
End Property
<System.Runtime.Serialization.DataMemberAttribute()> _
Public Property Values() As String()
Get
Return Me.ValuesField
End Get
Set
If (Object.ReferenceEquals(Me.ValuesField, value) <> true) Then
Me.ValuesField = value
Me.RaisePropertyChanged("Values")
End If
End Set
End Property
Public Event PropertyChanged As System.ComponentModel.PropertyChangedEventHandler Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged
Protected Sub RaisePropertyChanged(ByVal propertyName As String)
@ -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

View File

@ -4,7 +4,7 @@ Imports System.Text.RegularExpressions
Namespace Modules
Public Class BaseModule
Friend ReadOnly Logger As Logger
Private ReadOnly MyRegex As Regex = New Regex("{#(\w+)#([\:\.\w\s_-]+)}+")
Private ReadOnly MyRegex As Regex = New Regex("{#(\w+)#([\:\.\w\s_/-]+)}+")
Private ReadOnly SqlPhrases As New List(Of String) From {
"SELECT ", "UPDATE ", "DELETE ", "EXEC "
}

View File

@ -12,9 +12,12 @@ Namespace Modules
Public Const INT_VALUE_MACHINE = "MACHINE"
Public Const INT_VALUE_DOMAIN = "DOMAIN"
Public Const INT_VALUE_DATE = "DATE"
Public Const INT_VALUE_DATE_YYYY = "DATE_YYYY"
Public Const INT_VALUE_DATE_MM = "DATE_MM"
Public Const INT_VALUE_DATE_DD = "DATE_DD"
Public Const INT_VALUE_DATE_YYYY = "YYYY"
Public Const INT_VALUE_DATE_MM = "MM"
Public Const INT_VALUE_DATE_DD = "DD"
Public Const INT_VALUE_DATE_YYYY_MM_DD = "YYYY/MM/DD"
Public Const INT_VALUE_DATE_YYYY_MM_DD_2 = "YYYY_MM_DD"
Public Property PatternIdentifier As String = "INT" Implements IModule.PatternIdentifier
Public Property IsComplex As Boolean = False Implements IModule.IsComplex
@ -28,30 +31,55 @@ Namespace Modules
Dim oCounter = 0
Dim oNow As Date = Now
'TODO: Make date patterns dynamic
Logger.Trace("Replacing Internal Patterns")
' Replace CurrentDate(s)
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE)
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy-MM-dd"))
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY_MM_DD)
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_YYYY_MM_DD)
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy/MM/dd"))
IncrementCounterOrThrow(oCounter)
End While
Logger.Trace("Replace Counter: [{0}]", oCounter)
' Replace CurrentDate(s)
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY_MM_DD_2)
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_YYYY_MM_DD_2)
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy_MM_dd"))
IncrementCounterOrThrow(oCounter)
End While
Logger.Trace("Replace Counter: [{0}]", oCounter)
' Replace Year(s)
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_YYYY)
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_YYYY)
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("yyyy"))
IncrementCounterOrThrow(oCounter)
End While
Logger.Trace("Replace Counter: [{0}]", oCounter)
' Replace Month(s)
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_MM)
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_MM)
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("MM"))
IncrementCounterOrThrow(oCounter)
End While
Logger.Trace("Replace Counter: [{0}]", oCounter)
' Replace Day(s)
While ContainsPatternAndValue(oResult, PatternIdentifier, INT_VALUE_DATE_DD)
Logger.Trace("Replacing Pattern [{0}]", INT_VALUE_DATE_DD)
oResult = ReplacePattern(oResult, PatternIdentifier, oNow.ToString("dd"))
IncrementCounterOrThrow(oCounter)
End While
Logger.Trace("Replace Counter: [{0}]", oCounter)
Return oResult
End Function
End Class

View File

@ -6,7 +6,6 @@ Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.Language
Imports DigitalData.Modules
Imports DigitalData.Modules.EDMI
Imports DigitalData.Modules.EDMI.File
Imports DigitalData.Modules.EDMI.API.Rights
Imports DigitalData.Services.EDMIService.Messages
Imports DigitalData.Services.EDMIService.Exceptions

View File

@ -42,8 +42,8 @@ Namespace IDB
End If
Return pUserAttributes.ToDictionary(
Function(attr) attr.AttributeName,
Function(attr) attr.AttributeValues)
Function(attr) attr.Name,
Function(attr) attr.Values)
End Function
Public Function TestObjectIdExists(pObjectId As Long, Optional ByRef IsDeleted As Boolean = False, Optional ByRef IsActive As Boolean = False) As Boolean

View File

@ -8,13 +8,13 @@
''' Attribute values supplied by the user
''' </summary>
Public Class UserAttributeValue
Public Property AttributeName As String
Public Property AttributeValues As List(Of String)
Public Property AttributeId As Integer
Public Property Id As Integer
Public Property Name As String
Public Property Values As List(Of String)
Public Property ControlName As String
Public Overrides Function ToString() As String
Return AttributeName
Return Name
End Function
End Class

View File

@ -112,10 +112,10 @@ Namespace Methods.GlobalIndexer.ImportFile
End Try
End Function
Private Function GetVirtualPath(pFileInfo As FileInfo, pPathConvention As String, pUser As UserState, pAttributes As List(Of UserAttributeValue), pAutoAttributes As List(Of UserAttributeValue))
Private Function GetVirtualPath(pFileInfo As FileInfo, pPathConvention As String, pUser As UserState, pUserAttributes As List(Of UserAttributeValue), pAutoAttributes As List(Of UserAttributeValue))
Logger.Info("Generating virtual path for file [{0}]", pFileInfo.Name)
Dim oAttributeDict = Helpers.UserAttributesToDictionary(pAttributes)
Dim oUserAttributeDict = Helpers.UserAttributesToDictionary(pUserAttributes)
Dim oAutoAttributeDict = Helpers.UserAttributesToDictionary(pAutoAttributes)
If pPathConvention Is Nothing OrElse pPathConvention = String.Empty Then
@ -124,14 +124,15 @@ Namespace Methods.GlobalIndexer.ImportFile
End If
Dim oVirtualPath As String = Helpers.GetPlaceholderValue(pPathConvention, pFileInfo, pUser, oAttributeDict, oAutoAttributeDict)
Return oVirtualPath
Dim oDynamicPath As String = Helpers.GetPlaceholderValue(pPathConvention, pFileInfo, pUser, oUserAttributeDict, oAutoAttributeDict)
Logger.Info("Virtual Path for file [{0}] is [{1}]", pFileInfo.Name, oDynamicPath)
Return oDynamicPath
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
Private Function GetFilenameByNameconvention(pFileInfo As FileInfo, pNameconvention As String, pUser As UserState, pUserAttributes As List(Of UserAttributeValue), pAutoAttributes As List(Of UserAttributeValue)) As String
Logger.Info("Generating display filename for file [{0}]", pFileInfo.Name)
Dim oAttributeDict = Helpers.UserAttributesToDictionary(pAttributes)
Dim oUserAttributeDict = Helpers.UserAttributesToDictionary(pUserAttributes)
Dim oAutoAttributeDict = Helpers.UserAttributesToDictionary(pAutoAttributes)
If pNameconvention Is Nothing OrElse pNameconvention = String.Empty Then
@ -140,7 +141,8 @@ Namespace Methods.GlobalIndexer.ImportFile
End If
Dim oFileName As String = Helpers.GetPlaceholderValue(pNameconvention, pFileInfo, pUser, oAttributeDict, oAutoAttributeDict)
Dim oFileName As String = Helpers.GetPlaceholderValue(pNameconvention, pFileInfo, pUser, oUserAttributeDict, oAutoAttributeDict)
Return oFileName & pFileInfo.Extension
End Function
@ -158,7 +160,7 @@ Namespace Methods.GlobalIndexer.ImportFile
' 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)
Logger.Info("Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value.First())
Else
Logger.Warn("Attribute value could not be written")
End If

View File

@ -77,9 +77,9 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
pAutomaticIndex.Value, pFileInfo, pUserState, oAttributeDict, oAutoAttributeDict)
Return New UserAttributeValue With {
.AttributeValues = New List(Of String) From {oResult},
.AttributeName = pAutomaticIndex.Name,
.AttributeId = pAutomaticIndex.Id
.Values = New List(Of String) From {oResult},
.Name = pAutomaticIndex.Name,
.Id = pAutomaticIndex.Id
}
End If
@ -107,9 +107,9 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
' TODO: Return multiple values
Return New UserAttributeValue With {
.AttributeValues = New List(Of String) From {oValue},
.AttributeName = pAutomaticIndex.Name,
.AttributeId = pAutomaticIndex.Id
.Values = New List(Of String) From {oValue},
.Name = pAutomaticIndex.Name,
.Id = pAutomaticIndex.Id
}
Catch ex As Exception
Logger.Warn("Automatic Indexing for index failed.")

View File

@ -32,21 +32,21 @@ Namespace Methods.GlobalIndexer.ImportFile.Steps
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")).
Where(Function(attr) attr.Id = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")).
FirstOrDefault()
Dim oIndexPosition = pManualAttributes.IndexOf(oIndex)
Logger.Info("Postprocessing Index [{0}]", oIndex.AttributeName)
Logger.Info("Postprocessing Index [{0}]", oIndex.Name)
Dim oValues = GetPostprocessingValue(oIndex.AttributeValues, oProcessingRow)
Dim oValues = GetPostprocessingValue(oIndex.Values, oProcessingRow)
Logger.Info("New Value for Index [{0}] is [{1}]", oIndex.AttributeName, String.Join(",", oValues))
Logger.Info("New Value for Index [{0}] is [{1}]", oIndex.Name, String.Join(",", oValues))
' Replace the old AttributeValue with the new one
oAttributes.Item(oIndexPosition) = New UserAttributeValue With {
.AttributeId = oIndexId,
.AttributeName = oIndex.AttributeName,
.AttributeValues = oValues,
.Id = oIndexId,
.Name = oIndex.Name,
.Values = oValues,
.ControlName = oIndex.ControlName
}
Next

View File

@ -23,7 +23,7 @@ Namespace Methods.GlobalIndexer
''' Load Profiles for this Import
''' </summary>
Public Function LoadProfile(pProfileId As Integer) As Profile
Logger.Debug("Start of Method [LoadAutomaticIndexes]")
Logger.Debug("Start of Method [LoadProfile]")
Try
Dim oProfile = GetDatatable.Run(
@ -44,12 +44,12 @@ Namespace Methods.GlobalIndexer
.NameConvention = oRow.ItemEx("NAMENKONVENTION", ""),
.ObjectStore = oRow.ItemEx("OBJECT_STORE", "Work"),
.ShortName = oRow.ItemEx("KURZNAME", ""),
.DynamicPath = oRow.ItemEx("DYNAMIC_PATH", "")
.DynamicPath = oRow.ItemEx("DYNAMIC_FOLDER", "")
}
Return oProfileObject
Catch ex As Exception
LogAndThrow(ex, "Error while automatic loading indexes!")
LogAndThrow(ex, "Error while automatic loading profile!")
Return Nothing
End Try
End Function

View File

@ -81,7 +81,7 @@ Public Class DatatableJob
oResultTable.TableRelationColumn = oParentColumn
End If
oLogger.Debug("Fetched Datatable [{0}]", oDatatableName)
oLogger.Info("Fetched Datatable [{0}]", oDatatableName)
oResult.Tables.Add(oResultTable)
Catch ex As Exception
oLogger.Warn("Execute: Error while saving Table: [{0}]", oDatatableName)

View File

@ -36,24 +36,35 @@ Public Class WindowsService
Protected Overrides Sub OnStart(ByVal args As String())
Try
' Init
Dim oServicePath As String = AppDomain.CurrentDomain.BaseDirectory
Dim oServiceVersion As String = My.Application.Info.Version.ToString()
' Initializing Logger
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)
' Log Initial
Logger.Info("Service [{0}] is starting...", SERVICE_DISPLAY_NAME)
Logger.Info("ServiceDirectory: [{0}]", oServicePath)
Logger.Info("Version: [{0}]", oServiceVersion)
' Initializing Config
Logger.Info("Loading Config")
ConfigManager = New ConfigManager(Of Config)(LogConfig, oServicePath)
Config = ConfigManager.Config
LogConfig.Debug = ConfigManager.Config.Debug
' Setup Reload-timer for config
Dim oTimer As New Timers.Timer(60000)
AddHandler oTimer.Elapsed, AddressOf ReloadTimer_Tick
oTimer.Start()
' Setting Debug Flag
Logger.Info("Setting DEBUG Flag to [{0}]", ConfigManager.Config.Debug)
LogConfig.Debug = ConfigManager.Config.Debug
LogConfigScheduler.Debug = ConfigManager.Config.Debug
Logger.Debug("Connecting to Databases")
Firebird = StartFirebird()
@ -61,7 +72,6 @@ Public Class WindowsService
MSSQL_IDB = GetMSSQL_IDB(LogConfig)
Logger.Debug("Initializing EDMI Functions")
Archive = New EDMI.File.Archive(LogConfig)
Filesystem = New Filesystem.File(LogConfig)
GlobalState = New GlobalState(LogConfig, MSSQL_IDB, MSSQL_ECM)