Exemple #1
0
        /// <summary>
        /// 添加初始记录
        /// </summary>
        /// <returns></returns>
        public static void InitLottery()
        {
            string root = ConfigurationManager.AppSettings["lk28"];

            lock (lkinit)
            {
                string    url      = root + "?token=7904a63f2fc9c2d2&code=bjkl8&rows=5&format=json&date=" + DateTime.Now.ToString("yyyy-MM-dd");
                string    bjjson   = HttpUtils.HttpGet(url, "");
                MD_28Json bj28json = JsonConvert.DeserializeObject <MD_28Json>(bjjson);
                if (bj28json.data.Count > 0)
                {
                    LK28Item item = bj28json.data[0];
                    //已经开奖的记录是否存在,存在则不添加,不存在则添加
                    bool extbj = Lottery.ExistsBJ28(" and a.expect='" + (int.Parse(item.expect + 1)).ToString() + "'");
                    if (!extbj)
                    {
                        MD_Lottery lottery = new MD_Lottery
                        {
                            Type     = 10,
                            Expect   = (int.Parse(item.expect) + 1).ToString(),
                            Opentime = DateTime.Parse(DateTime.Parse(item.opentime).ToString("yyyy-MM-dd HH:mm") + ":00").AddMinutes(5),
                            Status   = 0
                        };
                        bool result = Lottery.AddBJRecord(lottery);
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 根据北京快乐8结果,计算28结果
        /// </summary>
        /// <returns></returns>
        public static string AddLottery()
        {
            lock (lkbj)
            {
                //是否有投注或封盘记录
                bool listtoady = Lottery.ExistsBJ28(" and a.status in (0,1) and convert(varchar(10),a.opentime,120)='" + DateTime.Now.ToString("yyyy-MM-dd") + "'");
                if (!listtoady)
                {
                    return("");
                }
                string    root     = ConfigurationManager.AppSettings["lk28"];
                string    url      = root + "?token=7904a63f2fc9c2d2&code=bjkl8&rows=5&format=json&date=" + DateTime.Now.ToString("yyyy-MM-dd");
                string    bjjson   = HttpUtils.HttpGet(url, "");
                MD_28Json bj28json = JsonConvert.DeserializeObject <MD_28Json>(bjjson);
                if (bj28json.data.Count > 0)
                {
                    LK28Item item = bj28json.data[0];
                    //10 北京28  11 加拿大28

                    //更新开奖信息
                    item.opencode = item.opencode.Substring(0, item.opencode.Length - 3);
                    MD_Lottery lottery = new MD_Lottery
                    {
                        Type     = 10,
                        Expect   = item.expect,
                        Opencode = item.opencode,
                        Opentime = DateTime.Parse(item.opentime),
                        Status   = 2
                    };
                    //获取的开奖记录 是否是当前正在开奖的记录
                    bool listltty = Lottery.ExistsBJ28(" and a.expect='" + item.expect + "' and a.status<>2");
                    if (listltty)
                    {
                        GetBJResult(lottery, item);
                        string result = OWZX.Data.Lottery.UpdateLottery(lottery);
                        if (result.EndsWith("成功"))
                        {
                            return(lottery.Expect);
                        }
                        else
                        {
                            Logs.Write("北京28更新结果异常:" + result);
                        }
                        return("");
                    }
                }
            }
            return("");
        }