Ejemplo n.º 1
0
        private UIDataManager()
        {
            //最新在线人数
            this.CurrentOnlineNumber = null;
            //开奖号码
            this.CurrentWinningNumber = null;

            #region 由于所赋的值都能保证其合法性,因此可以直接为字段而不是属性赋值,减少校验代码的性能损耗。
            //定码类型
            this.currentSelectedForecastType = GS.DEFAULT_FORECAST_TYPE;
            //排除最新期数号
            this.currentSelectedNewestPeriod = GS.DEFAULT_NEWEST_PERIOD_COUNT;
            //定码个数
            this.currentSelectedDingMaCount = GS.DEFAULT_DING_MA_COUNT;
            #endregion

            //当前计划状态(“最大连中”、“最大连挂”)
            CalMaxContinueWinAndMaxContinueLose();
            //当前计划状态(“中奖期数”、“没中奖期数”)
            CalTotalWinAndTotalLose();


            #region 创建下一轮要用的 WinLog,并填充当前可以准备的所有预测数据。
            //List<string> planForecastNumberList = CalPlanForecastList(new List<Number>(), this.currentSelectedDingMaCount, this.currentSelectedForecastType);
            //nextNewestLog = new WinLog(planForecastNumberList, 0, this.currentSelectedForecastType);

            List <Number> historyData = mgr.GetTopRangeHistorySourceData(0, this.currentSelectedNewestPeriod, true, false).ExtractWinningNumber();
            nextNewestLog = new WinLog(historyData, this.currentSelectedDingMaCount, this.currentSelectedForecastType);
            //nextNewestLogActuallyHistoryWinningNumberCount = historyData.Count;
            #endregion


            //绑定事件
            mgr.OnNewSourceDataAdded += Mgr_OnNewSourceDataAdded;
        }
Ejemplo n.º 2
0
 public override bool Equals(object obj)
 {
     if (obj != null && obj is WinLog)
     {
         WinLog that = obj as WinLog;
         if (this.sourceData == that.sourceData &&
             this.isWin == that.isWin &&
             this.currentForecastType == that.currentForecastType &&
             IsStringListEquals(this.firstTwoPlanForecast, that.firstTwoPlanForecast) &&
             IsStringListEquals(this.lastTwoPlanForecast, that.lastTwoPlanForecast))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
        public object Clone()
        {
            #region 旧方法。
            WinLog tmpLog = new WinLog(this.sourceData);
            tmpLog.firstTwoPlanForecast = new List <string>(this.firstTwoPlanForecast);
            tmpLog.lastTwoPlanForecast  = new List <string>(this.lastTwoPlanForecast);
            tmpLog.isWin = this.isWin;
            tmpLog.currentForecastType = this.currentForecastType;
            tmpLog.actuallyHistoryWinningNumberCount = this.actuallyHistoryWinningNumberCount;
            return(tmpLog);

            #endregion

            #region 新方法,BinaryClone() 方法有问题,List<> 列表没有实现 Serialize 特性,不能序列化。
            //return this.BinaryClone();
            #endregion
        }
Ejemplo n.º 4
0
        //private void Mgr_OnNewSourceDataAdded1(SourceData newData, int oldDataCount)
        //{
        //    #region 创建 WinLog 对象。
        //    //获取除了用来创建当前的 log 对象时使用的 newData 对象之外的 this.CurrentSelectedNewestPeriods 个最新的历史 SourceData 对象。
        //    List<SourceData> historyData = mgr.GetTopRangeHistorySourceDataExceptStartObject(newData.TimeId, this.currentSelectedNewestPeriod, true).ToList();
        //    List<string> planForecastNumberList = CalPlanForecastList(historyData.ExtractWinningNumber(), this.currentSelectedDingMaCount, this.currentSelectedForecastType);
        //    WinLog log = new WinLog(planForecastNumberList, this.currentSelectedForecastType, newData);
        //    #endregion

        //    winLogs.Add(log);
        //    SortWinLogsByTimeId(OrderType.Descending);


        //    nextNewestLog = log;
        //    #region 设置 “最新在线人数” 和 “最新的开奖号码” 值。
        //    ////由于最新添加到当前的源数据 newData 对象并不确保是时间上也是最新的,所以设置 “最新在线人数” 和 “最新的开奖号码” 不应该使用该对象的信息。
        //    //this.CurrentOnlineNumber = newData.OnlineNumber.ToNumber();
        //    //this.CurrentWinningNumber = newData.WinningNumber;

        //    //通过获取在本地 “数据池” 中最新的一个源数据对象 newestData 来设置 “最新在线人数” 和 “最新的开奖号码” 的值,这样就能保证信息是 “最新” 的。
        //    //如果源数据对象为空,则不做设置操作。
        //    SourceData newestData = mgr.GetTopNSourceData(1, true).SingleOrDefault();
        //    if (newestData != null)
        //    {
        //        this.CurrentOnlineNumber = newestData.OnlineNumber.ToNumber();
        //        this.CurrentWinningNumber = newestData.WinningNumber;
        //    }
        //    #endregion

        //    if (log.IsWin.Value)
        //    {
        //        this.TotalWin++;
        //    }
        //    else
        //    {
        //        this.TotalLose++;
        //    }

        //    //计算 “最大连中” 和 “最大连挂” 并设值。
        //    CalMaxContinueWinAndMaxContinueLose();

        //    if (this.OnNewWinLogAdded != null)
        //    {
        //        this.OnNewWinLogAdded(this, log, newData, this.WinLogs, winLogs.Count);
        //    }
        //}
        #endregion

        private void Mgr_OnNewSourceDataAdded(SourceData newData, int oldDataCount)
        {
            #region 填充上一轮已经预创建好的 WinLog 对象。
            lock (syncObj)
            {
                //填充上一轮已经预创建好的 WinLog 对象。
                nextNewestLog.FillResult(newData);
            }
            #endregion

            WinLog currentLog = nextNewestLog;

            //因为由于业务的需要, winLogs 集合默认是按 TimeId 从新到旧的顺序来排序的,即排在最前的是最新的,而大多数情况下新添加的就是 TimeId 值最新的,所以
            //用 Insert() 来代替 Add() 会比较节省性能。
            winLogs.Insert(0, currentLog);

            #region 通过一定的判断逻辑来尽量减少排序的操作次数,从而提高性能。
            int currentTimeId = currentLog.TimeId;
            //如果 newestTimeId 还没有值(初始值 -1 不算),则表示从来没有添加过 WinLog 元素。
            if (newestTimeId == -1)
            {
                newestTimeId = currentTimeId;
            }
            else
            {
                //如果当前添加的元素 currentLog 在列表集合 winLogs 中不是最新的,则进行排序。
                if (newestTimeId > currentTimeId)
                {
                    SortWinLogsByTimeIdDescending();
                }
                //更新 newestTimeId 的值。
                newestTimeId = Math.Max(newestTimeId, currentTimeId);
            }
            #endregion


            #region 创建下一轮要用的 WinLog,并填充当前可以准备的所有预测数据。
            ////获取 this.currentSelectedNewestPeriods 个最新的历史 SourceData 对象。
            List <SourceData> historyData = mgr.GetTopRangeHistorySourceData(0, this.currentSelectedNewestPeriod, true, false);

            lock (syncObj)
            {
                nextNewestLog = new WinLog(historyData.ExtractWinningNumber(), this.currentSelectedDingMaCount, this.currentSelectedForecastType);
                //nextNewestLogActuallyHistoryWinningNumberCount = historyData.Count;
            }
            #endregion



            #region 设置 “最新在线人数” 和 “最新的开奖号码” 值。
            ////由于最新添加到当前的源数据 newData 对象并不确保是时间上也是最新的,所以设置 “最新在线人数” 和 “最新的开奖号码” 不应该使用该对象的信息。
            //this.CurrentOnlineNumber = newData.OnlineNumber.ToNumber();
            //this.CurrentWinningNumber = newData.WinningNumber;

            //通过获取在本地 “数据池” 中最新的一个源数据对象 newestData 来设置 “最新在线人数” 和 “最新的开奖号码” 的值,这样就能保证信息是 “最新” 的。
            //如果源数据对象为空,则不做设置操作。
            SourceData newestData = mgr.GetTopRangeHistorySourceData(0, 1, false, false).SingleOrDefault();
            if (newestData != null)
            {
                this.CurrentOnlineNumber  = newestData.OnlineNumber.ToNumber();
                this.CurrentWinningNumber = newestData.WinningNumber;
            }
            #endregion

            #region 计算 “中奖总期数”、“没中奖总期数”、“最大连中”、“最大连挂”。
            if (currentLog.IsWin.Value)
            {
                this.TotalWin++;
            }
            else
            {
                this.TotalLose++;
            }

            //计算 “最大连中” 和 “最大连挂” 并设值。
            CalMaxContinueWinAndMaxContinueLose();
            #endregion

            if (this.OnNewWinLogAdded != null)
            {
                this.OnNewWinLogAdded(this, currentLog, newData, this.WinLogs, winLogs.Count);
            }
        }