merge historyitem and statusitem
This commit is contained in:
parent
835467f0d7
commit
343f47ca29
@ -1,38 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.diagnostics>
|
||||
<sources>
|
||||
<source name="System.ServiceModel"
|
||||
switchValue="Warning"
|
||||
propagateActivity="true" >
|
||||
<source name="System.ServiceModel" switchValue="Warning" propagateActivity="true">
|
||||
<listeners>
|
||||
<add name="xml"/>
|
||||
</listeners>
|
||||
</source>
|
||||
<source name="System.ServiceModel.MessageLogging">
|
||||
<listeners>
|
||||
<add name="xml" />
|
||||
<add name="xml"/>
|
||||
</listeners>
|
||||
</source>
|
||||
</sources>
|
||||
<sharedListeners>
|
||||
<add name="xml"
|
||||
type="System.Diagnostics.XmlWriterTraceListener"
|
||||
initializeData="E:\LogFiles\ECMJobRunner.svclog" />
|
||||
<add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="E:\LogFiles\ECMJobRunner.svclog"/>
|
||||
</sharedListeners>
|
||||
</system.diagnostics>
|
||||
<system.serviceModel>
|
||||
<diagnostics wmiProviderEnabled="true">
|
||||
<messageLogging
|
||||
logEntireMessage="true"
|
||||
logMalformedMessages="false"
|
||||
logMessagesAtServiceLevel="true"
|
||||
logMessagesAtTransportLevel="false"
|
||||
maxMessagesToLog="3000"
|
||||
maxSizeOfMessageToLog="2000"/>
|
||||
<messageLogging logEntireMessage="true" logMalformedMessages="false" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000"/>
|
||||
</diagnostics>
|
||||
</system.serviceModel>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2" />
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
</configuration>
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
@ -125,6 +126,7 @@
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.Designer.vb">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
@ -133,9 +135,7 @@
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Scheduler\JobConfig.vb" />
|
||||
<Compile Include="Scheduler\JobHistory.vb" />
|
||||
<Compile Include="Scheduler\JobListener.vb" />
|
||||
<Compile Include="Scheduler\JobResult.vb" />
|
||||
<Compile Include="Scheduler\JobScheduler.vb" />
|
||||
<Compile Include="Scheduler\JobStatus.vb" />
|
||||
<Compile Include="Scheduler\Jobs\DebugJob.vb" />
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -1,40 +1,41 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
Option Strict On
|
||||
Option Explicit On
|
||||
|
||||
Imports System
|
||||
|
||||
Namespace My.Resources
|
||||
|
||||
'This class was auto-generated by the StronglyTypedResourceBuilder
|
||||
'class via a tool like ResGen or Visual Studio.
|
||||
'To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
'with the /str option, or rebuild your VS project.
|
||||
|
||||
'Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
'-Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
'Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
'mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
'''<summary>
|
||||
''' A strongly-typed resource class, for looking up localized strings, etc.
|
||||
''' Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
'''</summary>
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0"), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.Microsoft.VisualBasic.HideModuleNameAttribute()> _
|
||||
Friend Module Resources
|
||||
|
||||
|
||||
Private resourceMan As Global.System.Resources.ResourceManager
|
||||
|
||||
|
||||
Private resourceCulture As Global.System.Globalization.CultureInfo
|
||||
|
||||
|
||||
'''<summary>
|
||||
''' Returns the cached ResourceManager instance used by this class.
|
||||
''' Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
|
||||
Get
|
||||
If Object.ReferenceEquals(resourceMan, Nothing) Then
|
||||
@ -44,17 +45,17 @@ Namespace My.Resources
|
||||
Return resourceMan
|
||||
End Get
|
||||
End Property
|
||||
|
||||
|
||||
'''<summary>
|
||||
''' Overrides the current thread's CurrentUICulture property for all
|
||||
''' resource lookups using this strongly typed resource class.
|
||||
''' Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
''' Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
'''</summary>
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Friend Property Culture() As Global.System.Globalization.CultureInfo
|
||||
Get
|
||||
Return resourceCulture
|
||||
End Get
|
||||
Set(ByVal value As Global.System.Globalization.CultureInfo)
|
||||
Set
|
||||
resourceCulture = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
'------------------------------------------------------------------------------
|
||||
' <auto-generated>
|
||||
' This code was generated by a tool.
|
||||
' Runtime Version:4.0.30319.42000
|
||||
' Dieser Code wurde von einem Tool generiert.
|
||||
' Laufzeitversion:4.0.30319.42000
|
||||
'
|
||||
' Changes to this file may cause incorrect behavior and will be lost if
|
||||
' the code is regenerated.
|
||||
' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
' der Code erneut generiert wird.
|
||||
' </auto-generated>
|
||||
'------------------------------------------------------------------------------
|
||||
|
||||
@ -13,42 +13,42 @@ Option Explicit On
|
||||
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
|
||||
<Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute(), _
|
||||
Global.System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.4.0.0"), _
|
||||
Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Partial Friend NotInheritable Class MySettings
|
||||
Inherits Global.System.Configuration.ApplicationSettingsBase
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
|
||||
|
||||
#Region "My.Settings Auto-Save Functionality"
|
||||
|
||||
Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings)
|
||||
|
||||
#Region "Automatische My.Settings-Speicherfunktion"
|
||||
#If _MyType = "WindowsForms" Then
|
||||
Private Shared addedHandler As Boolean
|
||||
Private Shared addedHandler As Boolean
|
||||
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
Private Shared addedHandlerLockObject As New Object
|
||||
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
<Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
|
||||
Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs)
|
||||
If My.Application.SaveMySettingsOnExit Then
|
||||
My.Settings.Save()
|
||||
End If
|
||||
End Sub
|
||||
#End If
|
||||
#End Region
|
||||
|
||||
|
||||
Public Shared ReadOnly Property [Default]() As MySettings
|
||||
Get
|
||||
|
||||
|
||||
#If _MyType = "WindowsForms" Then
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
If Not addedHandler Then
|
||||
SyncLock addedHandlerLockObject
|
||||
If Not addedHandler Then
|
||||
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
|
||||
addedHandler = True
|
||||
End If
|
||||
End SyncLock
|
||||
End If
|
||||
#End If
|
||||
Return defaultInstance
|
||||
End Get
|
||||
@ -57,13 +57,13 @@ Namespace My
|
||||
End Namespace
|
||||
|
||||
Namespace My
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
|
||||
<Global.Microsoft.VisualBasic.HideModuleNameAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Runtime.CompilerServices.CompilerGeneratedAttribute()> _
|
||||
Friend Module MySettingsProperty
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
|
||||
<Global.System.ComponentModel.Design.HelpKeywordAttribute("My.Settings")> _
|
||||
Friend ReadOnly Property Settings() As Global.ECM.JobRunner.Windows.My.MySettings
|
||||
Get
|
||||
Return Global.ECM.JobRunner.Windows.My.MySettings.Default
|
||||
|
||||
@ -12,27 +12,27 @@ Namespace Scheduler
|
||||
|
||||
Private ReadOnly Logger As Logger
|
||||
Private ReadOnly LogConfig As LogConfig
|
||||
Private ReadOnly History As JobHistory
|
||||
'Private ReadOnly History As JobHistory
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pJobHistory As JobHistory)
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New()
|
||||
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
History = pJobHistory
|
||||
'History = pJobHistory
|
||||
End Sub
|
||||
|
||||
Public Overrides Function JobWasExecuted(context As IJobExecutionContext, jobException As JobExecutionException, Optional cancellationToken As Threading.CancellationToken = Nothing) As Task
|
||||
' TODO: This might not be needed anymore
|
||||
'
|
||||
If jobException Is Nothing Then
|
||||
If TypeOf context.Result Is JobResult Then
|
||||
Dim oResult As JobResult = context.Result
|
||||
History.AddSuccess(context.JobDetail.Key.Name, oResult.Description, oResult.Steps)
|
||||
Else
|
||||
|
||||
History.AddSuccess(context.JobDetail.Key.Name, "Job Successful!", New List(Of HistoryItem.HistoryStep))
|
||||
If TypeOf context.Result Is StatusItem Then
|
||||
Dim oResult As StatusItem = context.Result
|
||||
Logger.Info("Job [{0}] was executed in [{1}]!", oResult.Name, oResult.ExecutionTime)
|
||||
'History.AddSuccess(context.JobDetail.Key.Name, oResult.Description, oResult.Steps)
|
||||
End If
|
||||
Else
|
||||
History.AddError(context.JobDetail.Key.Name, jobException.Message, New List(Of HistoryItem.HistoryStep))
|
||||
'History.AddError(context.JobDetail.Key.Name, jobException.Message, New List(Of HistoryItem.HistoryStep))
|
||||
End If
|
||||
|
||||
Return MyBase.JobWasExecuted(context, jobException, cancellationToken)
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
Imports ECM.JobRunner.Common
|
||||
|
||||
Public Class JobResult
|
||||
Public Property Successful As Boolean
|
||||
Public Property Description As String
|
||||
Public Property Steps As List(Of HistoryItem.HistoryStep)
|
||||
End Class
|
||||
@ -51,7 +51,7 @@ Namespace Scheduler
|
||||
|
||||
' initialize the scheduler
|
||||
Scheduler = Await Factory.GetScheduler()
|
||||
Scheduler.ListenerManager.AddJobListener(New JobListener(LogConfig, State.JobHistory))
|
||||
Scheduler.ListenerManager.AddJobListener(New JobListener(LogConfig))
|
||||
|
||||
' start the scheduler
|
||||
Await Scheduler.Start()
|
||||
|
||||
@ -19,6 +19,7 @@ Public Class JobStatus
|
||||
If oStatus IsNot Nothing Then
|
||||
oStatus.Name = pJob.JobDetail.Key.Name
|
||||
oStatus.StartTime = Date.Now
|
||||
oStatus.UpdateTime = Date.Now
|
||||
oStatus.Executing = True
|
||||
End If
|
||||
End Sub
|
||||
@ -32,28 +33,56 @@ Public Class JobStatus
|
||||
oStatus.ProgressTotal = pTotal
|
||||
oStatus.ProgressCurrent = pCurrent
|
||||
oStatus.ExecutionTime = pJob.JobRunTime
|
||||
oStatus.UpdateTime = Date.Now
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub Complete(pJob As Quartz.IJobExecutionContext)
|
||||
Public Function CompleteWithError(pJob As Quartz.IJobExecutionContext, pSteps As List(Of StatusItem.HistoryStep), pException As Exception) As StatusItem
|
||||
Return CompleteWithError(pJob, pSteps, pException.Message)
|
||||
End Function
|
||||
|
||||
Public Function CompleteWithError(pJob As Quartz.IJobExecutionContext, pSteps As List(Of StatusItem.HistoryStep), pMessage As String) As StatusItem
|
||||
Dim oStatus = GetJobStatus(pJob)
|
||||
|
||||
Logger.Info("Completing Job [{0}]", oStatus.Id)
|
||||
Logger.Info("Completing Job [{0}] with Error", oStatus.Id)
|
||||
|
||||
If oStatus IsNot Nothing Then
|
||||
oStatus.ProgressCurrent = oStatus.ProgressTotal
|
||||
oStatus.ExecutionTime = pJob.JobRunTime
|
||||
oStatus.Executing = False
|
||||
oStatus.CompleteTime = Date.Now
|
||||
oStatus.FailureMessage = pMessage
|
||||
oStatus.Successful = False
|
||||
oStatus.Steps = pSteps
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Return oStatus
|
||||
End Function
|
||||
|
||||
Public Function CompleteWithSuccess(pJob As Quartz.IJobExecutionContext, pSteps As List(Of StatusItem.HistoryStep), pMessage As String) As StatusItem
|
||||
Dim oStatus = GetJobStatus(pJob)
|
||||
|
||||
Logger.Info("Completing Job [{0}] with Success", oStatus.Id)
|
||||
|
||||
If oStatus IsNot Nothing Then
|
||||
oStatus.ProgressCurrent = oStatus.ProgressTotal
|
||||
oStatus.ExecutionTime = pJob.JobRunTime
|
||||
oStatus.Executing = False
|
||||
oStatus.CompleteTime = Date.Now
|
||||
oStatus.SuccessMessage = pMessage
|
||||
oStatus.Successful = False
|
||||
oStatus.Steps = pSteps
|
||||
End If
|
||||
|
||||
Return oStatus
|
||||
End Function
|
||||
|
||||
Private Function GetJobStatus(pJob As Quartz.IJobExecutionContext) As StatusItem
|
||||
Dim oJobId = GetJobId(pJob)
|
||||
Dim oExists = Entries.Where(Function(e) e.Id = oJobId).Any()
|
||||
Dim oExists = Entries.Where(Function(e) e.JobId = oJobId).Any()
|
||||
|
||||
If Not oExists Then
|
||||
Entries.Add(New StatusItem With {.Id = oJobId})
|
||||
Entries.Add(New StatusItem(oJobId))
|
||||
End If
|
||||
|
||||
Return Entries.Where(Function(e) e.Id = oJobId).SingleOrDefault()
|
||||
|
||||
@ -16,7 +16,7 @@ Namespace Scheduler.Jobs
|
||||
Friend ExecutionId As String
|
||||
Friend Name As String
|
||||
|
||||
Friend ResultItems As New List(Of HistoryItem.HistoryStep)
|
||||
Friend JobSteps As New List(Of StatusItem.HistoryStep)
|
||||
|
||||
Private ctx As IJobExecutionContext
|
||||
|
||||
@ -34,8 +34,10 @@ Namespace Scheduler.Jobs
|
||||
ExecutionId = Guid.NewGuid.ToString()
|
||||
Id = Integer.Parse(oArgs.Item("Id"))
|
||||
Name = oArgs.Item("Name")
|
||||
|
||||
State.JobStatus.Start(ctx)
|
||||
|
||||
Logger.Info("Job [{0}] is starting!", Id)
|
||||
|
||||
Return oJobData.Item(Constants.Scheduler.JOB_CONFIG_ARGUMENTS)
|
||||
End Function
|
||||
|
||||
@ -43,43 +45,47 @@ Namespace Scheduler.Jobs
|
||||
State.JobStatus.Update(ctx, pCurrentValue, pTotalValue)
|
||||
End Sub
|
||||
|
||||
Public Sub LogStep(pLevel As HistoryItem.StepLevel, pMessage As String, ParamArray pArgs As String())
|
||||
ResultItems.Add(New HistoryItem.HistoryStep With {
|
||||
Public Sub LogDebug(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Debug(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = pLevel
|
||||
.Level = StatusItem.STEP_DEBUG
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Function CompleteJob() As Task(Of Boolean)
|
||||
ctx.Result = New JobResult With {
|
||||
.Successful = True,
|
||||
.Steps = ResultItems,
|
||||
.Description = "Job completed."
|
||||
}
|
||||
State.JobStatus.Complete(ctx)
|
||||
Public Sub LogInfo(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Info(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = StatusItem.STEP_INFO
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Sub LogWarning(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Warn(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = StatusItem.STEP_WARNING
|
||||
})
|
||||
End Sub
|
||||
|
||||
Public Sub LogError(pMessage As String, ParamArray pArgs As String())
|
||||
Logger.Error(pMessage, pArgs)
|
||||
JobSteps.Add(New StatusItem.HistoryStep With {
|
||||
.Message = String.Format(pMessage, pArgs),
|
||||
.Level = StatusItem.STEP_ERROR
|
||||
})
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function CompleteJob(pMessage As String) As Task(Of Boolean)
|
||||
ctx.Result = State.JobStatus.CompleteWithSuccess(ctx, JobSteps, pMessage)
|
||||
Return Task.FromResult(True)
|
||||
End Function
|
||||
|
||||
Public Function CompleteJob(pCompletionMessage As String) As Task(Of Boolean)
|
||||
ctx.Result = New JobResult With {
|
||||
.Successful = True,
|
||||
.Steps = ResultItems,
|
||||
.Description = pCompletionMessage
|
||||
}
|
||||
State.JobStatus.Complete(ctx)
|
||||
|
||||
Return Task.FromResult(True)
|
||||
End Function
|
||||
|
||||
Public Function CompleteJob(pException As Exception) As Task(Of Boolean)
|
||||
ctx.Result = New JobResult With {
|
||||
.Successful = False,
|
||||
.Steps = ResultItems,
|
||||
.Description = pException.Message
|
||||
}
|
||||
State.JobStatus.Complete(ctx)
|
||||
|
||||
Public Function CompleteJobWithError(pException As Exception) As Task(Of Boolean)
|
||||
ctx.Result = State.JobStatus.CompleteWithError(ctx, JobSteps, pException)
|
||||
Return Task.FromResult(False)
|
||||
End Function
|
||||
End Class
|
||||
|
||||
@ -8,18 +8,17 @@ Namespace Scheduler.Jobs
|
||||
|
||||
Private Function IJob_Execute(context As IJobExecutionContext) As Task Implements IJob.Execute
|
||||
Dim oArgs = MyBase.InitializeJob(context)
|
||||
Dim oRandom = New Random()
|
||||
|
||||
Logger.Info("I'm a debug Job!")
|
||||
Logger.Info("Name: [{0}]", Name)
|
||||
Dim oTotal As Integer = oRandom.Next(5, 15)
|
||||
For index = 1 To oTotal
|
||||
Logger.Info("We are still waiting [{0}/{1}]", index, oTotal)
|
||||
LogInfo("We are still waiting [{0}/{1}]", index, oTotal)
|
||||
|
||||
Dim oResult = New JobResult() With {
|
||||
.Description = $"I'm a debug job and my result was [{Guid.NewGuid}]."
|
||||
}
|
||||
Threading.Thread.Sleep(1000)
|
||||
Next
|
||||
|
||||
context.Result = oResult
|
||||
|
||||
CompleteJob("Done!")
|
||||
Return Task.FromResult(True)
|
||||
Return CompleteJob("Finished, not waiting anymore!")
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
@ -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
|
||||
|
||||
@ -11,14 +11,7 @@ Namespace Scheduler.Jobs
|
||||
|
||||
Logger.Info("Running File Index [{0}]", Name)
|
||||
|
||||
Dim oResult = New JobResult() With {
|
||||
.Description = $"File Index Job [{Name}] completed!"
|
||||
}
|
||||
|
||||
context.Result = oResult
|
||||
|
||||
CompleteJob("Done!")
|
||||
Return Task.FromResult(True)
|
||||
Return CompleteJob("Done!")
|
||||
End Function
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
@ -63,8 +63,19 @@ Public Class Service
|
||||
|
||||
' start the service
|
||||
Dim oAddresses() As Uri = {Binding.GetAddress(Config.Host, Config.Port, Config.Name)}
|
||||
Logger.Info("Starting WCF Endpoint at [{0}]", oAddresses.First.ToString)
|
||||
ServiceHost = New WCF.ServiceHost(Of WCF.JobRunner)(oAddresses)
|
||||
ServiceHost.EnableMetadataExchange(True)
|
||||
|
||||
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()
|
||||
Logger.Info("WCF Endpoint started!")
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@ Public Class GetJobStatus
|
||||
|
||||
Public Function Run() As GetJobStatusResponse
|
||||
Return New GetJobStatusResponse With {
|
||||
.HistoryItems = State.JobHistory.Entries,
|
||||
.StatusItems = State.JobStatus.Entries
|
||||
}
|
||||
End Function
|
||||
@ -28,9 +27,6 @@ Public Class GetJobStatus
|
||||
Public Class GetJobStatusResponse
|
||||
Inherits Base.BaseResponse
|
||||
|
||||
<DataMember>
|
||||
Public Property HistoryItems As List(Of HistoryItem)
|
||||
|
||||
<DataMember>
|
||||
Public Property StatusItems As List(Of StatusItem)
|
||||
End Class
|
||||
|
||||
@ -16,7 +16,7 @@ Namespace WCF
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub EnableMetadataExchange(ByVal Optional EnableHttpGet As Boolean = True)
|
||||
Public Sub EnableMetadataExchange(Optional EnableHttpGet As Boolean = True)
|
||||
If State = CommunicationState.Opened Then
|
||||
Throw New InvalidOperationException("Host is already opened")
|
||||
End If
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user