public LotteryDataModel GetLotteryData()
        {
            LotteryDataModel lotteryData = new LotteryDataModel();

            lotteryData.MyLotteries  = _lotteryDatabase.GetLottery().ToList();
            lotteryData.MyNumberSets = _lotteryDatabase.GetNumberSet().ToList();
            lotteryData.MyNumberPool = _lotteryDatabase.GetNumberPool();
            return(lotteryData);
        }
예제 #2
0
        public IList <LotteryDataModel> GetLotteryHistory(int ltId)
        {
            string cacheKey = string.Format(Const.CACHE_KEY_LOTTERY_HISTORY, ltId);
            IList <LotteryDataModel> history = (IList <LotteryDataModel>)RTCache.Get(cacheKey);

            if (history == null || history.Count < 0)
            {
                history = new List <LotteryDataModel>();

                using (DbOperHandler dbOperHandler = new ComData().Doh())
                {
                    dbOperHandler.Reset();
                    dbOperHandler.SqlCmd = "select top 20 * from Sys_LotteryData where Type=" + ltId + " order by Title desc";
                    DataTable dataTable = dbOperHandler.GetDataTable();

                    if (dataTable != null && dataTable.Rows.Count > 0)
                    {
                        for (int i = 0; i < dataTable.Rows.Count; i++)
                        {
                            LotteryDataModel lot = new LotteryDataModel()
                            {
                                Id        = Convert.ToInt32(dataTable.Rows[i]["id"]),
                                Type      = Convert.ToInt32(dataTable.Rows[i]["Type"]),
                                Title     = Convert.ToString(dataTable.Rows[i]["Title"]),
                                Number    = Convert.ToString(dataTable.Rows[i]["Number"]),
                                NumberAll = Convert.ToString(dataTable.Rows[i]["NumberAll"]),
                                Total     = Convert.ToInt32(dataTable.Rows[i]["Total"]),
                                Dx        = Convert.ToInt32(dataTable.Rows[i]["Dx"]),
                                Ds        = Convert.ToInt32(dataTable.Rows[i]["Ds"]),
                                OpenTime  = Convert.ToDateTime(dataTable.Rows[i]["OpenTime"]),
                                STime     = Convert.ToDateTime(dataTable.Rows[i]["STime"]),
                                Flag      = Convert.ToInt32(dataTable.Rows[i]["Flag"]),
                                Flag2     = Convert.ToInt32(dataTable.Rows[i]["Flag2"]),
                                IsFill    = Convert.ToBoolean(dataTable.Rows[i]["IsFill"])
                            };

                            history.Add(lot);
                        }
                    }

                    //排序
                    if (history.Count > 0)
                    {
                        history = (from it in history orderby it.Title descending select it).ToList();
                    }

                    dataTable.Clear();
                    dataTable.Dispose();
                }

                RTCache.Insert(cacheKey, history);
            }

            return(history);
        }
예제 #3
0
        /// <summary>
        /// 更新彩票开奖信息
        /// </summary>
        /// <param name="type"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        public bool Update(int type, string title)
        {
            string cacheKey = string.Format(Const.CACHE_KEY_LOTTERY_HISTORY, type);
            IList <LotteryDataModel> history = GetLotteryHistory(type);

            //获取缓存数据
            LotteryDataModel lottery = (from it in history where it.Type == type && it.Title == title select it).FirstOrDefault();

            if (lottery == null)
            {
                return(false);
            }

            string number    = lottery.Number;
            string numberAll = lottery.NumberAll;
            int    num       = lottery.Total;
            string openTime  = lottery.OpenTime.ToString("yyyy-MM-dd HH:mm:ss");

            try
            {
                using (SqlConnection conn = new SqlConnection(ComData.connectionString))
                {
                    using (SqlCommand com = new SqlCommand())
                    {
                        conn.Open();
                        com.Connection  = conn;
                        com.CommandText = string.Format(@"INSERT INTO Sys_LotteryData(Type, Title, Number, NumberAll, Total, OpenTime, IsFill)
                                                    SELECT {0}, '{1}', '{2}', '{3}', {4}, '{5}', 1 
                                                    WHERE NOT EXISTS(SELECT 1 FROM Sys_LotteryData WHERE Type={0} and Title='{1}'); 
                                                    select @@identity as id; ", type, title, number, numberAll, num, openTime);

                        object id = com.ExecuteScalar(); //插入数据

                        //插入成功
                        if (!Convert.IsDBNull(id))
                        {
                            lottery.Id = Convert.ToInt32(id);
                            return(true);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("开奖入库异常 {0}", ex);
            }

            return(false);
        }
예제 #4
0
        public MainPageViewModel()
        {
            LotteryDataModel data = _numbrTumblrBusiness.GetLotteryData();

            if (data != null)
            {
                if (data.MyLotteries != null)
                {
                    _lotteries.AddRange(data.MyLotteries);
                }

                if (data.MyNumberSets != null)
                {
                    _numberSets.AddRange(data.MyNumberSets);
                }
                _numberPool = data.MyNumberPool;
            }
        }