public List <SysOperatorRole> GetRolesFromUI(SysOperator coreModel) { var result = new List <SysOperatorRole>(); SysOperatorRoleItems.FindAll(x => x.IsSelected).ForEach(x => { var role = coreModel.SysOperatorRoles.FirstOrDefault(r => r.RoleID == x.ID); if (role == null) { role = new SysOperatorRole() { OperatorID = OperatorID, RoleID = x.ID }; } result.Add(role); }); return(result); }
public HttpResponseMessage Post([FromBody] SysOperator sysOperatorInfo) { return(ActionWarpper.Process(sysOperatorInfo, OperationCodes.ASYSOPT, () => { var sysOperatorRepository = RepositoryManager.GetRepository <ISysOperatorRepository>(); var sysOperatorRoleRepo = RepositoryManager.GetRepository <ISysOperatorRoleRepository>(); string salt = Guid.NewGuid().ToString(); var hashPassword = SysOperatorExtension.ExcryptPassword(sysOperatorInfo.Password, salt); sysOperatorInfo.Password = hashPassword; sysOperatorInfo.Salt = salt; sysOperatorRepository.Insert(sysOperatorInfo); sysOperatorInfo.SysOperatorRoles.ForEach(a => a.OperatorID = sysOperatorInfo.OperatorID); sysOperatorInfo.SysOperatorRoles.ForEach(a => sysOperatorRoleRepo.Insert(a)); return Request.CreateResponse(HttpStatusCode.OK, sysOperatorInfo); }, this)); }
public void BindUI(SysOperator coreModel) { if (OperatorID == 0) { LanguageID = 2052; NewPasswordEnabled = true; Status = true; } else { Status = coreModel.Status == GeneralStatus.Enabled; coreModel.SysOperatorRoles.ForEach(x => { var item = SysOperatorRoleItems.FirstOrDefault(i => i.ID == x.RoleID); if (item != null) { item.IsSelected = true; } }); } }
public ActionResult Index(SysOperator model) { ViewBag.Skin = sysSkinBll.Getlists(); if (ModelState.IsValid) { var entity = sysOperatorBll.GetModel(model.ID); entity.RealName = model.RealName; entity.Mobile = model.Mobile; entity.IdCard = model.IdCard; entity.Email = model.Email; entity.Weibo = model.Weibo; entity.Skin = model.Skin; entity.Province = model.Province; entity.Area = model.Area; entity.County = model.County; entity.Community = model.Community; entity.Address = model.Address; entity.AlipayOpenid = model.AlipayOpenid; entity.WechatOpenid = model.WechatOpenid; var result = sysOperatorBll.Edit(entity); if (result.flag == true) { TempData["returnMsgType"] = "success"; TempData["returnMsg"] = "编辑成功"; } else { TempData["returnMsgType"] = "error"; TempData["returnMsg"] = "编辑失败"; } return(RedirectToAction("Index", "SysOperator", new { area = "System" })); } else { return(View("Index", model)); } }
public int Edit(SysOperator model) { int result; var entity = GetModel(model.ID); try { if (entity != null) { entity.Email = model.Email; entity.Weibo = model.Weibo; entity.Address = model.Address; } db.Entry <SysOperator>(entity).State = System.Data.Entity.EntityState.Modified; result = db.SaveChanges(); } catch (Exception ex) { LogUtil.Exception("ExceptionLogger", ex); result = 0; } return(result); }
private RldModel.SysOperator ToModel(SysOperator operatorInfo) { var sysOperator = new RldModel.SysOperator(); sysOperator.OperatorID = operatorInfo.OperatorID; sysOperator.LoginName = operatorInfo.LoginName; sysOperator.Password = operatorInfo.Password; sysOperator.LanguageID = operatorInfo.LanguageID; sysOperator.Photo = operatorInfo.Photo; sysOperator.Status = (operatorInfo.Status == GeneralStatus.Enabled) ? RldModel.GeneralStatus.Enabled : RldModel.GeneralStatus.Disabled; sysOperator.UpdateUserID = operatorInfo.UpdateUserID; sysOperator.UpdateDate = operatorInfo.UpdateDate; sysOperator.CreateUserID = operatorInfo.CreateUserID; sysOperator.CreateDate = operatorInfo.CreateDate; sysOperator.SysOperatorRoles = operatorInfo.SysOperatorRoles.Select(x => new RldModel.SysOperatorRole() { SysOperatorRoleID = x.SysOperatorRoleID, OperatorID = x.OperatorID, RoleID = x.RoleID, }).ToList(); return(sysOperator); }
public int AlterStatus(SysOperator model, long status, long oprid, int type) { return(operatorDal.AlterStatus(model, status, oprid, type)); }
public int Add(SysOperator model) { return(sysOperatorDal.Add(model)); }
protected void Page_Load(object sender, EventArgs e) { try { string appName = Request.ApplicationPath; //string PORTALHOST = System.Configuration.ConfigurationManager.AppSettings["GXTHOST"]; string PORTALHOST = "http://www.cscec3b.com:8888/Portal"; if (!Page.IsPostBack && Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri.IndexOf(PORTALHOST) > -1) { string rawURL = Request.RawUrl; string userNameKey = "UserName".ToLower(); string userName = "";//用户名 string PortalMenuKey = "PortalMenuName".ToLower(); string PortalMenuName = ""; string tokenKey = "token"; string token = "";//令牌 //1:获取广迅通点击后的Url Dictionary <string, string> dicQueryStr = new Dictionary <string, string>(); string queryStr = ""; if (rawURL.IndexOf("?") > -1) { queryStr = rawURL.Substring(rawURL.IndexOf("?") + 1); string[] str = queryStr.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in str) { string[] KeyValue = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); dicQueryStr.Add(KeyValue[0].ToLower(), KeyValue[1]); } } if (dicQueryStr.Count > 0) { if (dicQueryStr.ContainsKey(userNameKey)) { userName = dicQueryStr[userNameKey].ToUpper(); } if (dicQueryStr.ContainsKey(PortalMenuKey)) { PortalMenuName = dicQueryStr[PortalMenuKey]; } if (dicQueryStr.ContainsKey(tokenKey)) { token = dicQueryStr[tokenKey]; } } //2:调用Webservice确认 //GXTSingleLoginService.DataSvc data = new GXTSingleLoginService.DataSvc(); //GXTSingleLoginService.ReturnData rData = data.GetAllData(token, "usr"); //登录系统 SysOperator loginUser = MLogin.TheLoginSrv.GetSysOperator(userName); if (loginUser == null) { Session["LoginError"] = "在项目管理中未获取到用户“" + userName + "”信息!"; Server.Transfer("~/LoginError.aspx"); return; } List <SysRole> userJobs = MLogin.GetOperOnRoles(loginUser.Id, DateTime.Now).OfType <SysRole>().ToList(); if (userJobs == null || userJobs.Count == 0) { Session["LoginError"] = "用户“" + userName + "”未配置岗位信息!"; Server.Transfer("~/LoginError.aspx"); return; } Application[token + "UserName"] = userName; Application[token + "PortalMenuName"] = PortalMenuName; txtSessionKeyHidden.Value = token; listGroupJob.Items.Clear(); foreach (SysRole group in userJobs) { ListItem li = new ListItem(); li.Text = group.RoleName; li.Value = group.Id; listGroupJob.Items.Add(li); } if (listGroupJob.Items.Count > 0) { listGroupJob.SelectedIndex = 0; } //listGroupJob.Height = (Unit)(listGroupJob.Items.Count * 20); //listGroupJob.Height = 20; listGroupJob.Height = (Unit)((listGroupJob.Items.Count > 20 ? 20 : listGroupJob.Items.Count) * 20); if (listGroupJob.Items.Count == 1)//如果只有一个岗位就直接登录,否则提供选择 { Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "document.getElementById('btnEnter').click();", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "$(function() {popForm();});", true); } } } catch (Exception exp) { MessageBox(VirtualMachine.Component.Util.ExceptionUtil.ExceptionMessage(exp)); } }
protected void Page_Load(object sender, EventArgs e) { try { string appName = Request.ApplicationPath; string PORTALHOST = System.Configuration.ConfigurationManager.AppSettings["PORTALHOST"]; string SSOHOST = System.Configuration.ConfigurationManager.AppSettings["SSOHOST"]; //门户菜单集成,点击门户菜单时请求两次,第一次传过来菜单,第二次传过来票证 if (!Page.IsPostBack && Request.RawUrl != null && Request.RawUrl.Equals(appName + "/Login.aspx", StringComparison.OrdinalIgnoreCase) == false) // && Request.RawUrl.IndexOf("ticket") > -1 //&& Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri.IndexOf(PORTALHOST) > -1 { #region 单点登录集成CS tbMain.Visible = false; //获取票证作为键存储菜单名称 string ticketKey = "ticket"; string ticket = string.Empty; string PortalMenuKey = "PortalMenuName".ToLower(); string PortalMenuName = string.Empty; string proInfoAuthKey = "proInfoAuth".ToLower(); string proInfoAuth = string.Empty; string rawURL = Request.RawUrl; Dictionary <string, string> dicQueryStr = new Dictionary <string, string>(); string queryStr = ""; if (rawURL.IndexOf("?") > -1) { queryStr = rawURL.Substring(rawURL.IndexOf("?") + 1); string[] str = queryStr.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in str) { string[] KeyValue = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); dicQueryStr.Add(KeyValue[0].ToLower(), KeyValue[1]); } } if (dicQueryStr.Count > 0) { if (dicQueryStr.ContainsKey(ticketKey)) { ticket = dicQueryStr[ticketKey]; } if (dicQueryStr.ContainsKey(PortalMenuKey)) { PortalMenuName = dicQueryStr[PortalMenuKey]; } if (dicQueryStr.ContainsKey(proInfoAuthKey)) { proInfoAuth = dicQueryStr[proInfoAuthKey]; if (!string.IsNullOrEmpty(PortalMenuName)) { Application[PortalMenuName + "proInfoAuth"] = proInfoAuth; } } } #region 票证校验和获取用户信息 string url = string.Empty;//选择岗位页面URL try { System.Net.ServicePointManager.CertificatePolicy = new MyPolicy(); string service = Request.Url.GetLeftPart(UriPartial.Path); service += "?" + PortalMenuKey + "=" + PortalMenuName; if (ticket == null || ticket.Length == 0) { string redir = PORTALHOST + "cas.login?" + "service=" + service; Response.Redirect(redir); return; } string validateurl = SSOHOST + "serviceValidate?" + "ticket=" + ticket + "&" + "service=" + service; StreamReader Reader = new StreamReader(new WebClient().OpenRead(validateurl)); string resp = Reader.ReadToEnd(); NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); XmlTextReader reader = new XmlTextReader(resp, XmlNodeType.Element, context); string netid = null; while (reader.Read()) { if (reader.IsStartElement()) { string tag = reader.LocalName; if (tag == "user") { netid = reader.ReadString(); } } } reader.Close(); if (netid == null) { Session["LoginError"] = "身份验证失败,未获取到登录用户信息!"; Server.Transfer("~/LoginError.aspx"); } else { //访问的菜单名不能为空 if (string.IsNullOrEmpty(PortalMenuName)) { Session["LoginError"] = "请在门户URL参数中指定一个要访问的菜单!"; Server.Transfer("~/LoginError.aspx"); return; } SysOperator loginUser = MLogin.TheLoginSrv.GetSysOperator(netid); if (loginUser == null) { Session["LoginError"] = "在项目管理中未获取到用户“" + netid + "”信息!"; Server.Transfer("~/LoginError.aspx"); return; } List <SysRole> userJobs = MLogin.GetOperOnRoles(loginUser.Id, DateTime.Now).OfType <SysRole>().ToList(); if (userJobs == null || userJobs.Count == 0) { Session["LoginError"] = "用户“" + netid + "”未配置岗位信息!"; Server.Transfer("~/LoginError.aspx"); return; } Application[ticket + "UserName"] = netid; Application[ticket + "URLParam"] = queryStr; Application[ticket + "proInfoAuth"] = Application[PortalMenuName + "proInfoAuth"]; txtSessionKeyHidden.Value = ticket;//回传后Request.UrlReferrer.AbsoluteUri的ticket丢失,在点击确定按钮时需要用到该键 listGroupJob.Items.Clear(); foreach (SysRole group in userJobs) { ListItem li = new ListItem(); li.Text = group.RoleName; li.Value = group.Id; listGroupJob.Items.Add(li); } if (listGroupJob.Items.Count > 0) { listGroupJob.SelectedIndex = 0; } listGroupJob.Height = (Unit)(listGroupJob.Items.Count * 20); } } catch (Exception ex) { Session["LoginError"] = VirtualMachine.Component.Util.ExceptionUtil.ExceptionMessage(ex); Server.Transfer("~/LoginError.aspx"); } #endregion if (listGroupJob.Items.Count == 1)//如果只有一个岗位就直接登录,否则提供选择 { Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "document.getElementById('btnEnter').click();", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "$(function() {popForm();});", true); } #endregion } else { #region 单点登录集成BS //门户菜单集成,点击门户菜单时请求两次,第一次传过来菜单,第二次传过来票证 if (!Page.IsPostBack && Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri.IndexOf(PORTALHOST) > -1) { tbMain.Visible = false; //获取票证作为键存储菜单名称 string ticketKey = "ticket"; string ticket = string.Empty; string PortalMenuKey = "PortalMenuName".ToLower(); string PortalMenuName = string.Empty; string proInfoAuthKey = "proInfoAuth".ToLower(); string proInfoAuth = string.Empty; string rawURL = Request.RawUrl; Dictionary <string, string> dicQueryStr = new Dictionary <string, string>(); string queryStr = ""; if (rawURL.IndexOf("?") > -1) { queryStr = rawURL.Substring(rawURL.IndexOf("?") + 1); string[] str = queryStr.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in str) { string[] KeyValue = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); dicQueryStr.Add(KeyValue[0].ToLower(), KeyValue[1]); } } if (dicQueryStr.Count > 0) { if (dicQueryStr.ContainsKey(ticketKey)) { ticket = dicQueryStr[ticketKey]; } if (dicQueryStr.ContainsKey(PortalMenuKey)) { PortalMenuName = dicQueryStr[PortalMenuKey]; } if (dicQueryStr.ContainsKey(proInfoAuthKey)) { proInfoAuth = dicQueryStr[proInfoAuthKey]; } } if (string.IsNullOrEmpty(ticket)) { //string sessionKey = string.Empty;//门户地址里面的票证,作为唯一键 string refURL = Request.UrlReferrer.AbsoluteUri; queryStr = ""; dicQueryStr.Clear(); if (refURL.IndexOf("?") > -1) { queryStr = refURL.Substring(refURL.IndexOf("?") + 1); string[] str = queryStr.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in str) { string[] KeyValue = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); dicQueryStr.Add(KeyValue[0].ToLower(), KeyValue[1]); } } if (dicQueryStr.Count > 0) { if (dicQueryStr.ContainsKey(ticketKey)) { ticket = dicQueryStr[ticketKey]; } if (dicQueryStr.ContainsKey(PortalMenuKey)) { PortalMenuName = dicQueryStr[PortalMenuKey]; } if (dicQueryStr.ContainsKey(proInfoAuthKey)) { proInfoAuth = dicQueryStr[proInfoAuthKey]; } } } #region 票证校验和获取用户信息 string url = string.Empty;//选择岗位页面URL try { System.Net.ServicePointManager.CertificatePolicy = new MyPolicy(); string service = Request.Url.GetLeftPart(UriPartial.Path); if (ticket == null || ticket.Length == 0) { string redir = PORTALHOST + "cas.login?" + "service=" + service; Response.Redirect(redir); return; } string validateurl = SSOHOST + "serviceValidate?" + "ticket=" + ticket + "&" + "service=" + service; StreamReader Reader = new StreamReader(new WebClient().OpenRead(validateurl)); string resp = Reader.ReadToEnd(); NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); XmlTextReader reader = new XmlTextReader(resp, XmlNodeType.Element, context); string netid = null; while (reader.Read()) { if (reader.IsStartElement()) { string tag = reader.LocalName; if (tag == "user") { netid = reader.ReadString(); } } } reader.Close(); if (netid == null) { Session["LoginError"] = "身份验证失败,未获取到登录用户信息!"; Server.Transfer("~/LoginError.aspx"); } else { //访问的菜单名不能为空 if (string.IsNullOrEmpty(PortalMenuName)) { Session["LoginError"] = "请在门户URL参数中指定一个要访问的菜单!"; Server.Transfer("~/LoginError.aspx"); return; } SysOperator loginUser = MLogin.TheLoginSrv.GetSysOperator(netid); if (loginUser == null) { Session["LoginError"] = "在项目管理中未获取到用户“" + netid + "”信息!"; Server.Transfer("~/LoginError.aspx"); return; } List <SysRole> userJobs = MLogin.GetOperOnRoles(theSysOperator.Id, DateTime.Now).OfType <SysRole>().ToList(); if (userJobs == null || userJobs.Count == 0) { Session["LoginError"] = "用户“" + netid + "”未配置岗位信息!"; Server.Transfer("~/LoginError.aspx"); return; } //string sessionKey = string.Empty;//门户地址里面的票证,作为唯一键 //string refURL = Request.UrlReferrer.AbsoluteUri; //dicQueryStr.Clear(); //if (refURL.IndexOf("?") > -1) //{ // string queryStr = refURL.Substring(refURL.IndexOf("?") + 1); // string[] str = queryStr.Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries); // foreach (string s in str) // { // string[] KeyValue = s.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); // dicQueryStr.Add(KeyValue[0].ToLower(), KeyValue[1]); // } //} //if (dicQueryStr.Count > 0) //{ // if (dicQueryStr.ContainsKey(ticketKey)) // sessionKey = dicQueryStr[ticketKey]; //} Application[ticket + "UserName"] = netid; Application[ticket + "URLParam"] = queryStr; txtSessionKeyHidden.Value = ticket;//回传后Request.UrlReferrer.AbsoluteUri的ticket丢失,在点击确定按钮时需要用到该键 listGroupJob.Items.Clear(); foreach (SysRole group in userJobs) { ListItem li = new ListItem(); li.Text = group.RoleName; li.Value = group.Id; listGroupJob.Items.Add(li); } if (listGroupJob.Items.Count > 0) { listGroupJob.SelectedIndex = 0; } listGroupJob.Height = (Unit)(listGroupJob.Items.Count * 20); } } catch (Exception ex) { string message = ex.Message; System.Exception ex1 = ex.InnerException; while (ex1 != null) { message += ex1.Message; ex1 = ex1.InnerException; } Session["LoginError"] = message; Server.Transfer("~/LoginError.aspx"); } #endregion if (listGroupJob.Items.Count == 1)//如果只有一个岗位就直接登录,否则提供选择 { Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "document.getElementById('btnEnter').click();", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), ClientID, "$(function() {popForm();});", true); } } //else if (!IsPostBack && // Request.RawUrl != null && Request.RawUrl.Equals(appName + "/Login.aspx", StringComparison.OrdinalIgnoreCase) == false // && Request.RawUrl.ToLower().IndexOf("ticket=") == -1)//超时跳到门户登录 //{ // Response.Redirect("~/LoginPortal.aspx"); //} #endregion 单点登录集成广迅通 } } catch (Exception exp) { MessageBox(VirtualMachine.Component.Util.ExceptionUtil.ExceptionMessage(exp)); } }