Пример #1
0
        /// <summary>
        ///     从主站抓取开奖数据 昨天/今天
        /// </summary>
        /// <param name="IsToday"></param>
        /// <returns></returns>
        private List <YunNanKL10FEntity> GetDocByMainUrl(bool IsToday = true)
        {
            var list = new List <YunNanKL10FEntity>();

            try
            {
                var time = DateTime.Now;
                var arg  = new OpenCaiApiArg
                {
                    code = EnumHelper.GetLotteryCode(SCCLottery.YunNanKL10F),
                    date = time.ToString("yyyy-MM-dd")
                };
                if (!IsToday)
                {
                    arg.date = time.AddDays(-1).ToString("yyyy-MM-dd");
                }
                var data = OpenCaiApiServices.GetOpenCaiApiData(arg);
                if (data == null)
                {
                    return(list);
                }


                if (data.data != null)
                {
                    if (data.data.Count == 0)
                    {
                        return(list);
                    }

                    for (var i = 0; i < data.data.Count; i++)
                    {
                        var qi    = data.data[i].GetTermStr();
                        var qihao = qi.Length == 8 ? qi : qi.Remove(qi.Length - 3, 1);
                        var tmp   = new YunNanKL10FEntity
                        {
                            Id       = int.Parse(qihao),
                            OpenCode = data.data[i].GetOpenCodeStr(),
                            OpenTime = DateTime.Parse(data.data[i].opentime)
                        };
                        list.Add(tmp);
                    }

                    var checkDataHelper = new CheckDataHelper();
                    var dbdata          = services.GetListIn(currentLottery, IsToday)
                                          .ToDictionary(w => w.Term.ToString(), w => w.GetCodeStr());
                    checkDataHelper.CheckData(dbdata, list.ToDictionary(w => w.Id.ToString(), w => w.OpenCode),
                                              Config.Area, currentLottery);
                }
            }
            catch (Exception ee)
            {
                log.Error(GetType(),
                          string.Format("【{0}】通过站点抓取开奖列表时发生错误,错误信息【{1}】", Config.Area + currentLottery, ee.Message));
            }

            return(list);
        }
Пример #2
0
        /// <summary>
        ///     插入单条
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public bool SaveRecord(YunNanKL10FEntity data)
        {
            var model = new OpenCode8Model();

            model.Term = Convert.ToInt64(data.Id); //期号
            var haoMaArray = data.OpenCode.Split(',');

            model.OpenCode1 = Convert.ToInt32(haoMaArray[0]);
            model.OpenCode2 = Convert.ToInt32(haoMaArray[1]);
            model.OpenCode3 = Convert.ToInt32(haoMaArray[2]);
            model.OpenCode4 = Convert.ToInt32(haoMaArray[3]);
            model.OpenCode5 = Convert.ToInt32(haoMaArray[4]);
            model.OpenCode6 = Convert.ToInt32(haoMaArray[5]);
            model.OpenCode7 = Convert.ToInt32(haoMaArray[6]);
            model.OpenCode8 = Convert.ToInt32(haoMaArray[7]);
            model.OpenTime  = data.OpenTime;
            if (services.AddOpen8Code(currentLottery, model))
            {
                GetMaxPeriodNum((int)model.Term);  //添加成功存放期数
                return(true);
            }

            return(false);
        }
Пример #3
0
        /// <summary>
        ///     从备用站抓取开奖数据 昨天/今天
        /// </summary>
        /// <param name="IsToday"></param>
        /// <returns></returns>
        private List <YunNanKL10FEntity> GetDocByBackUrl(bool IsToday = true)


        {
            var list = new List <YunNanKL10FEntity>();

            try
            {
                var mainurl = "http://ynkl10.icaile.com/";
                var url     = "?op=dcjb&num={0}";
                var day     = "jt";

                if (!IsToday)
                {
                    day = "zt";
                }
                var HtmlResource = NetHelper.GetUrlResponse(Config.BackUrl + string.Format(url, day));
                if (HtmlResource == null)
                {
                    return(list);
                }

                var doc = new HtmlDocument();
                doc.LoadHtml(HtmlResource);
                var tables = doc.DocumentNode.SelectNodes("//*[@id=\"fixedtable\"]");
                foreach (var item in tables[0].ChildNodes)
                {
                    if (item.HasChildNodes && item.Name == "tr")
                    {
                        var opencode = new List <string>();
                        var num      = string.Empty;
                        foreach (var item2 in item.ChildNodes)
                        {
                            if (item2.GetAttributeValue("class", "") == "chart-bg-qh")
                            {
                                num = item2.InnerText.Trim();
                            }
                            if (item2.GetAttributeValue("class", "") == "chart-bg-kjhm")
                            {
                                opencode.Add(item2.InnerText.Trim());
                            }
                        }

                        if (opencode.Count == 8)
                        {
                            var tmp = new YunNanKL10FEntity
                            {
                                Id       = int.Parse(num),
                                OpenCode = string.Join(",", opencode),
                                OpenTime = GetOpenTimeByPeriodNum(int.Parse(num))
                            };
                            list.Add(tmp);
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                log.Error(GetType(),
                          string.Format("【{0}】通过站点抓取开奖列表时发生错误,错误信息【{1}】", Config.Area + currentLottery, ee.Message));
            }

            return(list);
        }