Esempio n. 1
0
 public int AddCaiKeBJDC(Caike_Body caike_Body, string matchDateCode)
 {
     try
     {
         int m = 0;
         caike_Body.records.ForEach((record) =>
         {
             bjdc_result _Result = new bjdc_result
             {
                 MatchId     = matchDateCode + record.matchNo,
                 MatchDate   = "",
                 MatchNumber = record.matchNo,
                 HomeTeam    = record.homeTeam,
                 GuestTeam   = record.guestTeam,
                 HalfScore   = record.hScoreText.Replace("-", ":"),
                 FullScore   = record.scoreText.Substring(record.scoreText.IndexOf(">") + 1, record.scoreText.Substring(record.scoreText.IndexOf(">") + 1).IndexOf("<")).Replace("-", ":"),
                 LeagueName  = record.leagueName,
                 AvgEu_SP    = "123456",
                 Url_Type    = (int)CollectionUrlEnum.url_caike
             };
             int i = 0;
             record.details.ForEach((detail) =>
             {
                 if (detail.name != "" && detail.name != "-" && detail.value != "" && detail.value != "-")
                 {
                     if (i == 0)
                     {
                         _Result.LetBall      = detail.name.Substring(detail.name.IndexOf("(") + 1, detail.name.IndexOf(")") - detail.name.IndexOf("(") - 1);
                         _Result.RQSPF_Result = detail.name.Substring(detail.name.IndexOf("(") + 1, detail.name.IndexOf(")") - detail.name.IndexOf("(") - 1);
                         _Result.RQSPF_SP     = detail.value;
                         i++;
                     }
                     else if (i == 1)
                     {
                         _Result.ZJQ_Result = Convert2Number(detail.name.Replace("球", "")).ToString();
                         _Result.ZJQ_SP     = detail.value;
                         i++;
                     }
                     else if (i == 2)
                     {
                         _Result.SXDS_Result = detail.name;
                         _Result.SXDS_SP     = detail.value;
                         i++;
                     }
                     else if (i == 3)
                     {
                         _Result.BF_SP = detail.name;
                         i++;
                     }
                     else if (i == 4)
                     {
                         _Result.BQC_Result = detail.name;
                         _Result.BQC_SP     = detail.value;
                         i++;
                     }
                 }
             });
             if (!string.IsNullOrEmpty(_Result.RQSPF_Result) && _Result.RQSPF_Result != "-" &&
                 !string.IsNullOrEmpty(_Result.ZJQ_Result) && _Result.ZJQ_Result != "-" &&
                 !string.IsNullOrEmpty(_Result.FullScore) && _Result.FullScore != "-" &&
                 !string.IsNullOrEmpty(_Result.SXDS_Result) && _Result.SXDS_Result != "-" &&
                 !string.IsNullOrEmpty(_Result.BQC_Result) && _Result.BQC_Result != "-")
             {
                 _Result.IsFinish = true;
             }
             else
             {
                 _Result.IsFinish = false;
             }
             var model = db.Queryable <bjdc_result>().Where(x => x.MatchId == _Result.MatchId).First();
             if (model == null)
             {
                 db.Insertable(_Result).ExecuteCommand();
                 m++;
             }
             else
             {
                 if (!model.IsFinish)
                 {
                     db.Updateable(_Result).ExecuteCommand();
                 }
             }
         });
         var lottery = db.Queryable <sys_lottery>().Where(x => x.LotteryCode == "zqdc").First();
         caike_Body.matchDates.ForEach((matchDate) =>
         {
             if (matchDate.code == matchDateCode)
             {
                 sys_issue _sys_Issue   = new sys_issue();
                 _sys_Issue.LotteryId   = lottery.Lottery_Id;
                 _sys_Issue.IssueNo     = matchDate.code;
                 _sys_Issue.LotteryCode = lottery.LotteryCode;
                 _sys_Issue.CreateTime  = DateTime.Now;
                 var Model = db.Queryable <sys_issue>().Where(x => x.LotteryId == _sys_Issue.LotteryId && x.LotteryCode == _sys_Issue.LotteryCode && x.IssueNo == _sys_Issue.IssueNo).First();
                 if (Model == null)
                 {
                     db.Insertable(_sys_Issue).ExecuteCommand();
                 }
             }
         });
         return(m);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 北京单场
 /// </summary>
 /// <param name="model"></param>
 public void Add_BJDC(List <jczq> model, string GameCode = "zqdc")
 {
     try
     {
         List <bjdc_result> bjdc_s = new List <bjdc_result>();
         foreach (var item in model)
         {
             bjdc_result resultModel = new bjdc_result
             {
                 MatchId     = item.id + item.TournamentNumber,
                 MatchDate   = item.MatchTime,
                 MatchNumber = item.TournamentNumber,
                 HomeTeam    = item.HomeTeam,
                 GuestTeam   = item.VisitingTeam,
                 LetBall     = item.LetBall,
                 HalfScore   = item.Score == "-" ? "-" : item.Score.Split(")")[0].Replace("(", "").Replace(")", ""),
                 FullScore   = item.Score == "-" ? "-" : item.Score.Split(")")[1].Replace(")", ""),
                 LeagueName  = item.TournamentType,
                 CreateTime  = DateTime.Now,
                 IssueNo     = item.id,
                 Url_Type    = (int)CollectionUrlEnum.url_500zx,
             };
             resultModel.League_Color = item.League_Color;
             foreach (var Sub_item in item.gameTypes)
             {
                 if (Sub_item.game == Game.让球胜平负)
                 {
                     resultModel.RQSPF_Result = Sub_item.FruitColor;
                     resultModel.RQSPF_SP     = Sub_item.Bonus;
                 }
                 else if (Sub_item.game == Game.总进球数)
                 {
                     resultModel.ZJQ_Result = Sub_item.FruitColor;
                     resultModel.ZJQ_SP     = Sub_item.Bonus;
                 }
                 else if (Sub_item.game == Game.比分)
                 {
                     //比分彩果FullScore
                     resultModel.BF_SP = Sub_item.Bonus;
                 }
                 else if (Sub_item.game == Game.单双)
                 {
                     resultModel.SXDS_Result = Sub_item.FruitColor;
                     resultModel.SXDS_SP     = Sub_item.Bonus;
                 }
                 else if (Sub_item.game == Game.半全场)
                 {
                     resultModel.BQC_Result = Sub_item.FruitColor;
                     resultModel.BQC_SP     = Sub_item.Bonus;
                 }
             }
             resultModel.AvgEu_SP = item.AvgOuCompensation;
             resultModel.IssueNo  = item.id;
             resultModel.IsFinish = false;
             if (!string.IsNullOrEmpty(resultModel.RQSPF_Result) && resultModel.RQSPF_Result != "-" &&
                 !string.IsNullOrEmpty(resultModel.ZJQ_Result) && resultModel.ZJQ_Result != "-" &&
                 !string.IsNullOrEmpty(resultModel.FullScore) && resultModel.FullScore != "-" &&
                 !string.IsNullOrEmpty(resultModel.SXDS_Result) && resultModel.SXDS_Result != "-" &&
                 !string.IsNullOrEmpty(resultModel.BQC_Result) && resultModel.BQC_Result != "-")
             {
                 resultModel.IsFinish = true;
             }
             bjdc_s.Add(resultModel);
         }
         int i = 0, m = 0;
         bjdc_s.ForEach((a) =>
         {
             bjdc_result result = db.Queryable <bjdc_result>().Where(x => x.MatchId == a.MatchId).First();
             if (result != null)
             {
                 var Issure = db.Queryable <bjdc_result>().OrderBy(x => x.IssueNo, OrderByType.Desc).GroupBy(p => p.IssueNo).Select(p => p.IssueNo).Skip(2).First();
                 if (result.IsFinish == false && Convert.ToInt32(result.IssueNo) > Convert.ToInt32(Issure))
                 {
                     db.Updateable(a).ExecuteCommand();
                     m++;
                 }
             }
             else
             {
                 db.Insertable(a).ExecuteCommand();
                 i++;
             }
         });
         ConSoleHelp("U", GameCode, bjdc_s.Select(x => x.IssueNo).FirstOrDefault(), m);
         ConSoleHelp("A", GameCode, bjdc_s.Select(x => x.IssueNo).FirstOrDefault(), i);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }