예제 #1
0
파일: BKBF.cs 프로젝트: chanhan/ap_follow
        //private bool CheckGame(BasicInfo oldInfo, BasicInfo newInfo)
        //{
        //    bool isLegal = true;
        //    //先检查新旧资料是否相同,不相同再比较比赛状态、分数
        //    if (!newInfo.ToString().Equals(oldInfo.ToString()))
        //    {
        //        //旧资料是未开赛,还没有比分,数据合法
        //        if (oldInfo.GameStates == "X")// && newInfo.GameStates == "X")
        //        {
        //            isLegal = true;
        //        }
        //        //旧资料是未开赛,还没有比分,数据合法
        //        //else if (newInfo.GameStates != "X")
        //        //{
        //        //    isLegal = false;
        //        //}
        //        else
        //        {
        //            if (int.Parse(oldInfo.AwayPoint) > int.Parse(newInfo.AwayPoint))
        //            {
        //                isLegal = false;
        //            }
        //            else
        //            {
        //                if (int.Parse(oldInfo.HomePoint) > int.Parse(newInfo.HomePoint))
        //                {
        //                    isLegal = false;
        //                }
        //            }
        //        }
        //    }
        //    return isLegal;
        //}
        /// <summary>
        /// 是否正常比分 
        /// 如果新的分数小于旧的分  就返回false (不正常的分数)并且把旧的分数赋值给新的
        /// </summary>
        /// <param name="oldInfo">旧的资料</param>
        /// <param name="newInfo">新的资料</param>
        /// <returns></returns>
        private bool IsNormalScore(BasicInfo oldInfo, BasicInfo newInfo)
        {
            bool ret = true;
            if (!newInfo.ToString().Equals(oldInfo.ToString()))
            {
                if (oldInfo.HomeBoard != null && oldInfo.AwayBoard != null && newInfo.AwayBoard != null && newInfo.HomeBoard != null)
                {
                    int oldHomeCount = 0, oldAwayCount = 0, newHomeCount = 0, newAwayCount = 0;
                    oldHomeCount = oldInfo.HomeBoard.Select<string, int>(q => Convert.ToInt32(q)).Sum();
                    oldAwayCount = oldInfo.AwayBoard.Select<string, int>(q => Convert.ToInt32(q)).Sum();
                    newHomeCount = newInfo.HomeBoard.Select<string, int>(q => Convert.ToInt32(q)).Sum();
                    newAwayCount = newInfo.AwayBoard.Select<string, int>(q => Convert.ToInt32(q)).Sum();
                    //foreach (string item in oldInfo.HomeBoard)
                    //{
                    //    int o=0;
                    //    int.TryParse(item, out o);
                    //    oldHomeCount += o;
                    //}
                    if (newHomeCount < oldHomeCount || newAwayCount < oldAwayCount)
                    {
                        newInfo.HomeBoard = oldInfo.HomeBoard;
                        newInfo.AwayBoard = oldInfo.AwayBoard;
                        ret = false;
                    }

                }
            }
            else
            {
                ret = false;
            }
            return ret;
        }
예제 #2
0
파일: BkOS.cs 프로젝트: chanhan/ap_follow
 /// <summary>
 /// 是否正常比分 
 /// 如果新的分数小于旧的分  就返回false (不正常的分数)并且把旧的分数赋值给新的
 /// </summary>
 /// <param name="oldInfo">旧的资料</param>
 /// <param name="newInfo">新的资料</param>
 /// <returns></returns>
 private bool IsNormalScore(BasicInfo oldInfo, BasicInfo newInfo)
 {
     bool ret = true;
     //如果赛事日期大于当前日期 且赛事状态是已开赛、结束、中止 就不跟新
     if (newInfo.GameTime.Date.CompareTo(DateTime.Now.Date) > 0 && (newInfo.GameStates == "S" || newInfo.GameStates == "E" || newInfo.GameStates == "P")) return false;
     if (!newInfo.ToString().Equals(oldInfo.ToString()))
     {
         if (oldInfo.HomeBoard != null && oldInfo.HomeBoard.Count > 0 && oldInfo.AwayBoard != null && oldInfo.AwayBoard.Count > 0 && newInfo.AwayBoard != null && newInfo.AwayBoard.Count > 0 && newInfo.HomeBoard != null && newInfo.HomeBoard.Count > 0)
         {
             try
             {  //先判断主客队节数
                 if (newInfo.HomeBoard.Count != newInfo.AwayBoard.Count)
                 {
                     ret = false;
                 }
                 if (ret)
                 {
                     //先比较节数,新数据节数小,不更新
                     if (oldInfo.HomeBoard.Count > newInfo.HomeBoard.Count)
                     {
                         ret = false;
                     }
                     if (oldInfo.AwayBoard.Count > newInfo.AwayBoard.Count)
                     {
                         ret = false;
                     }
                 }
                 //新数据节数大于等于旧数据节数,比较每节比分数
                 if (ret)
                 {
                     for (int i = 0; i < oldInfo.HomeBoard.Count; i++)
                     {
                         //新数据分数小,不更新
                         if (Convert.ToInt32(oldInfo.HomeBoard[i]) > Convert.ToInt32(newInfo.HomeBoard[i]))
                         {
                             ret = false;
                             break;
                         }
                     }
                     for (int i = 0; i < oldInfo.AwayBoard.Count; i++)
                     {
                         if (Convert.ToInt32(oldInfo.AwayBoard[i]) > Convert.ToInt32(newInfo.AwayBoard[i]))
                         {
                             ret = false;
                             break;
                         }
                     }
                 }
                 //新数据不合理,替换掉
                 if (!ret)
                 {
                     //比分输错,在下场比赛更新过来,作为正常分数处理
                     if (oldInfo.StateValue < newInfo.StateValue)
                     {
                         ret = true;
                     }
                     else
                     {
                         newInfo = oldInfo;
                     }
                 }
             }
             catch (Exception)
             {
                 throw;
             }
         }
         //旧赛事有比分新赛事每比分,不更新
         else if (oldInfo.HomeBoard != null && oldInfo.HomeBoard.Count > 0 && oldInfo.AwayBoard != null && oldInfo.AwayBoard.Count > 0 && newInfo.AwayBoard != null && newInfo.AwayBoard.Count == 0 && newInfo.HomeBoard != null && newInfo.HomeBoard.Count == 0)
         {
             ret = false;
         }
     }
     else
     {
         ret = false;
     }
     return ret;
 }