/// <summary>
        /// 修改最新一期的时间和开奖号码
        /// </summary>
        /// <param name="lotteryTcketInfo"></param>
        /// <returns></returns>
        public static int UpNewNum(LotteryTcketInfo lotteryTcketInfo)
        {
            string sqltext = @"begin tran tran_ADDSate declare @tran_error int;set @tran_error=0;declare @NewNumber nvarchar(50);declare @NewNumberID INT;declare @NewLastNumer int;declare @BigRate FLOAT;declare @SmallRate FLOAT;declare @SingleRate FLOAT;declare @DoubleRate FLOAT;declare @UserIntegration  INT;declare @NewUserIntegration int;declare @minID int;declare @MaxID int ;set  @minID=0;set @MaxID=0;declare @NtesID int;declare @LotteryTcketID int;declare @UserID int;begin try UPDATE [dbo].[LotteryTcketInfo] set [LotteryTcketNmber] =32568 ,[Timer]='2018-09-11 22:22' WHERE [LotteryTcket] = 20180909071 select top 1 @NewNumber=LotteryTcket  from	[dbo].[LotteryTcketInfo] order by [LotteryTcketID] desc if(@NewNumber=20180909071) begin select	@NewNumberID=[LotteryTcketID] from  [dbo].[LotteryTcketInfo] where  LotteryTcket= @NewNumber  select top(1) @minID=[BuyID] from  BuyInfo WHERE  [LotteryTcketID]=@NewNumberID	order  by [BuyID]  select top(1) @MaxID=[BuyID] from  BuyInfo WHERE  [LotteryTcketID]=@NewNumberID	order  by [BuyID] desc while @minID<= @MaxID begin select @NewLastNumer =RIGHT(LotteryTcketNmber, 1),@BigRate=BigRate,@SmallRate=SmallRate,@SingleRate=SingleRate,@DoubleRate=DoubleRate from LotteryTcketInfo	where LotteryTcket=@NewNumber; select @UserID=UserID,@LotteryTcketID=NtesItegration,@NtesID=NtesID  from  BuyInfo WHERE  BuyID=@minID if @NtesID=1 begin if @NewLastNumer>=5 begin update [dbo].[UserInfo] set UserIntegration=UserIntegration+@BigRate*@LotteryTcketID where UserID=@UserID end else begin update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID end end else if	@NtesID=2 begin if @NewLastNumer>=5 begin update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID end else begin  update [dbo].[UserInfo] set UserIntegration=UserIntegration+@SmallRate*@LotteryTcketID where UserID=@UserID end end else if	@NtesID=3 begin if (@NewLastNumer+ 4) % 2 = 1 begin update [dbo].[UserInfo] set UserIntegration=UserIntegration+@SingleRate*@LotteryTcketID where UserID=@UserID end else begin update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID end end else begin if (@NewLastNumer+ 4) % 2 = 1 begin update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID end else begin update [dbo].[UserInfo] set UserIntegration=UserIntegration+@DoubleRate*@LotteryTcketID where UserID=@UserID end end set	@minID=@minID+1;end end end try begin catch set @tran_error=@tran_error+1;end catch if(@tran_error>0) begin rollback tran tran_ADDSate;print @tran_error;end else begin commit tran tran_ADDSate;print @tran_error;end";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@LotteryTcketNmber", lotteryTcketInfo.LotteryTcketNmber),
                new SqlParameter("@Timer", lotteryTcketInfo.Timer),
                new SqlParameter("@LotteryTcket", lotteryTcketInfo.LotteryTcket),
            };
            return((int)SqlHelper.ExecuteNonQuery(connection, CommandType.Text, sqltext, para));
        }
        /// <summary>
        /// 开奖
        /// </summary>
        /// <param name="invitelInfo"></param>
        /// <returns></returns>
        public static int ADDSate(LotteryTcketInfo lotteryTcketInfo)
        {
            string sqltext = "insert into LotteryTcketInfo ([LotteryTcket],[LotteryTcketNmber],[BigRate],[SmallRate],[SingleRate],[DoubleRate],[Timer]) values(@LotteryTcket,@LotteryTcketNmber,@BigRate,@SmallRate,@SingleRate,@DoubleRate,@Timer)";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@LotteryTcket", lotteryTcketInfo.LotteryTcket),
                new SqlParameter("@LotteryTcketNmber", lotteryTcketInfo.LotteryTcketNmber),
                new SqlParameter("@BigRate", lotteryTcketInfo.BigRate),
                new SqlParameter("@SmallRate", lotteryTcketInfo.SmallRate),
                new SqlParameter("@SingleRate", lotteryTcketInfo.SingleRate),
                new SqlParameter("@DoubleRate", lotteryTcketInfo.DoubleRate),
                new SqlParameter("@Timer", lotteryTcketInfo.Timer)
            };
            return((int)SqlHelper.ExecuteNonQuery(connection, CommandType.Text, sqltext, para));
        }
Beispiel #3
0
 /// <summary>
 /// 修改最新一期的时间和开奖号码
 /// </summary>
 /// <param name="lotteryTcketInfo"></param>
 /// <returns></returns>
 public static int UpNewNum(LotteryTcketInfo lotteryTcketInfo)
 {
     return(DAL.UserServer.UpNewNum(lotteryTcketInfo));
 }
Beispiel #4
0
 public static int ADDSate(LotteryTcketInfo lotteryTcketInfo)
 {
     return(DAL.UserServer.ADDSate(lotteryTcketInfo));
 }
        /// <summary>
        /// 修改最新一期的时间和开奖号码
        /// </summary>
        /// <param name="lotteryTcketInfo"></param>
        /// <returns></returns>
        public static int UpNewNum(LotteryTcketInfo lotteryTcketInfo)
        {
            string sqltext = @"begin tran tran_ADDSate
	declare @tran_error int;
	set @tran_error=0;

	declare @NewNumber nvarchar(50);--最新一期的期号
	declare @NewNumberID INT;--最新一期期号的ID
	declare @NewLastNumer int;--开奖的号码最后一位
	declare @BigRate FLOAT;--大倍率
	declare @SmallRate FLOAT;--小倍率
	declare @SingleRate FLOAT;--单倍率
	declare @DoubleRate FLOAT;--双倍率

	declare @UserIntegration  INT; --用户积分
	declare @NewUserIntegration int; --操作中间变量
	declare @minID int;
	declare @MaxID int ;
	set  @minID=0;
	set @MaxID=0;

	declare @NtesID int;	  --状态(大0,小1,单2,双3)
	declare @LotteryTcketID int; --投注积分
	declare @UserID int;  --用户ID

begin try
	UPDATE [dbo].[LotteryTcketInfo] set [LotteryTcketNmber] =@LotteryTcketNmber ,[Timer]=@Timer WHERE [LotteryTcket] = @LotteryTcket
	select top 1 @NewNumber=LotteryTcket  from	[dbo].[LotteryTcketInfo] order by [LotteryTcketID] desc 

	if(@NewNumber=@LotteryTcket)
	begin
		 select	@NewNumberID=[LotteryTcketID] from  [dbo].[LotteryTcketInfo] where  LotteryTcket= @NewNumber
		 select top(1) @minID=[BuyID] from  BuyInfo WHERE  [LotteryTcketID]=@NewNumberID	order  by [BuyID]
		 select top(1) @MaxID=[BuyID] from  BuyInfo WHERE  [LotteryTcketID]=@NewNumberID	order  by [BuyID] desc
		 while @minID<= @MaxID
			begin
			   select @NewLastNumer =RIGHT(LotteryTcketNmber, 1),@BigRate=BigRate,@SmallRate=SmallRate,@SingleRate=SingleRate,@DoubleRate=DoubleRate from LotteryTcketInfo	where LotteryTcket=@NewNumber;
			   select @UserID=UserID,@LotteryTcketID=NtesItegration,@NtesID=NtesID  from  BuyInfo WHERE  BuyID=@minID
			   if @NtesID=1
					begin
						if @NewLastNumer>=5
							begin
								update [dbo].[UserInfo] set UserIntegration=UserIntegration+@BigRate*@LotteryTcketID where UserID=@UserID
							end
						else
							begin
								update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID
							end
					end
				else if	@NtesID=2
					begin
						if @NewLastNumer>=5
								begin
									update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID
								end
						else
								begin
								    update [dbo].[UserInfo] set UserIntegration=UserIntegration+@SmallRate*@LotteryTcketID where UserID=@UserID
								end
					end
				else if	@NtesID=3
					begin
						if (@NewLastNumer+ 4) % 2 = 1
								begin
									update [dbo].[UserInfo] set UserIntegration=UserIntegration+@SingleRate*@LotteryTcketID where UserID=@UserID
								end
						else
								begin
								    update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID
								end
					end
				else
					begin
						 if (@NewLastNumer+ 4) % 2 = 1
								begin
									update [dbo].[UserInfo] set UserIntegration=UserIntegration-@LotteryTcketID where UserID=@UserID
								end
						else
								begin
								    update [dbo].[UserInfo] set UserIntegration=UserIntegration+@DoubleRate*@LotteryTcketID where UserID=@UserID
								end
					end
				set	@minID=@minID+1;
		end
	end
end try
begin catch
		 set @tran_error=@tran_error+1	;
end catch
if(@tran_error>0)
	begin
		rollback tran tran_ADDSate; --执行出错,回滚事务(指定事务名称)
		print @tran_error;
	end 
else										
	begin
	  commit tran tran_ADDSate; --没有异常,提交事务(指定事务名称)
	  print @tran_error;
	end

			                                         
";

            SqlParameter[] para = new SqlParameter[]
            {
                new SqlParameter("@LotteryTcketNmber", lotteryTcketInfo.LotteryTcketNmber),
                new SqlParameter("@Timer", lotteryTcketInfo.Timer),
                new SqlParameter("@LotteryTcket", lotteryTcketInfo.LotteryTcket),
            };
            return((int)SqlHelper.ExecuteNonQuery(connection, CommandType.Text, sqltext, para));
        }
        public static void Updata()
        {
            string url      = "https://www.km28.com/lottery-gp/cqssc.html";
            string HtmlCode = GetHtmlSource(url);
            ////使用正则表达式清洗网页源代码中的数据
            String withoutNString = HtmlCode.Replace("\n", "");
            //过滤\r 转换成空
            String withoutRString = withoutNString.Replace("\r", "");
            //过滤\t 转换成空
            String withoutTString = withoutRString.Replace("\t", "");
            //过滤\ 转换成空
            String newString = withoutTString.Replace("\\", "");
            //获取html中的body标签
            String result = Regex.Match(newString, @"<body.*>.*</body>").ToString();
            //过滤注释
            String result2 = Regex.Replace(result, @"<!--(?s).*?-->", "", RegexOptions.IgnoreCase);
            //过滤nbsp标签
            String result3 = Regex.Replace(result2, @"&nbsp;", "", RegexOptions.IgnoreCase);
            String result4 = result3.Replace(" ", "");
            //获取body中的所有table
            Regex regex = new Regex(@"<table.*?>[\s\S]*?<\/table>");

            MatchCollection mc = regex.Matches(result4);
            //获取集合类中自己需要的某个table
            String    newHtmlStr = mc[0].ToString() + mc[1].ToString() + mc[2].ToString();
            DataTable dataTable  = new DataTable();
            //String strings = "a,b,c";
            //String[] stringArr = strings.Split(",");
            DateTime Dt = DateTime.Now;

            string dt  = Dt.ToString("yyyyMMdd");
            string dt1 = Dt.ToString("yyyy-MM-dd");

            string[] sArray = Regex.Split(newHtmlStr, "<tr>", RegexOptions.IgnoreCase);

            LotteryTcketInfo lotteryTcketInfo = new LotteryTcketInfo();


            for (int i = 2; i < sArray.Length; i++)
            {
                string ds = Regex.Replace(sArray[i], @"<[^>]*", "");//用Regex的replace 先将<str </str 给过滤掉
                ds = ds.Replace('>', ',');
                string[] stringArr = ds.Split(',');

                if (Regex.IsMatch(stringArr[5], @"^[0-9]{0,}$") == false)
                {   // 判断用户名的长度(4-20个字符)及内容(只能是数字)是否合法
                    continue;
                }
                lotteryTcketInfo.LotteryTcket = dt + (stringArr[1].Length == 3 ? stringArr[1] : "0" + stringArr[1]);

                long numtimer = Convert.ToInt64(DAL.InfoServer.SelectNewLotteryTcket());
                //判重
                if (numtimer > Convert.ToInt64(lotteryTcketInfo.LotteryTcket))
                {
                    continue;
                }
                else if (numtimer == Convert.ToInt64(lotteryTcketInfo.LotteryTcket))
                {
                    //修改最新一期的开奖号码,时间

                    lotteryTcketInfo.LotteryTcketNmber = stringArr[5];
                    lotteryTcketInfo.Timer             = dt1 + " " + stringArr[3] + ":00";
                    lotteryTcketInfo.Explain           = "";
                    lotteryTcketInfo.LotteryTcketID    = 0;
                    DAL.InfoServer.UpNewNum(lotteryTcketInfo);
                    //添加一期
                    lotteryTcketInfo.LotteryTcket   = (numtimer + 1).ToString();
                    lotteryTcketInfo.BigRate        = "1.8";
                    lotteryTcketInfo.DoubleRate     = "1.8";
                    lotteryTcketInfo.Explain        = "";
                    lotteryTcketInfo.LotteryTcketID = 0;
                    lotteryTcketInfo.SingleRate     = "1.8";
                    lotteryTcketInfo.SmallRate      = "1.8";
                    DAL.InfoServer.ADDSate(lotteryTcketInfo);
                }
                else
                {
                    if (i < sArray.Length)
                    {
                        lotteryTcketInfo.LotteryTcketNmber = stringArr[5];
                        lotteryTcketInfo.Timer             = dt1 + " " + stringArr[3] + ":00";
                        lotteryTcketInfo.BigRate           = "1.8";
                        lotteryTcketInfo.DoubleRate        = "1.8";
                        lotteryTcketInfo.Explain           = "";
                        lotteryTcketInfo.LotteryTcketID    = 0;
                        lotteryTcketInfo.SingleRate        = "1.8";
                        lotteryTcketInfo.SmallRate         = "1.8";
                        DAL.InfoServer.ADDSate(lotteryTcketInfo);
                    }
                    //添加最新一期的倍率
                    else if (i == sArray.Length)
                    {
                        lotteryTcketInfo.LotteryTcket   = (numtimer + 1).ToString();
                        lotteryTcketInfo.BigRate        = "1.8";
                        lotteryTcketInfo.DoubleRate     = "1.8";
                        lotteryTcketInfo.Explain        = "";
                        lotteryTcketInfo.LotteryTcketID = 0;
                        lotteryTcketInfo.SingleRate     = "1.8";
                        lotteryTcketInfo.SmallRate      = "1.8";
                        DAL.InfoServer.ADDSate(lotteryTcketInfo);
                    }
                }
            }
        }