public bool Add(int type, string title, string Number, string opentime, string NumberAll)
        {
            int num = LotterySum.SumNumber(Number);

            using (DbOperHandler dbOperHandler = new ComData().Doh())
            {
                dbOperHandler.Reset();
                dbOperHandler.AddFieldItem("Type", type);
                dbOperHandler.AddFieldItem("Title", title);
                dbOperHandler.AddFieldItem("Number", Number);
                dbOperHandler.AddFieldItem("NumberAll", NumberAll);
                dbOperHandler.AddFieldItem("Total", num);
                dbOperHandler.AddFieldItem("Opentime", Convert.ToDateTime(opentime));
                dbOperHandler.AddFieldItem("IsFill", "1");
                if (dbOperHandler.Insert("Sys_LotteryData") > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #2
0
        public bool AddYoule(int type, string title, string Number, string opentime, string NumberAll = "")
        {
            int num = LotterySum.SumNumber(Number);

            using (DbOperHandler dbOperHandler = new ComData().Doh())
            {
                NumberAll = string.IsNullOrEmpty(NumberAll) ? Number : NumberAll;
                dbOperHandler.Reset();
                dbOperHandler.AddFieldItem("Type", (object)type);
                dbOperHandler.AddFieldItem("Title", (object)title);
                dbOperHandler.AddFieldItem(nameof(Number), (object)Number);
                dbOperHandler.AddFieldItem(nameof(NumberAll), (object)NumberAll);
                dbOperHandler.AddFieldItem("Total", (object)num);
                dbOperHandler.AddFieldItem("Opentime", (object)opentime);
                dbOperHandler.AddFieldItem("IsFill", (object)"1");
                if (dbOperHandler.Insert("Sys_LotteryData") > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Example #3
0
        /// <summary>
        /// 已开奖
        /// </summary>
        /// <param name="type"></param>
        /// <param name="title"></param>
        /// <param name="number"></param>
        /// <param name="opentime"></param>
        /// <param name="numberAll"></param>
        /// <returns></returns>
        public static bool ExistLottery(int type, string title, string number, string opentime, string numberAll)
        {
            string cacheKey = string.Format(Const.CACHE_KEY_LOTTERY_HISTORY, type);
            IList <LotteryDataModel> history = _dal.GetLotteryHistory(type);

            //数据已存在
            if ((from it in history where it.Title == title select it).Count() > 0)
            {
                Log.ErrorFormat("彩票已开奖, 彩种: {0}, 期号: {1}", type, title);
                return(true);
            }

            //更新缓存
            if (history.Count > 0)
            {
                history.RemoveAt(history.Count - 1); //移除最后一条
            }

            history.Insert(0, new LotteryDataModel()
            {
                Type      = type,
                Title     = title,
                Number    = number,
                NumberAll = numberAll,
                Total     = LotterySum.SumNumber(number),
                Dx        = 0,
                Ds        = 0,
                Flag      = 0,
                Flag2     = 0,
                IsFill    = true,
                OpenTime  = Convert.ToDateTime(opentime)
            });

            RTCache.Insert(cacheKey, history);
            return(false);
        }
        /// <summary>
        /// 更新彩票开奖信息
        /// </summary>
        /// <param name="type"></param>
        /// <param name="title"></param>
        /// <param name="number"></param>
        /// <param name="opentime"></param>
        /// <param name="numberAll"></param>
        /// <returns></returns>
        public bool Update(int type, string title, string number, string opentime, string numberAll)
        {
            string cacheKey = string.Format(Const.CACHE_KEY_LOTTERY_HISTORY, type);
            IList <LotteryDataModel> history = GetLotteryHistory(type);

            //数据已存在
            if ((from it in history where it.Title == title select it).Count() > 0)
            {
                return(false);
            }

            try
            {
                int num = LotterySum.SumNumber(number);

                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))
                        {
                            //更新缓存
                            if (history.Count > 0)
                            {
                                history.RemoveAt(history.Count - 1); //移除最后一条
                            }

                            history.Insert(0, new LotteryDataModel()
                            {
                                Id        = Convert.ToInt32(id),
                                Type      = type,
                                Title     = title,
                                Number    = number,
                                NumberAll = numberAll,
                                Total     = num,
                                Dx        = 0,
                                Ds        = 0,
                                Flag      = 0,
                                Flag2     = 0,
                                IsFill    = true,
                                OpenTime  = Convert.ToDateTime(opentime)
                            });

                            RTCache.Insert(cacheKey, history);

                            return(true);
                        }
                        else
                        {
                            Log.ErrorFormat("彩票已开奖, 彩种: {0}, 期号: {1}", type, title);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.ErrorFormat("开奖入库异常 {0}", ex);
            }

            return(false);
        }