08-12-2022
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports ECM.JobRunner.Common
|
||||
Imports ECM.JobRunner.Windows.Scheduler
|
||||
Imports DigitalData.Modules.Windream
|
||||
|
||||
@@ -17,13 +16,12 @@ Public Class State
|
||||
|
||||
Public ReadOnly Property JobTypes As New List(Of JobType)
|
||||
Public ReadOnly Property ObjectTypes As New List(Of ObjectType)
|
||||
|
||||
Public ReadOnly Property JobDefinitions As New List(Of JobDefinition)
|
||||
|
||||
Public ReadOnly Property ProfileDefintions As New ProfileDefinitions
|
||||
|
||||
Public Class ProfileDefinitions
|
||||
Public Property ImportProfiles As New List(Of ImportProfile)
|
||||
Public Property ImportProfileSteps As New List(Of ImportProfileStep)
|
||||
End Class
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pWindream As Windream)
|
||||
@@ -45,6 +43,7 @@ Public Class State
|
||||
_ObjectTypes = GetObjectTypes()
|
||||
|
||||
_JobDefinitions = GetJobDefinitions(_JobTypes)
|
||||
_ProfileDefintions.ImportProfileSteps = GetImportProfileSteps()
|
||||
_ProfileDefintions.ImportProfiles = GetImportProfiles()
|
||||
End Sub
|
||||
|
||||
@@ -89,7 +88,7 @@ Public Class State
|
||||
Try
|
||||
Logger.Info("Loading Job Types..")
|
||||
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_TYPE WHERE ACTIVE = 1"
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_TYPE"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
@@ -119,33 +118,113 @@ Public Class State
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetImportProfileSteps() As List(Of ImportProfileStep)
|
||||
Dim oSteps As New List(Of ImportProfileStep)
|
||||
|
||||
Try
|
||||
Logger.Info("Loading Import Profiles Steps..")
|
||||
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_FIW_STEP"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Database Error while loading Import Profile Steps!")
|
||||
Return oSteps
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] Import Profile Steps loaded!", oTable.Rows.Count)
|
||||
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTypeId = oRow.ItemEx("PROFILE_ID", 0)
|
||||
|
||||
Dim oScope As ImportProfileStep.StepScope
|
||||
Select Case oRow.ItemEx("SCOPE", "FILE")
|
||||
Case "FOLDER"
|
||||
oScope = ImportProfileStep.StepScope.FOLDER
|
||||
Case "FILE"
|
||||
oScope = ImportProfileStep.StepScope.FILE
|
||||
End Select
|
||||
|
||||
Dim oMethod As ImportProfileStep.StepMethod
|
||||
Select Case oRow.ItemEx("METHOD", "ALL")
|
||||
Case "SUBSTRING"
|
||||
oScope = ImportProfileStep.StepMethod.SUBSTRING
|
||||
|
||||
Case "SPLIT"
|
||||
oScope = ImportProfileStep.StepMethod.SPLIT
|
||||
|
||||
Case "REGEX"
|
||||
oScope = ImportProfileStep.StepMethod.REGEX
|
||||
|
||||
Case "STATIC"
|
||||
oScope = ImportProfileStep.StepMethod.VALUE
|
||||
|
||||
Case Else
|
||||
oScope = ImportProfileStep.StepMethod.ALL
|
||||
End Select
|
||||
|
||||
Dim oStep As New ImportProfileStep With {
|
||||
.Id = oRow.ItemEx("GUID", 0),
|
||||
.ProfileId = oRow.ItemEx("PROFILE_ID", 0),
|
||||
.IndexName = oRow.Item("IDX_NAME"),
|
||||
.Method = oMethod,
|
||||
.Argument1 = oRow.ItemEx("ARGUMENT1", ""),
|
||||
.Argument2 = oRow.ItemEx("ARGUMENT2", ""),
|
||||
.Argument3 = oRow.ItemEx("ARGUMENT3", ""),
|
||||
.Scope = oScope,
|
||||
.Active = oRow.ItemEx("ACTIVE", 0)
|
||||
}
|
||||
|
||||
oSteps.Add(oStep)
|
||||
|
||||
Logger.Debug("Adding Import Profile Step for Index [{0}]", oStep.IndexName)
|
||||
Next
|
||||
|
||||
Return oSteps
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return oSteps
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetImportProfiles() As List(Of ImportProfile)
|
||||
Dim oProfiles As New List(Of ImportProfile)
|
||||
|
||||
Try
|
||||
Logger.Info("Loading Profiles..")
|
||||
Logger.Info("Loading Import Profiles..")
|
||||
|
||||
Dim oSQL As String = "SELECT * FROM TBECM_JR_FIW_PROFILE"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSQL)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Logger.Warn("Database Error while loading Profiles!")
|
||||
Logger.Warn("Database Error while loading Import Profiles!")
|
||||
Return oProfiles
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] Profiles loaded!", oTable.Rows.Count)
|
||||
Logger.Info("[{0}] Import Profiles loaded!", oTable.Rows.Count)
|
||||
|
||||
For Each oRow As DataRow In oTable.Rows
|
||||
Dim oTypeId = oRow.ItemEx("JOB_TYPE_ID", 0)
|
||||
Dim oProfile As New ImportProfile With {
|
||||
.Id = oRow.ItemEx("GUID", 0),
|
||||
.JobId = oRow.ItemEx("JR_JOB_ID", 0),
|
||||
.SourceFolder = oRow.ItemEx("SOURCE_FOLDER", "")
|
||||
.ObjectTypeName = oRow.Item("WM_OBJECTTYPE"),
|
||||
.SourceFolder = oRow.ItemEx("SOURCE_FOLDER", ""),
|
||||
.TargetFolder = oRow.ItemEx("TARGET_FOLDER", ""),
|
||||
.BackupFolder = oRow.ItemEx("BACKUP_FOLDER", ""),
|
||||
.SubfolderDateFormat = oRow.ItemEx("SF_DATE_FORMAT", ""),
|
||||
.DeleteFiles = oRow.ItemEx("DEL_FILE_SUCCESS", 0),
|
||||
.FileExcludeRegex = oRow.ItemEx("EXCLUDE_REGEX", ""),
|
||||
.IncludeSubfolders = oRow.ItemEx("INCL_SUBFOLDER", 0),
|
||||
.Active = oRow.ItemEx("ACTIVE", 0)
|
||||
}
|
||||
|
||||
oProfiles.Add(oProfile)
|
||||
|
||||
Logger.Debug("Adding Profile for Folder [{0}]", oProfile.SourceFolder)
|
||||
Logger.Debug("Adding Import Profile for Folder [{0}]", oProfile.SourceFolder)
|
||||
Next
|
||||
|
||||
Return oProfiles
|
||||
|
||||
Reference in New Issue
Block a user