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(); }
private static bool CheckTodayRefresh() { var rec = GlobalVarRecord.Get("SoldierRefresh"); if (string.IsNullOrEmpty(rec.Value) || !DateTime.TryParse(rec.Value, out var lastTime) || lastTime >= DateTime.Today) { return(false); } rec.Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); rec.Update(); return(true); }
public bool SignInAcc(MsgInformationEx MsgDTO, object[] param) { var days = (int)(long)param[0]; var record = GlobalVarRecord.Get("SignInAcc"); record.Value = "any"; record.ExpiryTime = DateTime.Now.AddDays(days); record.Update(); MsgSender.PushMsg(MsgDTO, "开启成功"); return(true); }
public static ArknightsMiniStoryRecord GetLast() { var lastestNoRec = GlobalVarRecord.Get("ArknightsMiniStoryNo"); if (string.IsNullOrEmpty(lastestNoRec.Value)) { lastestNoRec.Value = "0"; } var lastNo = int.Parse(lastestNoRec.Value); return(Get(lastNo)); }
public void Refresh() { foreach (var model in Models.Where(model => !string.IsNullOrEmpty(model.TimerID))) { SchedulerSvc.Remove(model.TimerID); } Models = new List <ShoppingNoticeModel>(); var shopInfo = GlobalVarRecord.Get("TodayShopInfo"); if (string.IsNullOrEmpty(shopInfo.Value)) { return; } var records = JsonConvert.DeserializeObject <List <ShopTimeRecord> >(shopInfo.Value); foreach (var record in records) { Models.Add(new ShoppingNoticeModel() { NoticeTime = record.OpenTime, Type = ShoppingNoticeType.OpenShop, Data = record.SellingGoods }); Models.Add(new ShoppingNoticeModel() { NoticeTime = record.OpenTime.AddMinutes(-30), Type = ShoppingNoticeType.Forecast }); Models.Add(new ShoppingNoticeModel() { NoticeTime = record.OpenTime.AddMinutes(5), Type = ShoppingNoticeType.CloseShop }); } Models = Models.Where(p => p.NoticeTime > DateTime.Now).OrderBy(p => p.NoticeTime).ToList(); foreach (var model in Models) { var interval = (model.NoticeTime - DateTime.Now).TotalMilliseconds; model.TimerID = SchedulerSvc.Add(interval, TimeUp, model, false); } }
public static IEnumerable <DailySellItemModel> GetDailySellItems() { var cache = GlobalVarRecord.Get("DailySellItems"); if (!string.IsNullOrEmpty(cache.Value)) { return(JsonConvert.DeserializeObject <DailySellItemModel[]>(cache.Value)); } var newitems = CreateDailySellItems(); cache.Value = JsonConvert.SerializeObject(newitems); cache.ExpiryTime = CommonUtil.UntilTommorow(); cache.Update(); return(newitems); }
public IEnumerable <ExpeditionSceneModel> TodayExpedition() { var cache = GlobalVarRecord.Get("TodayExpedition"); if (!string.IsNullOrEmpty(cache.Value)) { var modelNames = JsonConvert.DeserializeObject <string[]>(cache.Value); return(Scenes.Where(s => modelNames.Contains(s.Name)).ToList()); } var todayScenes = Rander.RandSort(Scenes.ToArray()).Take(3).ToList(); cache.Value = JsonConvert.SerializeObject(todayScenes.Select(s => s.Name).ToArray()); cache.ExpiryTime = CommonUtil.UntilTommorow(); cache.Update(); return(todayScenes); }
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(); }
public static void Insert(string Path) { var lastestNoRec = GlobalVarRecord.Get("ArknightsMiniStoryNo"); if (string.IsNullOrEmpty(lastestNoRec.Value)) { lastestNoRec.Value = "0"; } var lastNo = int.Parse(lastestNoRec.Value); var newRecord = new ArknightsMiniStoryRecord() { No = lastNo + 1, Path = Path, UpdateTime = DateTime.Now }; MongoService <ArknightsMiniStoryRecord> .Insert(newRecord); lastestNoRec.Value = newRecord.No.ToString(); lastestNoRec.Update(); }