protected override void ScheduleDo(SchedulerTimer timer) { var todayRecord = GlobalVarRecord.Get("TodayShopInfo"); if (!string.IsNullOrEmpty(todayRecord.Value)) { return; } var records = GetHours(3).Select(hour => { var isHalfHour = Rander.RandBool(); var dateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, hour, isHalfHour ? 30 : 0, 0); var goods = ArmerSvc.GetRandArmers(5).Select(p => p.Name); return(new ShopTimeRecord() { OpenTime = dateTime, SellingGoods = goods.ToArray() }); }).ToList(); todayRecord.Value = JsonConvert.SerializeObject(records); todayRecord.ExpiryTime = CommonUtil.UntilTommorow(); todayRecord.Update(); RandShopperSvc.Refresh(); }
protected override void ScheduleDo(SchedulerTimer timer) { var curLoad = pcCpuLoad.NextValue(); if (curLoad < 80) { return; } var ai = BindAiSvc.AiDic.Values.Where(p => p.IsConnected).RandElement(); MsgSender.PushMsg(0, Global.DeveloperNumber, $"CPU 超过警戒值!({curLoad}%)", ai.Name); }
private static void TestSchedulerTimer() { /* * Service Events - OnStart * SchedulerTimer: Interval=[0d 1h 0m 0s] * start=2/6/2009 11:50:18 AM * next=2/7/2009 12:00:00 AM * interval=3600000 * RoundOff[h=Quad m=Zero s=Zero i=43782000] * */ SchedulerTimer t; DateTime dt = DateTime.Parse("2/6/2009 11:50:18 AM"); /**/ t = new SchedulerTimer(dt, 0, 1, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n1 Hour schedule: " + t.ToString()); t = new SchedulerTimer(dt, 0, 2, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n2 Hour schedule: " + t.ToString()); t = new SchedulerTimer(dt, 0, 3, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n3 Hour schedule: " + t.ToString()); t = new SchedulerTimer(dt, 0, 4, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n4 Hour schedule: " + t.ToString()); t = new SchedulerTimer(dt, 0, 6, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n6 Hour schedule: " + t.ToString()); /**/ /**/ t = new SchedulerTimer(dt, 0, 12, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n12 Hour schedule: " + t.ToString()); //t = new SchedulerTimer(dt, 0, 24, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); //Console.WriteLine("\n\n24 Hour schedule: " + t.ToString()); t = new SchedulerTimer(dt, 1, 0, 0, 0, RoundOffStyle.Zero, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\nDaily schedule: " + t.ToString()); t = new SchedulerTimer(dt, 0, 0, 15, 0, RoundOffStyle.None, RoundOffStyle.Quad, RoundOffStyle.Zero); Console.WriteLine("\n\n15 Minute schedule: " + t.ToString()); t = new SchedulerTimer(dt, 0, 1, 0, 0, RoundOffStyle.Quad, RoundOffStyle.Zero, RoundOffStyle.Zero); Console.WriteLine("\n\n15 Minute schedule: " + t.ToString()); /**/ t = new SchedulerTimer(dt, 0, 0, 10, 0, RoundOffStyle.None, RoundOffStyle.Quad, RoundOffStyle.Zero); Console.WriteLine("\n\n10 Minute schedule: " + t.ToString()); }
protected override void ScheduleDo(SchedulerTimer timer) { if (!CheckTodayRefresh()) { return; } Logger.Log("Start SoldierStateRefresh."); Task.Run(() => { RebelProcess(); BecomeStarve(); }); }
public void Stop() { if (IsStarted) { Log.Info("stoping backup scheduler service..."); if (SchedulerTimer != null) { SchedulerTimer.Change(Timeout.Infinite, Timeout.Infinite); SchedulerTimer.Dispose(); SchedulerTimer = null; } Log.Info("backup scheduler service stoped"); IsStarted = false; } }
protected override void ScheduleDo(SchedulerTimer timer) { if (DateTime.Now.DayOfWeek != DayOfWeek.Monday) { return; } var record = GlobalVarRecord.Get("LastCountCleanDate"); var todayStr = DateTime.Now.ToString("yyyyMMdd"); if (record.Value == todayStr) { return; } MsgCounterSvc.CleanAll(); record.Value = todayStr; record.Update(); }
protected override void ScheduleDo(SchedulerTimer timer) { var curHour = DateTime.Now.Hour; var settings = MongoService <AutoPowerSetting> .Get(p => p.Hour == curHour); foreach (var setting in settings) { var GroupSettingMgr = AutofacSvc.Resolve <GroupSettingSvc>(); switch (setting.ActionType) { case AutoPowerSettingActionType.PowerOn: { var groupSetting = GroupSettingMgr[setting.GroupNum]; groupSetting.IsPowerOn = true; groupSetting.Update(); MsgSender.PushMsg(setting.GroupNum, 0, "开机成功!", groupSetting.BindAi); break; } case AutoPowerSettingActionType.PowerOff: { var groupSetting = GroupSettingMgr[setting.GroupNum]; groupSetting.IsPowerOn = false; groupSetting.Update(); MsgSender.PushMsg(setting.GroupNum, 0, "关机成功!", groupSetting.BindAi); break; } default: throw new ArgumentOutOfRangeException(); } } timer.Interval = SchedulerTimer.NextHourInterval; }
protected abstract void ScheduleDo(SchedulerTimer timer);
protected override void ScheduleDo(SchedulerTimer timer) { var dto = timer.Data as CacheCleanerDTO; CleanCache(dto); }
protected override void ScheduleDo(SchedulerTimer timer) { var outOfDateRecords = MongoService <DriftBottleRecord> .Get(r => r.ReceivedQQ != null); MongoService <DriftBottleRecord> .DeleteMany(outOfDateRecords); }
protected override void ScheduleDo(SchedulerTimer timer) { AutofacSvc.Resolve <HonorSvc>().RefreshData(); timer.Interval = (DateTime.Now.Date.AddDays(1) - DateTime.Now).TotalMilliseconds; }