Beispiel #1
0
        void CalNextTime(DateTime curTime)
        {
            DateTime curDate = curTime.Date;

            if (_dailyeventEntity.RecordDate != curTime.Date)
            {
                var openTime = DailyEventThread.CalTime(curDate, _config.OpenHour, _config.OpenMinute);
                var endTime  = DailyEventThread.CalTime(curDate, _config.EndHour, _config.EndMinute);
                if (curTime >= openTime)
                {
                    if (curTime > endTime)
                    {
                        openTime = openTime.AddDays(1);
                        endTime  = endTime.AddDays(1);
                    }
                }
                _nextInvokeTime = openTime;
                _endTime        = endTime;
            }
            else
            {
                var nextDate = curDate.AddDays(1);
                _nextInvokeTime = DailyEventThread.CalTime(nextDate, _config.OpenHour, _config.OpenMinute);
                _endTime        = DailyEventThread.CalTime(nextDate, _config.EndHour, _config.EndMinute);
            }
        }
Beispiel #2
0
        public void Invoke(DateTime curTime)
        {
            if (curTime < _nextInvokeTime)
            {
                return;
            }
            else if (curTime >= _endTime)
            {
                CalNextTime(curTime);
                return;
            }
            if (0 == Interlocked.Exchange(ref _syncInvoke, 1))
            {
                try
                {
                    DateTime curDate   = curTime.Date;
                    var      openTime  = DailyEventThread.CalTime(curDate, _config.OpenHour, _config.OpenMinute);
                    var      startTime = DailyEventThread.CalTime(curDate, _config.StartHour, _config.StartMinute);
                    var      endTime   = DailyEventThread.CalTime(curDate, _config.EndHour, _config.EndMinute);
                    _dailyeventEntity.OpenTime   = openTime;
                    _dailyeventEntity.StartTime  = startTime;
                    _dailyeventEntity.EndTime    = endTime;
                    _dailyeventEntity.RecordDate = curDate;
                    try
                    {
                        _startDelegate(startTime, endTime);
                    }
                    catch (Exception ex)
                    {
                        SystemlogMgr.Error("Dailyevent info Invoke inner", ex);
                    }

                    MonitorDailyeventMgr.Save(_dailyeventEntity.ZoneId, _dailyeventEntity.EventType,
                                              _dailyeventEntity.OpenTime, _dailyeventEntity.StartTime, _dailyeventEntity.EndTime,
                                              _dailyeventEntity.RecordDate);
                    CalNextTime(curTime);
                }
                catch (Exception ex)
                {
                    SystemlogMgr.Error("Dailyevent info Invoke", ex);
                }
                finally
                {
                    Interlocked.Exchange(ref _syncInvoke, 0);
                }
            }
        }