Exemple #1
0
 private static void ProcessEvent()
 {
     try
     {
         DateTime     now   = DateTime.Now;
         int          num   = (now.Hour * 60 + now.Minute) * 60;
         int          num2  = 0;
         List <Event> list  = new List <Event>();
         List <Event> list2 = new List <Event>();
         List <Event> list3 = new List <Event>();
         foreach (Event @event in EventDataContext.Instance.Event)
         {
             if (@event.StartTime == null && !(@event.StartCount > 0))
             {
                 if (@event.EndTime == null || now < @event.EndTime)
                 {
                     list.Add(@event);
                 }
                 else
                 {
                     list3.Add(@event);
                 }
             }
             else if (@event.StartTime != null)
             {
                 if (now >= @event.StartTime)
                 {
                     if (@event.EndTime == null || now < @event.EndTime)
                     {
                         if (@event.PeriodBegin == null)
                         {
                             list.Add(@event);
                         }
                         else if (now.TimeOfDay >= @event.PeriodBegin)
                         {
                             if (@event.PeriodEnd == null || now.TimeOfDay < @event.PeriodEnd)
                             {
                                 list.Add(@event);
                             }
                             else
                             {
                                 list2.Add(@event);
                             }
                         }
                         else
                         {
                             list2.Add(@event);
                         }
                     }
                     else
                     {
                         list3.Add(@event);
                     }
                 }
                 else
                 {
                     list2.Add(@event);
                 }
             }
             else if (@event.StartCount > 0)
             {
                 if (@event.StartCount <= EventDataContext.Instance.GetEventCount(@event.Name))
                 {
                     if (@event.EndTime == null || now < @event.EndTime)
                     {
                         if (@event.PeriodBegin == null)
                         {
                             list.Add(@event);
                         }
                         else if (now.TimeOfDay >= @event.PeriodBegin)
                         {
                             if (@event.PeriodEnd == null || now.TimeOfDay < @event.PeriodEnd)
                             {
                                 list.Add(@event);
                             }
                             else
                             {
                                 list2.Add(@event);
                             }
                         }
                         else
                         {
                             list2.Add(@event);
                         }
                     }
                     else
                     {
                         list3.Add(@event);
                     }
                 }
                 else
                 {
                     list2.Add(@event);
                 }
             }
         }
         foreach (Event event2 in list3)
         {
             EventDataContext.RemoveEvent(event2.Name);
         }
         foreach (Event event3 in list2)
         {
             EventDataContext.EndEvent(event3.Name);
         }
         foreach (KeyValuePair <string, Event> keyValuePair in EventDataContext.runnings)
         {
             Event value = keyValuePair.Value;
             if (value.NotifyMessage != null && value.NotifyMessage.Length > 0)
             {
                 int num3 = 1800;
                 if (value.NotifyInterval != null && value.NotifyInterval.Value >= 0)
                 {
                     num3 = value.NotifyInterval.Value;
                 }
                 num3 = num3 / 60 * 60;
                 if (num3 != 0 && num % num3 == 0)
                 {
                     Scheduler.Schedule(EventDataContext.Thread, Job.Create <string, int>(new Action <string, int>(EventDataContext.BroadcastMessage), value.NotifyMessage, -1), ++num2 * 1000);
                 }
             }
         }
         foreach (Event event4 in list)
         {
             EventDataContext.StartEvent(event4.Name, event4);
         }
         EventDataContext.processed = true;
         foreach (KeyValuePair <int, string> keyValuePair2 in EventDataContext.waitingServiceList)
         {
             Scheduler.Schedule(EventDataContext.Thread, Job.Create <int, string>(new Action <int, string>(EventDataContext.SendToFeatureMaxtrixUpdate), keyValuePair2.Key, keyValuePair2.Value), 10000);
         }
         EventDataContext.waitingServiceList.Clear();
     }
     finally
     {
         EventDataContext.ScheduleNextProcess();
     }
 }