Exemplo n.º 1
0
 /// <summary>
 /// 發送
 /// </summary>
 /// <param name="timerStorageBase"></param>
 private static void sendTimerData(TimerStorageBase timerStorageBase, bool isRemoved)
 {
     if (timerStorageBase.TimePeriodCollection == null)
     {
         GlobalHost.ConnectionManager.GetHubContext <Controllers.TestHub>()
         .Clients.All.receiveTimersData(JsonConvert.SerializeObject(new
         {
             @DataId                = ((dynamic)timerStorageBase.ITimerEvent).Id,
             @Name                  = ((dynamic)timerStorageBase.ITimerEvent).Name,
             @StartDateTime         = String.Empty,
             @EndDateTime           = String.Empty,
             @NextExecutionDateTime = String.Empty,
             @Status                = (int)timerStorageBase.TimerStatus,
             @IsRemoved             = isRemoved
         }));
     }
     else
     {
         GlobalHost.ConnectionManager.GetHubContext <Controllers.TestHub>()
         .Clients.All.receiveTimersData(JsonConvert.SerializeObject(new
         {
             @DataId                = ((dynamic)timerStorageBase.ITimerEvent).Id,
             @Name                  = ((dynamic)timerStorageBase.ITimerEvent).Name,
             @StartDateTime         = timerStorageBase.TimePeriodCollection.First().Start,
             @EndDateTime           = timerStorageBase.TimePeriodCollection.First().End,
             @NextExecutionDateTime = timerStorageBase.NextExecuteDateTime,
             @Status                = (int)timerStorageBase.TimerStatus,
             @IsRemoved             = isRemoved
         }));
     }
 }
        private static void TimerStorage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            TimerStorageBase timerStorageBase = sender as TimerStorageBase;

            if (e.PropertyName == nameof(timerStorageBase.TimerStatus) && timerStorageBase.TimerStatus == TimerStatus.Stopped)
            {
                timerStorageBase.Dispose();
            }
        }
Exemplo n.º 3
0
        private static void TimersTimerStorage_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            TimerStorageBase timerStorageBase = sender as TimerStorageBase;

            if (e.PropertyName == nameof(timerStorageBase.TimerStatus))
            {
                Console.WriteLine($"{e.PropertyName} 的狀態變化為 {timerStorageBase.TimerStatus}");
            }
            else if (e.PropertyName == nameof(timerStorageBase.NextExecuteDateTime))
            {
                Console.WriteLine($"{e.PropertyName} 的時間變化為 {timerStorageBase.NextExecuteDateTime}");
            }
        }