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

@@ -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)