示例#1
0
        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();
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }
示例#5
0
        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);
            }
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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();
        }
示例#9
0
        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();
        }