Example #1
0
 /// <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);
     }
 }
Example #2
0
        /// <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);
                }
            }
        }