/// <summary> /// 创建session /// </summary> /// <param name="userCode">用户code</param> /// <param name="pwd">用户密码</param> /// <param name="jobId">岗位Id</param> public void CreateSession(string userCode, string pwd, string jobId) { if (!string.IsNullOrEmpty(userCode) && !string.IsNullOrEmpty(jobId)) { UserSession user = new UserSession(); SysOperator loginUser = MLogin.TheLoginSrv.GetSysOperator(userCode); List <SysRole> listJobs = MLogin.GetOperOnRoles(loginUser.Id, DateTime.Now).OfType <SysRole>().ToList(); var loginJob = from j in listJobs where j.Id == jobId select j; SysRole theSysRole = listJobs.ElementAt(0); Application.Resource.CommonClass.Domain.Login theLogin = new Application.Resource.CommonClass.Domain.Login(); theLogin.Password = string.IsNullOrEmpty(pwd) ? loginUser.OperPassword : pwd; theLogin.LoginDate = DateTime.Now; theLogin.TheCurrency = MLogin.TheLoginSrv.GetBasicCurrencyInfo(); theLogin.TheSysRole = theSysRole; theLogin.ThePerson = MLogin.TheLoginSrv.GetPerson(loginUser.Id); theLogin.TheBusinessOperators = MLogin.TheLoginSrv.GetAuthor(loginUser.Id); theLogin.GroupName = "默认帐套";//Convert.ToString(this.cbbAppContext.SelectedItem); theLogin.Supplier = MLogin.SupplierResSrv.GetSelf(); theLogin.Customer = MLogin.ClientResSrv.GetSelf(); theLogin.TheRoles = MLogin.ClientResSrv.GetRoles(theSysRole.Id); if (theSysRole != null && theSysRole.Id != null) { theLogin.TheOperationOrgInfo = MLogin.TheLoginSrv.GetOperationOrgInfo(theSysRole.Id); if (theLogin.TheOperationOrgInfo != null) { theLogin.TheAccountOrgInfo = MLogin.ClientResSrv.GetAccountOrgInfo(theLogin.TheOperationOrgInfo.SysCode); } } //设置会计年月 //if (theBusinessModule.Id != null) // theLogin.TheComponentPeriod = theMLogin.GetComponentPeriod(theBusinessModule.Id, DateTime.Parse(this.txtLoginDate.Text)); //if (_FiscalModule.Id != null) // theLogin.FiscalModule = theMLogin.GetComponentPeriod(_FiscalModule.Id, DateTime.Parse(this.txtLoginDate.Text)); //AppDomain.CurrentDomain.SetData("TheLogin", theLogin); //ContextConfig config = AppDomain.CurrentDomain.GetData("ContextConfig") as ContextConfig; //config.ExecuteInitailMethod(theLogin.TheSysRole.Id, theLogin.ThePerson.Id, theLogin.LoginDate); user.TheJobs = listJobs; user.TheLogin = theLogin; Session["UserSession"] = user; } }
private bool SetLoginInfo() { try { UserSession user = new UserSession(); var loginJob = from j in listJobs where j.Id == cbUserJobs.SelectedValue select j; SysRole theSysRole = listJobs.ElementAt(0); Application.Resource.CommonClass.Domain.Login theLogin = new Application.Resource.CommonClass.Domain.Login(); string perId = theSysOperator.Id; string pwd = txtPassword.Text; theLogin.Password = pwd; theLogin.LoginDate = DateTime.Now; theLogin.TheCurrency = MLogin.TheLoginSrv.GetBasicCurrencyInfo(); theLogin.TheSysRole = theSysRole; theLogin.ThePerson = MLogin.TheLoginSrv.GetPerson(perId); theLogin.TheBusinessOperators = MLogin.TheLoginSrv.GetAuthor(perId); theLogin.GroupName = "默认帐套";//Convert.ToString(this.cbbAppContext.SelectedItem); theLogin.Supplier = MLogin.SupplierResSrv.GetSelf(); theLogin.Customer = MLogin.ClientResSrv.GetSelf(); theLogin.TheRoles = MLogin.ClientResSrv.GetRoles(theSysRole.Id); if (theSysRole != null && theSysRole.Id != null) { theLogin.TheOperationOrgInfo = MLogin.TheLoginSrv.GetOperationOrgInfo(theSysRole.Id); if (theLogin.TheOperationOrgInfo != null) { theLogin.TheAccountOrgInfo = MLogin.ClientResSrv.GetAccountOrgInfo(theLogin.TheOperationOrgInfo.SysCode); } } //设置会计年月 //if (theBusinessModule.Id != null) // theLogin.TheComponentPeriod = theMLogin.GetComponentPeriod(theBusinessModule.Id, DateTime.Parse(this.txtLoginDate.Text)); //if (_FiscalModule.Id != null) // theLogin.FiscalModule = theMLogin.GetComponentPeriod(_FiscalModule.Id, DateTime.Parse(this.txtLoginDate.Text)); //AppDomain.CurrentDomain.SetData("TheLogin", theLogin); //ContextConfig config = AppDomain.CurrentDomain.GetData("ContextConfig") as ContextConfig; //config.ExecuteInitailMethod(theLogin.TheSysRole.Id, theLogin.ThePerson.Id, theLogin.LoginDate); user.TheJobs = listJobs; user.TheLogin = theLogin; Session["UserSession"] = user; } catch (Exception ee) { lblMessage.Text = ExceptionUtil.ExceptionMessage(ee); lblMessage.Style.Add("color", "red"); return(false); } return(true); }