Пример #1
0
        public UserPlanInfoInputValidator()
        {
            _planInfoQueryService = ObjectContainer.Resolve <IPlanInfoQueryService>();
            RuleFor(p => p.PlanIds).Must(p =>
            {
                if (p == null || p.Count <= 0)
                {
                    return(false);
                }

                return(true);
            }).WithMessage("至少选择一个计划");

            RuleFor(p => p.PlanIds).Must(p =>
            {
                if (p.Count != p.Distinct().Count())
                {
                    return(false);
                }
                return(true);
            }).WithMessage("不允许选择重复的计划");

            RuleFor(p => p.PlanIds).Must(p =>
            {
                var lotterySession = NullLotterySession.Instance;
                var planInfos      = _planInfoQueryService.GetPlanInfoByLotteryId(lotterySession.SystemTypeId);
                var allPlanIds     = planInfos.Select(q => q.Id).ToList();

                if (p.All(t => allPlanIds.Any(b => b == t.PlanId)))
                {
                    return(true);
                }
                return(false);
            }).WithMessage("计划选择错误,该彩种在系统中包含这类型的计划");
        }
Пример #2
0
        private async Task InitLotteryPredictTable(LotteryInfoDto lotteryInfo)
        {
            var lotteryPlans  = _planInfoQueryService.GetPlanInfoByLotteryId(lotteryInfo.Id);
            var predictTables = lotteryPlans.Select(p => p.PlanNormTable).ToList();
            var predictDbName = AanalyseDbName(lotteryInfo.LotteryCode);
            var result        = await _commandService.SendAsync(new InitPredictTableCommand(Guid.NewGuid().ToString(), predictDbName, lotteryInfo.LotteryCode, predictTables));

            if (result.Status == AsyncTaskStatus.Success)
            {
                await _commandService.SendAsync(new CompleteDynamicTableCommand(lotteryInfo.Id, true));
            }
        }