private static string GetTaskDayOfWeek(WlbScheduledTask.WlbTaskDaysOfWeek taskDaysOfWeek, WlbScheduledTask.WlbTaskDaysOfWeek taskDaysofWeekSortedList) { string returnStr = ""; returnStr += WlbScheduledTask.DaysOfWeekL10N(taskDaysOfWeek); //count the bits set in days of week. //this workaround had to be made to determine whether the original task was set for //weekends/weekdays/alldays uint bitCount = Bitcount((int)taskDaysofWeekSortedList); if (bitCount == 2) { returnStr += " (" + Messages.ResourceManager.GetString("WLB_DAY_WEEKENDS") + ")"; } else if (bitCount == 5) { returnStr += " (" + Messages.ResourceManager.GetString("WLB_DAY_WEEKDAYS") + ")"; } else if (bitCount == 7) { returnStr += " (" + Messages.ResourceManager.GetString("WLB_DAY_ALL") + ")"; } return(returnStr); }
public void NextAndPreviousDayOfTheWeek() { //Single days Dictionary <WlbScheduledTask.WlbTaskDaysOfWeek, WlbScheduledTask.WlbTaskDaysOfWeek> dotw = new Dictionary <WlbScheduledTask.WlbTaskDaysOfWeek, WlbScheduledTask.WlbTaskDaysOfWeek>() { { WlbScheduledTask.WlbTaskDaysOfWeek.Saturday, WlbScheduledTask.WlbTaskDaysOfWeek.Sunday }, { WlbScheduledTask.WlbTaskDaysOfWeek.Sunday, WlbScheduledTask.WlbTaskDaysOfWeek.Monday }, { WlbScheduledTask.WlbTaskDaysOfWeek.Monday, WlbScheduledTask.WlbTaskDaysOfWeek.Tuesday }, { WlbScheduledTask.WlbTaskDaysOfWeek.Tuesday, WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday }, { WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday, WlbScheduledTask.WlbTaskDaysOfWeek.Thursday }, { WlbScheduledTask.WlbTaskDaysOfWeek.Thursday, WlbScheduledTask.WlbTaskDaysOfWeek.Friday }, { WlbScheduledTask.WlbTaskDaysOfWeek.Friday, WlbScheduledTask.WlbTaskDaysOfWeek.Saturday } }; foreach (var day in dotw) { Assert.AreEqual(day.Value, WlbScheduledTask.NextDay(day.Key), "next day of the week"); Assert.AreEqual(day.Key, WlbScheduledTask.PreviousDay(day.Value), "previous day of the week"); } //Weekends const WlbScheduledTask.WlbTaskDaysOfWeek beforeWeekend = (WlbScheduledTask.WlbTaskDaysOfWeek.Friday | WlbScheduledTask.WlbTaskDaysOfWeek.Saturday); const WlbScheduledTask.WlbTaskDaysOfWeek afterWeekend = (WlbScheduledTask.WlbTaskDaysOfWeek.Sunday | WlbScheduledTask.WlbTaskDaysOfWeek.Monday); Assert.AreEqual(afterWeekend, WlbScheduledTask.NextDay(WlbScheduledTask.WlbTaskDaysOfWeek.Weekends)); Assert.AreEqual(beforeWeekend, WlbScheduledTask.PreviousDay(WlbScheduledTask.WlbTaskDaysOfWeek.Weekends)); //Weekdays const WlbScheduledTask.WlbTaskDaysOfWeek beforeWeek = (WlbScheduledTask.WlbTaskDaysOfWeek.Sunday | WlbScheduledTask.WlbTaskDaysOfWeek.Monday | WlbScheduledTask.WlbTaskDaysOfWeek.Tuesday | WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday | WlbScheduledTask.WlbTaskDaysOfWeek.Thursday); const WlbScheduledTask.WlbTaskDaysOfWeek afterWeek = (WlbScheduledTask.WlbTaskDaysOfWeek.Tuesday | WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday | WlbScheduledTask.WlbTaskDaysOfWeek.Thursday | WlbScheduledTask.WlbTaskDaysOfWeek.Friday | WlbScheduledTask.WlbTaskDaysOfWeek.Saturday); Assert.AreEqual(afterWeek, WlbScheduledTask.NextDay(WlbScheduledTask.WlbTaskDaysOfWeek.Weekdays)); Assert.AreEqual(beforeWeek, WlbScheduledTask.PreviousDay(WlbScheduledTask.WlbTaskDaysOfWeek.Weekdays)); const WlbScheduledTask.WlbTaskDaysOfWeek everyDay = (WlbScheduledTask.WlbTaskDaysOfWeek.Sunday | WlbScheduledTask.WlbTaskDaysOfWeek.Monday | WlbScheduledTask.WlbTaskDaysOfWeek.Tuesday | WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday | WlbScheduledTask.WlbTaskDaysOfWeek.Thursday | WlbScheduledTask.WlbTaskDaysOfWeek.Friday | WlbScheduledTask.WlbTaskDaysOfWeek.Saturday); Assert.AreEqual(everyDay, WlbScheduledTask.NextDay(WlbScheduledTask.WlbTaskDaysOfWeek.All)); Assert.AreEqual(everyDay, WlbScheduledTask.PreviousDay(WlbScheduledTask.WlbTaskDaysOfWeek.All)); }
/// <summary> /// Accepts a client's local time DayOfWeek and ExecuteTime of a scheduled task /// and returns the DaysOfWeek and ExecuteTime adjusted to UTC time /// </summary> /// <param name="LocalDaysOfWeek">Task's DaysOfWeek value in local time</param> /// <param name="LocalExecuteTime">Task's ExecuteTime in local time</param> /// <param name="UtcDaysOfWeek">(Output) Task's DaysOfWeek value adjusted to UTC</param> /// <param name="UtcExecuteTime">(Output) Task's ExecuteTime value adjusted to UTC</param> public static void GetUTCTaskTimes(WlbScheduledTask.WlbTaskDaysOfWeek LocalDaysOfWeek, DateTime LocalExecuteTime, out WlbScheduledTask.WlbTaskDaysOfWeek UtcDaysOfWeek, out DateTime UtcExecuteTime) { UtcDaysOfWeek = LocalDaysOfWeek; UtcExecuteTime = LocalExecuteTime.AddMinutes(LocalOffsetMinutes()); if (DateTime.Compare(LocalExecuteTime.Date, UtcExecuteTime.Date) < 0) { UtcDaysOfWeek = WlbScheduledTask.NextDay(LocalDaysOfWeek); } else if (DateTime.Compare(LocalExecuteTime.Date, UtcExecuteTime.Date) > 0) { UtcDaysOfWeek = WlbScheduledTask.PreviousDay(LocalDaysOfWeek); } }
public WlbScheduledTask.WlbTaskDaysOfWeek FindSelectedDay(WlbScheduledTask.WlbTaskDaysOfWeek daysOfWeek) { uint bitCount = WlbOptModeScheduler.Bitcount((int)daysOfWeek); if (bitCount == 2) { return(WlbScheduledTask.WlbTaskDaysOfWeek.Weekends); } else if (bitCount == 5) { return(WlbScheduledTask.WlbTaskDaysOfWeek.Weekdays); } else if (bitCount == 7) { return(WlbScheduledTask.WlbTaskDaysOfWeek.All); } return(daysOfWeek); }
/// <summary> /// Creates an artificial sort key that is used to sort the presentation of scheduled tasks. /// </summary> /// <param name="localDaysOfWeek">WlbScheduledTask.DaysOfWeek enumeration of the task denoting on which days it will execute</param> /// <param name="localExecuteTime">DateTime execute time of the task denoting on when the task </param> /// <returns></returns> private static int GetSortKey(WlbScheduledTask.WlbTaskDaysOfWeek localDaysOfWeek, DateTime localExecuteTime) { int sortKey; //The day of week is the primary sort item switch (localDaysOfWeek) { //Put ALL tasks at the front of the list case WlbScheduledTask.WlbTaskDaysOfWeek.All: { sortKey = 0; break; } //Next are WEEKDAY tasks case WlbScheduledTask.WlbTaskDaysOfWeek.Weekdays: { sortKey = 200000; break; } //Next are WEEKEND tasks case WlbScheduledTask.WlbTaskDaysOfWeek.Weekends: { sortKey = 400000; break; } //Finally, single-day tasks default: { sortKey = (int)localDaysOfWeek * 1000000; break; } } //Add the execute time of day as a secondary sort item //Multiply it by 100 to allow room for disabled tasks sortKey += (int)localExecuteTime.TimeOfDay.TotalMinutes * 100; return(sortKey); }
/// <summary> /// Accepts UTC DayOfWeek and ExecuteTime of a scheduled task /// and returns the DaysOfWeek and ExecuteTime adjusted to client's local time /// </summary> /// <param name="UtcDaysOfWeek">Task's DaysOfWeek value in UTC</param> /// <param name="UtcExecuteTime">Task's ExecuteTime in UTC</param> /// <param name="LocalDaysOfWeek">(Output) Task's DaysOfWeek value adjusted to local time</param> /// <param name="LocalExecuteTime">(Output) Task's ExecuteTime value adjusted to local time</param> public static void GetLocalTaskTimes(WlbScheduledTask.WlbTaskDaysOfWeek UtcDaysOfWeek, DateTime UtcExecuteTime, out WlbScheduledTask.WlbTaskDaysOfWeek LocalDaysOfWeek, out DateTime LocalExecuteTime) { LocalDaysOfWeek = UtcDaysOfWeek; LocalExecuteTime = UtcExecuteTime.AddMinutes(LocalOffsetMinutes() * -1); if (UtcDaysOfWeek != WlbTaskDaysOfWeek.None && UtcDaysOfWeek != WlbTaskDaysOfWeek.All && UtcDaysOfWeek != WlbTaskDaysOfWeek.Weekdays && UtcDaysOfWeek != WlbTaskDaysOfWeek.Weekends) { if (DateTime.Compare(UtcExecuteTime.Date, LocalExecuteTime.Date) < 0) { LocalDaysOfWeek = WlbScheduledTask.NextDay(UtcDaysOfWeek); } else if (DateTime.Compare(UtcExecuteTime.Date, LocalExecuteTime.Date) > 0) { LocalDaysOfWeek = WlbScheduledTask.PreviousDay(UtcDaysOfWeek); } } }
private string GetDayString(WlbScheduledTask.WlbTaskDaysOfWeek day) { return(WlbScheduledTask.DaysOfWeekL10N(day)); }
private string GetLocalizedDayOfWeek(WlbScheduledTask.WlbTaskDaysOfWeek daysOfWeek) { return(WlbScheduledTask.DaysOfWeekL10N(daysOfWeek)); }
private static string GetTaskDayOfWeek(WlbScheduledTask.WlbTaskDaysOfWeek taskDaysOfWeek) { return(WlbScheduledTask.DaysOfWeekL10N(taskDaysOfWeek)); }
public static DayOfWeek ConvertFromWlbTaskDayOfWeek(WlbScheduledTask.WlbTaskDaysOfWeek wlbDayOfWeek) { return((DayOfWeek)(Math.Log((int)wlbDayOfWeek, 2))); }
private void FindTheSelectedDay() { WlbScheduledTask.WlbTaskDaysOfWeek foundDay = dialog.FindSelectedDay(WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday); Assert.AreEqual(WlbScheduledTask.WlbTaskDaysOfWeek.Wednesday, foundDay); }