Exemplo n.º 1
0
        ///<summary>
        /// 执行计划任务
        ///</summary>
        public static void Execute()
        {
            Config.Event[] simpleItems = WshelperConfigs.GetConfig().ScheduledEvents;

            List <Event> list = new List <Event>();

            foreach (Config.Event newEvent in simpleItems)
            {
                if (!newEvent.Enabled)
                {
                    continue;
                }
                Event e = new Event();
                e.Key          = newEvent.Key;
                e.ScheduleType = newEvent.ScheduleType;
                list.Add(e);
            }

            Event[] items = list.ToArray();
            Event   item  = null;

            for (int i = 0; i < items.Length; i++)
            {
                item = items[i];
                //if (item.ShouldExecute)
                //{
                //    item.UpdateTime();
                IEvent e = item.IEventInstance;
                ManagedThreadPool.QueueUserWorkItem(e.Execute);
                //}
            }
        }
Exemplo n.º 2
0
 static EventManager()
 {
     if (WshelperConfigs.GetConfig().TimerMinutesInterval > 0)
     {
         TimerMinutesInterval = WshelperConfigs.GetConfig().TimerMinutesInterval;
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 实现接口的Init方法
 /// </summary>
 /// <param name="context"></param>
 public void Init(HttpApplication context)
 {
     if (eventTimer == null && WshelperConfigs.GetConfig().ScheduledEnabled)
     {
         eventTimer = new Timer(ScheduledEventWorkCallback, context.Context, 0, EventManager.TimerMinutesInterval * 1000 * 60);
     }
 }
Exemplo n.º 4
0
 private void ScheduledEventWorkCallback(object sender)
 {
     try
     {
         if (WshelperConfigs.GetConfig().ScheduledEnabled)
         {
             EventManager.Execute();
         }
     }
     catch (Exception ex)
     {
         //    logger.Error(String.Format("执行计划任务出错:\r\n{0}", ex));
     }
 }