Example #1
0
    // 校验 Sign, 代理商合法性, 时间戳
    private int Valid(ref DataSet ReturnDS, ref string UseLotteryList, ref double Balance, ref short State, long AgentID, DateTime TimeStamp, string Sign, params object[] Params)
    {
        UseLotteryList = "";
        Balance = 0;
        State = 0;

        TimeSpan ts = DateTime.Now - TimeStamp;

        if (Math.Abs(ts.TotalSeconds) > 300)
        {
            BuildReturnDataSetForError(-20, "访问超时", ref ReturnDS);

            new Log("Agent\\ElectronTicket").Write("访问超时");

            return -20;
        }

        DataTable dt = new DAL.Tables.T_ElectronTicketAgents().Open("", "[ID] = " + AgentID.ToString(), "");

        if (dt == null)
        {
            BuildReturnDataSetForError(-9999, "未知错误", ref ReturnDS);

            new Log("Agent\\ElectronTicket").Write("未知错误");

            return -9999;
        }

        if (dt.Rows.Count < 1)
        {
            BuildReturnDataSetForError(-1, "代理商ID错误", ref ReturnDS);

            new Log("Agent\\ElectronTicket").Write("代理商ID错误");

            return -1;
        }

        string IPAddressLimit = dt.Rows[0]["IPAddressLimit"].ToString();

        if (IPAddressLimit != "")
        {
            IPAddressLimit = "," + IPAddressLimit + ",";

            if (IPAddressLimit.IndexOf("," + GetClientIPAddress() + ",") < 0)
            {
                BuildReturnDataSetForError(-25, "IP地址限制", ref ReturnDS);

                new Log("Agent\\ElectronTicket").Write("IP地址限制");

                return -25;
            }
        }

        string Key = dt.Rows[0]["Key"].ToString();
        string SignSource = AgentID.ToString() + ParamterToString(TimeStamp);

        foreach (object Param in Params)
        {
            SignSource += ParamterToString(Param);
        }

        SignSource += Key;

        if (Shove._Security.Encrypt.MD5(SignSource).ToLower() != Sign.ToLower())
        {
            BuildReturnDataSetForError(-2, "签名校验失败", ref ReturnDS);

            new Log("Agent\\ElectronTicket").Write("签名校验失败");

            return -2;
        }

        UseLotteryList = dt.Rows[0]["UseLotteryList"].ToString();
        Balance = Shove._Convert.StrToDouble(dt.Rows[0]["Balance"].ToString(), 0);
        State = Shove._Convert.StrToShort(dt.Rows[0]["State"].ToString(), 0);

        return 0;
    }
 private int Valid(ref DataSet ReturnDS, ref string UseLotteryList, ref double Balance, ref short State, long AgentID, DateTime TimeStamp, string Sign, params object[] Params)
 {
     UseLotteryList = "";
     Balance = 0.0;
     State = 0;
     TimeSpan span = (TimeSpan)(DateTime.Now - TimeStamp);
     if (Math.Abs(span.TotalSeconds) > 300.0)
     {
         this.BuildReturnDataSetForError(-20, "访问超时", ref ReturnDS);
         new Log(@"Agent\ElectronTicket").Write("访问超时");
         return -20;
     }
     DataTable table = new Tables.T_ElectronTicketAgents().Open("", "[ID] = " + AgentID.ToString(), "");
     if (table == null)
     {
         this.BuildReturnDataSetForError(-9999, "未知错误", ref ReturnDS);
         new Log(@"Agent\ElectronTicket").Write("未知错误");
         return -9999;
     }
     if (table.Rows.Count < 1)
     {
         this.BuildReturnDataSetForError(-1, "代理商ID错误", ref ReturnDS);
         new Log(@"Agent\ElectronTicket").Write("代理商ID错误");
         return -1;
     }
     string str = table.Rows[0]["IPAddressLimit"].ToString();
     if ((str != "") && (("," + str + ",").IndexOf("," + this.GetClientIPAddress() + ",") < 0))
     {
         this.BuildReturnDataSetForError(-25, "IP地址限制", ref ReturnDS);
         new Log(@"Agent\ElectronTicket").Write("IP地址限制");
         return -25;
     }
     string str2 = table.Rows[0]["Key"].ToString();
     string str3 = AgentID.ToString() + this.ParamterToString(TimeStamp);
     foreach (object obj2 in Params)
     {
         str3 = str3 + this.ParamterToString(obj2);
     }
     if (Encrypt.MD5(str3 + str2).ToLower() != Sign.ToLower())
     {
         this.BuildReturnDataSetForError(-2, "签名校验失败", ref ReturnDS);
         new Log(@"Agent\ElectronTicket").Write("签名校验失败");
         return -2;
     }
     UseLotteryList = table.Rows[0]["UseLotteryList"].ToString();
     Balance = _Convert.StrToDouble(table.Rows[0]["Balance"].ToString(), 0.0);
     State = _Convert.StrToShort(table.Rows[0]["State"].ToString(), 0);
     return 0;
 }
 public int Login(ref string ReturnDescription)
 {
     DataTable table = new Tables.T_ElectronTicketAgents().Open("", "ID=" + this.ID, "");
     if ((table == null) || (table.Rows.Count < 1))
     {
         ReturnDescription = "用户不存在";
         return -1;
     }
     if (table.Rows[0]["Password"].ToString() != PF.EncryptPassword(this.Password))
     {
         ReturnDescription = "密码错误";
         return -2;
     }
     if (table.Rows[0]["State"].ToString() != "1")
     {
         ReturnDescription = "代理商帐号已经过期";
         return -2;
     }
     this.Name = table.Rows[0]["Name"].ToString();
     this.Password = table.Rows[0]["Password"].ToString();
     this.Company = table.Rows[0]["Company"].ToString();
     this.Url = table.Rows[0]["Url"].ToString();
     this.Balance = Convert.ToDouble(table.Rows[0]["Balance"].ToString());
     this.State = _Convert.StrToShort(table.Rows[0]["State"].ToString(), 0);
     this.UseLotteryList = table.Rows[0]["UseLotteryList"].ToString();
     this.IPAddressLimit = table.Rows[0]["IPAddressLimit"].ToString();
     this.SaveUserIDToCookie();
     return 0;
 }
 public int EditByID(ref string ReturnDescription)
 {
     if (this.ID < 0)
     {
         throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
     }
     DataTable table = new Tables.T_ElectronTicketAgents().Open("", "[ID] = " + this.ID, "");
     if ((table == null) || (table.Rows.Count < 1))
     {
         ReturnDescription = "数据库读写错误";
         return -1;
     }
     new Tables.T_ElectronTicketAgents { Balance = { Value = this.Balance }, Company = { Value = this.Company }, Password = { Value = this.Password }, Name = { Value = this.Name }, State = { Value = this.State }, Url = { Value = this.Url }, UseLotteryList = { Value = this.UseLotteryList }, IPAddressLimit = { Value = this.IPAddressLimit } }.Update("[ID] = " + this.ID.ToString());
     return 0;
 }
 public int GetInformationByName(ref string ReturnDescription)
 {
     if (this.Name == "")
     {
         throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
     }
     DataTable table = new Tables.T_ElectronTicketAgents().Open("", "[Name] = " + Utility.FilteSqlInfusion(this.Name), "");
     if ((table == null) || (table.Rows.Count < 1))
     {
         ReturnDescription = "数据库读写错误";
         return -1;
     }
     this.ID = _Convert.StrToInt(table.Rows[0]["ID"].ToString(), 0);
     this.Password = table.Rows[0]["Password"].ToString();
     this.Company = table.Rows[0]["Company"].ToString();
     this.Url = table.Rows[0]["Url"].ToString();
     this.Balance = Convert.ToDouble(table.Rows[0]["Balance"].ToString());
     this.State = _Convert.StrToShort(table.Rows[0]["State"].ToString(), 0);
     this.UseLotteryList = table.Rows[0]["UseLotteryList"].ToString();
     this.IPAddressLimit = table.Rows[0]["IPAddressLimit"].ToString();
     return 0;
 }