private List <int> GetPredictData(PlanInfoDto normPlanInfo, LotteryDataList lotteryDataList) { var predictData = new List <int>(); if (normPlanInfo.PlanPosition == PlanPosition.Single) { var positionInfo = normPlanInfo.PositionInfos.First(); predictData.AddRange(lotteryDataList.LotteryDatas(positionInfo.Position)); } else if (normPlanInfo.PlanPosition == PlanPosition.Multiple) { var positions = normPlanInfo.PositionInfos.Select(p => p.Position).ToArray(); predictData.AddRange(lotteryDataList.LotteryDatas(NumberType.Number, positions)); } else { var positionInfo = normPlanInfo.PositionInfos.First(); predictData.AddRange(lotteryDataList.LotteryDatas(positionInfo.Position, NumberType.Rank)); } return(predictData); }
private PredictDataDto PredictAppointedPeroidNormData(string lotteryId, int predictPeriod, NormConfigDto userNorm, bool isSwitchFormula = false) { var lotteryCount = GetHistoryLotteryCount(userNorm); var predictLotteryData = _lotteryDataQueryService.GetPredictPeriodDatas(lotteryId, predictPeriod - 1, lotteryCount); var lotteryDataList = new LotteryDataList(predictLotteryData); var lotteryEngine = EngineContext.LotterEngine(lotteryId); var normPlanInfo = _planInfoQueryService.GetPlanInfoById(userNorm.PlanId); var predictData = GetPredictData(normPlanInfo, lotteryDataList); var positionInfo = normPlanInfo.PositionInfos.First(); var count = positionInfo.MaxValue - positionInfo.MinValue + 1; string predictedData = String.Empty; IDictionary <int, double> predictedDataRate; try { AlgorithmType algorithmType = normPlanInfo.AlgorithmType; if (isSwitchFormula) { algorithmType = AlgorithmType.Mock; } try { predictedDataRate = lotteryEngine.GetPerdictor(algorithmType) .Predictor(predictData, count, userNorm.UnitHistoryCount, userNorm.HistoryCount, new Tuple <int, int>(positionInfo.MinValue, positionInfo.MaxValue)); } catch (Exception e) { try { algorithmType = AlgorithmType.Temperature; predictedDataRate = lotteryEngine.GetPerdictor(algorithmType) .Predictor(predictData, count, userNorm.UnitHistoryCount, userNorm.HistoryCount, new Tuple <int, int>(positionInfo.MinValue, positionInfo.MaxValue)); } catch (Exception e2) { algorithmType = AlgorithmType.Mock; predictedDataRate = lotteryEngine.GetPerdictor(algorithmType) .Predictor(predictData, count, userNorm.UnitHistoryCount, userNorm.HistoryCount, new Tuple <int, int>(positionInfo.MinValue, positionInfo.MaxValue)); } } var computePredictResult = ComputePredictFatory.CreateComputePredictResult(normPlanInfo.PredictCode, predictedDataRate); predictedData = computePredictResult.GetPredictedData(normPlanInfo, userNorm); //predictedDataRate != null ? //GetPredictedDataByRate(predictedDataRate, normPlanInfo.DsType, userNorm) //: GetPredictedDataMock(normPlanInfo, userNorm); } catch (Exception ex) { _logger.Error(ex); predictedData = GetPredictedDataMock(normPlanInfo, userNorm); } var predictDataInfo = new PredictDataDto() { NormConfigId = userNorm.Id, CurrentPredictPeriod = predictPeriod, StartPeriod = predictPeriod, EndPeriod = predictPeriod + userNorm.PlanCycle - 1, MinorCycle = 1, PredictedData = predictedData, PredictedResult = (int)PredictedResult.Running, PredictType = normPlanInfo.DsType, }; return(predictDataInfo); }