/// <summary> /// Initializes a new instance of the <see cref="Job"/> class. /// </summary> /// <param name="job">The job</param> /// The resource. /// <summary> /// Initializes a new instance of the <see cref="Job"/> class. /// </summary> public Job(AutomationManagement.Models.Job job) { Requires.Argument("job", job).NotNull(); if (job.Context == null || job.Context.RunbookVersion == null || job.Context.RunbookVersion.Runbook == null || job.Context.JobParameters == null) { throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.InvalidJobModel)); } this.Id = new Guid(job.Id); this.AccountId = new Guid(job.AccountId); this.Exception = job.Exception; this.CreationTime = DateTime.SpecifyKind(job.CreationTime, DateTimeKind.Utc).ToLocalTime(); this.LastModifiedTime = DateTime.SpecifyKind(job.LastModifiedTime, DateTimeKind.Utc).ToLocalTime(); this.StartTime = job.StartTime.HasValue ? DateTime.SpecifyKind(job.StartTime.Value, DateTimeKind.Utc).ToLocalTime() : this.StartTime; this.EndTime = job.EndTime.HasValue ? DateTime.SpecifyKind(job.EndTime.Value, DateTimeKind.Utc).ToLocalTime() : this.EndTime; this.LastStatusModifiedTime = DateTime.SpecifyKind(job.LastStatusModifiedTime, DateTimeKind.Utc).ToLocalTime(); this.Status = job.Status; this.StatusDetails = job.StatusDetails; this.RunbookId = new Guid(job.Context.RunbookVersion.Runbook.Id); this.RunbookName = job.Context.RunbookVersion.Runbook.Name; this.ScheduleName = job.Context.Schedule != null ? job.Context.Schedule.Name : string.Empty; this.JobParameters = from jobParameter in job.Context.JobParameters where jobParameter.Name != Constants.JobStartedByParameterName select new JobParameter(jobParameter); }
private AutomationManagement.Models.Job GetJobModel(string automationAccountName, Guid jobId) { AutomationManagement.Models.Job jobModel = this.automationManagementClient.Jobs.Get( automationAccountName, jobId.ToString()) .Job; if (jobModel == null) { throw new ResourceNotFoundException(typeof(Job), string.Format(CultureInfo.CurrentCulture, Resources.JobNotFoundById, jobId)); } return(jobModel); }
public IEnumerable <JobStreamItem> ListJobStreamItems(string automationAccountName, Guid jobId, DateTime createdSince, string streamTypeName) { AutomationManagement.Models.Job jobModel = this.GetJobModel(automationAccountName, jobId); IList <AutomationManagement.Models.JobStreamItem> jobStreamItemModels = AutomationManagementClient.ContinuationTokenHandler( skipToken => { var response = this.automationManagementClient.JobStreams.ListStreamItems( automationAccountName, new AutomationManagement.Models.JobStreamListStreamItemsParameters { JobId = jobModel.Id, StartTime = createdSince.ToUniversalTime(), StreamType = streamTypeName, SkipToken = skipToken }); return(new ResponseWithSkipToken <AutomationManagement.Models.JobStreamItem>( response, response.JobStreamItems)); }); return(jobStreamItemModels.Select(jobStreamItemModel => new JobStreamItem(jobStreamItemModel))); }