Beispiel #1
0
        public void updateOdds1x2(string scheduleID)
        {
            try
            {
                OddsDAO oddsDAO = new OddsDAO();
                CompanyDAO companyDAO = new CompanyDAO();
                WebClientBLL bll = new WebClientBLL();
                string actual = bll.UpdateOdds1x2Content(scheduleID);

                //获取赔率原始数据
                Regex reg = new Regex("game\\=Array\\(\"" + "\\w[^;" + "]*;");
                Match mat = reg.Match(actual);
                if (mat != null && !String.IsNullOrEmpty(mat.Value))
                {

                    //所有公司数据
                    string source = mat.Value.Substring(12, mat.Value.Length - 10 - 4);
                    //分解出每个公司数据
                    string[] compstrs = Regex.Split(source, "\",\"", RegexOptions.IgnoreCase);
                    foreach (string compstr in compstrs)
                    {
                        JObject item = new JObject();
                        string[] oddsArr = compstr.Replace("\"", "").Split('|');

                        #region 插入公司数据
                        if (!companyDAO.Exists(int.Parse(oddsArr[0])) && oddsArr.Length > 22)
                        {
                            SeoWebSite.Model.Company company = new SeoWebSite.Model.Company();
                            company.id = int.Parse(oddsArr[0]);
                            company.fullname = oddsArr[21];
                            company.name = oddsArr[2];
                            company.isprimary = Convert.ToBoolean(int.Parse(oddsArr[22]));
                            company.isexchange = Convert.ToBoolean(int.Parse(oddsArr[23]));
                            companyDAO.Add(company);
                        }
                        #endregion

                        #region 插入欧赔数据
                        if (!oddsDAO.Exists(int.Parse(oddsArr[1])))
                        {
                            Odds odds = new Odds();
                            odds.scheduleid = int.Parse(scheduleID);
                            odds.companyid = int.Parse(oddsArr[0]);
                            odds.id = int.Parse(oddsArr[1]);
                            odds.s_win = decimal.Parse(oddsArr[3]);
                            odds.s_draw = decimal.Parse(oddsArr[4]);
                            odds.s_lost = decimal.Parse(oddsArr[5]);
                            odds.s_winper = decimal.Parse(oddsArr[6]);
                            odds.s_drawper = decimal.Parse(oddsArr[7]);
                            odds.s_lostper = decimal.Parse(oddsArr[8]);
                            if (!String.IsNullOrEmpty(oddsArr[9]))
                            {
                                odds.s_return = decimal.Parse(oddsArr[9]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[10]))
                            {
                                odds.e_win = decimal.Parse(oddsArr[10]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[11]))
                            {
                                odds.e_draw = decimal.Parse(oddsArr[11]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[12]))
                            {
                                odds.e_lost = decimal.Parse(oddsArr[12]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[13]))
                            {
                                odds.e_winper = decimal.Parse(oddsArr[13]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[14]))
                            {
                                odds.e_drawper = decimal.Parse(oddsArr[14]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[15]))
                            {
                                odds.e_lostper = decimal.Parse(oddsArr[15]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[16]))
                            {
                                odds.e_return = decimal.Parse(oddsArr[16]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[17]))
                            {
                                odds.winkelly = decimal.Parse(oddsArr[17]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[18]))
                            {
                                odds.drawkelly = decimal.Parse(oddsArr[18]);
                            }
                            if (!String.IsNullOrEmpty(oddsArr[19]))
                            {
                                odds.lostkelly = decimal.Parse(oddsArr[19]);
                            }
                            string[] timeArr = oddsArr[20].Split(',');
                            odds.lastupdatetime = new DateTime(int.Parse(timeArr[0]), int.Parse(timeArr[1].Remove(2)), int.Parse(timeArr[2]), int.Parse(timeArr[3]), int.Parse(timeArr[4]), int.Parse(timeArr[5])).AddHours(8);
                            oddsDAO.Add(odds);
                        }
                        #endregion
                    }
                }
            }
            catch (WebException e)
            {
                HttpWebResponse response = (HttpWebResponse)e.Response;
                if (response != null)  //排除对象为空的错误
                {
                    if (response.StatusCode == HttpStatusCode.NotFound)  //判断是否是404错误
                        sdal.Delete(Convert.ToInt32(scheduleID));
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 public List<SeoWebSite.Model.Odds> DataTableToList(DataTable dt)
 {
     List<SeoWebSite.Model.Odds> modelList = new List<SeoWebSite.Model.Odds>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         SeoWebSite.Model.Odds model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new SeoWebSite.Model.Odds();
             if(dt.Rows[n]["id"]!=null && dt.Rows[n]["id"].ToString()!="")
             {
                 model.id=int.Parse(dt.Rows[n]["id"].ToString());
             }
             if(dt.Rows[n]["companyid"]!=null && dt.Rows[n]["companyid"].ToString()!="")
             {
                 model.companyid=int.Parse(dt.Rows[n]["companyid"].ToString());
             }
             if(dt.Rows[n]["s_win"]!=null && dt.Rows[n]["s_win"].ToString()!="")
             {
                 model.s_win=decimal.Parse(dt.Rows[n]["s_win"].ToString());
             }
             if(dt.Rows[n]["s_draw"]!=null && dt.Rows[n]["s_draw"].ToString()!="")
             {
                 model.s_draw=decimal.Parse(dt.Rows[n]["s_draw"].ToString());
             }
             if(dt.Rows[n]["s_lost"]!=null && dt.Rows[n]["s_lost"].ToString()!="")
             {
                 model.s_lost=decimal.Parse(dt.Rows[n]["s_lost"].ToString());
             }
             if(dt.Rows[n]["s_winper"]!=null && dt.Rows[n]["s_winper"].ToString()!="")
             {
                 model.s_winper=decimal.Parse(dt.Rows[n]["s_winper"].ToString());
             }
             if(dt.Rows[n]["s_drawper"]!=null && dt.Rows[n]["s_drawper"].ToString()!="")
             {
                 model.s_drawper=decimal.Parse(dt.Rows[n]["s_drawper"].ToString());
             }
             if(dt.Rows[n]["s_lostper"]!=null && dt.Rows[n]["s_lostper"].ToString()!="")
             {
                 model.s_lostper=decimal.Parse(dt.Rows[n]["s_lostper"].ToString());
             }
             if(dt.Rows[n]["s_return"]!=null && dt.Rows[n]["s_return"].ToString()!="")
             {
                 model.s_return=decimal.Parse(dt.Rows[n]["s_return"].ToString());
             }
             if(dt.Rows[n]["e_win"]!=null && dt.Rows[n]["e_win"].ToString()!="")
             {
                 model.e_win=decimal.Parse(dt.Rows[n]["e_win"].ToString());
             }
             if(dt.Rows[n]["e_draw"]!=null && dt.Rows[n]["e_draw"].ToString()!="")
             {
                 model.e_draw=decimal.Parse(dt.Rows[n]["e_draw"].ToString());
             }
             if(dt.Rows[n]["e_lost"]!=null && dt.Rows[n]["e_lost"].ToString()!="")
             {
                 model.e_lost=decimal.Parse(dt.Rows[n]["e_lost"].ToString());
             }
             if(dt.Rows[n]["e_winper"]!=null && dt.Rows[n]["e_winper"].ToString()!="")
             {
                 model.e_winper=decimal.Parse(dt.Rows[n]["e_winper"].ToString());
             }
             if(dt.Rows[n]["e_drawper"]!=null && dt.Rows[n]["e_drawper"].ToString()!="")
             {
                 model.e_drawper=decimal.Parse(dt.Rows[n]["e_drawper"].ToString());
             }
             if(dt.Rows[n]["e_lostper"]!=null && dt.Rows[n]["e_lostper"].ToString()!="")
             {
                 model.e_lostper=decimal.Parse(dt.Rows[n]["e_lostper"].ToString());
             }
             if(dt.Rows[n]["e_return"]!=null && dt.Rows[n]["e_return"].ToString()!="")
             {
                 model.e_return=decimal.Parse(dt.Rows[n]["e_return"].ToString());
             }
             if(dt.Rows[n]["winkelly"]!=null && dt.Rows[n]["winkelly"].ToString()!="")
             {
                 model.winkelly=decimal.Parse(dt.Rows[n]["winkelly"].ToString());
             }
             if(dt.Rows[n]["drawkelly"]!=null && dt.Rows[n]["drawkelly"].ToString()!="")
             {
                 model.drawkelly=decimal.Parse(dt.Rows[n]["drawkelly"].ToString());
             }
             if(dt.Rows[n]["lostkelly"]!=null && dt.Rows[n]["lostkelly"].ToString()!="")
             {
                 model.lostkelly=decimal.Parse(dt.Rows[n]["lostkelly"].ToString());
             }
             if(dt.Rows[n]["lastupdatetime"]!=null && dt.Rows[n]["lastupdatetime"].ToString()!="")
             {
                 model.lastupdatetime=DateTime.Parse(dt.Rows[n]["lastupdatetime"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
Beispiel #3
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(SeoWebSite.Model.Odds model)
 {
     dal.Add(model);
 }
Beispiel #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(SeoWebSite.Model.Odds model)
 {
     return(dal.Update(model));
 }
Beispiel #5
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <SeoWebSite.Model.Odds> DataTableToList(DataTable dt)
        {
            List <SeoWebSite.Model.Odds> modelList = new List <SeoWebSite.Model.Odds>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                SeoWebSite.Model.Odds model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new SeoWebSite.Model.Odds();
                    if (dt.Rows[n]["id"] != null && dt.Rows[n]["id"].ToString() != "")
                    {
                        model.id = int.Parse(dt.Rows[n]["id"].ToString());
                    }
                    if (dt.Rows[n]["companyid"] != null && dt.Rows[n]["companyid"].ToString() != "")
                    {
                        model.companyid = int.Parse(dt.Rows[n]["companyid"].ToString());
                    }
                    if (dt.Rows[n]["s_win"] != null && dt.Rows[n]["s_win"].ToString() != "")
                    {
                        model.s_win = decimal.Parse(dt.Rows[n]["s_win"].ToString());
                    }
                    if (dt.Rows[n]["s_draw"] != null && dt.Rows[n]["s_draw"].ToString() != "")
                    {
                        model.s_draw = decimal.Parse(dt.Rows[n]["s_draw"].ToString());
                    }
                    if (dt.Rows[n]["s_lost"] != null && dt.Rows[n]["s_lost"].ToString() != "")
                    {
                        model.s_lost = decimal.Parse(dt.Rows[n]["s_lost"].ToString());
                    }
                    if (dt.Rows[n]["s_winper"] != null && dt.Rows[n]["s_winper"].ToString() != "")
                    {
                        model.s_winper = decimal.Parse(dt.Rows[n]["s_winper"].ToString());
                    }
                    if (dt.Rows[n]["s_drawper"] != null && dt.Rows[n]["s_drawper"].ToString() != "")
                    {
                        model.s_drawper = decimal.Parse(dt.Rows[n]["s_drawper"].ToString());
                    }
                    if (dt.Rows[n]["s_lostper"] != null && dt.Rows[n]["s_lostper"].ToString() != "")
                    {
                        model.s_lostper = decimal.Parse(dt.Rows[n]["s_lostper"].ToString());
                    }
                    if (dt.Rows[n]["s_return"] != null && dt.Rows[n]["s_return"].ToString() != "")
                    {
                        model.s_return = decimal.Parse(dt.Rows[n]["s_return"].ToString());
                    }
                    if (dt.Rows[n]["e_win"] != null && dt.Rows[n]["e_win"].ToString() != "")
                    {
                        model.e_win = decimal.Parse(dt.Rows[n]["e_win"].ToString());
                    }
                    if (dt.Rows[n]["e_draw"] != null && dt.Rows[n]["e_draw"].ToString() != "")
                    {
                        model.e_draw = decimal.Parse(dt.Rows[n]["e_draw"].ToString());
                    }
                    if (dt.Rows[n]["e_lost"] != null && dt.Rows[n]["e_lost"].ToString() != "")
                    {
                        model.e_lost = decimal.Parse(dt.Rows[n]["e_lost"].ToString());
                    }
                    if (dt.Rows[n]["e_winper"] != null && dt.Rows[n]["e_winper"].ToString() != "")
                    {
                        model.e_winper = decimal.Parse(dt.Rows[n]["e_winper"].ToString());
                    }
                    if (dt.Rows[n]["e_drawper"] != null && dt.Rows[n]["e_drawper"].ToString() != "")
                    {
                        model.e_drawper = decimal.Parse(dt.Rows[n]["e_drawper"].ToString());
                    }
                    if (dt.Rows[n]["e_lostper"] != null && dt.Rows[n]["e_lostper"].ToString() != "")
                    {
                        model.e_lostper = decimal.Parse(dt.Rows[n]["e_lostper"].ToString());
                    }
                    if (dt.Rows[n]["e_return"] != null && dt.Rows[n]["e_return"].ToString() != "")
                    {
                        model.e_return = decimal.Parse(dt.Rows[n]["e_return"].ToString());
                    }
                    if (dt.Rows[n]["winkelly"] != null && dt.Rows[n]["winkelly"].ToString() != "")
                    {
                        model.winkelly = decimal.Parse(dt.Rows[n]["winkelly"].ToString());
                    }
                    if (dt.Rows[n]["drawkelly"] != null && dt.Rows[n]["drawkelly"].ToString() != "")
                    {
                        model.drawkelly = decimal.Parse(dt.Rows[n]["drawkelly"].ToString());
                    }
                    if (dt.Rows[n]["lostkelly"] != null && dt.Rows[n]["lostkelly"].ToString() != "")
                    {
                        model.lostkelly = decimal.Parse(dt.Rows[n]["lostkelly"].ToString());
                    }
                    if (dt.Rows[n]["lastupdatetime"] != null && dt.Rows[n]["lastupdatetime"].ToString() != "")
                    {
                        model.lastupdatetime = DateTime.Parse(dt.Rows[n]["lastupdatetime"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }