Example #1
0
 /// <summary>
 /// 在开奖结果的信息公布之后,根据指定的 “预测列表”、“定码类型” 和开奖结果的源数据对象 sourceData 来创建一个用来存储开奖记录数据的对象。
 /// 即根据:计划预测 “PlanForecast”、定码类型 “currentForecastType”、计划结果 “isWin” 和 SourceData 对象来创建 WinLog 对象。
 /// </summary>
 /// <param name="planForecastNumberList"></param>
 /// <param name="actuallyHistoryWinningNumberCount"> 实际上能够获取得到用来计算 “计划预测” 列表的 “排除最新期数号” 数量(因为有时候能获取到的 “排除最新期数号” 的数量并不一定能够达到所要求获取的数量)。</param>
 /// <param name="forecastType"></param>
 /// <param name="sourceData"></param>
 public WinLog(List <string> planForecastNumberList, int actuallyHistoryWinningNumberCount, ForecastType forecastType, SourceData sourceData) : this(planForecastNumberList, actuallyHistoryWinningNumberCount, forecastType)
 {
     FillResult(sourceData);
 }
Example #2
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);
            }
        }
Example #3
0
 /// <summary>
 /// 在开奖结果的信息公布之后,根据开奖结果的源数据对象 sourceData 来创建一个用来存储开奖记录数据的对象。
 /// 即根据 SourceData 对象创建 WinLog 对象。
 /// </summary>
 /// <param name="sourceData">初始化当前的 WinLog 对象相关数据所需要的元数据对象。</param>
 public WinLog(SourceData sourceData) : this()
 {
     FillResult(sourceData);
 }
Example #4
0
 public int IndexOf(SourceData data)
 {
     return(sourceDatas.IndexOf(data));
 }