private void ProccessStatisticsAction()
 {
     JObject result = new JObject();
     try
     {
         int matchid = int.Parse(Request.Form["matchid"]);
         string[] scriptids = Request.Form["scriptids"].Split(',');
         string[] wins = Request.Form["wins"].Split(',');
         string[] victorys = Request.Form["victorys"].Split(',');
         BetExpBLL betExpBLL = new BetExpBLL();
         if (!betExpBLL.ExistsStatistics(matchid))
         {
             for (int i = 0; i < scriptids.Length; i++)
             {
                 string win = (wins[i]=="true" ? "win":"lost");
                 string victory = (victorys[i]=="true" ? "resultwin":"resultlost");
                 bll.Increase(int.Parse(scriptids[i]), win, victory);
             }
             betExpBLL.Update(matchid, true);
         }
         result.Add("success",true);
     }
     catch (Exception e)
     {
         result.Add("success", false);
         result.Add("error", e.ToString());
     }
     JsonStr = result.ToString();
 }
Beispiel #2
0
        /// <summary>
        /// 获得平均凯利线性图形
        /// </summary>
        /// <param name="scheduleID"></param>
        /// <param name="companyids"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public string GetKellyAverageLineChart(string scheduleID, string[] companyids, double time,bool isRefresh)
        {
            string jsonStr = "";
            BetExpBLL bll = new BetExpBLL();
            if (bll.Exists(int.Parse(scheduleID)) && !isRefresh)
            {
                BetExp betExp = bll.GetModel(int.Parse(scheduleID));
                jsonStr = betExp.data;
            }
            else
            {
                if (companyids == null || companyids.Length == 0)
                {
                    companyids = dal.getLastCompanyIDs(scheduleID, 1);
                }

                DataSet dsStart = dal.GetCompanyStartPoint(scheduleID, companyids);
                DataSet dsEnd = dal.GetCompanyEndPoint(scheduleID, companyids);

                DateTime firsttime = DateTime.Parse(dsStart.Tables[0].Rows[0][0].ToString());
                DateTime lasttime = DateTime.Parse(dsEnd.Tables[0].Rows[0][0].ToString());

                DateTime firsttime1 = lasttime.AddSeconds(-time);

                if (firsttime1 > firsttime)
                {
                    firsttime = firsttime1;
                }
                float inithome = 0;
                float initdraw = 0;
                float initaway = 0;
                float initrate = 0;

                JsonSerializer serializer = GetJsonSerializer();
                double timespace = lasttime.Subtract(firsttime).TotalSeconds / 30;
                Odds1x2History firthmodel = new Odds1x2History();
                JArray data = new JArray();
                while (firsttime <= lasttime)
                {
                    ds = dal.GetAveNumByCompanys(scheduleID, string.Join(",", companyids), firsttime);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        DataRow dr = ds.Tables[0].Rows[0];
                        List<float> homeKelly = new List<float>();
                        List<float> drawKelly = new List<float>();
                        List<float> awayKelly = new List<float>();
                        List<float> returnrateKelly = new List<float>();
                        List<Odds1x2History> oddsList = dal.GetLastListByCompanys(int.Parse(scheduleID), string.Join(",", companyids), firsttime);
                        foreach (Odds1x2History item in oddsList)
                        {
                            homeKelly.Add(item.home * float.Parse(dr["avghomep"].ToString()));
                            drawKelly.Add(item.draw * float.Parse(dr["avgdrawp"].ToString()));
                            awayKelly.Add(item.away * float.Parse(dr["avgawayp"].ToString()));
                            returnrateKelly.Add(item.returnrate * 100);
                        }

                        JObject result = new JObject();
                        if (data.Count <= 0)
                        {
                            inithome = homeKelly.Average();
                            initdraw = drawKelly.Average();
                            initaway = awayKelly.Average();
                            initrate = returnrateKelly.Average();
                        }

                        result.Add("avehome", (homeKelly.Average() - inithome) * 10);
                        result.Add("avedraw", (drawKelly.Average() - initdraw) * 10);
                        result.Add("aveaway", (awayKelly.Average() - initaway) * 10);
                        result.Add("returnrate", (returnrateKelly.Average() - initrate) * 10);
                        result.Add("varhome", this.CalculationVariance(homeKelly));
                        result.Add("vardraw", this.CalculationVariance(drawKelly));
                        result.Add("varaway", this.CalculationVariance(awayKelly));
                        result.Add("time", JProperty.FromObject(firsttime, serializer));
                        data.Add(result);
                        firsttime = firsttime.AddSeconds(timespace);
                    }
                }
                jsonStr =  data.ToString();
                bll.Delete(int.Parse(scheduleID));
                string[] valueArr = new string[data.Count];
                for (int i = 0; i < data.Count; i++)
                {
                    valueArr[i] = bll.GetTrendsValue(JObject.Parse(data[data.Count - (data.Count - i)].ToString()),"");
                }
                bll.Add(new BetExp(int.Parse(scheduleID), jsonStr, string.Join(",", valueArr),"*" + bll.GetChangesValue(data,""), false));
            }
            return jsonStr;
        }
Beispiel #3
0
        /// <summary>
        /// 获得平均凯利线性图形
        /// </summary>
        /// <param name="scheduleID"></param>
        /// <param name="companyids"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public string GetKellyAverageLineChart(string scheduleID, string[] companyids, double time, bool isRefresh)
        {
            string    jsonStr = "";
            BetExpBLL bll     = new BetExpBLL();

            if (bll.Exists(int.Parse(scheduleID)) && !isRefresh)
            {
                BetExp betExp = bll.GetModel(int.Parse(scheduleID));
                jsonStr = betExp.data;
            }
            else
            {
                if (companyids == null || companyids.Length == 0)
                {
                    companyids = dal.getLastCompanyIDs(scheduleID, 1);
                }

                DataSet dsStart = dal.GetCompanyStartPoint(scheduleID, companyids);
                DataSet dsEnd   = dal.GetCompanyEndPoint(scheduleID, companyids);

                DateTime firsttime = DateTime.Parse(dsStart.Tables[0].Rows[0][0].ToString());
                DateTime lasttime  = DateTime.Parse(dsEnd.Tables[0].Rows[0][0].ToString());

                DateTime firsttime1 = lasttime.AddSeconds(-time);

                if (firsttime1 > firsttime)
                {
                    firsttime = firsttime1;
                }
                float inithome = 0;
                float initdraw = 0;
                float initaway = 0;
                float initrate = 0;

                JsonSerializer serializer = GetJsonSerializer();
                double         timespace  = lasttime.Subtract(firsttime).TotalSeconds / 30;
                Odds1x2History firthmodel = new Odds1x2History();
                JArray         data       = new JArray();
                while (firsttime <= lasttime)
                {
                    ds = dal.GetAveNumByCompanys(scheduleID, string.Join(",", companyids), firsttime);
                    if (ds.Tables[0].Rows.Count == 1)
                    {
                        DataRow               dr              = ds.Tables[0].Rows[0];
                        List <float>          homeKelly       = new List <float>();
                        List <float>          drawKelly       = new List <float>();
                        List <float>          awayKelly       = new List <float>();
                        List <float>          returnrateKelly = new List <float>();
                        List <Odds1x2History> oddsList        = dal.GetLastListByCompanys(int.Parse(scheduleID), string.Join(",", companyids), firsttime);
                        foreach (Odds1x2History item in oddsList)
                        {
                            homeKelly.Add(item.home * float.Parse(dr["avghomep"].ToString()));
                            drawKelly.Add(item.draw * float.Parse(dr["avgdrawp"].ToString()));
                            awayKelly.Add(item.away * float.Parse(dr["avgawayp"].ToString()));
                            returnrateKelly.Add(item.returnrate * 100);
                        }

                        JObject result = new JObject();
                        if (data.Count <= 0)
                        {
                            inithome = homeKelly.Average();
                            initdraw = drawKelly.Average();
                            initaway = awayKelly.Average();
                            initrate = returnrateKelly.Average();
                        }

                        result.Add("avehome", (homeKelly.Average() - inithome) * 10);
                        result.Add("avedraw", (drawKelly.Average() - initdraw) * 10);
                        result.Add("aveaway", (awayKelly.Average() - initaway) * 10);
                        result.Add("returnrate", (returnrateKelly.Average() - initrate) * 10);
                        result.Add("varhome", this.CalculationVariance(homeKelly));
                        result.Add("vardraw", this.CalculationVariance(drawKelly));
                        result.Add("varaway", this.CalculationVariance(awayKelly));
                        result.Add("time", JProperty.FromObject(firsttime, serializer));
                        data.Add(result);
                        firsttime = firsttime.AddSeconds(timespace);
                    }
                }
                jsonStr = data.ToString();
                bll.Delete(int.Parse(scheduleID));
                string[] valueArr = new string[data.Count];
                for (int i = 0; i < data.Count; i++)
                {
                    valueArr[i] = bll.GetTrendsValue(JObject.Parse(data[data.Count - (data.Count - i)].ToString()), "");
                }
                bll.Add(new BetExp(int.Parse(scheduleID), jsonStr, string.Join(",", valueArr), "*" + bll.GetChangesValue(data, ""), false));
            }
            return(jsonStr);
        }