Exemplo n.º 1
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept = HttpContentTypes.ApplicationJson;
            var response    = _httpClient.Get(_dataSite.Url);
            var crawlResult = response.RawText.ToObject();

            var period = Convert.ToInt32(crawlResult.current.periodNumber);

            if (period > finalData)
            {
                var resultList  = new List <LotteryDataDto>();
                var lotteryData = new LotteryDataDto()
                {
                    LotteryId   = _dataSite.LotteryId,
                    Period      = period,
                    LotteryTime = Convert.ToDateTime(crawlResult.current.awardTime),
                    Data        = crawlResult.current.awardNumbers
                };
                resultList.Add(lotteryData);

                return(resultList);
            }

            return(null);
        }
Exemplo n.º 2
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept    = HttpContentTypes.ApplicationJson;
            _httpClient.Request.UserAgent = CHROME_UA;
            var response  = _httpClient.Get(_dataSite.Url);
            var crawlData = response.DynamicBody;

            if (crawlData != null && crawlData.status == 1)
            {
                var lotteryDatas = crawlData.data.list;

                var resultList = new List <LotteryDataDto>();
                foreach (var item in lotteryDatas)
                {
                    string periodStr = item.issue.ToString();
                    periodStr = periodStr.Substring(2);
                    var period = Convert.ToInt32(periodStr);
                    if (period > finalData)
                    {
                        var lotteryData = new LotteryDataDto()
                        {
                            LotteryId   = _dataSite.LotteryId,
                            Period      = period,
                            LotteryTime = DateTimeExtensions.TimeStampConvetDateTime(Convert.ToInt64(item.kjtime)),
                            Data        = GetLotteryData(item.kjhm)
                        };
                        resultList.Add(lotteryData);
                    }
                }
                return(resultList);
            }
            return(null);
        }
Exemplo n.º 3
0
 public AddLotteryDataCommand(string id, LotteryDataDto lotteryDataDto) : base(id)
 {
     Period      = lotteryDataDto.Period;
     LotteryId   = lotteryDataDto.LotteryId;
     Data        = lotteryDataDto.Data;
     LotteryTime = lotteryDataDto.LotteryTime;
 }
Exemplo n.º 4
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept    = HttpContentTypes.ApplicationJson;
            _httpClient.Request.UserAgent = CHROME_UA;
            var response  = _httpClient.Get(_dataSite.Url);
            var crawlData = response.DynamicBody;

            if (crawlData != null && crawlData.errorCode == 0)
            {
                var resultList   = new List <LotteryDataDto>();
                var lotteryDatas = crawlData.result.data;
                foreach (var data in lotteryDatas)
                {
                    string periodStr = data.preDrawIssue.ToString();
                    periodStr = periodStr.Substring(2);
                    var period = Convert.ToInt32(periodStr);
                    if (period > finalData)
                    {
                        var lotteryData = new LotteryDataDto()
                        {
                            LotteryId   = _dataSite.LotteryId,
                            Period      = period,
                            LotteryTime = Convert.ToDateTime(data.preDrawTime),
                            Data        = data.preDrawCode
                        };
                        resultList.Add(lotteryData);
                    }
                }

                return(resultList);
            }

            return(null);
        }
Exemplo n.º 5
0
 public void AddLotteryData(LotteryDataDto data)
 {
     if (_lotteryNumbers.ContainsKey(data.Period))
     {
         throw new LotteryDataException("已经存在这一期的开奖数据");
     }
     _lotteryNumbers.Add(data.Period, new LotteryNumber(data));
 }
Exemplo n.º 6
0
        private void VerifyTodayFirstPeriod(LotteryDataDto crawlFinalData)
        {
            var startTimePoint = _timeRuleManager.TodayTimeRule.StartTime.TotalSeconds;
            var endTimePoint   = crawlFinalData.LotteryTime.TimeOfDay.TotalSeconds;
            var interval       = _timeRuleManager.TodayTimeRule.Tick.TotalSeconds;

            var currentCount            = Convert.ToInt32(Math.Ceiling((endTimePoint - startTimePoint) / interval));
            var computeTodayFirstPeriod = crawlFinalData.Period - currentCount + 1;

            if (computeTodayFirstPeriod != _lotteryFinalData.TodayFirstPeriod)
            {
                SendCommandAsync(new UpdateNextDayFirstPeriodCommand(LotteryFinalData.Id, crawlFinalData.LotteryId, computeTodayFirstPeriod));
            }
        }
Exemplo n.º 7
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept = HttpContentTypes.ApplicationJson;
            var formData = new Dictionary <string, object>()
            {
                { "lotid", "1028" },
                { "size", "500" },
                { "time", DateTime.Now.ToString("yyyy-MM-dd") }
            };
            var    response    = _httpClient.Post(_dataSite.Url, formData, null);
            var    crawlResult = response.RawText.ToObject();
            string success     = crawlResult.success.ToString();

            if (success.ToUpper() == "Y")
            {
                var resultList = new List <LotteryDataDto>();
                foreach (var item in crawlResult.content)
                {
                    var period = Convert.ToInt32(item.speriod);
                    if (period > finalData)
                    {
                        var lotteryData = new LotteryDataDto()
                        {
                            LotteryId   = _dataSite.LotteryId,
                            Period      = period,
                            LotteryTime = Convert.ToDateTime(item.dopen_time),
                            Data        = GetLotteryData(item.sopencode.ToString())
                        };
                        resultList.Add(lotteryData);
                    }
                }
                return(resultList);
            }



            return(null);
        }
Exemplo n.º 8
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept    = HttpContentTypes.ApplicationXml;
            _httpClient.Request.UserAgent = CHROME_UA;
            var response  = _httpClient.Get(_site);
            var crawlData = response.RawText;

            crawlData = crawlData.Replace("gb2312", "utf-8");
            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(crawlData);

            var lotteryDatas = xmlDoc.SelectNodes("/xml/row");

            if (lotteryDatas != null)
            {
                var resultList = new List <LotteryDataDto>();
                foreach (XmlNode item in lotteryDatas)
                {
                    var periodStr = item.Attributes["expect"].Value.Replace("-", "");
                    var period    = Convert.ToInt32(periodStr);
                    if (period > finalData)
                    {
                        var lotteryData = new LotteryDataDto()
                        {
                            LotteryId   = _dataSite.LotteryId,
                            Period      = period,
                            LotteryTime = Convert.ToDateTime(item.Attributes["opentime"].Value),
                            Data        = GetLotteryData(item.Attributes["opencode"].Value)
                        };
                        resultList.Add(lotteryData);
                    }
                }
                return(resultList);
            }

            return(null);
        }
Exemplo n.º 9
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept = HttpContentTypes.ApplicationJson;
            var response    = _httpClient.Post(_dataSite.Url, new { limit = _dataSite.Count }, contentType: "application/json");
            var crawlResult = response.DynamicBody;

            if (crawlResult.status == 1)
            {
                var resultDatas  = new List <LotteryDataDto>(_dataSite.Count);
                var requestDatas = crawlResult.data;
                var count        = 1;
                foreach (var item in requestDatas)
                {
                    var period = Convert.ToInt32(item.issue);
                    if (period <= finalData)
                    {
                        continue;
                    }
                    var data = new LotteryDataDto()
                    {
                        Data        = GetLotteryData(item.kjhm),
                        LotteryId   = _dataSite.LotteryId,
                        LotteryTime = DateTimeExtensions.TimeStampConvetDateTime(Convert.ToInt64(item.kjtime)),
                        Period      = period
                    };
                    resultDatas.Add(data);
                    count++;
                    //if (count > _dataSite.Count)
                    //{
                    //    break;
                    //}
                }

                return(resultDatas);
            }
            return(null);
        }
Exemplo n.º 10
0
        protected override IList <LotteryDataDto> RequestDatas(int finalData)
        {
            _httpClient.Request.Accept    = HttpContentTypes.ApplicationJson;
            _httpClient.Request.UserAgent = CHROME_UA;
            var response  = _httpClient.Get(_dataSite.Url, new { gameCode = "bjpk10" });
            var crawlData = response.DynamicBody;

            var period = Convert.ToInt32(crawlData.preIssue);

            if (period > finalData)
            {
                var resultList = new List <LotteryDataDto>();

                var openNumArr = crawlData.openNum;

                string dataStr = String.Empty;
                foreach (var number in openNumArr)
                {
                    dataStr += number + ",";
                }
                Debug.Assert(!string.IsNullOrEmpty(dataStr));
                dataStr = dataStr.Remove(dataStr.Length - 1);

                var lotteryData = new LotteryDataDto()
                {
                    LotteryId   = _dataSite.LotteryId,
                    Period      = period,
                    LotteryTime = DateTimeExtensions.TimeStampConvetDateTime(Convert.ToInt64(crawlData.currentOpenDateTime) / 1000),
                    Data        = dataStr
                };

                resultList.Add(lotteryData);
                return(resultList);
            }
            return(null);
        }
Exemplo n.º 11
0
 public void RemoveLotteryData(LotteryDataDto data)
 {
     RemoveLotteryData(data.Period);
 }
Exemplo n.º 12
0
        private void UpdateNextFirstPeriod(LotteryDataDto crawlFinalData)
        {
            var nextDayFirstPeriod = crawlFinalData.Period + 1;

            SendCommandAsync(new UpdateNextDayFirstPeriodCommand(LotteryFinalData.Id, crawlFinalData.LotteryId, nextDayFirstPeriod));
        }
Exemplo n.º 13
0
 public LotteryNumber(LotteryDataDto lotteryData)
 {
     _lotteryData = lotteryData;
     _datas       = _lotteryData.Data.Split(',').Select(p => Convert.ToInt32(p)).ToArray();
 }