protected override bool EntityTaskHandler(VisitingOrderLateNoPaymentModel model, bool mustBackup = true)
        {
            if (null != model)
            {
                TimeSpan duetime = model.LastPaymentTime.Subtract(DateTime.Now);    //延迟执行时间(以毫秒为单位)

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.OrderID, model);
                }

                //输出消息
                string message = string.Format("〖上门订单(ID:{0})〗在{1}天{2}小时{3}分{4}秒后未付款系统将自动取消订单", model.OrderID, duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.OrderID, timer);

                return(true);
            }

            return(false);
        }
Exemple #2
0
        protected override bool EntityTaskHandler(MallOrderLateReceiveModel model, bool mustBackup = true)
        {
            if (null != model)
            {
                DateTime lastTime = model.ShipTime.AddDays(Startup.B2COrderConfig.WaitReceiptGoodsDays);

                TimeSpan duetime = lastTime.Subtract(DateTime.Now);    //延迟执行时间(以毫秒为单位)

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.OrderID, model);
                }

                //输出消息
                string message = string.Format("〖精品汇订单(ID:{0})〗在{1}天{2}小时{3}分{4}秒后未收货系统将自动确认收货", model.OrderID, duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.OrderID, timer);

                return(true);
            }

            return(false);
        }
        protected override bool EntityTaskHandler(WelfareRemindModel model, bool mustBackup = true)
        {
            if (null != model)
            {
                TimeSpan duetime = model.ApplyStartTime.AddMinutes(-Startup.WelfareConfig.BeforeRemindMinutes).Subtract(DateTime.Now);    //延迟执行时间(以毫秒为单位)

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.WelfareID, model);
                }

                //输出消息
                string message = string.Format("〖福利:{0}〗将在{1}天{2}小时{3}分{4}秒后提醒用户参与报名", model.WelfareID, duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.WelfareID, timer);

                return(true);
            }

            return(false);
        }
        protected override bool EntityTaskHandler(ReservationOrderLateReceiveModel model, bool mustBackup = true)
        {
            if (null != model)
            {
                TimeSpan duetime = model.WorkerFinishTime.AddDays(Startup.AppointConfig.EndServiceWaitUserDays).Subtract(DateTime.Now);    //延迟执行时间(以毫秒为单位)

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.OrderID, model);
                }

                //输出消息
                string message = string.Format("〖预约订单(ID:{0})〗在{1}天{2}小时{3}分{4}秒后未确认服务完成系统将自动确认服务完成", model.OrderID, duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.OrderID, timer);

                return(true);
            }

            return(false);
        }
        protected override bool EntityTaskHandler(LegworkOrderTimeoutModel model, bool mustBackup = true)
        {
            if (null != model)
            {
                DateTime lastTime = model.CreateTime.AddSeconds(Startup.LegworkGlobalConfig.OrderTimeout);

                TimeSpan duetime = lastTime.Subtract(DateTime.Now);    //延迟执行时间(以毫秒为单位)

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.OrderID, model);
                }

                //输出消息
                string message = string.Format("〖跑腿订单(ID:{0})〗在{1}天{2}小时{3}分{4}秒后没有员工接单,系统将自动取消订单", model.OrderID, duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.OrderID, timer);

                return(true);
            }

            return(false);
        }
        protected override bool EntityTaskHandler(MallOrderNoPaymentModel model, bool mustBackup = true)
        {
            //对象不为null
            if (null != model)
            {
                DateTime lastTime = model.NeedPayTime ?? model.CreateTime.AddMinutes(Startup.B2COrderConfig.WaitPaymentMinutes);

                TimeSpan duetime = lastTime.Subtract(DateTime.Now);    //延迟执行时间

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.OrderID, model);
                }

                //输出消息
                string message = string.Format("〖精品汇订单(ID:{0})〗在{1}天{2}小时{3}分{4}秒后未付款系统将自动取消订单", model.OrderID, duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.OrderID, timer);

                return(true);
            }

            return(false);
        }
Exemple #7
0
        protected override bool EntityTaskHandler(WelfareLotteryModel model, bool mustBackup = true)
        {
            if (null != model)
            {
                TimeSpan duetime = model.LotteryTime.Subtract(DateTime.Now);    //延迟执行时间(以毫秒为单位)

                if (duetime.Ticks < 0)
                {
                    duetime = TimeoutZero;
                }

                System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(Execute), model, duetime, TimeoutInfinite);

                if (mustBackup)
                {
                    //复制到备份区以防数据丢失
                    BackBeforeDone(model.WelfareID, model);
                }

                //输出消息
                string message = string.Format("〖福利:{0}〗将于{2}天{3}小时{4}分{5}秒后({1})开奖", model.Name, model.LotteryTime.ToString("yyyy/MM/dd HH:mm:ss"), duetime.Days, duetime.Hours, duetime.Minutes, duetime.Seconds);

                RunLogger(message);

                Schedulers.Add(model.WelfareID, timer);

                return(true);
            }

            return(false);
        }
        /// <summary>
        /// 执行单次请求并返回是否需要继续指示信号
        /// </summary>
        /// <returns></returns>
        protected override bool SingleRequest()
        {
            var levelList = EnumExtensions.GetEnumDesc <CacheLevel>(typeof(CacheLevel));

            foreach (var level in levelList)
            {
                //更新周期(以毫秒为单位)
                TimeSpan period = new TimeSpan(0);

                var levelConfig = Startup.CacheMaintainConfigs.FirstOrDefault(p => p.Level == level.EnumItem);

                if (null != levelConfig && levelConfig.PeriodTime > 0)
                {
                    int time = levelConfig.PeriodTime;

                    switch (levelConfig.TimeOption)
                    {
                    case SysEnums.CacheTimeOption.Day: period = new TimeSpan(time, 0, 0, 0); break;

                    case SysEnums.CacheTimeOption.Hour: period = new TimeSpan(0, time, 0, 0); break;

                    case SysEnums.CacheTimeOption.Minute: period = new TimeSpan(0, 0, time, 0); break;
                    }

                    ScheduleClocker clocker = new ScheduleClocker(new TimeSpan(0), period, Execute, level.EnumItem);

                    Schedulers.Add(level.Name, clocker);
                }
            }

            return(true);
        }
 public Scheduler(ITrigger trigger = null)
 {
     this.jobDetail = JobBuilder.Create <EventRaiserJob>()
                      .WithIdentity(this.name.ToString(), "Scheduler")
                      .Build();
     Schedulers.Add(this.name, this);
     this.Trigger = trigger;
 }
Exemple #10
0
        public async void Start(string baseUrl, FeedNode feedNode)
        {
            if (Schedulers.ContainsKey(baseUrl))
            {
                return;
            }

            Logger.GetLogger(baseUrl).Info(baseUrl + " feed scheduler starting");

            this.baseUrl  = baseUrl;
            this.feedNode = feedNode;
            Schedulers.Add(baseUrl, this);

            Logger.GetLogger(baseUrl).Info(baseUrl + " feed scheduler started");

            await SyncFeed();

            AddExtractJob();
        }
Exemple #11
0
        /// <summary>
        /// Start service plugin
        /// </summary>
        public void Start()
        {
            _mainPluginTask = Task.Run(async() =>
            {
                try
                {
                    _scheduler    = await _schedulerFactory.GetScheduler();
                    SchedulerName = _scheduler.SchedulerName;
                    Schedulers.Add(_scheduler);
                    await _scheduler.Start();
                    _logger.Info($"Scheduler [{SchedulerName}] has been succesfully started");
                }
                catch (Exception e)
                {
                    _logger.Error(e, $"Scheduler [{SchedulerName}] start error");
                }
            });

            Task.WaitAll(_mainPluginTask);
        }
Exemple #12
0
 public void LoadSchedulers()
 {
     using (SqlConnection conn = new SqlConnection(AppSettings.GetConnectionString(this, "Shcedulers")))
     {
         conn.Open();
         using (SqlCommand command = new SqlCommand(@"SELECT Name,EndPointConfigurationName FROM Schedulers", conn))
         {
             using (SqlDataReader reader = command.ExecuteReader())
             {
                 if (Schedulers == null)
                 {
                     Schedulers = new ObservableCollection <SchedulerView>();
                 }
                 while (reader.Read())
                 {
                     Schedulers.Add(new SchedulerView()
                     {
                         Name = reader["Name"].ToString(), EndPointAddress = reader["EndPointConfigurationName"].ToString()
                     });
                 }
             }
         }
     }
 }
Exemple #13
0
        private async void SynchronizationAsync()
        {
            var request = await Service.CalendarList.List().ExecuteAsync();

            var calendars = request.Items;

            calendars.Remove(calendars.First(calendar => calendar.Id == "addressbook#[email protected]"));

            foreach (var scheduler in Schedulers)
            {
                if (calendars.Select(calendar => calendar.Id).Contains(scheduler.Calendar.Id))
                {
                    if (scheduler.Calendar.AccessRole == "reader")
                    {
                        continue;
                    }
                    var events = Service.Events.List(scheduler.Calendar.Id).ExecuteAsync().Result.Items;
                    /// Сравнение текущих ивентов с гугловскими
                    for (var i = 0; i < scheduler.Events.Count; i++)
                    {
                        var thisEvent = scheduler.Events[i];

                        if (events.Select(evt => evt.Id).Contains(thisEvent.Id))
                        {
                            var googleEvent = events.First(@event => @event.Id == thisEvent.Id);

                            if (googleEvent.Updated >= thisEvent.Updated)
                            {
                                lock (scheduler.Events)
                                {
                                    thisEvent = googleEvent;
                                }
                            }
                            else
                            {
                                await Service.Events.Patch(thisEvent, scheduler.Calendar.Id, thisEvent.Id).ExecuteAsync();
                            }
                        }
                        else if (thisEvent.Id != null)
                        {
                            lock (scheduler.Events)
                            {
                                scheduler.Events.Remove(thisEvent);
                            }
                        }
                        else
                        {
                            await Service.Events.Insert(thisEvent, scheduler.Calendar.Id).ExecuteAsync();
                        }
                    }

                    ///Сравниваем гугловские с текущими
                    foreach (var googleEvent in events)
                    {
                        if (!scheduler.Events.Select(e => e.Id).Contains(googleEvent.Id))
                        {
                            scheduler.Events.Add(googleEvent);
                        }
                    }

                    var googleCalendar = calendars.First(calendar => calendar.Id == scheduler.Calendar.Id);

                    if (googleCalendar.BackgroundColor != scheduler.Calendar.BackgroundColor)
                    {
                        scheduler.ChangeColor(ColorTranslator.FromHtml(googleCalendar.BackgroundColor));
                        ChangePanelBoxColor(ColorTranslator.FromHtml(googleCalendar.BackgroundColor), scheduler.Calendar.Id);
                    }
                }
                else
                {
                    var newCalendar = new Google.Apis.Calendar.v3.Data.Calendar
                    {
                        Summary     = scheduler.Calendar.Summary,
                        Description = scheduler.Calendar.Description
                    };

                    scheduler.Calendar.Id       = Service.Calendars.Insert(newCalendar).ExecuteAsync().Result.Id;
                    scheduler.Calendar.Selected = true;
                    scheduler.Calendar.ETag     = null;
                    var req = Service.CalendarList.Update(scheduler.Calendar, scheduler.Calendar.Id);
                    req.ColorRgbFormat = true;
                    await req.ExecuteAsync();

                    foreach (var @event in scheduler.Events)
                    {
                        @event.Id = Service.Events.Insert(@event, scheduler.Calendar.Id).ExecuteAsync().Result.Id;
                    }
                }
            }

            foreach (var googleCalendar in calendars)
            {
                if (!Schedulers.Select(scheduler => scheduler.Calendar.Id).Contains(googleCalendar.Id))
                {
                    lock (Schedulers)
                    {
                        var scheduler = new Scheduler(googleCalendar, Service.Events.List(googleCalendar.Id).ExecuteAsync().Result.Items.ToArray());
                        Schedulers.Add(scheduler);
                        AddToPanel(scheduler);
                    }
                }
            }

            Invalidate();
            UpdateTable(null, null);
        }