/// <summary> /// Creates a new IJob instance for the appropriate job type. /// </summary> /// <param name="jobSpec">The job specification to initialize the job for.</param> /// <returns>An instance of a job ready to be started.</returns> public static IJob AcquireJob(JobSpecLite jobSpec) { Job job; switch (jobSpec.Type) { case JobTypes.ApplyDbIndexes: job = (Job)Bootstrap.ServiceProvider.GetService(typeof(CreateMongoIndexes)); break; case JobTypes.ImportMapData: job = (Job)Bootstrap.ServiceProvider.GetService(typeof(ImportMapData)); break; case JobTypes.ImportMarketData: job = (Job)Bootstrap.ServiceProvider.GetService(typeof(ImportMarketData)); break; default: job = null; break; } job.JobSpec = jobSpec; return(job); }
/// <summary> /// Creates a new IJob instance for the appropriate job type. /// </summary> /// <param name="jobSpec">The job specification to initialize the job for.</param> /// <param name="dbFactory">An option DbFactory to use with the new job.</param> /// <returns>An instance of a job ready to be started.</returns> public static IJob AcquireJob(JobSpecLite jobSpec, IDbFactory dbFactory = null) { IJob job; switch (jobSpec.Type) { case JobTypes.ApplyDbIndexes: job = new CreateMongoIndexes(jobSpec, dbFactory ?? DbFactory); break; case JobTypes.ImportMapData: job = new ImportMapData(jobSpec, dbFactory ?? DbFactory); break; case JobTypes.ImportMarketData: job = new ImportMarketData(jobSpec, dbFactory ?? DbFactory); break; default: job = null; break; } return((IJob)job); }
/// <summary> /// Updates the job status and end timestamp. /// </summary> /// <param name="jobSpec">The job spec.</param> /// <param name="status">The new status for the job.</param> /// <param name="timestamp">The new timestamp for the job's start.</param> public void UpdateStatusAndEndTimestamp(JobSpecLite jobSpec, string status, DateTime timestamp) { var jobCol = this.DbFactory.GetCollection <JobSpec <string> >(CollectionNames.Jobs); jobCol.UpdateOne( Builders <JobSpec <string> > .Filter.Eq(j => j.Uuid, jobSpec.Uuid), Builders <JobSpec <string> > .Update.Set(j => j.Status, status).Set(j => j.EndTimestamp, timestamp)); }
internal static void InternalAddMessageToJob(IDbFactory dbFactory, JobSpecLite jobSpec, JobMessageLevel level, string message) { // TODO: Make Job Message expiry configurable via the settings db. var expiry = DateTime.Now.AddDays(3); var messageCollection = dbFactory.GetCollection <JobMessage>(CollectionNames.JobMessages); messageCollection.InsertOneAsync(new JobMessage { JobUuid = jobSpec.Uuid, MasterJobUuid = jobSpec.MasterUuid, ExpireAt = expiry, Timestamp = DateTime.Now, Level = (ushort)level, Message = message }); }
/// <summary> /// Initializes a new instance of the <see cref="Job"/> class. /// </summary> /// <param name="jobSpec">The job specification this is running for.</param> /// <param name="dbFactory">The dbFactory for this job to use.</param> public Job(JobSpecLite jobSpec, IDbFactory dbFactory) { this.JobSpec = jobSpec; this.DbFactory = dbFactory; this.Messages = new List <string>(); }
/// <summary> /// Initializes a new instance of the <see cref="ImportMarketData"/> class. /// </summary> /// <param name="jobSpec">The job specification this is running for.</param> /// <param name="dbFactory">The dbFactory for this job to use.</param> public ImportMarketData(JobSpecLite jobSpec, IDbFactory dbFactory) : base(jobSpec, dbFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="EveDataJob"/> class. /// </summary> /// <param name="jobSpec">The job specification this is running for.</param> /// <param name="dbFactory">The dbFactory for this job to use.</param> public EveDataJob(JobSpecLite jobSpec, IDbFactory dbFactory) : base(jobSpec, dbFactory) { }
/// <summary> /// Initializes a new instance of the <see cref="CreateMongoIndexes"/> class. /// </summary> /// <param name="jobSpec">The job specification this is running for.</param> /// <param name="dbFactory">The dbFactory for this job to use.</param> public CreateMongoIndexes(JobSpecLite jobSpec, IDbFactory dbFactory) : base(jobSpec, dbFactory) { }
/// <summary> /// Adds a message to the associated job at the specified level. /// </summary> /// <param name="jobSpec">The job spec.</param> /// <param name="level">The message level.</param> /// <param name="message">The message.</param> public void AddMessageToJob(JobSpecLite jobSpec, JobMessageLevel level, string message) { JobMessageRepository.InternalAddMessageToJob(this.DbFactory, jobSpec, level, message); }