예제 #1
0
        public JsonResult doLogin()
        {
            string flag    = "success";
            string message = "";

            if (!string.IsNullOrEmpty(Request["vcode"]))
            {
                string strAccountId = Request["account"];
                string strPassword  = Request["password"];

                // 是否存在?
                if (!MemberDBUtils.MemberIsExist(GetControl(), strAccountId))
                {
                    flag    = "failed";
                    message = "用户名或密码错误";
                }
                else
                {
                    Hashtable aHT = new Hashtable();
                    PickParam(aHT).SetParam("DOMAINNAME", "caika.com");
                    PickParam(aHT).SetParam("DOMAINUSER", Request["account"]);
                    PickParam(aHT).SetParam("PSTPWD", Request["password"]);
                    PickParam(aHT).SetParam("IP", Request.UserHostAddress);
                    if (PickParam(aHT).SetCmd(APassport.CSignOn).ExecuteCmd(new APassport()).IsOK())
                    {
                        Authorizes.SetAuthorizeCache(Request, Response, PickParam(aHT).GetValue("passport") as Hashtable);
                    }
                    else
                    {
                        flag    = "failed";
                        message = PickParam(aHT).GetError();
                    }
                }
            }
            else
            {
                flag    = "failed";
                message = "验证码失效";
            }

            return(Json(new { state = flag, message = message }));
        }
예제 #2
0
        public JsonResult doRegister()
        {
            string flag    = "success";
            string message = "";

            if (!string.IsNullOrEmpty(Request["vcode"]))
            {
                string strAccountId = Request["account"];
                string strPassword  = Request["password"];
                string strAgentCode = Request["agentcode"];
                if (string.IsNullOrEmpty(strAgentCode))
                {
                    strAgentCode = "000101999";
                }

                // 是否存在?
                if (MemberDBUtils.MemberIsExist(GetControl(), strAccountId))
                {
                    flag    = "failed";
                    message = "用户名已存在";
                }
                else
                {
                    Hashtable aHT = new Hashtable();
                    PickParam(aHT).SetParam("DOMAINUSER", strAccountId);
                    PickParam(aHT).SetParam("DOMAINNAME", "caika.com");
                    PickParam(aHT).SetParam("PSTPWD", strPassword);
                    PickParam(aHT).SetParam("TYPE", account_type.NormalAcount);
                    PickParam(aHT).SetParam("IP", Request.UserHostAddress);
                    PickParam(aHT).SetParam(MemberDBUtils.GetMemberDigest(GetControl()));
                    PickParam(aHT).SetParam("PARENTAGENT", strAgentCode);

                    // 校验应用许可权的合法性
                    ParamUtil checkLicense = PickParam().Merge(aHT).SetCmd(ADomain.CCheckLicense).ExecuteCmd(new ADomain());
                    if (!checkLicense.IsOK())
                    {
                        flag    = "failed";
                        message = checkLicense.GetError();
                    }
                    else
                    {
                        // 先注册通行证、然后再添加会员账户
                        // 执行CRegister命令后会破坏aHT参数信息,所以在此创建一个临时aHT1用于避免原始参数集合不被破坏。
                        Hashtable aHT1 = new Hashtable();
                        if (PickParam(aHT1).Merge(aHT).SetCmd(APassport.CRegister).ExecuteCmd(new APassport()).IsOK())
                        {
                            // 创建会员账户
                            Hashtable aHT2 = new Hashtable();
                            MemberDBUtils.CreateMemberRecord(GetControl(), PickParam(aHT2).Merge(aHT).ParamTable);
                            if (!PickParam(aHT2).IsOK())
                            {
                                flag    = "failed";
                                message = PickParam(aHT2).GetError();
                            }
                            else
                            {
                                // 注册完成后直接登录
                                if (PickParam(aHT).SetCmd(APassport.CSignOn).ExecuteCmd(new APassport()).IsOK())
                                {
                                    Authorizes.SetAuthorizeCache(Request, Response, PickParam(aHT).GetValue("passport") as Hashtable);
                                }
                                else
                                {
                                    flag    = "failed";
                                    message = PickParam(aHT).GetError();
                                }
                            }
                        }
                        else
                        {
                            flag    = "failed";
                            message = PickParam(aHT1).GetError();
                        }
                    }
                }
            }
            else
            {
                flag    = "failed";
                message = "验证码失效";
            }

            return(Json(new { state = flag, message = message }));
        }
예제 #3
0
        private void Controls_RequestValidationEvent(object sender, EventArgs e)
        {
            IControlValidation objControl = (IControlValidation)sender;

            objControl.IsValid     = true;
            objControl.IsValidated = true;

            switch (((Control)sender).Name)
            {
            case "TxtAgentCode":
                if (objControl.IsEmpty)
                {
                    objControl.IsValid            = false;
                    objControl.ValidationErrorMsg = "上级代理商编号不能为空!";
                }
                else
                {
                    ParamUtil aPU = new ParamUtil().SQLCmdLoadData().SQLWithOutSchema()
                                    .SQLEntityScript("BASE_CATEGORY", string.Format("SELECT CATEGORYID FROM BASE_CATEGORY WHERE CATEGORYID='{0}'", objControl.CurrentText))
                                    .ExecuteCmd(ADataLoader.DataLoader());
                    if (!aPU.IsOK())
                    {
                        objControl.IsValid            = false;
                        objControl.ValidationErrorMsg = aPU.GetError();
                    }
                    else
                    {
                        if (aPU.GetValueAsDataSet().Tables["BASE_CATEGORY"].Rows.Count == 0)
                        {
                            objControl.IsValid            = false;
                            objControl.ValidationErrorMsg = string.Format("代理商编号[{0}]无效!", objControl.CurrentText);
                        }
                    }
                }
                break;

            case "TxtAccountID":
                if (objControl.IsEmpty)
                {
                    objControl.IsValid            = false;
                    objControl.ValidationErrorMsg = "账户名不能为空!";
                }
                else
                {
                    if (objControl.CurrentText.Length < 4 || objControl.CurrentText.Length > 18)
                    {
                        objControl.IsValid            = false;
                        objControl.ValidationErrorMsg = "账户名长度必须在(4-18)之间!";
                    }
                    else
                    {
                        // 是否存在?
                        if (MemberDBUtils.MemberIsExist(GetControl(), TxtAccountID.Text))
                        {
                            objControl.IsValid            = false;
                            objControl.ValidationErrorMsg = string.Format("账号[{0}]已经存在!", TxtAccountID.Text);
                        }
                    }
                }
                break;

            case "TxtPassword":
            case "TxtConfirm":
                if (objControl.IsEmpty)
                {
                    objControl.IsValid            = false;
                    objControl.ValidationErrorMsg = "密码不能为空!";
                }
                else
                {
                    if (objControl.CurrentText.Length < 4 || objControl.CurrentText.Length > 18)
                    {
                        objControl.IsValid            = false;
                        objControl.ValidationErrorMsg = "密码长度必须在(4-18)之间!";
                    }
                }

                if (objControl.IsValidated && objControl.IsValid)
                {
                    if (TxtPassword.Text != TxtConfirm.Text)
                    {
                        objControl.IsValid            = false;
                        objControl.ValidationErrorMsg = "两次密码输入不一致!";
                        if (objControl == TxtPassword && string.IsNullOrEmpty(TxtConfirm.Text))
                        {
                            objControl.IsValid = true;
                        }
                    }
                    else
                    {
                        TxtPassword.IsValid = true;
                        TxtConfirm.IsValid  = true;
                    }
                }
                break;
            }

            if (!objControl.IsValid && objControl.IsValidated)
            {
                ((Control)objControl).Focus();
            }
        }