Пример #1
0
    private void BindData()
    {
        DataTable dt = new DAL.Tables.T_CardPasswordAgents().Open("[ID], [Name]", "", "[ID]");

        if (dt == null)
        {
            PF.GoError(ErrorNumber.DataReadWrite, "数据库繁忙,请重试", "Admin_CardPasswordAdd");

            return;
        }

        Shove.ControlExt.FillDropDownList(ddlCardPasswordAgents, dt, "Name", "ID");
    }
 public int EditByID(ref string ReturnDescription)
 {
     if (this.ID < 0)
     {
         throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
     }
     DataTable table = new Tables.T_CardPasswordAgents().Open("", "[ID] = " + this.ID, "");
     if ((table == null) || (table.Rows.Count < 1))
     {
         ReturnDescription = "数据库读写错误";
         return -1;
     }
     new Tables.T_CardPasswordAgents { Company = { Value = this.Company }, Password = { Value = this.Password }, Name = { Value = this.Name }, State = { Value = this.State }, Url = { Value = this.Url } }.Update("[ID] = " + this.ID.ToString());
     return 0;
 }
Пример #3
0
    // 正常用户登录
    public int Login(ref string ReturnDescription)
    {
        DataTable dt = new DAL.Tables.T_CardPasswordAgents().Open("", "ID=" + ID, "");

        if ((dt == null) || (dt.Rows.Count < 1))
        {
            ReturnDescription = "用户不存在";

            return -1;
        }

        if (dt.Rows[0]["Password"].ToString() != PF.EncryptPassword(Password))
        {
            ReturnDescription = "密码错误";

            return -2;
        }

        //if (!Shove._Convert.StrToBool(dt.Rows[0]["State"].ToString(), false))
        if(dt.Rows[0]["State"].ToString() != "1")
        {
            ReturnDescription = "代理商帐号已经过期";

            return -2;
        }

        Name = dt.Rows[0]["Name"].ToString();
        Password = dt.Rows[0]["Password"].ToString();
        Company = dt.Rows[0]["Company"].ToString();
        Url = dt.Rows[0]["Url"].ToString();
        State = Shove._Convert.StrToShort(dt.Rows[0]["State"].ToString(), 0);

        // 校验成功
        SaveUserIDToCookie();

        return 0;
    }
Пример #4
0
    public int GetInformationByID(ref string ReturnDescription)
    {
        if (ID < 0)
        {
            throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
        }

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

        if ((dt == null) || (dt.Rows.Count < 1))
        {
            ReturnDescription = "数据库读写错误";

            return -1;
        }

        Name = dt.Rows[0]["Name"].ToString();
        Password = dt.Rows[0]["Password"].ToString();
        Company = dt.Rows[0]["Company"].ToString();
        Url = dt.Rows[0]["Url"].ToString();
        State = Shove._Convert.StrToShort(dt.Rows[0]["State"].ToString(), 0);

        return 0;
    }
Пример #5
0
    public int EditByID(ref string ReturnDescription)
    {
        if (ID < 0)
        {
            throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
        }

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

        if ((dt == null) || (dt.Rows.Count < 1))
        {
            ReturnDescription = "数据库读写错误";

            return -1;
        }

        DAL.Tables.T_CardPasswordAgents t_CardPasswordAgents = new DAL.Tables.T_CardPasswordAgents();

        t_CardPasswordAgents.Company.Value = Company;
        t_CardPasswordAgents.Password.Value = Password;
        t_CardPasswordAgents.Name.Value = Name;
        t_CardPasswordAgents.State.Value = State;
        t_CardPasswordAgents.Url.Value = Url;

        t_CardPasswordAgents.Update("[ID] = " + ID.ToString());

        return 0;
    }
Пример #6
0
    public int GetInformationByName(ref string ReturnDescription)
    {
        if (Name == "")
        {
            throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
        }

        DataTable dt = new DAL.Tables.T_CardPasswordAgents().Open("", "[Name] = " + Shove._Web.Utility.FilteSqlInfusion(Name), "");

        if ((dt == null) || (dt.Rows.Count < 1))
        {
            ReturnDescription = "数据库读写错误";

            return -1;
        }

        ID = Shove._Convert.StrToInt(dt.Rows[0]["ID"].ToString(), 0);
        Password = dt.Rows[0]["Password"].ToString();
        Company = dt.Rows[0]["Company"].ToString();
        Url = dt.Rows[0]["Url"].ToString();
        State = Shove._Convert.StrToShort(dt.Rows[0]["State"].ToString(), 0);

        return 0;
    }
Пример #7
0
 private int Valid(ref DataSet ReturnDS, ref short State, int AgentID, string TimeStamp, string Sign, params object[] Params)
 {
     DateTime time;
     try
     {
         time = DateTime.Parse(TimeStamp);
     }
     catch
     {
         this.BuildReturnDataSetForError(-11, "时间戳格式错误", ref ReturnDS);
         return -4;
     }
     State = 0;
     TimeSpan span = (TimeSpan)(DateTime.Now - time);
     if (Math.Abs(span.TotalSeconds) > 300.0)
     {
         this.BuildReturnDataSetForError(-2, "访问超时", ref ReturnDS);
         return -2;
     }
     Thread.Sleep(200);
     DataTable table = new Tables.T_CardPasswordAgents().Open("", "[ID] = " + AgentID.ToString(), "");
     if (table == null)
     {
         this.BuildReturnDataSetForError(-9999, "未知错误", ref ReturnDS);
         return -9999;
     }
     if (table.Rows.Count < 1)
     {
         this.BuildReturnDataSetForError(-1, "代理商ID错误", ref ReturnDS);
         return -1;
     }
     string str = table.Rows[0]["IPAddressLimit"].ToString();
     if ((str != "") && (("," + str + ",").IndexOf("," + this.GetClientIPAddress() + ",") < 0))
     {
         this.BuildReturnDataSetForError(-3, "IP地址限制", ref ReturnDS);
         return -3;
     }
     string str2 = table.Rows[0]["Key"].ToString();
     string str3 = AgentID.ToString() + TimeStamp;
     foreach (object obj2 in Params)
     {
         str3 = str3 + this.ParamterToString(obj2);
     }
     if (Encrypt.MD5(str3 + str2).ToLower() != Sign.ToLower())
     {
         this.BuildReturnDataSetForError(-4, "签名校验失败", ref ReturnDS);
         return -4;
     }
     State = _Convert.StrToShort(table.Rows[0]["State"].ToString(), 0);
     return 0;
 }
Пример #8
0
    // 错误码:
    //  -1 代理商ID错误
    //  -2 访问超时
    //  -3 IP地址限制
    //  -4 签名失败
    //  -5 卡号不存在
    //  -6 卡号已经被使用
    //  -7 失效时间不能小于当前时间
    //  -8 参数不符合规定或者未提供
    //  -9 代理商被停用
    //  -10 卡号不存在、已失效、已被更换、已被使用
    //  -11 时间戳格式错误

    //  -9999 未知错误

    // 校验 Sign, 代理商合法性, 时间戳
    private int Valid(ref DataSet ReturnDS, ref short State, int AgentID, string TimeStamp, string Sign, params object[] Params)
    {
        DateTime t_DateTime;

        try
        {
            t_DateTime = DateTime.Parse(TimeStamp);
        }
        catch
        {
            BuildReturnDataSetForError(-11, "时间戳格式错误", ref ReturnDS);

            return -4;
        }

        State = 0;

        TimeSpan ts = DateTime.Now - t_DateTime;

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

            return -2;
        }

        System.Threading.Thread.Sleep(200);             //休眠 200 毫秒

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

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

            return -9999;
        }

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

            return -1;
        }

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

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

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

                return -3;
            }
        }

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

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

        SignSource += Key;

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

            return -4;
        }

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

        return 0;
    }
 private void BindData()
 {
     DataTable dt = new Tables.T_CardPasswordAgents().Open("[ID], [Name]", "", "[ID]");
     if (dt == null)
     {
         PF.GoError(4, "数据库繁忙,请重试", "Admin_CardPasswordAdd");
     }
     else
     {
         ControlExt.FillDropDownList(this.ddlCardPasswordAgents, dt, "Name", "ID");
     }
 }
 public int GetInformationByID(ref string ReturnDescription)
 {
     if (this.ID < 0)
     {
         throw new Exception("CardPassword 尚未初始化到具体的数据实例上,请先使用 GetInformation 等获取数据信息");
     }
     DataTable table = new Tables.T_CardPasswordAgents().Open("", "[ID] = " + this.ID, "");
     if ((table == null) || (table.Rows.Count < 1))
     {
         ReturnDescription = "数据库读写错误";
         return -1;
     }
     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.State = _Convert.StrToShort(table.Rows[0]["State"].ToString(), 0);
     return 0;
 }
 public int Login(ref string ReturnDescription)
 {
     DataTable table = new Tables.T_CardPasswordAgents().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.State = _Convert.StrToShort(table.Rows[0]["State"].ToString(), 0);
     this.SaveUserIDToCookie();
     return 0;
 }