コード例 #1
0
 public override string IntsListToJsonString(List <InstClass> Insts)
 {
     String[] strInsts = new String[Insts.Count];
     for (int i = 0; i < Insts.Count; i++)
     {
         InstClass ic = Insts[i];
         strInsts[i] = ic.GetJson();
     }
     return(String.Format("[{0}]", Array2String(strInsts)));
 }
コード例 #2
0
        public override string IntsToJsonString(string ccs, int unit)
        {
            //unit为单位 0,元;1,角;2,分,3,其他
            ccs = ccs.Trim();
            ccs = ccs.Replace("  ", "");
            ccs = ccs.Replace("+", " ");
            ccs = ccs.Trim();
            if (ccs.Length == 0)
            {
                return("");
            }
            String[]         ccsarr  = ccs.Split(' ');
            List <InstClass> InsArr  = new List <InstClass>();
            double           unitVal = 0;

            unitVal = getUnitValue(unit);
            //int ArrCnt = 0;
            for (int i = 0; i < ccsarr.Length; i++)//遍历所有指令
            {
                String   cc;
                String   ccNos;      // As String,
                String   ccCars;     //As String,
                Int64    ccUnitCost; // As Long,
                String[] ccArr;
                cc = ccsarr[i].Trim();
                if (cc.Length == 0)
                {
                    continue;
                }
                ccArr = cc.Split('/');
                if (ccArr.Length < 3)
                {
                    continue;
                }
                ccNos = ccArr[0].Trim(); //第一个是指令类型 ,A1~8 C2~3 P2~3,以及其他趣味类型
                var items = rules.AllRules.Where(a => a.Value.instType == ccNos);
                if (items.Count() != 1)  //如果并未识别到投注类型,投注跳过
                {
                    continue;
                }
                LotteryBetRuleClass currRule = items.First().Value;                       //获取到类型
                string strNums   = ccArr[1];                                              //
                String ccOrgCars = ccArr[1].Trim();
                ccCars     = ToStdFmt(ccOrgCars, ccNos.ToUpper().StartsWith("P")).Trim(); //车号组合标准格式
                ccUnitCost = Int64.Parse(ccArr[2]);
                if (ccUnitCost == 0)
                {
                    continue;
                }



                InstClass ic = new InstClass();
                ic.ruleId    = currRule.BetRule;                         //配置文件里面指定的规则号
                ic.betNum    = getNums(ccNos, rules, ccCars).ToString(); //所有指令数量都为1?好像也不是的,而是组合数
                ic.itemTimes = String.Format("{0:N2}", unitVal * ccUnitCost);
                ic.selNums   = ccCars;                                   //Array2String(strNums.Split(',')).Replace(", ", ",");
                string strOdds = null;
                if (currRule.OddsDic.ContainsKey(setting.Odds.ToString()))
                {
                    strOdds = currRule.OddsDic[setting.Odds.ToString()];
                }
                double odds         = 0.0;
                bool   needCalcOdds = true;
                if (!string.IsNullOrEmpty(strOdds))
                {
                    if (double.TryParse(strOdds, out odds))
                    {
                        needCalcOdds = false;
                    }
                }
                if (needCalcOdds)//当没有取到赔率,或者赔率非法,才去计算
                {
                    odds = getRealOdds(ccNos, rules, setting.Odds);
                }
                ic.jsOdds    = string.Format("{0:N2}", Math.Round(odds, 2));//string.Format("{0:N2}",getRealOdds(setting.Odds, rules.elementCount, rules.baseTimes, rules.calcTimes, currRule.oddsTimes));//  String.Format("{0:N2}", setting.Odds);
                ic.priceMode = unit;
                InsArr.Add(ic);
            }
            if (InsArr.Count > 0)
            {
                return(this.IntsListToJsonString(InsArr));
            }
            else
            {
                return("");
            }
        }
コード例 #3
0
        String cRuleId_B = "8140102"; // '后5位定胆
        public override string IntsToJsonString(String ccs, int unit)
        {
            //unit为单位 0,元;1,角;2,分,3,其他
            ccs = ccs.Trim();
            ccs = ccs.Replace("  ", "");
            ccs = ccs.Replace("+", " ");
            ccs = ccs.Trim();
            if (ccs.Length == 0)
            {
                return("");
            }
            String[]         ccsarr  = ccs.Split(' ');
            List <InstClass> InsArr  = new List <InstClass>();
            double           unitVal = 0;

            unitVal = getUnitValue(unit);
            int ArrCnt = 0;

            for (int i = 0; i < ccsarr.Length; i++)
            {
                String   cc;
                String   ccNos;      // As String,
                String   ccCars;     //As String,
                Int64    ccUnitCost; // As Long,
                String[] ccArr;
                cc = ccsarr[i].Trim();
                if (cc.Length == 0)
                {
                    continue;
                }
                ccArr = cc.Split('/');
                if (ccArr.Length < 3)
                {
                    continue;
                }
                ccNos = ccArr[0].Trim();
                String ccOrgCars = ccArr[1].Trim();
                ccCars     = toStdCarFmt(ccOrgCars).Trim();//车号组合标准格式
                ccUnitCost = Int64.Parse(ccArr[2]);
                String[] sArr = new String[5];
                String[] bArr = new String[5];
                for (int j = 0; j < 5; j++)
                {
                    sArr[j] = "";
                    bArr[j] = "";
                }
                int sArrCnt, bArrCnt;
                sArrCnt = 0;
                bArrCnt = 0;
                for (int j = 0; j < ccNos.Length; j++)
                {
                    String strsNo;                  //As String
                    int    iNo;                     // As Integer
                    strsNo = ccNos.Substring(j, 1); // Mid(ccNos, j, 1)
                    if (strsNo.Equals("0"))
                    {
                        strsNo = "10";
                    }
                    iNo = int.Parse(strsNo);
                    if (iNo <= 5)
                    {
                        sArr[iNo - 1] = ccCars.Trim();
                        sArrCnt++;
                    }
                    else
                    {
                        bArr[iNo - 5 - 1] = ccCars.Trim();
                        bArrCnt++;
                    }
                }
                if (sArrCnt > 0)
                {
                    InstClass ic = new InstClass();
                    ic.ruleId    = cRuleId_S;
                    ic.betNum    = String.Format("{0}", ccOrgCars.Length * sArrCnt);
                    ic.itemTimes = String.Format("{0:N2}", unitVal * ccUnitCost);
                    ic.selNums   = Array2String(sArr).Replace(", ", ",");
                    ic.jsOdds    = String.Format("{0:N2}", GobalSetting.Odds);
                    ic.priceMode = unit;
                    InsArr.Add(ic);
                }
                if (bArrCnt > 0)
                {
                    InstClass ic = new InstClass();
                    ic.ruleId    = cRuleId_B;
                    ic.betNum    = String.Format("{0}", ccOrgCars.Length * bArrCnt);
                    ic.itemTimes = String.Format("{0:N2}", unitVal * ccUnitCost);
                    ic.selNums   = Array2String(bArr).Replace(", ", ",");
                    ic.jsOdds    = String.Format("{0:N2}", GobalSetting.Odds);
                    ic.priceMode = unit;
                    InsArr.Add(ic);
                }
            }
            if (InsArr.Count > 0)
            {
                return(this.IntsListToJsonString(InsArr));
            }
            else
            {
                return("");
            }
        }