예제 #1
0
        private void statOddsHistory()
        {
            if (Request["stypeid"] != null && Request["oddsarr"] != null)
            {
                try
                {
                    string[]       sclassArr     = Request.Form["stypeid"].Split('^');
                    string[]       oddsArr       = Request.Form["oddsarr"].Split('^');
                    string[]       scheduleArr   = Request.Form["schedulearr"].Split('^');
                    List <string>  swhereList    = new List <string>();
                    List <string>  ewhereList    = new List <string>();
                    List <string>  oddswhereList = new List <string>();
                    List <decimal> swlist        = new List <decimal>();
                    List <decimal> sdlist        = new List <decimal>();
                    List <decimal> sllist        = new List <decimal>();
                    List <decimal> ewlist        = new List <decimal>();
                    List <decimal> edlist        = new List <decimal>();
                    List <decimal> ellist        = new List <decimal>();
                    foreach (string oddsStr in oddsArr)
                    {
                        string[] odds = oddsStr.Split('|');
                        swhereList.Add("(companyid=" + odds[0] + " and s_win=" + odds[3] +
                                       " and s_draw=" + odds[4] + " and s_lost=" + odds[5] + ")");
                        swlist.Add(Convert.ToDecimal(odds[6]));
                        sdlist.Add(Convert.ToDecimal(odds[7]));
                        sllist.Add(Convert.ToDecimal(odds[8]));
                        if (!String.IsNullOrEmpty(odds[10]) && !String.IsNullOrEmpty(odds[11]) && !String.IsNullOrEmpty(odds[12]))
                        {
                            ewhereList.Add("(companyid=" + odds[0] + " and (e_win=" + odds[10] +
                                           ") and (e_draw=" + odds[11] + ") and (e_lost=" + odds[12] + "))");
                            ewlist.Add(Convert.ToDecimal(odds[13]));
                            edlist.Add(Convert.ToDecimal(odds[14]));
                            ellist.Add(Convert.ToDecimal(odds[15]));
                        }
                    }
                    string swhereStr = "(" + String.Join(" or ", swhereList.ToArray()) + ")";
                    string ewhereStr = "(" + String.Join(" or ", ewhereList.ToArray()) + ")";
                    //string ewhereStr = "(" + String.Join(" or ", ewhereList.ToArray()) + ")";

                    DataSet sds = scheduleBLL.statOddsHistory1(null, null, swhereStr);
                    DataSet eds = scheduleBLL.statOddsHistory1(null, null, ewhereStr);

                    DataTable dt = new DataTable();
                    dt.Columns.Add("name", typeof(string));
                    dt.Columns.Add("perwin", typeof(float));
                    dt.Columns.Add("perdraw", typeof(float));
                    dt.Columns.Add("perlost", typeof(float));
                    dt.Columns.Add("oddswin", typeof(float));
                    dt.Columns.Add("oddsdraw", typeof(float));
                    dt.Columns.Add("oddslost", typeof(float));
                    dt.Columns.Add("avgscore", typeof(float));
                    dt.Columns.Add("totalCount", typeof(int));

                    if (Convert.ToInt32(eds.Tables[0].Rows[0]["totalCount"]) > 0 &&
                        Convert.ToInt32(sds.Tables[0].Rows[0]["totalCount"]) > 0)
                    {
                        Common.DataCache.SetCache("swhere", swhereStr);
                        Common.DataCache.SetCache("ewhere", ewhereStr);
                        Common.DataCache.SetCache("cclassid", sclassArr[9]);
                        Common.DataCache.SetCache("sclassid", sclassArr[0]);

                        dt.ImportRow(sds.Tables[0].Rows[0]);
                        dt.Rows[0]["name"]     = "全局初";
                        dt.Rows[0]["oddswin"]  = swlist.Average();
                        dt.Rows[0]["oddsdraw"] = sdlist.Average();
                        dt.Rows[0]["oddslost"] = sllist.Average();
                        dt.ImportRow(eds.Tables[0].Rows[0]);
                        dt.Rows[1]["name"]     = "全局终";
                        dt.Rows[1]["oddswin"]  = ewlist.Average();
                        dt.Rows[1]["oddsdraw"] = edlist.Average();
                        dt.Rows[1]["oddslost"] = ellist.Average();
                        sds = scheduleBLL.statOddsHistory1(sclassArr[9], null, swhereStr);
                        eds = scheduleBLL.statOddsHistory1(sclassArr[9], null, ewhereStr);
                        dt.ImportRow(sds.Tables[0].Rows[0]);
                        dt.Rows[2]["name"]     = "国家初";
                        dt.Rows[2]["oddswin"]  = Convert.ToDecimal(dt.Rows[0][1]) - swlist.Average();
                        dt.Rows[2]["oddsdraw"] = Convert.ToDecimal(dt.Rows[0][2]) - sdlist.Average();
                        dt.Rows[2]["oddslost"] = Convert.ToDecimal(dt.Rows[0][3]) - sllist.Average();
                        dt.ImportRow(eds.Tables[0].Rows[0]);
                        dt.Rows[3]["name"]     = "国家终";
                        dt.Rows[3]["oddswin"]  = Convert.ToDecimal(dt.Rows[1][1]) - ewlist.Average();
                        dt.Rows[3]["oddsdraw"] = Convert.ToDecimal(dt.Rows[1][2]) - edlist.Average();
                        dt.Rows[3]["oddslost"] = Convert.ToDecimal(dt.Rows[1][3]) - ellist.Average();
                        sds = scheduleBLL.statOddsHistory1(null, sclassArr[0], swhereStr);
                        eds = scheduleBLL.statOddsHistory1(null, sclassArr[0], ewhereStr);
                        dt.ImportRow(sds.Tables[0].Rows[0]);
                        dt.Rows[4]["name"] = "赛事初";
                        dt.ImportRow(eds.Tables[0].Rows[0]);
                        dt.Rows[5]["name"] = "赛事终";
                    }

                    JObject result = JObject.Parse("{success:true}");
                    result.Add("data", JArray.FromObject(dt));
                    StringJSON = result.ToString();
                }
                catch (Exception e)
                {
                    StringJSON = "{success:false,error:message:'" + e.Message + "'}";
                }
            }
        }