public bool ReplacementCheckIfProgramsMatch(ScheduleEntry entryToCompare, ScheduleEntry entryInStore, ScheduleEntry nextEntryInStore) { if (!OriginalCheckIfProgramsMatch(entryToCompare, entryInStore, nextEntryInStore)) return false; bool flagsMatch = ScheduleEntryFlagsMatch(entryToCompare, entryInStore); if (Program.options.safeMode) return true; else return flagsMatch; }
public void AddSchedule(ScheduleEntry schedule) { lock (_lock) { _schedules.Add(schedule); } Save(); }
public void BadTuesdayTest() { try { ScheduleEntry se = new ScheduleEntry("10:01", "tuesday", "5", "10"); Assert.Fail(); } catch { Assert.IsTrue(true); } }
public static bool ScheduleEntryFlagsMatch(ScheduleEntry se1, ScheduleEntry se2) { bool allPropertiesMatch = true; foreach (PropertyInfo property in scheduleEntryPropertiesToCompare_) { object val1 = property.GetValue(se1, null); object val2 = property.GetValue(se2, null); if ((val1 == null && val2 != null) || (val2 == null && val1 != null) || !val1.Equals(val2)) { Util.Trace(TraceLevel.Warning, "Mismatch found on {0} property for schedule entry {1}", property.Name, se1); allPropertiesMatch = false; } } return allPropertiesMatch; }
private static bool ShouldRunSchedule(ScheduleEntry schedule) { bool shouldRun = false; if (!schedule.LastRun.HasValue) { shouldRun = true; } else if (schedule.LastRun + schedule.RunEvery < DateTime.Now) { shouldRun = true; } if (shouldRun & schedule.RunOnlyAtNight) { shouldRun = IsCurrentlyNight(); } return(shouldRun); }
private ScheduleEntry GenerateScheduleEntry() { ScheduleEntry result = null; if (rbOneTime.Checked) { SimpleScheduleEntry sse = new SimpleScheduleEntry(); sse.StartDate = new DateTime( (m_oneTimeStartDate + TimeSpan.FromSeconds(m_oneTimeStartTime)).Ticks, DateTimeKind.Unspecified); sse.EndDate = new DateTime( (m_oneTimeEndDate + TimeSpan.FromSeconds(m_oneTimeEndTime)).Ticks, DateTimeKind.Unspecified); result = sse; } else if (rbRecurring.Checked) { RecurringScheduleEntry rse = new RecurringScheduleEntry(); rse.StartDate = m_recurringDateFrom; rse.EndDate = m_recurringDateTo; DayOfWeek dow = DayOfWeek.Monday; rse.Frequency = GetRecurringFrequencyDropdown(ref dow); rse.DayOfWeek = dow; if (rse.Frequency == RecurringFrequency.Weekly) { rse.WeeksPeriod = Convert.ToInt32(nudWeeklyFrequency.Value); } rse.DayOfMonth = Convert.ToInt32(nudRecurDayOfMonth.Value); rse.OverflowResolution = GetRecurringOverflowDropdown(); rse.StartTimeInSeconds = m_recurringStartTime; rse.EndTimeInSeconds = m_recurringEndTime; result = rse; } if (result != null) { result.Title = tbTitle.Text; result.Options = GetTypeFlags(); } return(result); }
public void Analyse_DefaultDataColumnRuleEngine_Colums1_Valid() { List <string> lines = new List <string>() { "blue (part of)" }; ScheduleEntry scheduleEntry = new ScheduleEntry { EntryText = lines }; EntryTextColumnBuilder builder = new EntryTextColumnBuilder(new DefaultDataColumnRuleEngine(), new DefaultWhiteSpaceSizeCalculator(), new DefaultNoteExtractor()); string[] columns = builder.Build(scheduleEntry.EntryText); Assert.AreEqual("blue (part of)", columns[0]); Assert.AreEqual("", columns[1]); Assert.AreEqual("", columns[2]); Assert.AreEqual("", columns[3]); }
public void Analyse_DefaultDataColumnRuleEngine_Colums1234_Valid() { List <string> lines = new List <string>() { "1 28.01.2009 Transformer Chamber (Ground 23.01.2009 EGL551039" }; ScheduleEntry scheduleEntry = new ScheduleEntry { EntryText = lines }; EntryTextColumnBuilder builder = new EntryTextColumnBuilder(new DefaultDataColumnRuleEngine(), new DefaultWhiteSpaceSizeCalculator(), new DefaultNoteExtractor()); string[] columns = builder.Build(scheduleEntry.EntryText); Assert.AreEqual("1 28.01.2009", columns[0]); Assert.AreEqual("Transformer Chamber (Ground", columns[1]); Assert.AreEqual("23.01.2009", columns[2]); Assert.AreEqual("EGL551039", columns[3]); }
public void ScheduleEntrySetter_Process_ColumnsAreNull_Inalid() { ScheduleEntry scheduleEntry = new ScheduleEntry() { EntryText = new List <string>() { "1 28.01.2009 Transformer Chamber (Ground 23.01.2009 EGL551039", "tinted blue Floor) 99 years from", "(part of) 23.1.2009", "NOTE: This is a note" } }; string[] columns = null; ScheduleEntrySetter setter = new ScheduleEntrySetter(scheduleEntry); setter.Process(new DefaultNoteExtractor(), columns); scheduleEntry.IsValid.Should().BeFalse("because the columns are null"); }
/// <summary> /// When the user double-clicks an entry on the left list box, we open the edition box for this entry. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lbEntries_DoubleClick(object sender, EventArgs e) { if (lbEntries.SelectedIndex == -1) { return; } ScheduleEntry entry = lbEntriesData[lbEntries.SelectedIndex]; using (EditScheduleEntryWindow f = new EditScheduleEntryWindow()) { f.ScheduleEntry = entry; DialogResult dr = f.ShowDialog(); if (dr == DialogResult.Cancel) { return; } Scheduler.Remove(entry); Scheduler.Add(f.ScheduleEntry); } }
public void Dispatch(ScheduleEntry nextAction) { switch (nextAction.Action) { case ScheduleAction.GetCommand: DispatchCommand(nextAction.Agent as IBeing); break; case ScheduleAction.SeedGrows: break; case ScheduleAction.PlantGrows: break; case ScheduleAction.Unset: //0.2.DEBUG: create a schedule dump routine, add it to exceptions throw new Exception("Unset action got into schedule somehow."); default: throw new Exception($"Need to write Dispatch() case for ScheduleAction.{nextAction.Action}."); } }
///GENMHASH:C11AE4C223D196AB7A57470F94A0CDC6:8297A81A7146CC702F9E8049568353EE public RedisCacheImpl WithPatchSchedule(ScheduleEntry scheduleEntry) { RedisPatchScheduleImpl psch = null; if (!this.patchSchedules.PatchSchedulesAsMap().Any()) { psch = this.patchSchedules.DefineInlinePatchSchedule(); this.patchScheduleAdded = true; psch.Inner.ScheduleEntries = new List <ScheduleEntryInner>(); this.patchSchedules.AddPatchSchedule(psch); } else if (!this.patchScheduleAdded) { psch = this.patchSchedules.UpdateInlinePatchSchedule(); } else { psch = this.patchSchedules.GetPatchSchedule(); } psch.Inner.ScheduleEntries.Add(scheduleEntry.Inner); return(this); }
public void TestScheduleEntryNotExists() { ScheduleEntry entry = new ScheduleEntry() { Id = 1, AwayTeamId = 3, GameDate = new DateTime(2020, 1, 17), HomeTeamId = 2 }; repo.Insert(entry); ScheduleEntry entry2 = new ScheduleEntry() { Id = 1, AwayTeamId = 3, GameDate = new DateTime(2020, 1, 18), HomeTeamId = 2 }; Assert.IsFalse(repo.Exists(entry2)); }
public void PatchSchedules_PutGetDelete() { using (var context = MockContext.Start(this.GetType().FullName)) { var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2"); Assert.Contains("sunny-scheduling-dv2", response.Id); Assert.Equal("sunny-scheduling-dv2", response.Name); Assert.True("succeeded".Equals(response.ProvisioningState, StringComparison.OrdinalIgnoreCase)); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); ScheduleEntry[] entries = new ScheduleEntry[] { new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Monday, StartHourUtc = 10, MaintenanceWindow = TimeSpan.FromHours(10) }, new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Tuesday, StartHourUtc = 11, MaintenanceWindow = TimeSpan.FromHours(11) } }; ValidateResponseForSchedulePatch(_client.PatchSchedules.CreateOrUpdate(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2", parameters: new RedisPatchSchedulesRequest(entries))); ValidateResponseForSchedulePatch(_client.PatchSchedules.Get(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2")); _client.PatchSchedules.Delete(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2"); var ex = Assert.Throws <CloudException>(() => _client.PatchSchedules.Get(resourceGroupName: "sunnyjapan", name: "sunny-scheduling-dv2")); Assert.Contains("There are no patch schedules found for redis cache 'sunny-scheduling-dv2'", ex.Message); Assert.Equal(HttpStatusCode.NotFound, ex.Response.StatusCode); } }
public void TestGetScheduleEntries() { ScheduleEntry entry = new ScheduleEntry() { Id = 1, AwayTeamId = 3, GameDate = DateTime.Now, HomeTeamId = 2 }; repo.Insert(entry); ScheduleEntry entry2 = new ScheduleEntry() { Id = 2, AwayTeamId = 5, GameDate = new DateTime(2020, 1, 12), HomeTeamId = 2 }; repo.Insert(entry2); Assert.AreEqual(2, repo.GetScheduleEntries().Count()); }
public void TestGetScheduleEntry() { ScheduleEntry entry = new ScheduleEntry() { Id = 1, AwayTeamId = 3, GameDate = DateTime.Now, HomeTeamId = 2 }; repo.Insert(entry); ScheduleEntry entry2 = new ScheduleEntry() { Id = 2, AwayTeamId = 5, GameDate = new DateTime(2020, 1, 12), HomeTeamId = 2 }; repo.Insert(entry2); Assert.IsNotNull(repo.GetScheduleEntry(2)); }
private bool ProgramIdsMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return(mxfEntry.Program.GetUIdValue() == storeEntry.Program.GetUIdValue()); }
private void ReplacementMergeScheduleEntriesInner(ScheduleEntry[] scheduleEntriesToMerge) { if (scheduleEntriesToMerge.Count() == 0) { return; // nothing to do. } Util.WaitForBackgroundThreads(); Service targetService = scheduleEntriesToMerge[0].Service; Util.Trace(TraceLevel.Info, "Processing schedule entries for {0}", targetService); long id = targetService.Id; FixServiceAssignmentsForServiceChannels(targetService); Util.WaitForBackgroundThreads(); OriginalMergeScheduleEntries(scheduleEntriesToMerge); Util.WaitForBackgroundThreads(); ScheduleEntries self = ThisAsScheduleEntries(); Mutex mutex = null; try { mutex = targetService.AcquireUpdateLock(); List <ScheduleEntry> storeEntries = GetScheduleEntriesForService(new ScheduleEntries(self.ObjectStore), targetService); storeEntries.Sort(CompareScheduleEntryStartTimes); Util.Trace(TraceLevel.Verbose, "store: {0} mxf: {1}", ListScheduleEntrys(storeEntries), ListScheduleEntrys(scheduleEntriesToMerge)); #region pad store entry list with bogus begin/end time entries // Create bogus store entries at the beginning and end of time to make the loop below simpler. ScheduleEntry endOfTimeEntry = new ScheduleEntry(); endOfTimeEntry.StartTime = DateTime.MaxValue; endOfTimeEntry.EndTime = DateTime.MaxValue; storeEntries.Add(endOfTimeEntry); ScheduleEntry beginningOfTimeEntry = new ScheduleEntry(); beginningOfTimeEntry.StartTime = DateTime.MinValue; beginningOfTimeEntry.StartTime = DateTime.MinValue; storeEntries.Insert(0, beginningOfTimeEntry); #endregion List <ScheduleEntry> adds = new List <ScheduleEntry>(); List <ScheduleEntry> updates = new List <ScheduleEntry>(); List <ScheduleEntry> deletes = new List <ScheduleEntry>(); int mxfIndex = 0; int storeIndex = 1; DateTime lastMXFEndTime = new DateTime(0); while (mxfIndex < scheduleEntriesToMerge.Count()) { ScheduleEntry mxfEntry = scheduleEntriesToMerge[mxfIndex]; ScheduleEntry storeEntry = storeEntries[storeIndex]; if (lastMXFEndTime > storeEntry.StartTime) { ScheduleEntry lastMxfEntry = scheduleEntriesToMerge[mxfIndex - 1]; if (lastMXFEndTime > storeEntry.EndTime) { Util.Trace(TraceLevel.Verbose, "Store entry is contained within timeslot of previous MXF entry, removing it. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { deletes.Add(storeEntry); } ++storeIndex; continue; } Util.Trace(TraceLevel.Verbose, "Store entry overlaps with previous MXF entry. Truncating start. store: {0} mxf: {1}", storeEntry, lastMxfEntry); if (!Program.options.safeMode) { storeEntry.StartTime = lastMxfEntry.EndTime; updates.Add(storeEntry); ++storeIndex; continue; } } if (TimeIsAboutAtOrBefore(storeEntry.EndTime, mxfEntry.StartTime)) { Util.Trace(TraceLevel.Verbose, "Ignoring store ScheduleEntry {0} as it does not overlap the current MXF entry : {1}", storeEntry, mxfEntry); ++storeIndex; continue; } if (TimeslotsMatch(mxfEntry, storeEntry)) { lastMXFEndTime = storeEntry.EndTime; if (mxfEntry.Program.Id != storeEntry.Program.Id) { SeriesInfo mxfSeries = mxfEntry.Program.Series; SeriesInfo storeSeries = storeEntry.Program.Series; if (mxfSeries != null && storeSeries != null && mxfSeries.Id == storeSeries.Id && mxfEntry.Program.IsGeneric && !storeEntry.Program.IsGeneric) { Util.Trace(TraceLevel.Info, "Skipping update because the MXF has a generic entry while DB already has a specific episode: store: {0} mxf: {1}", storeEntry, mxfEntry); } else { Util.Trace(TraceLevel.Warning, "Programs do not match after normal ScheduleEntriesToMerge, queueing update. Store: {0} MXF: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { storeEntry.Program = mxfEntry.Program; MergeProgramsInjector.UpdateScheduleEntryFlags(mxfEntry, storeEntry); updates.Add(storeEntry); } } } else if (!MergeProgramsInjector.ScheduleEntryFlagsMatch(storeEntry, mxfEntry)) { Util.Trace(TraceLevel.Warning, "Mismatched scheduleEntry flags found, queueing update. store: {0} MXF: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { MergeProgramsInjector.UpdateScheduleEntryFlags(mxfEntry, storeEntry); // MS MergeScheduleEntries treats this as an add/remove rather than an update. I don't like this, hopefully // this way can work. updates.Add(storeEntry); } } else { Util.Trace(TraceLevel.Verbose, "Entry for store and MXF already match: {0}", storeEntry); } ++mxfIndex; ++storeIndex; continue; } ScheduleEntry lastStoreEntry = storeEntries[storeIndex - 1]; // If we get here, store entry ends after mxf entry starts. Find out if the program ID matches; it may be only a timeslot change. if (storeEntry.Program.Id == mxfEntry.Program.Id) { Util.Trace(TraceLevel.Warning, "DB entry overlapping the MXF ScheduleEntry has the same program. Updating the timeslot and possibly flags. store: {0} MXF: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { if (TimeApproxEquals(mxfEntry.StartTime, lastStoreEntry.EndTime)) { storeEntry.StartTime = lastStoreEntry.EndTime; } else { storeEntry.StartTime = mxfEntry.StartTime; } ScheduleEntry nextStoreEntry = storeEntries[storeIndex + 1]; if (TimeApproxEquals(mxfEntry.EndTime, nextStoreEntry.StartTime)) { storeEntry.EndTime = nextStoreEntry.StartTime; } else { storeEntry.EndTime = mxfEntry.EndTime; } MergeProgramsInjector.UpdateScheduleEntryFlags(mxfEntry, storeEntry); updates.Add(storeEntry); } lastMXFEndTime = storeEntry.EndTime; ++mxfIndex; ++storeIndex; continue; } if (storeEntry.StartTime < mxfEntry.StartTime && TimeIsAboutAtOrBefore(storeEntry.EndTime, mxfEntry.EndTime)) { Util.Trace(TraceLevel.Warning, "DB entry overlapping MXF ScheduleEntry is earlier. Truncating the end of it. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { storeEntry.EndTime = mxfEntry.StartTime; updates.Add(storeEntry); } ++storeIndex; continue; } if (TimeIsAboutAtOrBefore(mxfEntry.StartTime, storeEntry.StartTime) && TimeIsAboutAtOrBefore(storeEntry.EndTime, mxfEntry.EndTime)) { Util.Trace(TraceLevel.Warning, "DB entry timeslot is within MXF ScheduleEntry timeslot. Deleting it. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { deletes.Add(storeEntry); } ++storeIndex; continue; } if (TimeIsAboutAtOrBefore(mxfEntry.EndTime, storeEntry.StartTime)) { Util.Trace(TraceLevel.Warning, "Next db entry is entirely after the MXF entry. Adding the MXF entry. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { // check for rounding error. if (mxfEntry.EndTime > storeEntry.StartTime) { mxfEntry.EndTime = storeEntry.StartTime; } adds.Add(mxfEntry); } lastMXFEndTime = mxfEntry.EndTime; ++mxfIndex; continue; } // If we ge there, store entry starts within MXF entry and ends later. Util.Trace(TraceLevel.Warning, "Overlapping store entry is at end of MXF ScheduleEntry. Truncating the start. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { storeEntry.StartTime = mxfEntry.EndTime; updates.Add(storeEntry); } ++storeIndex; } if (!Program.options.safeMode && updates.Count + adds.Count + deletes.Count > 0) { List <ScheduleEntry> emptyList = new List <ScheduleEntry>(); ApplyMergedScheduleEntriesToStore(targetService, emptyList, emptyList, deletes); ApplyMergedScheduleEntriesToStore(targetService, updates, emptyList, emptyList); ApplyMergedScheduleEntriesToStore(targetService, emptyList, adds, emptyList); } } finally { targetService.ReleaseUpdateLock(mutex); } }
private ScheduleEntry SmartFindStartScheduleEntry(StoredObjectsEnumerator <ScheduleEntry> enumerator, ScheduleEntry entryToMerge) { ScheduleEntry current = null; ServiceStartTimeKey key = new ServiceStartTimeKey(entryToMerge.Service, entryToMerge.StartTime - TimeSpan.FromSeconds(1)); if (enumerator.Seek(key, SeekType.BeforeEQ)) { current = enumerator.Current; if (current.Service == null || current.Service.Id != entryToMerge.Service.Id || current.EndTime < entryToMerge.StartTime + TimeSpan.FromSeconds(1)) { current = this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id); } return(current); } enumerator.Reset(); return(this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id)); }
public void WednesdayTest() { ScheduleEntry se = new ScheduleEntry("12:01", "Wednesday", "5", "10"); Assert.IsNotNull(se); }
public bool OriginalCheckIfProgramsMatch(ScheduleEntry entryToCompare, ScheduleEntry entryInStore, ScheduleEntry nextEntryInStore) { return false; }
public void DeleteSchedule(ScheduleEntry scheduleEntry) { DeleteSchedules(new[] { scheduleEntry }); }
public static TVProgramme TVProgrammeFromScheduleEntry(ScheduleEntry se) { return TVProgrammeFromScheduleEntry(se, false); }
private ScheduleEntry SmartFindStartScheduleEntry(StoredObjectsEnumerator<ScheduleEntry> enumerator, ScheduleEntry entryToMerge) { ScheduleEntry current = null; ServiceStartTimeKey key = new ServiceStartTimeKey(entryToMerge.Service, entryToMerge.StartTime - TimeSpan.FromSeconds(1)); if (enumerator.Seek(key, SeekType.BeforeEQ)) { current = enumerator.Current; if (current.Service == null || current.Service.Id != entryToMerge.Service.Id || current.EndTime < entryToMerge.StartTime + TimeSpan.FromSeconds(1)) { current = this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id); } return current; } enumerator.Reset(); return this.NextScheduleEntryForService(enumerator, entryToMerge.Service.Id); }
private void ReplacementMergeScheduleEntriesInner(ScheduleEntry[] scheduleEntriesToMerge) { if (scheduleEntriesToMerge.Count() == 0) return; // nothing to do. Util.WaitForBackgroundThreads(); Service targetService = scheduleEntriesToMerge[0].Service; Util.Trace(TraceLevel.Info, "Processing schedule entries for {0}", targetService); long id = targetService.Id; FixServiceAssignmentsForServiceChannels(targetService); Util.WaitForBackgroundThreads(); OriginalMergeScheduleEntries(scheduleEntriesToMerge); Util.WaitForBackgroundThreads(); ScheduleEntries self = ThisAsScheduleEntries(); Mutex mutex = null; try { mutex = targetService.AcquireUpdateLock(); List<ScheduleEntry> storeEntries = GetScheduleEntriesForService(new ScheduleEntries(self.ObjectStore), targetService); storeEntries.Sort(CompareScheduleEntryStartTimes); Util.Trace(TraceLevel.Verbose, "store: {0} mxf: {1}", ListScheduleEntrys(storeEntries), ListScheduleEntrys(scheduleEntriesToMerge)); #region pad store entry list with bogus begin/end time entries // Create bogus store entries at the beginning and end of time to make the loop below simpler. ScheduleEntry endOfTimeEntry = new ScheduleEntry(); endOfTimeEntry.StartTime = DateTime.MaxValue; endOfTimeEntry.EndTime = DateTime.MaxValue; storeEntries.Add(endOfTimeEntry); ScheduleEntry beginningOfTimeEntry = new ScheduleEntry(); beginningOfTimeEntry.StartTime = DateTime.MinValue; beginningOfTimeEntry.StartTime = DateTime.MinValue; storeEntries.Insert(0, beginningOfTimeEntry); #endregion List<ScheduleEntry> adds = new List<ScheduleEntry>(); List<ScheduleEntry> updates = new List<ScheduleEntry>(); List<ScheduleEntry> deletes = new List<ScheduleEntry>(); int mxfIndex = 0; int storeIndex = 1; DateTime lastMXFEndTime = new DateTime(0); while (mxfIndex < scheduleEntriesToMerge.Count()) { ScheduleEntry mxfEntry = scheduleEntriesToMerge[mxfIndex]; ScheduleEntry storeEntry = storeEntries[storeIndex]; if (lastMXFEndTime > storeEntry.StartTime) { ScheduleEntry lastMxfEntry = scheduleEntriesToMerge[mxfIndex - 1]; if (lastMXFEndTime > storeEntry.EndTime) { Util.Trace(TraceLevel.Verbose, "Store entry is contained within timeslot of previous MXF entry, removing it. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { deletes.Add(storeEntry); } ++storeIndex; continue; } Util.Trace(TraceLevel.Verbose, "Store entry overlaps with previous MXF entry. Truncating start. store: {0} mxf: {1}", storeEntry, lastMxfEntry); if (!Program.options.safeMode) { storeEntry.StartTime = lastMxfEntry.EndTime; updates.Add(storeEntry); ++storeIndex; continue; } } if (TimeIsAboutAtOrBefore(storeEntry.EndTime, mxfEntry.StartTime)) { Util.Trace(TraceLevel.Verbose, "Ignoring store ScheduleEntry {0} as it does not overlap the current MXF entry : {1}", storeEntry, mxfEntry); ++storeIndex; continue; } if (TimeslotsMatch(mxfEntry, storeEntry)) { lastMXFEndTime = storeEntry.EndTime; if (mxfEntry.Program.Id != storeEntry.Program.Id) { SeriesInfo mxfSeries = mxfEntry.Program.Series; SeriesInfo storeSeries = storeEntry.Program.Series; if (mxfSeries != null && storeSeries != null && mxfSeries.Id == storeSeries.Id && mxfEntry.Program.IsGeneric && !storeEntry.Program.IsGeneric) { Util.Trace(TraceLevel.Info, "Skipping update because the MXF has a generic entry while DB already has a specific episode: store: {0} mxf: {1}", storeEntry, mxfEntry); } else { Util.Trace(TraceLevel.Warning, "Programs do not match after normal ScheduleEntriesToMerge, queueing update. Store: {0} MXF: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { storeEntry.Program = mxfEntry.Program; MergeProgramsInjector.UpdateScheduleEntryFlags(mxfEntry, storeEntry); updates.Add(storeEntry); } } } else if (!MergeProgramsInjector.ScheduleEntryFlagsMatch(storeEntry, mxfEntry)) { Util.Trace(TraceLevel.Warning, "Mismatched scheduleEntry flags found, queueing update. store: {0} MXF: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { MergeProgramsInjector.UpdateScheduleEntryFlags(mxfEntry, storeEntry); // MS MergeScheduleEntries treats this as an add/remove rather than an update. I don't like this, hopefully // this way can work. updates.Add(storeEntry); } } else { Util.Trace(TraceLevel.Verbose, "Entry for store and MXF already match: {0}", storeEntry); } ++mxfIndex; ++storeIndex; continue; } ScheduleEntry lastStoreEntry = storeEntries[storeIndex - 1]; // If we get here, store entry ends after mxf entry starts. Find out if the program ID matches; it may be only a timeslot change. if (storeEntry.Program.Id == mxfEntry.Program.Id) { Util.Trace(TraceLevel.Warning, "DB entry overlapping the MXF ScheduleEntry has the same program. Updating the timeslot and possibly flags. store: {0} MXF: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { if (TimeApproxEquals(mxfEntry.StartTime, lastStoreEntry.EndTime)) { storeEntry.StartTime = lastStoreEntry.EndTime; } else { storeEntry.StartTime = mxfEntry.StartTime; } ScheduleEntry nextStoreEntry = storeEntries[storeIndex + 1]; if (TimeApproxEquals(mxfEntry.EndTime, nextStoreEntry.StartTime)) { storeEntry.EndTime = nextStoreEntry.StartTime; } else { storeEntry.EndTime = mxfEntry.EndTime; } MergeProgramsInjector.UpdateScheduleEntryFlags(mxfEntry, storeEntry); updates.Add(storeEntry); } lastMXFEndTime = storeEntry.EndTime; ++mxfIndex; ++storeIndex; continue; } if (storeEntry.StartTime < mxfEntry.StartTime && TimeIsAboutAtOrBefore(storeEntry.EndTime, mxfEntry.EndTime)) { Util.Trace(TraceLevel.Warning, "DB entry overlapping MXF ScheduleEntry is earlier. Truncating the end of it. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { storeEntry.EndTime = mxfEntry.StartTime; updates.Add(storeEntry); } ++storeIndex; continue; } if (TimeIsAboutAtOrBefore(mxfEntry.StartTime, storeEntry.StartTime) && TimeIsAboutAtOrBefore(storeEntry.EndTime, mxfEntry.EndTime)) { Util.Trace(TraceLevel.Warning, "DB entry timeslot is within MXF ScheduleEntry timeslot. Deleting it. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { deletes.Add(storeEntry); } ++storeIndex; continue; } if (TimeIsAboutAtOrBefore(mxfEntry.EndTime, storeEntry.StartTime)) { Util.Trace(TraceLevel.Warning, "Next db entry is entirely after the MXF entry. Adding the MXF entry. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { // check for rounding error. if (mxfEntry.EndTime > storeEntry.StartTime) mxfEntry.EndTime = storeEntry.StartTime; adds.Add(mxfEntry); } lastMXFEndTime = mxfEntry.EndTime; ++mxfIndex; continue; } // If we ge there, store entry starts within MXF entry and ends later. Util.Trace(TraceLevel.Warning, "Overlapping store entry is at end of MXF ScheduleEntry. Truncating the start. store: {0} mxf: {1}", storeEntry, mxfEntry); if (!Program.options.safeMode) { storeEntry.StartTime = mxfEntry.EndTime; updates.Add(storeEntry); } ++storeIndex; } if (!Program.options.safeMode && updates.Count + adds.Count + deletes.Count > 0) { List<ScheduleEntry> emptyList = new List<ScheduleEntry>(); ApplyMergedScheduleEntriesToStore(targetService, emptyList, emptyList, deletes); ApplyMergedScheduleEntriesToStore(targetService, updates, emptyList, emptyList); ApplyMergedScheduleEntriesToStore(targetService, emptyList, adds, emptyList); } } finally { targetService.ReleaseUpdateLock(mutex); } }
private void ReplacementMergeScheduleEntries(ScheduleEntry[] scheduleEntriesToMerge) { ReplacementMergeScheduleEntriesInner(scheduleEntriesToMerge); }
private bool ProgramIdsMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return mxfEntry.Program.GetUIdValue() == storeEntry.Program.GetUIdValue(); }
private void OriginalMergeScheduleEntries(ScheduleEntry[] scheduleEntriesToMerge) { }
private ScheduleEntry FindStartScheduleEntry(StoredObjectsEnumerator<ScheduleEntry> enumerator, ScheduleEntry scheduleEntryToMerge) { ScheduleEntry result = (ScheduleEntry)FindStartScheduleEntry_.Invoke( ThisAsScheduleEntries(), new object[] { enumerator, scheduleEntryToMerge }); if (result == null) { Util.Trace(TraceLevel.Error, "FindStartScheduleEntry returned null for ScheduleEntry {0}", scheduleEntryToMerge); result = enumerator.Current; } return result; }
private bool TimeslotsOverlap(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return(TimeIsBetween(mxfEntry.StartTime, storeEntry.StartTime, storeEntry.EndTime) || TimeIsBetween(mxfEntry.EndTime, storeEntry.StartTime, storeEntry.EndTime) || TimeIsBetween(storeEntry.StartTime, mxfEntry.StartTime, mxfEntry.EndTime) || TimeslotsExactMatch(mxfEntry, storeEntry)); }
private void ApplyUpdatedScheduleEntryToStore(ScheduleEntry entry) { ApplyMergedScheduleEntriesToStore( entry.Service, new List<ScheduleEntry> { entry }, new List<ScheduleEntry>(), new List<ScheduleEntry>()); }
public static bool ScheduleEntryProgramsAndTimeslotMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return mxfEntry.Program != null && storeEntry.Program != null && mxfEntry.Program.Id == storeEntry.Program.Id && TimeslotsMatch(mxfEntry, storeEntry); }
public void GetScheduleEntry() { ScheduleEntry e = RunTest(ScheduleEntry.GetScheduleEntry(Api, Settings.TestProject, Settings.TestEvent)); Assert.AreEqual(Settings.TestEvent, e.id); }
private bool TimeslotsExactMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return (mxfEntry.StartTime == storeEntry.StartTime) && (mxfEntry.EndTime == storeEntry.EndTime); }
public static void UpdateScheduleEntryFlags(ScheduleEntry src, ScheduleEntry dst) { foreach(PropertyInfo property in scheduleEntryPropertiesToCompare_) property.SetValue(dst, property.GetValue(src, null), null); }
private bool TimeslotsOverlap(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return TimeIsBetween(mxfEntry.StartTime, storeEntry.StartTime, storeEntry.EndTime) || TimeIsBetween(mxfEntry.EndTime, storeEntry.StartTime, storeEntry.EndTime) || TimeIsBetween(storeEntry.StartTime, mxfEntry.StartTime, mxfEntry.EndTime) || TimeslotsExactMatch(mxfEntry, storeEntry); }
// Placeholder to copy the original MergePrograms implmentation into public Microsoft.MediaCenter.Guide.Program OriginalMergePrograms(ScheduleEntry source, ScheduleEntry existing, Service targetService) { return null; }
private static int CompareScheduleEntryStartTimes(ScheduleEntry entry1, ScheduleEntry entry2) { if (entry1.StartTime < entry2.StartTime) return -1; if (entry2.StartTime < entry1.StartTime) return 1; return 0; }
public Microsoft.MediaCenter.Guide.Program ReplacementMergePrograms(ScheduleEntry source, ScheduleEntry existing, Service targetService) { var program = OriginalMergePrograms(source, existing, targetService); if (program.GetUIdValue() == source.Program.GetUIdValue() && !ScheduleEntryFlagsMatch(source, existing)) { if (!Program.options.safeMode) { Util.Trace(TraceLevel.Warning, "ScheduleEntry flags do not match. Updating flags in the db: MXF: {0} Store: {1}", source, existing); UpdateScheduleEntryFlags(source, existing); existing.Update(); } } return program; }
public void DeleteSchedules(ScheduleEntry[] scheduleEntries) { lock (_lock) { foreach (ScheduleEntry scheduleEntry in scheduleEntries) { _schedules.Remove(scheduleEntry); } } Save(); }
public static bool ScheduleEntryProgramsAndTimeslotMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return(mxfEntry.Program != null && storeEntry.Program != null && mxfEntry.Program.Id == storeEntry.Program.Id && TimeslotsMatch(mxfEntry, storeEntry)); }
public ScheduleEntryDTO SaveScheduleEntry(ScheduleEntryDTO entry) { Log.WriteWarning("SaveScheduleEntry:Username={0},entryId={1}", SecurityInfo.SessionData.Profile.UserName, entry.GlobalId); ScheduleEntry db = null; if (!SecurityInfo.Licence.IsInstructor) { throw new LicenceException("This feature is allowed for Instructor account"); } using (var trans = Session.BeginSaveTransaction()) { var dbProfile = Session.Load <Profile>(SecurityInfo.SessionData.Profile.GlobalId); int count = Session.QueryOver <ScheduleEntry>().Where( x => x.Profile == dbProfile && x.GlobalId != entry.GlobalId && (x.StartTime <= entry.StartTime && x.EndTime > entry.StartTime || x.StartTime < entry.EndTime && x.EndTime >= entry.EndTime)).RowCount(); if (count > 0) { throw new AlreadyOccupiedException("This user is busy at the selected time"); } if (entry.GlobalId != Constants.UnsavedGlobalId) { db = Session.Get <ScheduleEntry>(entry.GlobalId); Mapper.Map(entry, db); } else { db = entry.Map <ScheduleEntry>(); db.Profile = dbProfile; } if (entry.MyPlaceId == null) { db.MyPlace = Session.QueryOver <MyPlace>().Where(x => x.Profile == dbProfile && x.IsDefault).SingleOrDefault(); } if (db.MyPlace.Profile != dbProfile) { throw new CrossProfileOperationException("MyPlace not belong to this user"); } db.Activity = Session.Get <Activity>(entry.ActivityId); if (entry.CustomerGroupId.HasValue) { db.CustomerGroup = Session.Get <CustomerGroup>(entry.CustomerGroupId); if (db.CustomerGroup.Profile != dbProfile) { throw new CrossProfileOperationException("Group not belong to this user"); } } if (db.Activity.Profile != dbProfile) { throw new CrossProfileOperationException("Activity not belong to this user"); } dbProfile.DataInfo.ScheduleEntryHash = Guid.NewGuid(); db = Session.Merge(db); trans.Commit(); } return(Mapper.Map <ScheduleEntry, ScheduleEntryDTO>(db)); }
private static bool TimeslotsMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return(TimeApproxEquals(mxfEntry.StartTime, storeEntry.StartTime) && TimeApproxEquals(mxfEntry.EndTime, storeEntry.EndTime)); }
public VerifyLoad(string mxfFile, bool verbose = false) { if (mxfFile.StartsWith("http")) { mxfFile = Helper.Epg123MxfPath; } mxf mxf; Logger.WriteMessage("Entering VerifyLoad()"); Helper.SendPipeMessage("Importing|Verifying MXF Load..."); using (var stream = new StreamReader(mxfFile)) { var serializer = new XmlSerializer(typeof(mxf)); TextReader reader = new StringReader(stream.ReadToEnd()); mxf = (mxf)serializer.Deserialize(reader); reader.Close(); } if (!(mxf.Providers[0]?.Name ?? string.Empty).Equals("EPG123") && !(mxf.Providers[0]?.Name ?? string.Empty).Equals("HDHR2MXF")) { Logger.WriteInformation("The imported MXF file is not a guide listings file created by EPG123. Skipping schedule entry verifications."); Logger.WriteInformation("Exiting VerifyLoad()"); return; } var entriesChecked = 0; var correctedCount = 0; foreach (var mxfService in mxf.With[0].Services) { // get wmcService that matches mxfService using the UId Service wmcService = null; try { wmcService = WmcStore.WmcObjectStore.UIds[mxfService.Uid].Target as Service; } catch { // ignored } if (wmcService == null) { Logger.WriteError($"Service {mxfService.Uid}: {mxfService.CallSign} is not present in the WMC database."); continue; } // get schedule entries for service var mxfScheduleEntries = mxf.With[0].ScheduleEntries.FirstOrDefault(scheduleEntries => scheduleEntries.Service != null && scheduleEntries.Service.Equals(mxfService.Id)); if (mxfScheduleEntries == null || mxfScheduleEntries.ScheduleEntry.Count == 0) { continue; } // check to see if the service has any schedule entries if (wmcService.ScheduleEntries.Empty && mxfScheduleEntries.ScheduleEntry.Count > 0) { if (verbose) { Logger.WriteInformation($"Service {mxfService.Uid}: {mxfService.CallSign} does not have any schedule entries in the WMC database."); } continue; } // check mxf file for discontinuities var discontinuities = -1; var mxfStartTime = DateTime.MinValue; foreach (var entry in mxfScheduleEntries.ScheduleEntry.Where(entry => entry.StartTime != DateTime.MinValue)) { if (mxfStartTime == DateTime.MinValue) { mxfStartTime = entry.StartTime; } ++discontinuities; if (discontinuities != 1) { continue; } Logger.WriteInformation($"Service {mxfService.Uid}: {mxfService.CallSign} has a time discontinuity at {entry.StartTime.ToLocalTime()}. Skipping verification of this station's schedule entries."); break; } if (discontinuities > 0) { continue; } if (mxfStartTime > DateTime.UtcNow) { Logger.WriteInformation($"Service {mxfService.Uid}: {mxfService.CallSign}: first mxf schedule entry to verify is in the future at {mxfStartTime.ToLocalTime()}."); } // build a list of wmc schedule entries based on start times var wmcScheduleEntryTimes = new Dictionary <DateTime, ScheduleEntry>(wmcService.ScheduleEntries.Count()); foreach (ScheduleEntry wmcScheduleEntry in wmcService.ScheduleEntries) { try { if (wmcScheduleEntry.LockCount == 0 || wmcScheduleEntry.Program == null) { throw new Exception(); } wmcScheduleEntryTimes.Add(wmcScheduleEntry.StartTime, wmcScheduleEntry); } catch { // remove duplicate start time entry; probably from a discontinuity try { RemoveScheduleEntry(wmcScheduleEntry); } catch { // ignored } } } // make everything right try { var mxfLastStartTime = DateTime.MinValue; foreach (var mxfScheduleEntry in mxfScheduleEntries.ScheduleEntry) { ++entriesChecked; // update mxfScheduleEntry start time if needed if (mxfScheduleEntry.StartTime != DateTime.MinValue) { mxfStartTime = mxfScheduleEntry.StartTime; } // only verify programs that are in the future and not currently showing or is the next showing if (mxfStartTime < DateTime.UtcNow || DateTime.UtcNow > mxfLastStartTime && DateTime.UtcNow < mxfStartTime + TimeSpan.FromSeconds(mxfScheduleEntry.Duration)) { wmcScheduleEntryTimes.Remove(mxfStartTime); mxfLastStartTime = mxfStartTime; mxfStartTime += TimeSpan.FromSeconds(mxfScheduleEntry.Duration); continue; } // find the program in the MXF file for this schedule entry var mxfProgram = mxf.With[0].Programs[int.Parse(mxfScheduleEntry.Program) - 1]; var mxfEndTime = mxfStartTime + TimeSpan.FromSeconds(mxfScheduleEntry.Duration); // verify a schedule entry exists matching the MXF file and determine whether there needs to be intervention var addEntry = false; var replaceEntry = false; if (!wmcScheduleEntryTimes.TryGetValue(mxfStartTime, out var wmcScheduleEntry)) { addEntry = true; } else if (wmcScheduleEntry.Program.GetUIdValue() != mxfProgram.Uid) { if (!IsSameSeries(wmcScheduleEntry.Program, mxfProgram)) { if (wmcScheduleEntry.EndTime == mxfEndTime && wmcScheduleEntry.ProgramContent == null) { replaceEntry = true; } else { addEntry = true; } } else if (wmcScheduleEntry.ProgramContent == null || wmcScheduleEntry.Program.IsGeneric) { replaceEntry = true; } else if (wmcScheduleEntry.Program.IsMovie && wmcScheduleEntry.Program.Description.Equals(mxfProgram.Description)) { replaceEntry = true; } else { addEntry = true; } } if (addEntry) { try { if (verbose) { Logger.WriteInformation($"Service {mxfService.CallSign}: Adding schedule entry from {mxfStartTime.ToLocalTime()} to {mxfEndTime.ToLocalTime()} for program [{mxfProgram.Uid.Substring(9)} - [{mxfProgram.Title}] - [{mxfProgram.EpisodeTitle}]]."); } var addProgram = WmcStore.WmcObjectStore.UIds[mxfProgram.Uid].Target as Program; var addScheduleEntry = new ScheduleEntry(addProgram, wmcService, mxfStartTime, TimeSpan.FromSeconds(mxfScheduleEntry.Duration), mxfScheduleEntry.Part, mxfScheduleEntry.Parts); UpdateScheduleEntryTags(addScheduleEntry, mxfScheduleEntry); WmcStore.WmcObjectStore.Add(addScheduleEntry); ++correctedCount; } catch (Exception e) { Logger.WriteWarning($"Service {mxfService.CallSign}: Failed to add schedule entry from {mxfStartTime.ToLocalTime()} to {mxfEndTime.ToLocalTime()} for program [{mxfProgram.Uid.Substring(9)} - [{mxfProgram.Title}] - [{mxfProgram.EpisodeTitle}]].\nmessage {e.Message}\n{e.StackTrace}"); break; } } if (replaceEntry) { if (verbose) { Logger.WriteInformation($"Service {mxfService.CallSign}: Replacing schedule entry program on {mxfStartTime.ToLocalTime()} from [{wmcScheduleEntry.Program.GetUIdValue().Substring(9)} - [{wmcScheduleEntry.Program.Title}]-[{wmcScheduleEntry.Program.EpisodeTitle}]] to [{mxfProgram.Uid.Substring(9)} - [{mxfProgram.Title}]-[{mxfProgram.EpisodeTitle}]]"); } UpdateScheduleEntryTags(wmcScheduleEntry, mxfScheduleEntry); wmcScheduleEntry.Update(delegate { wmcScheduleEntry.Program = WmcStore.WmcObjectStore.UIds[mxfProgram.Uid].Target as Program; wmcScheduleEntry.EndTime = mxfEndTime; }); ++correctedCount; if (wmcScheduleEntry.ProgramContent != null) { UpdateOneTimeRequest(wmcScheduleEntry); } } if (!addEntry && Math.Abs(wmcScheduleEntry.Duration.TotalSeconds - mxfScheduleEntry.Duration) > 1.0) { // change the start time of the next wmc schedule entry if possible/needed if (!wmcScheduleEntryTimes.ContainsKey(mxfEndTime) && wmcScheduleEntryTimes.TryGetValue(wmcScheduleEntry.EndTime, out var scheduleEntry) && scheduleEntry.EndTime > mxfEndTime) { try { wmcScheduleEntryTimes.Remove(scheduleEntry.StartTime); scheduleEntry.Update(delegate { scheduleEntry.StartTime = mxfEndTime; }); wmcScheduleEntryTimes.Add(scheduleEntry.StartTime, scheduleEntry); } catch { // ignored } } // correct the end time of current wmc schedule entry try { if (verbose) { Logger.WriteInformation($"Service {mxfService.CallSign} at {mxfStartTime.ToLocalTime()}: Changing end time of [{wmcScheduleEntry.Program.GetUIdValue().Substring(9)} - [{wmcScheduleEntry.Program.Title}]-[{wmcScheduleEntry.Program.EpisodeTitle}]] from {wmcScheduleEntry.EndTime.ToLocalTime()} to {mxfEndTime.ToLocalTime()}"); } wmcScheduleEntry.Update(delegate { wmcScheduleEntry.EndTime = mxfEndTime; }); } catch (Exception e) { Logger.WriteWarning($"Service {mxfService.CallSign} at {mxfStartTime.ToLocalTime()}: Failed to change end time of [{wmcScheduleEntry.Program.GetUIdValue().Substring(9)} - [{wmcScheduleEntry.Program.Title}]-[{wmcScheduleEntry.Program.EpisodeTitle}]] from {wmcScheduleEntry.EndTime.ToLocalTime()} to {mxfEndTime.ToLocalTime()}\nmessage {e.Message}\n{e.StackTrace}"); break; } } if (!addEntry) { wmcScheduleEntryTimes.Remove(mxfStartTime); } mxfLastStartTime = mxfStartTime; mxfStartTime = mxfEndTime; } // remove orphaned wmcScheduleEntries foreach (var orphans in wmcScheduleEntryTimes) { try { if (orphans.Value.StartTime <= DateTime.UtcNow || orphans.Value.StartTime >= mxfStartTime) { continue; } if (verbose) { Logger.WriteInformation($"Service {mxfService.CallSign}: Removing schedule entry on {orphans.Value.StartTime.ToLocalTime()} for [{orphans.Value.Program.GetUIdValue().Replace("!Program!", "")} - [{orphans.Value.Program.Title}]-[{orphans.Value.Program.EpisodeTitle}]] due to being replaced/overlapped by another schedule entry."); } RemoveScheduleEntry(orphans.Value); } catch (Exception e) { if (verbose) { Logger.WriteInformation($"Service {mxfService.CallSign} at {orphans.Value.StartTime.ToLocalTime()}: Failed to remove [{orphans.Value.Program.GetUIdValue().Replace("!Program!", "")} - [{orphans.Value.Program.Title}]-[{orphans.Value.Program.EpisodeTitle}]] due to being overlapped by another schedule entry.\nmessage {e.Message}\n{e.StackTrace}"); } } } } catch (Exception e) { Logger.WriteInformation($"Exception caught for {mxfService.CallSign} at {mxfStartTime.ToLocalTime()}, message {e.Message}\n{e.StackTrace}"); } } Logger.WriteInformation($"Checked {entriesChecked} entries and corrected {correctedCount} of them."); Logger.WriteMessage("Exiting VerifyLoad()"); }
private bool TimeslotsExactMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return((mxfEntry.StartTime == storeEntry.StartTime) && (mxfEntry.EndTime == storeEntry.EndTime)); }
private static bool ShouldRunSchedule(ScheduleEntry schedule) { bool shouldRun = false; if (!schedule.LastRun.HasValue) { shouldRun = true; } else if (schedule.LastRun + schedule.RunEvery < DateTime.Now) { shouldRun = true; } if (shouldRun & schedule.RunOnlyAtNight) { shouldRun = IsCurrentlyNight(); } return shouldRun; }
private ScheduleEntry FindStartScheduleEntry(StoredObjectsEnumerator <ScheduleEntry> enumerator, ScheduleEntry scheduleEntryToMerge) { ScheduleEntry result = (ScheduleEntry)FindStartScheduleEntry_.Invoke( ThisAsScheduleEntries(), new object[] { enumerator, scheduleEntryToMerge }); if (result == null) { Util.Trace(TraceLevel.Error, "FindStartScheduleEntry returned null for ScheduleEntry {0}", scheduleEntryToMerge); result = enumerator.Current; } return(result); }
private static bool TimeslotsMatch(ScheduleEntry mxfEntry, ScheduleEntry storeEntry) { return TimeApproxEquals(mxfEntry.StartTime, storeEntry.StartTime) && TimeApproxEquals(mxfEntry.EndTime, storeEntry.EndTime); }
/// <summary> /// Determines whether a schedule entry actually occurs in the future. /// </summary> /// <param name="scheduleEntry">The EPG schedule entry.</param> /// <returns>True if the schedule entry is in the future; false otherwise.</returns> private static bool FutureAiring(ScheduleEntry scheduleEntry) { return scheduleEntry.StartTime >= DateTime.Now; }
/// <summary> /// Patch schedule on a Premium Cluster Cache. /// </summary> /// <param name="scheduleEntry">Patch schedule entry for Premium Redis Cache.</param> /// <return>The next stage of Redis Cache with Premium SKU definition.</return> RedisCache.Update.IUpdate RedisCache.Update.IUpdate.WithPatchSchedule(ScheduleEntry scheduleEntry) { return(this.WithPatchSchedule(scheduleEntry) as RedisCache.Update.IUpdate); }
private void ExecuteSchedule(ScheduleEntry schedule) { if (ShouldRunSchedule(schedule)) { _log.Log($"Running schedule: {schedule}"); SlackChatHubType channelType = schedule.ChannelType == ResponseType.Channel ? SlackChatHubType.Channel : SlackChatHubType.DM; var slackMessage = new SlackMessage { Text = schedule.Command, User = new SlackUser { Id = schedule.UserId, Name = schedule.UserName }, ChatHub = new SlackChatHub { Id = schedule.Channel, Type = channelType }, }; _noobotCore.MessageReceived(slackMessage); schedule.LastRun = DateTime.Now; } }
/// <summary> /// Patch schedule on a Premium Cluster Cache. /// </summary> /// <param name="scheduleEntry">Patch schedule entry for Premium Redis Cache.</param> /// <return>The next stage of Redis Cache with Premium SKU definition.</return> RedisCache.Definition.IWithPremiumSkuCreate RedisCache.Definition.IWithPremiumSkuCreate.WithPatchSchedule(ScheduleEntry scheduleEntry) { return(this.WithPatchSchedule(scheduleEntry) as RedisCache.Definition.IWithPremiumSkuCreate); }
// Private - medium level Object Store private bool GetScheduleEntryWithID(string progUID, out ScheduleEntry se) { se = null; long UID; if (!long.TryParse(progUID, NumberStyles.Any, CultureInfo.GetCultureInfo("EN-US"), out UID)) return false; StoredObject so = os.Fetch(UID); if (!(so is ScheduleEntry)) return false; se = (ScheduleEntry)so; return true; }
public void PatchSchedules_PutGetDelete() { using (var context = MockContext.Start(this.GetType().FullName)) { var _redisCacheManagementHelper = new RedisCacheManagementHelper(this, context); _redisCacheManagementHelper.TryRegisterSubscriptionForResource(); var resourceGroupName = TestUtilities.GenerateName("RedisSchedules"); var redisCacheName = TestUtilities.GenerateName("RedisSchedules"); var _client = RedisCacheManagementTestUtilities.GetRedisManagementClient(this, context); _redisCacheManagementHelper.TryCreateResourceGroup(resourceGroupName, RedisCacheManagementHelper.Location); _client.Redis.Create(resourceGroupName, redisCacheName, parameters: new RedisCreateParameters { Location = RedisCacheManagementHelper.Location, Sku = new Sku() { Name = SkuName.Premium, Family = SkuFamily.P, Capacity = 1 } }); // First try to get cache and verify that it is premium cache RedisResource response = _client.Redis.Get(resourceGroupName, redisCacheName); Assert.Contains(redisCacheName, response.Id); Assert.Equal(redisCacheName, response.Name); Assert.Equal("succeeded", response.ProvisioningState, ignoreCase: true); Assert.Equal(SkuName.Premium, response.Sku.Name); Assert.Equal(SkuFamily.P, response.Sku.Family); ScheduleEntry[] entries = new ScheduleEntry[] { new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Monday, StartHourUtc = 10, MaintenanceWindow = TimeSpan.FromHours(10) }, new ScheduleEntry { DayOfWeek = DayOfWeekEnum.Tuesday, StartHourUtc = 11, MaintenanceWindow = TimeSpan.FromHours(11) } }; ValidateResponseForSchedulePatch( _client.PatchSchedules.CreateOrUpdate( resourceGroupName, redisCacheName, parameters: new RedisPatchSchedule(entries)), redisCacheName); ValidateResponseForSchedulePatch( _client.PatchSchedules.Get(resourceGroupName, redisCacheName), redisCacheName); _client.PatchSchedules.Delete(resourceGroupName, redisCacheName); var ex = Assert.Throws <CloudException>(() => _client.PatchSchedules.Get(resourceGroupName, redisCacheName)); Assert.Contains("There are no patch schedules found for redis cache", ex.Message); } }
public IActionResult RemovePromotion(int Id) { ScheduleEntry obj = _db.ScheduleEntry.Find(Id); return(View(obj)); }
public void GetScheduleEntries() { ApiList <ScheduleEntry> entries = RunTest(ScheduleEntry.GetScheduleEntries(Api, Settings.TestProject, Settings.TestSchedule)); Assert.IsTrue(entries.All(Api).Any(e => e.id == Settings.TestEvent)); }
public Request ScheduleOneTimeRecording(ScheduleEntry scheduleEntry) { var channel = scheduleEntry.Service.GetBestChannel(channels.Value); OneTimeRequest req = recScheduler.CreateOneTimeRequest(scheduleEntry, channel); // Add 5 minutes of padding on either end req.PrePaddingRequested = TimeSpan.FromSeconds(300); req.PostPaddingRequested = TimeSpan.FromSeconds(300); req.Quality = RecordQualityBest; req.UpdateRequestedPrograms(); UpdateDelegate upd = new UpdateDelegate(ScheduleRecording_Done); req.UpdateAndSchedule(upd, recScheduler); return req; }
public void GetSubscriptions() { ScheduleEntry e = ScheduleEntry.GetScheduleEntry(Api, Settings.TestProject, Settings.TestEvent).Result; RunTest(Subscription.GetSubscription(Api, e)); }
public static TVProgramme TVProgrammeFromScheduleEntry(ScheduleEntry se, bool omitDescription) { TVProgramme tvp = new TVProgramme(); Program p = se.Program; if (p == null) return null; tvp.MCProgramID = string.Copy( p.Id.ToString("G17") ); Service tvs = se.Service; if (tvs == null) return null; if (! string.IsNullOrEmpty(p.Title)) tvp.Title = string.Copy( p.Title ); if (!string.IsNullOrEmpty(p.EpisodeTitle)) { if (p.EpisodeNumber > 0) tvp.EpisodeTitle = string.Copy( p.EpisodeNumber.ToString() ) + ". " + string.Copy( p.EpisodeTitle ); else tvp.EpisodeTitle = string.Copy( p.EpisodeTitle ); } if (!omitDescription) { if (!string.IsNullOrEmpty(p.Description)) tvp.Description = string.Copy( p.Description ); if (p.GuideImage != null) if (!string.IsNullOrEmpty(p.GuideImage.AbsoluteUri)) tvp.GuideImageUri = string.Copy(p.GuideImage.AbsoluteUri); } else { tvp.Description = ""; // OMIT description to keep transfer to client lean tvp.GuideImageUri = ""; } //if (!string.IsNullOrEmpty(p.StarRating)) if (p.HalfStars > 0) tvp.StarRating = p.HalfStars; if (!string.IsNullOrEmpty(p.MpaaRatingString)) tvp.MPAARating = string.Copy( p.MpaaRatingString ); if (!string.IsNullOrEmpty(se.TVRatingString)) tvp.TVRating = string.Copy ( se.TVRatingString ); if (p.OriginalAirdate != null) tvp.OriginalAirDate = p.OriginalAirdate.Ticks; // Flags tvp.HasSubtitles = se.IsSubtitled; tvp.IsFirstShowing = (!se.IsRepeat); tvp.IsHD = (se.IsHdtv); tvp.ProgramType = ProgrammeTypeForProgram(p); // Series? SeriesInfo si = p.Series; if (si != null) { tvp.IsSeries = true; tvp.SeriesID = si.Id; } else tvp.IsSeries = false; tvp.StartTime = se.StartTime.Ticks; tvp.StopTime = se.EndTime.Ticks; tvp.Id = string.Copy ( se.Id.ToString("G17") ); // CHANNEL tvp.ServiceID = string.Copy ( tvs.Id.ToString("G17") ); return tvp; }