Example #1
0
        public IActionResult Index(int page = 1)
        {
            var ads = _service.Get();


            return(View(ads.ToList()));
        }
Example #2
0
        private static bool IsCharactorCreator(MsgInformation MsgDTO, string charactor)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == MsgDTO.FromGroup &&
                                                             cs.Charactor == charactor);

            return(query.First().Creator == MsgDTO.FromQQ);
        }
Example #3
0
        private static bool IsExistCharactor(long groupNumber, string charactor)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == groupNumber &&
                                                             cs.Charactor == charactor);

            return(!query.IsNullOrEmpty());
        }
Example #4
0
        public bool DeleteCharactor(MsgInformationEx MsgDTO, object[] param)
        {
            var charactor = param[0] as string;

            var query = MongoService <CharactorSetting> .Get(c => c.GroupNumber == MsgDTO.FromGroup &&
                                                             c.Charactor == charactor);

            if (query.IsNullOrEmpty())
            {
                MsgSender.PushMsg(MsgDTO, "这个人物还没有被创建呢!");
                return(false);
            }

            if (query.First().Creator != MsgDTO.FromQQ)
            {
                MsgSender.PushMsg(MsgDTO, "你只能删除自己创建的人物噢!");
                return(false);
            }

            foreach (var c in query)
            {
                MongoService <CharactorSetting> .Delete(c);
            }

            MsgSender.PushMsg(MsgDTO, "删除成功!");
            return(true);
        }
Example #5
0
        public bool FishingBottle(MsgInformationEx MsgDTO, object[] param)
        {
            if (OSPersonBuff.CheckBuff(MsgDTO.FromQQ, "昙天"))
            {
                MsgSender.PushMsg(MsgDTO, "你当前无法捞瓶子!(昙天)");
                return(false);
            }

            if (Rander.RandInt(100) < ItemRate)
            {
                FishItem(MsgDTO);
                return(true);
            }

            var query = MongoService <DriftBottleRecord> .Get(r => r.FromQQ != MsgDTO.FromQQ && r.FromGroup != MsgDTO.FromGroup && !r.ReceivedQQ.HasValue);

            if (query.IsNullOrEmpty())
            {
                FishItem(MsgDTO);
                return(true);
            }

            var bottle = query.RandElement();

            PrintBottle(MsgDTO, bottle);

            bottle.ReceivedGroup = MsgDTO.FromGroup;
            bottle.ReceivedQQ    = MsgDTO.FromQQ;
            bottle.ReceivedTime  = DateTime.Now;

            MongoService <DriftBottleRecord> .Update(bottle);

            return(true);
        }
Example #6
0
        private static KanColeGirlVoice GetRanAlertContent(int aimHour)
        {
            var tag   = HourToTag(aimHour);
            var query = MongoService <KanColeGirlVoice> .Get(a => a.Tag == tag).OrderBy(a => a.Id).ToList();

            return(query.RandElement());
        }
Example #7
0
        private void AddInBlackList(long QQNum)
        {
            var query = MongoService <BlackList> .Get(b => b.QQNum == QQNum);

            if (!query.IsNullOrEmpty())
            {
                var black = query.First();
                black.BlackCount++;
                black.UpdateTime = DateTime.Now;

                MongoService <BlackList> .Update(black);

                if (black.BlackCount > MaxTolerateCount && !BlackList.Contains(QQNum))
                {
                    BlackList.Add(QQNum);
                }
                return;
            }

            MongoService <BlackList> .Insert(new BlackList
            {
                BlackCount = 1,
                UpdateTime = DateTime.Now,
                QQNum      = QQNum
            });
        }
Example #8
0
        public bool LimitItemReport(MsgInformationEx MsgDTO, object[] param)
        {
            var LimitHonor      = HonorSvc.HonorList.First(h => h is LimitHonorModel model && model.IsCurLimit);
            var LimitItemsNames = LimitHonor.Items.Select(i => i.Name);

            var allRecord = MongoService <ItemCollectionRecord> .Get(r => r.HonorCollections.ContainsKey(LimitHonor.Name));

            var itemDic = LimitItemsNames.ToDictionary(p => p, p => 0);

            foreach (var colle in allRecord.Select(record => record.HonorCollections[LimitHonor.Name]))
            {
                foreach (var(key, value) in colle.Items)
                {
                    itemDic[key] += value;
                }
            }

            var honorCount = allRecord.Count(r => r.HonorList != null && r.HonorList.Contains(LimitHonor.Name));
            var msg        = $"限定物品收集情况:\r\n{string.Join("\r\n", itemDic.Select(p => $"{p.Key}:{p.Value}"))}\r\n";

            msg += $"共有 {honorCount} 人达成了本月限定成就";

            MsgSender.PushMsg(MsgDTO, msg);
            return(true);
        }
Example #9
0
        public bool ViewCharactor(MsgInformationEx MsgDTO, object[] param)
        {
            var charactor = param[0] as string;

            var query = MongoService <CharactorSetting> .Get(c => c.GroupNumber == MsgDTO.FromGroup &&
                                                             c.Charactor == charactor);

            if (query.IsNullOrEmpty())
            {
                MsgSender.PushMsg(MsgDTO, "这个人物还没有创建哦~");
                return(false);
            }

            var msg     = charactor + ':';
            var builder = new StringBuilder();

            builder.Append(msg);
            foreach (var c in query)
            {
                builder.Append($"\r\n{c.SettingName}:{c.Content}");
            }
            msg = builder.ToString();

            MsgSender.PushMsg(MsgDTO, msg);
            return(true);
        }
Example #10
0
        private static bool IsSettingExist(long fromGroup, string charactor, string settingName)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == fromGroup &&
                                                             cs.Charactor == charactor &&
                                                             cs.SettingName == settingName);

            return(!query.IsNullOrEmpty());
        }
Example #11
0
        public void RefreshData()
        {
            var Groups = GroupSettingSvc.AllGroups.Select(p => p.GroupNum).ToArray();

            HelloList = MongoService <HelloRecord> .Get(p => Groups.Contains(p.GroupNum));

            MultiMediaHelloList = CommonUtil.ReadJsonData_NamedList <MultiMediaHelloRecord>("Standard/MultiMediaHelloData");
        }
Example #12
0
        private static bool IsSettingFull(long fromGroup, string charactor, string settingName)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == fromGroup &&
                                                             cs.Charactor == charactor &&
                                                             cs.SettingName != settingName);

            return(!query.IsNullOrEmpty() && query.Count > MaxSettingPerChar);
        }
Example #13
0
        public override void Initialization()
        {
            base.Initialization();

            var records = MongoService <SignInGroupRecord> .Get();

            GroupSignInDic = records.ToDictionary(p => p.GroupNum, p => p);
        }
Example #14
0
        public AliveStateSvc()
        {
            CacheDic = new ConcurrentDictionary <string, AliveStateCache>();
            var allCaches = MongoService <AliveStateCache> .Get();

            foreach (var Cache in allCaches)
            {
                CacheDic.TryAdd(Cache.Key, Cache);
            }
        }
        public async Task <ActionResult <CalculatedElementData> > GetCostAttributeMongo(int id)
        {
            var keyValue = $"CalculatedElementData:CostingVersionId:{id}";
            Expression <Func <CalculatedElementData, bool> > filter = x => x.BidId == id;

            var ret = await _mongoService.Get(filter);

            Log.Information($"Get user: Ok");
            return(Ok(ret));
        }
Example #16
0
        private static bool IsQQFullChar(MsgInformation MsgDTO)
        {
            var query = MongoService <CharactorSetting> .Get(cs => cs.GroupNumber == MsgDTO.FromGroup &&
                                                             cs.Creator == MsgDTO.FromQQ);

            if (query.IsNullOrEmpty())
            {
                return(false);
            }
            query = query.GroupBy(p => p.Charactor).Select(p => p.First()).ToList();
            return(!query.IsNullOrEmpty() && query.Count > MaxCharNumPerQQ);
        }
Example #17
0
        public bool ClearSayings(MsgInformationEx MsgDTO, object[] param)
        {
            var query = MongoService <Saying> .Get(s => s.FromGroup == MsgDTO.FromGroup &&
                                                   (s.Content.Contains(MsgDTO.Msg) ||
                                                    s.Charactor.Contains(MsgDTO.Msg) ||
                                                    s.Cartoon.Contains(MsgDTO.Msg)));

            var count = query.Count;

            MongoService <Saying> .DeleteMany(query);

            MsgSender.PushMsg(MsgDTO, $"共删除{count}条语录");
            return(true);
        }
Example #18
0
        public IActionResult Index(string sport = null, string search = null)
        {
            var matches = _db.Matches.Where(a =>
                                            a.Status.Equals(MatchStatus.Active) || a.Status.Equals(MatchStatus.Waiting));

            if (sport != null)
            {
                matches = matches.Where(a => a.Sport.Equals((Sport)Enum.Parse(typeof(Sport), sport)));
            }
            if (search != null)
            {
                matches = matches.Where(a => a.Title.ToLower().Contains(search.ToLower()));
            }

            ViewData["search"] = search;

            matches = matches.Include(a => a.Bets.OrderBy(b => b.Description));


            var map = new Dictionary <Sport, Dictionary <string, List <Matches> > >();

            foreach (var match in matches)
            {
                if (!map.ContainsKey(match.Sport))
                {
                    map.Add(match.Sport, new Dictionary <string, List <Matches> >());
                }

                if (!map[match.Sport].ContainsKey(match.Tournament))
                {
                    map[match.Sport].Add(match.Tournament, new List <Matches>());
                }

                map[match.Sport][match.Tournament].Add(match);
            }

            if (sport == null)
            {
                ViewData["sport"] = "";
            }
            else
            {
                ViewData["sport"] = sport;
            }

            ViewBag.Banners = _service.Get();

            return(View(map));
        }
Example #19
0
        private static bool CheckLimit(MsgInformationEx MsgDTO, IVipArmer armer)
        {
            if (armer.LimitCount == 0)
            {
                return(true);
            }

            var(startDate, endDate) = ParseDateRange(armer.LimitInterval);
            var purchaseRec = MongoService <VipSvcPurchaseRecord> .Get(p =>
                                                                       p.QQNum == MsgDTO.FromQQ && p.SvcName == armer.Name && p.PurchaseTime > startDate && p.PurchaseTime <= endDate);

            if (purchaseRec.Count < armer.LimitCount)
            {
                return(true);
            }

            MsgSender.PushMsg(MsgDTO, $"你{LimitIntervalToString(armer.LimitInterval)}已经买了{armer.LimitCount}次了", true);
            return(false);
        }
Example #20
0
        public void Review(MsgInformationEx MsgDTO)
        {
            var record = MongoService <PicReviewRecord> .Get(p => p.Status == PicReviewStatus.Waiting).OrderBy(p => p.CreateTime).FirstOrDefault();

            if (record == null)
            {
                MsgSender.PushMsg(MsgDTO, "暂无待审核的图片!");
                return;
            }

            var msg = $"{CodeApi.Code_Image_Relational($"{CachePath}{record.PicName}")}\r\n";

            msg += $"来自 {GroupSettingSvc[record.GroupNum].Name} 的 {record.QQNum}\r\n";
            msg += $"用途:{record.Usage}\r\n";
            msg += "是否通过?";
            var option = WaiterSvc.WaitForOptions(MsgDTO.FromGroup, MsgDTO.FromQQ, msg, new[] { "通过", "不通过", "取消" }, MsgDTO.BindAi);

            if (option < 0 || option == 2)
            {
                MsgSender.PushMsg(MsgDTO, "操作取消!");
                return;
            }

            record.Status     = option == 0 ? PicReviewStatus.Passed : PicReviewStatus.Refused;
            record.ReviewTime = DateTime.Now;
            record.Update();

            ReviewCallBack[record.Usage](record);

            msg = record.Status == PicReviewStatus.Passed
                ? $"恭喜你,你在{record.CreateTime:yyyy-MM-dd HH:mm:ss}提交的用于{record.Usage}的图片审核通过!"
                : $"很遗憾,你在{record.CreateTime:yyyy-MM-dd HH:mm:ss}提交的用于{record.Usage}的图片未能审核通过!";
            MsgSender.PushMsg(record.GroupNum, record.QQNum, msg, GroupSettingSvc[record.GroupNum].BindAi);

            var picTempFile = new FileInfo($"{CachePath}{record.PicName}");

            picTempFile.Delete();

            var count = MongoService <PicReviewRecord> .Count(p => p.Status == PicReviewStatus.Waiting);

            MsgSender.PushMsg(MsgDTO, $"审核完毕!还有{count}张待审核的图片!");
        }
Example #21
0
        private static string GetRanSaying(long fromGroup, string keyword = null)
        {
            var query = MongoService <Saying> .Get(p => p.FromGroup == fromGroup);

            if (keyword != null)
            {
                query = query.Where(p => p.Cartoon.Contains(keyword) ||
                                    p.Charactor.Contains(keyword) ||
                                    p.Content.Contains(keyword)).ToList();
            }

            if (query.IsNullOrEmpty())
            {
                return(string.Empty);
            }

            var saying = query.RandElement();

            return(GetShownSaying(saying));
        }
Example #22
0
        public bool ItemCount(MsgInformationEx MsgDTO, object[] param)
        {
            var name = param[0] as string;

            if (HonorSvc.FindItem(name) == null)
            {
                MsgSender.PushMsg(MsgDTO, "未查找到相关物品!");
                return(false);
            }

            var honor = HonorSvc.FindHonorName(name);

            var recs = MongoService <ItemCollectionRecord> .Get(p =>
                                                                p.HonorCollections != null && p.HonorCollections.ContainsKey(honor) && p.HonorCollections[honor].Items.ContainsKey(name));

            var count = recs.Sum(r => r.HonorCollections[honor].Items[name]);

            MsgSender.PushMsg(MsgDTO, $"当前{name}被收集了{count}个");
            return(true);
        }
        public async Task <ActionResult <CalculatedElementData> > GetCostAttributeMongo(int bidId)
        {
            const string logMessage = "Get costattribute, ";
            var          keyValue   = $"CalculatedElementData:CostingVersionId:{bidId}";
            Expression <Func <CalculatedElementData, bool> > expression = x => x.BidId == bidId;

            try
            {
                Log.Information($"{logMessage}begin");
                var ret = await _mongoService.Get(expression);

                Log.Information($"{logMessage}end");
                return(Ok(/*ret*/));
            }
            catch (Exception ex)
            {
                Log.Error($"{logMessage}error, {ex.Message}");
                return(BadRequest());
            }
        }
Example #24
0
        public static SignInSuccessiveRecord MakeUp(long GroupNum, long QQNum)
        {
            var lastTwo = MongoService <SignInSuccessiveRecord> .Get(p => p.GroupNum == GroupNum && p.QQNum == QQNum).OrderByDescending(p => p.EndDate).Take(2).ToList();

            if (lastTwo.IsNullOrEmpty())
            {
                return(null);
            }

            if (lastTwo.Count == 1 || lastTwo[0].StartDate > lastTwo[1].EndDate.AddDays(1))
            {
                lastTwo[0].StartDate = lastTwo[0].StartDate.AddDays(-1);
                lastTwo[0].Update();
                return(lastTwo[0]);
            }

            lastTwo[0].StartDate = lastTwo[1].StartDate;
            lastTwo[0].Update();
            lastTwo[1].Delete();

            return(lastTwo[0]);
        }
Example #25
0
        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;
        }
Example #26
0
        private static KanColeGirlVoice GetRandVoiceInfo(string name)
        {
            var query = MongoService <KanColeGirlVoice> .Get(p => p.Name.Contains(name));

            return(query.IsNullOrEmpty() ? null : query.RandElement());
        }
Example #27
0
        protected override void ScheduleDo(SchedulerTimer timer)
        {
            var outOfDateRecords = MongoService <DriftBottleRecord> .Get(r => r.ReceivedQQ != null);

            MongoService <DriftBottleRecord> .DeleteMany(outOfDateRecords);
        }
Example #28
0
 public ActionResult <List <User> > Get() =>
 _mongoService.Get();
Example #29
0
        public static Dictionary <int, int> LevelAnalyze()
        {
            var pets = MongoService <PetRecord> .Get();

            return(pets.GroupBy(p => p.Level).ToDictionary(p => p.Key, p => p.Count()).OrderByDescending(p => p.Key).ToDictionary(p => p.Key, p => p.Value));
        }
        public static int GetSumIntimate(long GroupNum, long firstQQ, long secondQQ)
        {
            var records = MongoService <IntimateRelationshipRecord> .Get(p => p.GroupNum == GroupNum && p.QQPair.Contains(firstQQ) && p.QQPair.Contains(secondQQ));

            return(records.Sum(p => p.Value));
        }