protected override void Execute(Hashtable Params) { switch (ActionUtil.GetCmd(Params)) { case ActionUtil.AutoRun: CBTypes.Items.Add(account_type.NormalAcount); CBTypes.Items.Add(account_type.VirtualAccount); CBTypes.Items.Add(account_type.AgentAccount); CBTypes.Items.Add(account_type.ManageAccount); CBTypes.SelectedIndex = 0; _objValidationHelper.Add(TxtAccountID); _objValidationHelper.Add(TxtPassword); _objValidationHelper.Add(TxtConfirm); _objValidationHelper.Add(CBTypes); _objValidationHelper.Add(TxtParentAgent); standardGrid1.DataMember = DictSet.TableName; standardGrid1.DataSource = MemberDBUtils.GetMemberDigest(GetControl()); _objValidationHelper.ResetAllState(false, false); _objValidationHelper.ValidateAll(); break; } base.Execute(Params); }
public static Hashtable GetAuthorizeCache(HttpRequestBase Request) { Hashtable result = null; if (Request.Cookies["__sid"] != null) { string sid = Request.Cookies["__sid"].Value; string ticket = ACachTool.PickCachTool().GetValue(sid) as string; if (!string.IsNullOrEmpty(ticket)) { // 从服务器缓存中得到seession的ticket信息 FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(ticket); if (authTicket != null && !authTicket.Expired && authTicket.UserData == Request.UserHostAddress) { Hashtable aHT = ACachTool.PickCachTool().GetValue(authTicket.Name) as Hashtable; if (aHT != null) { ParamUtil.Pick(aHT).ImportSets(MemberDBUtils.GetMemberDigest(BaseControl.GlobalControl, ParamUtil.Pick(aHT).GetValueAsString("DOMAINUSER"))); ParamUtil.Pick(aHT).SetParam("ticket", authTicket); // 缓存续期 ACachTool.PickCachTool().SetValue(sid, FormsAuthentication.Encrypt(authTicket), 30, true); ACachTool.PickCachTool().SetValue(authTicket.Name, aHT, 30, true); result = aHT; } } } } return(result); }
private void BtnOK_Click(object sender, EventArgs e) { if (!_objValidationHelper.ValidateAll()) { AlertBox.ShowWarning("窗体输入项存在校检错误,请核对!", this, MessageBoxButtons.OK); return; } try { Hashtable aHT = new Hashtable(); PickParam(aHT).SetParam("DOMAINUSER", TxtAccountID.Text); PickParam(aHT).SetParam("DOMAINNAME", SuperDomain); PickParam(aHT).SetParam("PSTPWD", TxtPassword.Text); PickParam(aHT).SetParam("TYPE", (string)CBTypes.SelectedItem); PickParam(aHT).SetParam("PARENTAGENT", TxtParentAgent.Text); PickParam(aHT).SetParam(standardGrid1.DataSource); // 创建会员账户 Hashtable aTmp = new Hashtable(); MemberDBUtils.CreateMemberRecord(GetControl(), PickParam(aTmp).Merge(aHT).ParamTable); if (!PickParam(aTmp).IsOK()) { AlertBox.ShowWarning(PickParam(aTmp).GetError(), this.MyParent, MessageBoxButtons.OK); return; } // 先注册通行证、然后再添加会员账户 // 执行CRegister命令后会破坏aHT参数信息,所以在此创建一个临时aHT1用于避免原始参数集合不被破坏。 Hashtable aHT1 = new Hashtable(); if (PickParam(aHT1).Merge(aHT).SetCmd(APassport.CRegister).ExecuteCmd(new APassport()).IsOK()) { foreach (string domain in Domains.Where(cm => cm != SuperDomain)) { Hashtable aHT2 = new Hashtable(); // 绑定关联的应用域 PickParam(aHT2).Merge(aHT).SetParam("DOMAINNAME", domain); if (!PickParam(aHT2).SetCmd(APassport.CRegister).ExecuteCmd(new APassport()).IsOK()) { GetControl().WriteError(string.Format("绑定关联的应用域{0}失败!", domain)); } } } DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception ex) { AlertBox.ShowError(ex.ToString(), this.MyParent, MessageBoxButtons.OK); } }
private void CreateNewAccount(Hashtable Params) { IModelForm instance = PickParam(Params).GetValue <IModelForm>(ActionUtil.ActionID); if (instance != null) { FCreateAccount fInstance = new FCreateAccount(); if (fInstance.ShowViewDialog(instance) == DialogResult.OK) { DataSet dsPassport = MemberDBUtils.GetMemberAndPassport(GetControl(), fInstance.AccountID, fInstance.SuperDomain); if (dsPassport != null) { StandardGrid gridList = instance.GetActived <ListModelFormProxy>().GridControl; // 为列表数据源构建一条新记录,并定位到新记录上。 DataRow rowNew = ((DataSet)gridList.DataSource).Tables[gridList.DataMember].NewRow(); foreach (DataRow rowField in instance.GetItem <StandardModelSettings>(PickParam(Params).GetValueAsString("ListModelView")).Fields.Tables[DictSet.TableName].Rows) { FieldItem fieldItem = new FieldItem(rowField); try { rowNew[fieldItem.FieldName] = dsPassport.Tables[fieldItem.PersistentTable].Rows[0][fieldItem.PersistentField]; } catch (Exception) { } } ((DataSet)gridList.DataSource).Tables[gridList.DataMember].Rows.Add(rowNew); rowNew.AcceptChanges(); // 插入新行并列表重新定位。 DataGridViewRow objCurrentRow = gridList.Rows.OfType <DataGridViewRow>().FirstOrDefault(cm => ((DataRowView)cm.DataBoundItem).Row == rowNew); if (objCurrentRow != null) { gridList.CurrentCell = gridList[0, objCurrentRow.Index]; gridList.InvalidateRow(objCurrentRow.Index); } } AlertBox.ShowTips("创建成功!", instance, MessageBoxButtons.OK); } } }
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 })); }
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 })); }
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(); } }