Esempio n. 1
0
        /// <summary>
        /// 停止需要停止的任务
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static void StopEventsInTimeFrame(CancellationToken cancellationToken)
        {
            AMSEventCollection events = AMSEventSqlAdapter.Instance.LoadNeedStopEvents();

            AMSQueueItemCollection messages = new AMSQueueItemCollection();

            foreach (AMSEvent eventData in events)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                if (LockHelper.IsLockAvailable(eventData))
                {
                    messages.Add(eventData.ToQueueMessage(AMSQueueItemType.StopEvent));
                    TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60012, "Add stop new event {0} to queue.", eventData.ID);
                }
            }

            GetQueue().AddMessages(string.Empty, messages.ToArray());
        }
Esempio n. 2
0
        /// <summary>
        /// 检查需要启动的事件
        /// </summary>
        /// <returns></returns>
        public static void StartEventsInTimeFrame(CancellationToken cancellationToken)
        {
            AMSWorkerSettings  settings = AMSWorkerSettings.GetConfig();
            AMSEventCollection events   = AMSEventSqlAdapter.Instance.LoadNeedStartEvents(settings.Durations.GetDuration("createChannelWarmup", TimeSpan.FromMinutes(20)));

            AMSQueueItemCollection messages = new AMSQueueItemCollection();

            foreach (AMSEvent eventData in events)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    break;
                }

                if (LockHelper.IsLockAvailable(eventData))
                {
                    messages.Add(eventData.ToQueueMessage(AMSQueueItemType.StartEvent));

                    TraceHelper.AMSTaskTraceSource.TraceEvent(TraceEventType.Verbose, 60011, "Add start new event {0} to queue.", eventData.ID);
                }
            }

            GetQueue().AddMessages(string.Empty, messages.ToArray());
        }