public string CreateNewJob([FromBody] JobScheduleData data) { // Reconstruct var job = data.Job.CreateJob(); var schedule = data.Schedule.CreateSchedule(job); // See if we can use it if (!schedule.IsActive) { throw new ArgumentException(Properties.Resources.ScheduleInPast); } // Connect job.Schedules.Add(schedule); // Process ServerRuntime.VCRServer.UpdateJob(job, schedule.UniqueID.Value); // Update recently used channels UserProfileSettings.AddRecentChannel(data.Job.Source); UserProfileSettings.AddRecentChannel(data.Schedule.Source); // Report return(ServerRuntime.GetUniqueWebId(job, schedule)); }
public void UpdateRecording(string detail, [FromBody] JobScheduleData data) { // Parameter analysieren VCRJob job; var schedule = ServerRuntime.ParseUniqueWebId(detail, out job); // Validate if (schedule == null) { throw new ArgumentException("Job or Schedule not found"); } // Take the new job data var newJob = data.Job.CreateJob(job.UniqueID.Value); var newSchedule = data.Schedule.CreateSchedule(schedule.UniqueID.Value, newJob); // All exceptions still active var activeExceptions = data.Schedule.Exceptions ?? Enumerable.Empty <PlanException>(); var activeExceptionDates = new HashSet <DateTime>(activeExceptions.Select(exception => exception.ExceptionDate)); // Copy over all exceptions newSchedule.Exceptions.AddRange(schedule.Exceptions.Where(exception => activeExceptionDates.Contains(exception.When))); // See if we can use it if (!newSchedule.IsActive) { throw new ArgumentException(Properties.Resources.ScheduleInPast); } // Copy all schedules expect the one wie founr newJob.Schedules.AddRange(job.Schedules.Where(oldSchedule => !ReferenceEquals(oldSchedule, schedule))); // Add the updated variant newJob.Schedules.Add(newSchedule); // Send to persistence ServerRuntime.VCRServer.UpdateJob(newJob, newSchedule.UniqueID.Value); // Update recently used channels UserProfileSettings.AddRecentChannel(data.Job.Source); UserProfileSettings.AddRecentChannel(data.Schedule.Source); }
public string CreateNewRecording(string detail, [FromBody] JobScheduleData data) { // Parameter analysieren VCRJob job; ServerRuntime.ParseUniqueWebId(detail + Guid.NewGuid().ToString("N"), out job); // Validate if (job == null) { throw new ArgumentException("Job not found"); } // Take the new job data var newJob = data.Job.CreateJob(job.UniqueID.Value); var newSchedule = data.Schedule.CreateSchedule(newJob); // See if we can use it if (!newSchedule.IsActive) { throw new ArgumentException(Properties.Resources.ScheduleInPast); } // Add all existing newJob.Schedules.AddRange(job.Schedules); // Add the new one newJob.Schedules.Add(newSchedule); // Send to persistence ServerRuntime.VCRServer.UpdateJob(newJob, newSchedule.UniqueID.Value); // Update recently used channels UserProfileSettings.AddRecentChannel(data.Job.Source); UserProfileSettings.AddRecentChannel(data.Schedule.Source); // Report return(ServerRuntime.GetUniqueWebId(newJob, newSchedule)); }