private void LoadNavigation() { #region 导航信息 NavigationMenu.Items.Clear(); int nCompanyId = ((BasePage)this.Page).CompanyId; int nAccountId = ((BasePage)this.Page).AccountId; int nSysProjectId = ValidatorHelper.ToInt(CommonMethod.GetConfigValue("SYSPROJECTID"), 1); int nSysCompanyId = ValidatorHelper.ToInt(CommonMethod.GetConfigValue("SYSCOMPANYID"), 1); USER_SHARE_ACCOUNTMODEL account = AccountBusiness.GetAccountModel(nAccountId); DataTable dt = CompanyFunBusiness.GetAccountFunMenu(nAccountId, account.ISADMIN, nSysProjectId, nCompanyId); if (dt != null) { DataRow[] rows = dt.Select("PROJECTID=" + nSysProjectId, ""); divNavigation.Visible = nAccountId > 0 && rows.Length > 0; MenuItem menu = null; foreach (DataRow dr in rows) { menu = new MenuItem(); menu.Text = CommonMethod.FinalString(dr["CFANOTHERNAME"]); menu.NavigateUrl = ResolveUrl("~/" + CommonMethod.FinalString(dr["CFPAGEURL"])); menu.ToolTip = CommonMethod.FinalString(dr["CFDESC"]); NavigationMenu.Items.Add(menu); } } else { ((BasePage)this.Page).Alert("您没有此系统权限!"); Response.Redirect(ResolveUrl("~/Login.aspx")); } #endregion #region 欢迎信息 if (this.Page is BasePage && ((BasePage)this.Page).AccountId > 0) { lblCompany.Text = ((BasePage)this.Page).CompanyName; lblWelcome.Text = string.Format("欢迎您,<span class=\"bold\">{0}</span> ", ((BasePage)this.Page).RealName); lblWelcome.Visible = true; lnkLogOut.Visible = true; } else { lblWelcome.Visible = false; lnkLogOut.Visible = false; } #endregion }
/// <summary> /// 账号登陆 /// </summary> /// <param name="context"></param> /// <param name="xmlDoc"></param> /// <param name="sResponse"></param> private void AccountLogin(HttpContext context, XmlDocument xmlDoc, ServiceResponse sResponse) { XmlNode xnKey = xmlDoc.SelectSingleNode("request/appkey"); XmlNode xnCompanyCode = xmlDoc.SelectSingleNode("request/companycode"); XmlNode xnAccountName = xmlDoc.SelectSingleNode("request/accountname"); XmlNode xnAccountPwd = xmlDoc.SelectSingleNode("request/accountpwd"); USER_SHARE_PROJECTMODEL projectModel = null; //appkey参数验证 if (xnKey.InnerText.Trim().Length > 0) { projectModel = ProjectBusiness.GetProjectModelByKey(xnKey.InnerText.Trim()); if (projectModel == null) { sResponse.ErrorType = ShareEnum.ApiResultStatus.KeyErr; sResponse.ErrorDesc = "不存在的密钥KEY"; context.Response.Write(sResponse.GetXML()); return; } else { //companycode参数验证 if (xnCompanyCode == null || xnCompanyCode.InnerText.Trim().Length == 0) { sResponse.ErrorType = ShareEnum.ApiResultStatus.InputParaErr; sResponse.ErrorDesc = "缺少传入参数companycode"; return; } if (!CompanyBusiness.IsCompanyCodeExists(xnCompanyCode.InnerText.Trim())) { sResponse.ErrorType = ShareEnum.ApiResultStatus.UnValidCompanyCode; sResponse.ErrorDesc = "不存在的公司编码信息"; return; } //accountpwd参数验证 if (xnAccountPwd == null || xnAccountPwd.InnerText.Trim().Length == 0) { sResponse.ErrorType = ShareEnum.ApiResultStatus.InputParaErr; sResponse.ErrorDesc = "缺少传入参数accountpwd"; return; } //accountname参数验证 if (xnAccountName == null || xnAccountName.InnerText.Trim().Length == 0) { sResponse.ErrorType = ShareEnum.ApiResultStatus.InputParaErr; sResponse.ErrorDesc = "缺少传入参数accountname"; return; } string strAppKey = xnKey.InnerText.Trim(); string strCompanyCode = xnCompanyCode.InnerText.Trim(); string strAccountName = xnAccountName.InnerText.Trim(); string strPwd = xnAccountPwd.InnerText.Trim(); USER_SHARE_ACCOUNTMODEL accountModel = AccountBusiness.GetAccountModel(strCompanyCode, strAccountName, strPwd); if (accountModel == null) { sResponse.ErrorType = ShareEnum.ApiResultStatus.UnValidUser; sResponse.ErrorDesc = "用户名和密码不匹配"; return; } if (accountModel.STATUS != int.Parse(ShareEnum.AccountStatus.Normal.ToString("d"))) { sResponse.ErrorType = ShareEnum.ApiResultStatus.UnValidUser; sResponse.ErrorDesc = "此用户已停用"; return; } USER_SHARE_COMPANYRELATEMODEL companyModel = CompanyBusiness.GetModel(accountModel.COMPANYID); //不存在公司信息或 公司编码和传入的编码不一致 if (companyModel == null || companyModel.COMPANYCODE.ToString() != strCompanyCode) { sResponse.ErrorType = ShareEnum.ApiResultStatus.CompanyNotMatchAccount; sResponse.ErrorDesc = "公司信息和账号信息不匹配"; return; } if (companyModel.STATUS != int.Parse(ShareEnum.CompanyRelateStatus.Normal.ToString("d"))) { sResponse.ErrorType = ShareEnum.ApiResultStatus.CompanyStopUse; sResponse.ErrorDesc = "此公司已停用"; return; } StringBuilder sbContent = new StringBuilder(); sbContent.AppendFormat("<accountid>{0}</accountid>", accountModel.ACCOUNTID); sbContent.AppendFormat("<truename>{0}</truename>", accountModel.REALNAME); sbContent.AppendFormat("<companyid>{0}</companyid>", companyModel.COMPANYID); sbContent.AppendFormat("<companyname>{0}</companyname>", companyModel.COMPANYNAME); sbContent.AppendFormat("<sharecompanyid>{0}</sharecompanyid>", companyModel.SHARECOMPANYID); sbContent.AppendFormat("<sharecompanyname>{0}</sharecompanyname>", companyModel.COMPANYNAME); sbContent.AppendFormat("<productids>{0}</productids>", companyModel.PRODUCTIDS); sbContent.AppendFormat("<groupid>{0}</groupid>", companyModel.GROUPID); sbContent.AppendFormat("<groupname>{0}</groupname>", companyModel.COMPANYNAME); sbContent.AppendFormat("<groupidn>{0}</groupidn>", companyModel.GROUPIDN); sbContent.Append("<accountmenu>"); //账户拥有的菜单返回 DataTable dt = CompanyFunBusiness.GetAccountFunMenu(accountModel.ACCOUNTID, accountModel.ISADMIN, projectModel.PROJECTID, accountModel.COMPANYID); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { sbContent.AppendFormat(@"<menuitem><menuid>{0}</menuid><name>{1}</name> <linkurl>{2}</linkurl><parentid>{3}</parentid><sortnum>{4}</sortnum> <desc>{5}</desc></menuitem>", dr["FMID"], dr["CFANOTHERNAME"], dr["CFPAGEURL"], dr["CFPARENTID"], dr["CFSORTNUM"], dr["CFDESC"]); } } sbContent.Append("</accountmenu>"); sResponse.Result = sbContent.ToString(); } } }
private void SysLogin(int nAccountId, string strAccount, string strPwd, string strAppKey, string strCompanyCode) { #region 登录 USER_SHARE_ACCOUNTMODEL account = null; if (nAccountId > 0) { account = AccountBusiness.GetAccountModel(nAccountId); } else { account = AccountBusiness.GetAccountModel(strCompanyCode, strAccount, strPwd); } if (account == null) { Alert(nAccountId > 0 ? "不存在此账号!" : "用户名密码不匹配!"); return; } else { if (account.STATUS != int.Parse(ShareEnum.AccountStatus.Normal.ToString("d"))) { Alert("此账号已无效,请确认!"); return; } USER_SHARE_PROJECTMODEL project = null; if (strAppKey.Length > 0) { project = ProjectBusiness.GetProjectModelByKey(strAppKey); if (project == null) { Alert("不存在的项目密钥,请确认!"); return; } if (project.STATUS == int.Parse(ShareEnum.ProjectStatus.StopUse.ToString("d"))) { Alert("此项目已停用,请确认!"); return; } } USER_SHARE_COMPANYRELATEMODEL company = CompanyBusiness.GetModel(account.COMPANYID); if (company == null) { Alert("不存在的公司信息,请确认!"); return; } if (company.STATUS.ToString() == ShareEnum.CompanyRelateStatus.StopUse.ToString("d")) { Alert("此公司信息已无效,请确认!"); return; } if (company.COMPANYCODE.ToString() != strCompanyCode) { Alert("公司信息和账号信息不匹配"); return; } int nProjectId = ValidatorHelper.ToInt(CommonMethod.GetConfigValue("SYSPROJECTID"), 0); HttpCookie ck = new HttpCookie("USP"); ck.Values.Add("AccountId", account.ACCOUNTID.ToString()); ck.Values.Add("RealName", Server.UrlEncode(account.REALNAME)); ck.Values.Add("ProjectId", project == null ? "0" : project.PROJECTID.ToString()); ck.Values.Add("CompanyId", account.COMPANYID.ToString()); ck.Values.Add("GroupId", CommonMethod.FinalString(company.GROUPID)); ck.Values.Add("CompanyName", Server.UrlEncode(company.COMPANYNAME)); ck.Values.Add("CompanyCode", company.COMPANYCODE.ToString()); Response.Cookies.Add(ck); //由登录页面进入 if (strAppKey.Length == 0) { //公司编码记录到Cookie HttpCookie ckCode = new HttpCookie("CompanyCode"); ckCode.Values.Add("CompanyCode", txtCompanyCode.Text.Trim()); Response.Cookies.Add(ckCode); } //获取菜单 DataTable dt = CompanyFunBusiness.GetAccountFunMenu(account.ACCOUNTID, account.ISADMIN, nProjectId, account.COMPANYID); if (dt != null) { DataRow[] rows = dt.Select("PROJECTID=" + nProjectId, ""); if (rows != null && rows.Length > 0) { Response.Redirect(rows[0]["CFPAGEURL"].ToString()); } else { Alert("您没有此系统权限!"); return; } } else { Alert("您没有此系统权限!"); return; } } #endregion }