/// <summary> /// Create job information from the job /// </summary> public JobInfo(IJobState job, IEnumerable <IJobSchedule> schedule) { if (job is IAmiIdentified ident) { this.Key = ident.Key; this.Tag = ident.Tag; this.ModifiedOn = ident.ModifiedOn; } else { this.Key = job.Job.Id.ToString(); this.Tag = job.GetType().Assembly.GetName().Version.ToString(); this.ModifiedOn = ApplicationServiceContext.Current.StartTime; } this.Name = job.Job.Name; this.CanCancel = job.Job.CanCancel; this.State = job.CurrentState; this.Description = job.Job.Description; this.Parameters = job.Job.Parameters?.Select(o => new JobParameter() { Key = o.Key, Type = o.Value.Name }).ToList(); this.LastStart = job.LastStartTime; this.LastFinish = job.LastStopTime; this.JobType = job.GetType().AssemblyQualifiedName; this.Schedule = schedule?.Select(o => new JobScheduleInfo(o)).ToList(); this.Progress = job.Progress; this.StatusText = job.StatusText; }