public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var bonusLevelList = new List <int>();

            switch (GameType)
            {
            case "T14C":
                CaculateBonus_14C(checker, bonusLevelList);
                break;

            case "TR9":
                CaculateBonus_R9(checker, bonusLevelList);
                break;

            default:
                CaculateBonus(checker, bonusLevelList);
                break;
            }
            return(bonusLevelList);
        }
Exemple #2
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var wins  = checker.WinNumbers.Skip(TotalNumber - BallNumber).ToArray();
            var isWin = false;

            if ((AnteCodeNumbers[0].Contains(wins[0]) && AnteCodeNumbers[1].Contains(wins[1])) ||
                (AnteCodeNumbers[1].Contains(wins[0]) && AnteCodeNumbers[0].Contains(wins[1])))
            {
                isWin = true;
            }
            var bonusLevelList = new List <int>();

            if (isWin)
            {
                bonusLevelList.Add(0);
            }
            return(bonusLevelList);
        }
Exemple #3
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var wins   = checker.WinNumbers.Skip(TotalNumber - BallNumber).ToArray();
            var sum    = int.Parse(antecode);
            int target = 0;

            foreach (var num in wins)
            {
                target += int.Parse(num);
            }
            var bonusLevelList = new List <int>();

            if (target == sum)
            {
                bonusLevelList.Add(GetBonusGrade(wins));
            }
            return(bonusLevelList);
        }
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            AnalyzeAnteCode(antecode);

            string msg;
            var    checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            List <string[]> rlt = new List <string[]>();

            for (var i = 0; i < AnteCodeNumbers.Length; i++)
            {
                rlt.Add(AnteCodeNumbers[i].Split(' '));
            }
            var bonusLevelList = new List <int>();
            var c = new ArrayCombination();

            c.Calculate(rlt.ToArray(), (item) =>
            {
                if (item.Distinct().Count() == BallNumber)
                {
                    if (IsWin(item, checker.WinNumbers))
                    {
                        bonusLevelList.Add(0);
                    }
                }
            });
            return(bonusLevelList);
        }
Exemple #5
0
        public Task <IHttpActionResult> Get(string expr = null, string action = null)
        {
            if (action != null)
            {
                switch (action)
                {
                case "purge":
                    AnalyzerFactory.PurgeCache();
                    break;

                default:
                    throw new ArgumentException("无效的操作。", nameof(action));
                }
            }
            if (expr != null)
            {
                long[] idPair;
                try
                {
                    idPair = JsonConvert.DeserializeObject <long[]>(expr);
                }
                catch (Exception ex) when(ex is JsonSerializationException ||
                                          ex is JsonReaderException)
                {
                    throw new ArgumentException(ex.Message, nameof(expr));
                }
                if (idPair.Length != 2)
                {
                    throw new ArgumentException("无效的节点对。节点对有且仅有两个元素。", nameof(expr));
                }
                return(Get(idPair[0], idPair[1]));
            }
            return(Task.FromResult((IHttpActionResult)Ok()));
        }
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var bonusLevelList = new List <int>();

            // 判断大小单双
            string[] s_10 = GetCodeStatus(checker.WinNumbers[3]);
            string[] s_01 = GetCodeStatus(checker.WinNumbers[4]);
            if (s_10.Contains(AnteCodeNumbers[0]) && s_01.Contains(AnteCodeNumbers[1]))
            {
                bonusLevelList.Add(0);
            }
            return(bonusLevelList);
        }
Exemple #7
0
        private static MappingResolver MapFiles(string source, string target, string definitionFolder)
        {
            var definitionName = Path.GetFileNameWithoutExtension(source);

            var definitionStore = DefinitionFactory.Open(definitionName, definitionFolder);

            using (var sourceStream = File.OpenRead(source))
                using (var targetStream = File.OpenRead(target))
                {
                    var sourceAnalyzer = AnalyzerFactory.Create(sourceStream);
                    var targetAnalyzer = AnalyzerFactory.Create(targetStream);

                    var sourceType = definitionStore[sourceAnalyzer.LayoutHash];
                    var targetType = definitionStore[targetAnalyzer.LayoutHash];

                    if (sourceType == null)
                    {
                        return(null);
                    }

                    sourceAnalyzer = AnalyzerFactory.Create(sourceType, sourceStream);
                    if (targetType != null)
                    {
                        targetAnalyzer = AnalyzerFactory.Create(targetType, targetStream);
                    }

                    var resolver = new MappingResolver(definitionName, sourceAnalyzer, targetAnalyzer);
                    return(resolver);
                }
        }
Exemple #8
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            // 江西时时彩四星单选特殊处理奖等
            if (GameCode == "JXSSC" && BallNumber == 4)
            {
                return(Caculate_JXSSC_4XDX(AnteCodeNumbers, checker.WinNumbers));
            }
            else
            {
                var bonusLevelList = new List <int>();
                for (var i = TotalNumber - BallNumber; i < TotalNumber; i++)
                {
                    if (!AnteCodeNumbers[i].Contains(checker.WinNumbers[i]))
                    {
                        return(bonusLevelList);
                    }
                }
                bonusLevelList.Add(0);
                return(bonusLevelList);
            }
        }
Exemple #9
0
        private static string GetSubQueryString(string sen, float boost)
        {
            string queryString = sen;

            BooleanQuery query  = new BooleanQuery();
            QueryParser  parser = new QueryParser(MyLucene.GetLuceneVersion(), "name", AnalyzerFactory.GetAnalyzer());
            Query        q      = parser.Parse(queryString);

            q.SetBoost(boost * 9);
            query.Add(q, BooleanClause.Occur.SHOULD);

            parser = new QueryParser(MyLucene.GetLuceneVersion(), "oldName", AnalyzerFactory.GetAnalyzer());
            q      = parser.Parse(queryString);
            q.SetBoost(boost * 7);
            query.Add(q, BooleanClause.Occur.SHOULD);

            parser = new QueryParser(MyLucene.GetLuceneVersion(), "shortName", AnalyzerFactory.GetAnalyzer());
            q.SetBoost(boost * 10);
            q = parser.Parse(queryString);
            query.Add(q, BooleanClause.Occur.SHOULD);

            parser = new QueryParser(MyLucene.GetLuceneVersion(), "japName", AnalyzerFactory.GetAnalyzer());
            q.SetBoost(boost * 8);
            q = parser.Parse(queryString);
            query.Add(q, BooleanClause.Occur.SHOULD);

            parser = new QueryParser(MyLucene.GetLuceneVersion(), "enName", AnalyzerFactory.GetAnalyzer());
            q.SetBoost(boost * 7);
            q = parser.Parse(queryString);
            query.Add(q, BooleanClause.Occur.SHOULD);

            return(query.ToString());
        }
Exemple #10
0
        /// <summary>
        /// 检查投注号码格式是否正确
        /// </summary>
        /// <param name="antecode">投注号码</param>
        /// <param name="errMsg">错误消息</param>
        /// <returns>格式是否正确</returns>
        public bool CheckAntecode(string antecode, out string errMsg)
        {
            // 前置验证 - 彩种、玩法、投注号码
            PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种");
            PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法");
            PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码");

            AnteCodeNumbers = antecode.Split(Spliter);
            if (AnteCodeNumbers.Length != TotalNumber)
            {
                errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, TotalNumber);
                return(false);
            }
            var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType);

            for (var i = 0; i < TotalNumber; i++)
            {
                // 检查每一个号码
                if (!orderAnalyzer.CheckOneAntecodeNumber(AnteCodeNumbers[i], out errMsg))
                {
                    return(false);
                }
            }
            errMsg = "";
            return(true);
        }
Exemple #11
0
        /// <summary>
        /// 检查投注号码格式是否正确
        /// </summary>
        /// <param name="antecode">投注号码</param>
        /// <param name="errMsg">错误消息</param>
        /// <returns>格式是否正确</returns>
        public bool CheckAntecode(string antecode, out string errMsg)
        {
            // 前置验证 - 彩种、玩法、投注号码
            PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种");
            PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法");
            PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码");

            AnteCodeNumbers = antecode.Split(Spliter);
            if (AnteCodeNumbers.Length != BallNumber)
            {
                errMsg = string.Format("投注号码必须是被\"{0}\"切分成 {1}个部分的字符串", Spliter, BallNumber);
                return(false);
            }
            var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType);
            var i             = 0;

            for (; i < BallNumber; i++)
            {
                // 检查每一个号码
                if (!orderAnalyzer.CheckComboAntecodeNumber(AnteCodeNumbers[i], null, out errMsg))
                {
                    return(false);
                }
                // 分组,以去除号码中的重复项
                var group = AnteCodeNumbers[i].GroupBy(c => c);
                if (group.Count() != AnteCodeNumbers[i].Length)
                {
                    errMsg = "号码中有重复的数字 - " + antecode;
                    return(false);
                }
            }
            errMsg = "";
            return(true);
        }
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var bonusLevelList = new List <int>();
            var wins           = checker.WinNumbers.Skip(TotalNumber - BallNumber).ToArray();
            var groupWin       = wins.GroupBy(a => a);

            if (groupWin.Count() == wins.Length)
            {
                if (IsWin(wins, AnteCodeNumbers))
                {
                    bonusLevelList.Add(0);
                }
            }
            return(bonusLevelList);
        }
Exemple #13
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var bonusLevelList = new List <int>();
            var sum            = int.Parse(antecode);
            int target         = 0;

            for (int i = 1; i <= BallNumber; i++)
            {
                target += int.Parse(checker.WinNumbers[TotalNumber - i]);
            }
            if (target == sum)
            {
                bonusLevelList.Add(0);
            }
            return(bonusLevelList);
        }
Exemple #14
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var bonusLevelList = new List <int>();

            if (IsRed)    // 选一红投
            {
                var win = int.Parse(checker.WinNumbers[0]);
                if (win >= MinNumber && win <= MaxNumber)
                {
                    bonusLevelList.Add(0);
                }
            }
            else    // 选一数投
            {
                if (AnteCodeNumbers.Contains(checker.WinNumbers[0]))
                {
                    bonusLevelList.Add(0);
                }
            }
            return(bonusLevelList);
        }
        /// <summary>
        /// 检查投注号码格式是否正确
        /// </summary>
        /// <param name="antecode">投注号码</param>
        /// <param name="errMsg">错误消息</param>
        /// <returns>格式是否正确</returns>
        public bool CheckAntecode(string antecode, out string errMsg)
        {
            // 前置验证 - 彩种、玩法、投注号码
            PreconditionAssert.IsNotEmptyString(GameCode, "检查投注号码格式前,必须设置彩种");
            PreconditionAssert.IsNotEmptyString(GameType, "检查投注号码格式前,必须设置玩法");
            PreconditionAssert.IsNotEmptyString(antecode, "必须传入非空的投注号码");

            AnteCodeNumbers = antecode.Split(Spliter);
            if (AnteCodeNumbers.Length < BallNumber || AnteCodeNumbers.Length > AllNumber)
            {
                errMsg = string.Format("投注号码必须是由\"{0}\"连接的 {1} - {2}个数字组成", Spliter, BallNumber, AllNumber);
                return(false);
            }
            var orderAnalyzer = AnalyzerFactory.GetOrderAnalyzer(GameCode, GameType);

            for (var i = 0; i < AnteCodeNumbers.Length; i++)
            {
                // 检查每一个号码
                if (!orderAnalyzer.CheckOneAntecodeNumber(AnteCodeNumbers[i], out errMsg))
                {
                    return(false);
                }
            }
            var groupCount = AnteCodeNumbers.GroupBy(a => a).Count();

            if (groupCount != AnteCodeNumbers.Length)
            {
                errMsg = string.Format("投注号码有重复数字出现:{0}", antecode);
                return(false);
            }
            errMsg = "";
            return(true);
        }
Exemple #16
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var isWin = true;

            for (int i = 0; i < BallNumber; i++)
            {
                if (!AnteCodeNumbers.Contains(checker.WinNumbers[i]))
                {
                    isWin = false;
                    break;
                }
            }
            var bonusLevelList = new List <int>();

            if (isWin)
            {
                bonusLevelList.Add(0);
            }
            return(bonusLevelList);
        }
        /// <summary>
        /// 检查中奖号码格式是否正确
        /// </summary>
        /// <param name="winNumber">中奖号码</param>
        /// <param name="gameType">玩法</gameType>
        /// <param name="errMsg">错误消息</param>
        /// <returns>格式是否正确</returns>
        public bool CheckWinNumber(ISportResult winNumber, string gameType, out string errMsg)
        {
            if (!string.IsNullOrEmpty(gameType) && gameType != GameType)
            {
                var orderAnalyzer = AnalyzerFactory.GetSportAnteCodeChecker(GameCode, gameType);
                return(orderAnalyzer.CheckWinNumber(winNumber, null, out errMsg));
            }
            else
            {
                // 前置验证 - 彩种、玩法、投注号码
                PreconditionAssert.IsNotEmptyString(GameCode, "检查中奖号码格式前,必须设置彩种");
                PreconditionAssert.IsNotNull(winNumber, "必须传入非空的比赛结果");
                PreconditionAssert.IsNotEmptyString(winNumber.GetMatchId(GameCode), "必须传入比赛编号");

                _winNumbers = EffectiveWinNumber.Split(Spliter);
                var result = winNumber.GetMatchResult(GameCode, GameType);
                if (result != CancelMatchResultFlag && !_winNumbers.Contains(result))
                {
                    errMsg = string.Format("错误的比赛结果格式,允许的格式:{0},取消结果格式:{1},实际为:'{2}'.", EffectiveWinNumber, CancelMatchResultFlag, result);
                    return(false);
                }
                errMsg = "";
                return(true);
            }
        }
        public void test_WHEN_expression_is_array_THEN_array_analyzer_is_created()
        {
            Expression <Func <SPListItem, object[]> > expr = x => new[] { x["Count"] };
            var analyzerFactory = new AnalyzerFactory(null, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <ArrayAnalyzer>());
        }
        public void test_WHEN_expression_is_orelse_THEN_orelse_analyzer_is_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => (int)x["Count"] == 1 || (int)x["Count"] == 1;
            var analyzerFactory = new AnalyzerFactory(null, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <OrElseAnalyzer>());
        }
        public void test_WHEN_expression_IS_in_THEN_in_analyzer_IS_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => (new[] { 0, 1, 2 }).Contains((int)x[new Guid("{1DF87A41-D795-4C0F-915F-DC3D54B296AA}")]);
            var analyzerFactory = new AnalyzerFactory(null, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <InAnalyzer>());
        }
        public void test_WHEN_expression_IS_contains_THEN_contains_analyzer_IS_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => ((string)x["Count"]).Contains("foo");
            var analyzerFactory = new AnalyzerFactory(null, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <ContainsAnalyzer>());
        }
        public void test_WHEN_expression_IS_beginswith_THEN_beginswith_analyzer_IS_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => ((string)x["Count"]).StartsWith("foo");
            var analyzerFactory = new AnalyzerFactory(null, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <BeginsWithAnalyzer>());
        }
 static SPSearch()
 {
     // factories setup
     var operandBuilder = new OperandBuilder();
     var operationResultBuilder = new OperationResultBuilder();
     var analyzerFactory = new AnalyzerFactory(operandBuilder, operationResultBuilder);
     TranslatorFactory = new TranslatorFactory(analyzerFactory);
 }
Exemple #24
0
        static SPSearch()
        {
            // factories setup
            var operandBuilder         = new OperandBuilder();
            var operationResultBuilder = new OperationResultBuilder();
            var analyzerFactory        = new AnalyzerFactory(operandBuilder, operationResultBuilder);

            TranslatorFactory = new TranslatorFactory(analyzerFactory);
        }
        public void test_WHEN_expression_is_not_includes_explicit_cast_string_based_syntax_THEN_not_includes_analyzer_is_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => !((DataTypes.Integer)x["Count"]).Includes(1);
            var operandBuilder  = new OperandBuilder();
            var analyzerFactory = new AnalyzerFactory(operandBuilder, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <NotIncludesAnalyzer>());
        }
        public void test_WHEN_expression_is_not_includes_with_lookupId_THEN_not_includes_analyzer_is_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => !((int)x["Count"]).Includes(1, true);
            var operandBuilder  = new OperandBuilder();
            var analyzerFactory = new AnalyzerFactory(operandBuilder, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <NotIncludesAnalyzer>());
        }
        public void test_WHEN_expression_is_neq_THEN_neq_analyzer_is_created()
        {
            Expression <Func <SPListItem, bool> > expr = x => (int)x["Count"] != 1;
            var operandBuilder  = new OperandBuilder();
            var analyzerFactory = new AnalyzerFactory(operandBuilder, null);
            var analyzer        = analyzerFactory.Create(expr);

            Assert.That(analyzer, Is.InstanceOf <NeqAnalyzer>());
        }
        public void test_THAT_binary_or_expression_IS_not_valid_expression()
        {
            Expression <Func <SPListItem, bool> > expr = x => (string)x["Email"] == "*****@*****.**" |
                                                         (int)x["Count1"] == 1;
            var operandBuilder  = new OperandBuilder();
            var analyzerFactory = new AnalyzerFactory(operandBuilder, null);
            var analyzer        = new OrElseAnalyzer(null, analyzerFactory);

            Assert.That(analyzer.IsValid(expr), Is.False);
        }
        public void test_THAT_logical_and_expression_IS_valid_expression()
        {
            Expression <Func <SPListItem, bool> > expr = x => (string)x["Email"] == "*****@*****.**" &&
                                                         (int)x["Count1"] == 1;
            var operandBuilder  = new OperandBuilder();
            var analyzerFactory = new AnalyzerFactory(operandBuilder, null);
            var analyzer        = new AndAlsoAnalyzer(null, analyzerFactory);

            Assert.That(analyzer.IsValid(expr), Is.True);
        }
Exemple #30
0
        public IList <int> CaculateBonus(string antecode, string winNumber)
        {
            string msg;

            if (!CheckAntecode(antecode, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, antecode, "投注号码格式错误 - " + msg);
            }
            var checker = AnalyzerFactory.GetWinNumberAnalyzer(GameCode, GameType);

            if (!checker.CheckWinNumber(winNumber, out msg))
            {
                throw new AntecodeFormatException(GameCode, GameType, winNumber, "中奖号码格式错误 - " + msg);
            }
            var bonusLevelList = new List <int>();

            if (BallNumber == 1)    // 任选一,定位到中奖号码的第一位进行比较
            {
                if (AnteCodeNumbers.Contains(checker.WinNumbers[0]))
                {
                    bonusLevelList.Add(0);
                }
            }
            else if (BallNumber <= TotalNumber)     // 任选的数量小于等于总号码数。如:任选四、任选五
            {
                var p = new Combination();
                p.Calculate(AnteCodeNumbers, BallNumber, (num) =>
                {
                    if (IsWin_Less(checker.WinNumbers, num))
                    {
                        bonusLevelList.Add(0);
                    }
                });
            }
            else    // 任选的数量大于等于总号码数。如:任选七
            {
                var winTime = 0;
                foreach (var item in checker.WinNumbers)
                {
                    if (AnteCodeNumbers.Contains(item))
                    {
                        winTime++;
                    }
                }
                if (winTime == TotalNumber)
                {
                    var p = new Combination();
                    p.Calculate(AnteCodeNumbers.Take(AnteCodeNumbers.Length - 5).ToArray(), BallNumber - 5, (item) =>
                    {
                        bonusLevelList.Add(0);
                    });
                }
            }
            return(bonusLevelList);
        }
Exemple #31
0
        public void ImportWinNumber(string issuseNumber, string winNumber)
        {
            if (string.IsNullOrEmpty(issuseNumber))
            {
                return;
            }
            if (string.IsNullOrEmpty(winNumber))
            {
                return;
            }


            var msg = string.Empty;

            AnalyzerFactory.GetWinNumberAnalyzer(this.CurrentGameCode).CheckWinNumber(winNumber, out msg);
            if (!string.IsNullOrEmpty(msg))
            {
                throw new Exception(msg);
            }

            //开启事务
            using (LottertDataDB)
            {
                LottertDataDB.Begin();

                this.ClearGameChartCache("QueryDLT_JiBenZouSi_Info");
                this.ClearGameChartCache("QueryDLT_DX_Info");
                this.ClearGameChartCache("QueryDLT_JiOu_Info");
                this.ClearGameChartCache("QueryDLT_ZhiHe_Info");
                this.ClearGameChartCache("QueryDLT_HeZhi_Info");
                this.ClearGameChartCache("QueryDLT_Chu3_Info");
                this.ClearGameChartCache("QueryDLT_KuaDu_SW_Info");
                this.ClearGameChartCache("QueryDLT_KuaDu_12_Info");
                this.ClearGameChartCache("QueryDLT_KuaDu_23_Info");
                this.ClearGameChartCache("QueryDLT_KuaDu_34_Info");
                this.ClearGameChartCache("QueryDLT_KuaDu_45_Info");
                this.ClearNewWinNumberCache("QueryDLT_GameWinNumber");

                Import_JBZS(issuseNumber, winNumber);
                Import_DX(issuseNumber, winNumber);
                Import_JiOu(issuseNumber, winNumber);
                Import_ZhiHe(issuseNumber, winNumber);
                Import_DLT_HeZhi(issuseNumber, winNumber);
                Import_DLT_Chu3(issuseNumber, winNumber);
                Import_DLT_KuaDu_SW(issuseNumber, winNumber);
                Import_DLT_KuaDu_12(issuseNumber, winNumber);
                Import_DLT_KuaDu_23(issuseNumber, winNumber);
                Import_DLT_KuaDu_34(issuseNumber, winNumber);
                Import_DLT_KuaDu_45(issuseNumber, winNumber);
                Add_GameWinNumber(issuseNumber, winNumber);

                LottertDataDB.Commit();
            }
        }
        private ProblemCollection CheckSymbol([CanBeNull] ISymbol symbol)
        {
            if (symbol != null)
            {
                // When unable to load external annotations, the rule would likely report lots
                // of false positives. This is prevented by letting it throw here and report nothing.
                var analyzerFactory = new AnalyzerFactory(ExternalAnnotationsRegistry.GetCached(), appliesToItem);

                BaseAnalyzer analyzer = analyzerFactory.CreateFor(symbol);
                analyzer.Analyze(ReportProblem);
            }

            return Problems;
        }