merge historyitem and statusitem
This commit is contained in:
@@ -6,47 +6,6 @@ Imports ECM.JobRunner.Common
|
||||
|
||||
Namespace Scheduler.Jobs
|
||||
|
||||
''' <summary>
|
||||
'''
|
||||
''' Parameters / Properties
|
||||
''' =======================
|
||||
'''
|
||||
''' - SourceDirectory
|
||||
''' - TargetDirectory
|
||||
''' - Include Subdirectories
|
||||
''' - Delete Subdirectories
|
||||
''' - Backup
|
||||
''' - BackupFolder
|
||||
''' - Overwrite
|
||||
''' - Windream DocType
|
||||
''' - Delete Files
|
||||
''' - Delete Directory
|
||||
''' - Delay
|
||||
'''
|
||||
''' Rules
|
||||
''' ======
|
||||
'''
|
||||
''' - TargetIndex
|
||||
''' - Active
|
||||
''' - Index From
|
||||
''' - Static
|
||||
''' - Static Value
|
||||
''' - File
|
||||
''' - Folder
|
||||
''' - Index Type
|
||||
''' - Separator
|
||||
''' - Current Date
|
||||
''' - Current Short Date
|
||||
''' - KOMPLETT
|
||||
''' - BEREICH
|
||||
''' - REST
|
||||
''' - TRENNZEICHEN
|
||||
''' - Separator
|
||||
''' - Remove Zeroes
|
||||
''' - Include Extension
|
||||
''' - OrderKey
|
||||
'''
|
||||
''' </summary>
|
||||
Public Class FileImportJob
|
||||
Inherits BaseJob
|
||||
Implements IJob
|
||||
@@ -69,7 +28,7 @@ Namespace Scheduler.Jobs
|
||||
Dim oObjectType = State.ObjectTypes.Where(Function(o) o.Name = oProfile.ObjectTypeName).SingleOrDefault()
|
||||
|
||||
If IO.Directory.Exists(oProfile.SourceFolder) = False Then
|
||||
LogStep(HistoryItem.StepLevel.Error, "Source directory [{0}] does not exist!", oProfile.SourceFolder)
|
||||
LogError("Source directory [{0}] does not exist!", oProfile.SourceFolder)
|
||||
Return Task.FromResult(False)
|
||||
End If
|
||||
|
||||
@@ -84,8 +43,7 @@ Namespace Scheduler.Jobs
|
||||
Return CompleteJob("No files for profile")
|
||||
End If
|
||||
|
||||
Logger.Info("[{0}] files found in source directory [{1}]", oFileNames.Count, oProfile.SourceFolder)
|
||||
LogStep(HistoryItem.StepLevel.Info, "{0} files found in source directory {1}", oFileNames.Count, oProfile.SourceFolder)
|
||||
LogInfo("{0} files found in source directory {1}", oFileNames.Count, oProfile.SourceFolder)
|
||||
|
||||
' - [ ] Process Rules, build list of files and indexes
|
||||
' - [x] Process Regex to filter out files
|
||||
@@ -110,15 +68,13 @@ Namespace Scheduler.Jobs
|
||||
' Check time to filter out files
|
||||
Dim oDateFilteredFiles = oFilteredFiles.Where(Function(f) FileIsOlderThan(f, pMinutes:=1)).ToList()
|
||||
Dim oDateFilteredCount = oFilteredFiles.Except(oDateFilteredFiles).Count()
|
||||
Logger.Debug("[{0}] Files filtered out for being too new.", oDateFilteredCount)
|
||||
LogStep(HistoryItem.StepLevel.Debug, "{0} Files filtered out for being too new.", oDateFilteredCount)
|
||||
LogDebug("{0} Files filtered out for being too new.", oDateFilteredCount)
|
||||
oFilteredFiles = oDateFilteredFiles
|
||||
|
||||
' Process Regex to filter out files
|
||||
Dim oRegexFilteredFiles = oFilteredFiles.Where(Function(f) Not FileMatchesRegex(f, oRegexList))
|
||||
Dim oRegexFilteredCount = oFilteredFiles.Except(oRegexFilteredFiles).Count()
|
||||
Logger.Debug("[{0}] Files filtered out for matching exclusion Regex.", oRegexFilteredCount)
|
||||
LogStep(HistoryItem.StepLevel.Debug, "{0} Files filtered out for matching exclusion Regex.", oRegexFilteredCount)
|
||||
LogDebug("{0} Files filtered out for matching exclusion Regex.", oRegexFilteredCount)
|
||||
oFilteredFiles = oDateFilteredFiles
|
||||
|
||||
'-------------------------------------------------------------------------------------------------
|
||||
@@ -143,8 +99,7 @@ Namespace Scheduler.Jobs
|
||||
oImportedFiles.Add(oFile)
|
||||
Next
|
||||
|
||||
Logger.Info("[{0}] files successfully Imported!", oImportedFiles.Count)
|
||||
LogStep(HistoryItem.StepLevel.Info, "{0} files successfully Imported!", oImportedFiles.Count)
|
||||
LogInfo("{0} files successfully Imported!", oImportedFiles.Count)
|
||||
|
||||
Dim oIndexedFiles As New List(Of ImportFile)
|
||||
For Each oFile In oImportedFiles
|
||||
@@ -156,8 +111,7 @@ Namespace Scheduler.Jobs
|
||||
Logger.Info("Indexing of file [{0}] done!", oFile.FilePathWindream)
|
||||
Next
|
||||
|
||||
Logger.Info("[{0}] files successfully Indexed!", oIndexedFiles.Count)
|
||||
LogStep(HistoryItem.StepLevel.Info, "{0} files successfully Indexed!", oIndexedFiles.Count)
|
||||
LogInfo("{0} files successfully Indexed!", oIndexedFiles.Count)
|
||||
|
||||
If oProfile.DeleteFiles = True Then
|
||||
Logger.Debug("Deleting [{0}] files before finishing job.", oFiles.Count)
|
||||
@@ -175,10 +129,9 @@ Namespace Scheduler.Jobs
|
||||
Return CompleteJob($"{oImportedFiles.Count} files successfully Processed!")
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
LogError("Unexpected Error: [{0}]", ex.Message)
|
||||
|
||||
LogStep(HistoryItem.StepLevel.Error, "Unexpected Error: [{0}]", ex.Message)
|
||||
|
||||
Return CompleteJob(ex)
|
||||
Return CompleteJobWithError(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -287,8 +240,7 @@ Namespace Scheduler.Jobs
|
||||
oValue = oValue.Substring(oStartIndex, oLength)
|
||||
Catch ex As Exception
|
||||
Dim oMessage = "Method SUBSTRING could not be applied to Index '{0}' and Parameters StartIndex [{1}], Length [{2}]. Error: '{3}'"
|
||||
LogStep(HistoryItem.StepLevel.Error, oMessage, oStep.IndexName, ex.Message, oStep.Argument1, oStep.Argument2)
|
||||
Logger.Error(ex)
|
||||
LogError(oMessage, oStep.IndexName, ex.Message, oStep.Argument1, oStep.Argument2)
|
||||
End Try
|
||||
|
||||
Case Common.Constants.METHOD_SPLIT
|
||||
@@ -306,8 +258,7 @@ Namespace Scheduler.Jobs
|
||||
Dim oSplit = oValue.Split(oSeparator)
|
||||
oValue = oSplit(oIndex)
|
||||
Catch ex As Exception
|
||||
LogStep(HistoryItem.StepLevel.Error, "Method SPLIT could not be applied to Index '{0}'. Error: '{1}'", oStep.IndexName, ex.Message)
|
||||
Logger.Error(ex)
|
||||
LogError("Method SPLIT could not be applied to Index '{0}'. Error: '{1}'", oStep.IndexName, ex.Message)
|
||||
End Try
|
||||
|
||||
Case Common.Constants.METHOD_REGEX
|
||||
@@ -321,8 +272,7 @@ Namespace Scheduler.Jobs
|
||||
oValue = oFalseValue
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LogStep(HistoryItem.StepLevel.Error, "Method REGEX could not be applied to Index '{0}'. Error: '{1}'", oStep.IndexName, ex.Message)
|
||||
Logger.Error(ex)
|
||||
LogError("Method REGEX could not be applied to Index '{0}'. Error: '{1}'", oStep.IndexName, ex.Message)
|
||||
End Try
|
||||
|
||||
Case Common.Constants.METHOD_VALUE
|
||||
|
||||
Reference in New Issue
Block a user