/// <summary> /// Initializes a new instance of the <see cref="T:LFNet.Common.Scheduler.Job" /> class. /// </summary> public Job(IJobConfiguration configuration, Type jobType, JobLockProvider jobLockProvider, JobHistoryProvider jobHistoryProvider) { this._id = Guid.NewGuid().ToString("N").Substring(0, 10).ToLower(); this._isBusy = new Synchronized <bool>(); this._lastResult = new Synchronized <string>(); this._lastRunStartTime = new Synchronized <DateTime>(); this._lastRunFinishTime = new Synchronized <DateTime>(); this._lastStatus = new Synchronized <JobStatus>(); this._nextRunTime = new Synchronized <DateTime>(); this._status = new Synchronized <JobStatus>(); this._runLock = new object(); this._name = configuration.Name; this._description = configuration.Description; this._group = configuration.Group; this._interval = configuration.Interval; this._isTimeOfDay = configuration.IsTimeOfDay; this._keepAlive = configuration.KeepAlive; this._arguments = configuration.Arguments; this._jobType = jobType; this._jobLockProvider = jobLockProvider ?? new DefaultJobLockProvider(); this._jobHistoryProvider = jobHistoryProvider; this._instance = null; this._timer = new Timer(new TimerCallback(this.OnTimerCallback)); if (this._jobHistoryProvider != null) { this._jobHistoryProvider.RestoreHistory(this); } }
/// <summary> /// Initializes a new instance of the <see cref="JobRunner"/> class. /// </summary> public JobRunner(IJobConfiguration configuration, Type jobType, JobLockProvider jobLockProvider, JobHistoryProvider jobHistoryProvider, IDependencyResolver dependencyResolver) { _id = Guid.NewGuid().ToString("N").Substring(0, 10).ToLower(); _isBusy = new Synchronized<bool>(); _lastResult = new Synchronized<string>(); _lastRunStartTime = new Synchronized<DateTime>(); _lastRunFinishTime = new Synchronized<DateTime>(); _lastStatus = new Synchronized<JobStatus>(); _nextRunTime = new Synchronized<DateTime>(); _status = new Synchronized<JobStatus>(); _runLock = new object(); _name = configuration.Name; _description = configuration.Description; _group = configuration.Group; _interval = configuration.Interval; _isTimeOfDay = configuration.IsTimeOfDay; _keepAlive = configuration.KeepAlive; _arguments = configuration.Arguments; _jobType = jobType; _jobLockProvider = jobLockProvider ?? new DefaultJobLockProvider(); _dependencyResolver = dependencyResolver ?? new DefaultDependencyResolver(); _jobHistoryProvider = jobHistoryProvider; _instance = null; _timer = new Timer(OnTimerCallback); if (_jobHistoryProvider != null) _jobHistoryProvider.RestoreHistory(this); Trace.TraceInformation("Job {0} created on {1}.", Name, Environment.MachineName); }
/// <summary> /// Initializes a new instance of the <see cref="JobRunner"/> class. /// </summary> public JobRunner(IJobConfiguration configuration, Type jobType, JobLockProvider jobLockProvider, JobHistoryProvider jobHistoryProvider, IDependencyResolver dependencyResolver) { _id = Guid.NewGuid().ToString("N").Substring(0, 10).ToLower(); _isBusy = new Synchronized <bool>(); _lastResult = new Synchronized <string>(); _lastRunStartTime = new Synchronized <DateTime>(); _lastRunFinishTime = new Synchronized <DateTime>(); _lastStatus = new Synchronized <JobStatus>(); _nextRunTime = new Synchronized <DateTime>(); _status = new Synchronized <JobStatus>(); _runLock = new object(); _name = configuration.Name; _description = configuration.Description; _group = configuration.Group; _interval = configuration.Interval; _isTimeOfDay = configuration.IsTimeOfDay; _keepAlive = configuration.KeepAlive; _arguments = configuration.Arguments; _jobType = jobType; _jobLockProvider = jobLockProvider ?? new DefaultJobLockProvider(); _dependencyResolver = dependencyResolver ?? new DefaultDependencyResolver(); _jobHistoryProvider = jobHistoryProvider; _instance = null; _timer = new Timer(OnTimerCallback); if (_jobHistoryProvider != null) { _jobHistoryProvider.RestoreHistory(this); } Trace.TraceInformation("Job {0} created on {1}.", Name, Environment.MachineName); }
private ITask GetTask(IJobConfiguration jobDef, int jobId, int layerId) { IJob xJob = (from j in _MediaServicesContext.Jobs select j).Where(j => j.Name == getJobName(jobDef)).FirstOrDefault(); string taskKey = getTaskName(jobDef, jobId, layerId); return((from t in xJob.Tasks select t).Where(t => t.Name == taskKey).FirstOrDefault()); }
public virtual string Serialize(IJobConfiguration config) { if (config == null) { return(""); } return(SerializeToXElement(config).ToString()); }
public static IJobConfiguration <T> UseCron <T>(this IJobConfiguration <T> @this, string cronExpression, DateTimeOffset?startingFrom = null) where T : IJob { var expression = CrontabSchedule.Parse(cronExpression); startingFrom = CalculateNextDate(expression, startingFrom ?? DateTimeOffset.Now); return(@this.RunWithSequence(startingFrom.Value, x => CalculateNextDate(expression, x))); }
public static JobConfigurationTemplateDto ToDto(this IJobConfiguration configuration, IJobConfigurationMapper mapper) { return(new JobConfigurationTemplateDto() { Description = configuration.Description, DisplayName = configuration.DisplayName, ExampleConfiguration = mapper.Serialize(configuration.CreateExample()) }); }
public Service(IJobConfiguration jobConfiguration, ICustomerAPI customerAPI) { _jobConfiguration = jobConfiguration; _customerAPI = customerAPI; }
public CustomJob(IJobConfiguration jobConfiguration) { JobConfiguration = jobConfiguration; }
/// <summary> /// Initializes a new instance of the <see cref="JobRunner"/> class. /// </summary> public JobRunner(IJobConfiguration configuration, Type jobType, JobLockProvider jobLockProvider) : this(configuration, jobType, jobLockProvider, null) { }
public static IJobConfiguration <T> RunEvery <T>(this IJobConfiguration <T> @this, TimeSpan interval) where T : IJob { return(@this.UseWaitSource(new IntervalWaitSource(interval))); }
public static IJobConfiguration <T> RunWithSequence <T>(this IJobConfiguration <T> @this, DateTimeOffset startingFrom, Func <DateTimeOffset, DateTimeOffset> thenAt) where T : IJob { return(@this.UseWaitSource(new WaitUntilNextDateWaitSource(startingFrom, thenAt))); }
private string getTaskName(IJobConfiguration myJobDef, int id, int layer) { IAsset myInputAsset = (from m in _MediaServicesContext.Assets select m).Where(m => m.Id == myJobDef.InputAssetId[id]).FirstOrDefault(); return(string.Format("{1}.Task[{0}]{2}", layer, myInputAsset.Name, myJobDef.TaskId[id])); }
private string getJobName(IJobConfiguration myJobDef) { return(string.Format("[{0}]{1}", myJobDef.Id, myJobDef.Processor)); }
/// <summary> /// Initializes a new instance of the <see cref="T:LFNet.Common.Scheduler.Job" /> class. /// </summary> public Job(IJobConfiguration configuration, Type jobType, JobLockProvider jobLockProvider) : this(configuration, jobType, jobLockProvider, null) { }
/// <summary> /// Can this Job handle the given configuration /// </summary> /// <param name="jobConfiguration"></param> /// <returns></returns> public bool CanHandle(IJobConfiguration jobConfiguration) { return(jobConfiguration is T); }
protected XElement SerializeToXElement(IJobConfiguration config) { return(config?.ToXElement(config.GetType())); }