public List <Link> GetLink() { BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); string condition = string.Format(@"[UserType]=1 and UserCode ='{0}' ", U.userCode); DataSet dataSet = UserManager.GetUserRoleInfoList(condition); string RoleCode = ""; for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { RoleCode += "'" + dataSet.Tables[0].Rows[i]["RoleCode"].ToString() + "',"; } if (RoleCode != "") { RoleCode = RoleCode.Substring(0, RoleCode.Length - 1); StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT DISTINCT "); strSql.Append("[Code],[oaName],[link],[sort],[img],[State]"); strSql.Append(" FROM ViewRoleLink where "); strSql.Append(string.Format("RoleCode In ({0}) order by sort asc", RoleCode)); using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities()) { DataSet Dt = SqlQueryForDataTatable1(Db.Database, strSql.ToString()); List <Link> result1 = List.ToList <Link>(Dt, 0); return(result1.ToList()); } } else { return(null); } }
public ActionResult ToLogin() { //登录接口加载 EastEliteICMSWS.EastEliteICMSWSSoapClient Service = new EastEliteICMSWS.EastEliteICMSWSSoapClient(); //登录错误信息 string err = ""; StringBuilder script = new StringBuilder(); BLL.Cookie.TeUser U = new BLL.Cookie.TeUser(); //加载数据 string UserCode = Request.Form["inputUserCode"].ToString(); string Password = Request.Form["inputPassword"].ToString(); byte userType = byte.Parse(Request.Form["inputUserType"].ToString()); //验证 if (string.IsNullOrEmpty(UserCode)) { err = "姓名或代码不能为空!"; script.Append(String.Format("<script>alert('{0}');location.href='{1}'</script>", err, Url.Action("Login"))); return(Content(script.ToString(), "Text/html")); } if (string.IsNullOrEmpty(Password)) { err = "密码不能为空!"; script.Append(String.Format("<script>alert('{0}');location.href='{1}'</script>", err, Url.Action("Login"))); return(Content(script.ToString(), "Text/html")); } //Password = BLL.MD5.Lower32(Password);//用户密码加密 string result = Service.CheckUserLoginDeviceItem(UserCode, userType, Password); //访问接口验证登录 ///登录失败 if (result.IndexOf("FAIL") > -1) { int Start = result.IndexOf("FAIL") + 9; int End = result.IndexOf("!") + 1; err = result.Substring(Start, End - Start); script.Append(String.Format("<script>alert('{0}');location.href='{1}'</script>", err, Url.Action("Login"))); return(Content(script.ToString(), "Text/html")); } else if (result.IndexOf("SUCC") > -1) //登录成功 { U = GetCookie.GetUserNameForSerVice(result); U.userName = U.userName; GetCookie.SetCookie("Dfbg_OAUser", Newtonsoft.Json.JsonConvert.SerializeObject(U), 30); FormsAuthentication.SetAuthCookie(UserCode, false); BLL.Log.UserLog.AddUserLog("登录成功", U.userName + " 成功登录统一管理平台系统 "); return(Redirect("~/Home/Index")); } else { //非法登录 script.Append(String.Format("<script>alert('{0}');location.href='{1}'</script>", "非法登录", Url.Action("Login"))); return(Content(script.ToString(), "Text/html")); } }
// GET: /UserRoleInfo/ public ActionResult UserRoleSeachList() { BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); ViewBag.Agencylists = AgencyManager.GetAgencyNameList(U.rootCode, "( [SubAgencyTypeID]=1 OR [SubAgencyTypeID]=2 OR [SubAgencyTypeID]=9 )"); ViewBag.Rolelists = UserManager.GetRoleInfoNameList(); return(View()); }
public ActionResult Index() { BLL.Role.UserRoleInfo Role = new BLL.Role.UserRoleInfo(); ViewBag.IsAdmin = Role.IsAdmin(); BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); U.userName = U.userName; return(View(U)); }
public ActionResult Edit(BLL.SMSModel.RoleInfo model) { try { BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); RoleInfo item = new RoleInfo(); ///系统验证 if (string.IsNullOrEmpty(Request.Form["Link"])) { return(Content(@"<script language='javascript'> alert('请选择系统权限!');location.href='" + Url.Action("Edit", new { Code = model.Code }) + "'; </script>", "Text/html")); } if (UserManager.IsContainRoleInfoName(model.Name) && model.Name != TempData["Name"].ToString()) { return(Content(@"<script language='javascript'> alert('该角色已经存在,请不要重复!');location.href='" + Url.Action("Edit", new { Code = model.Code }) + "'; </script>", "Text/html")); } item.code = model.Code; item.handledID = U.userCode; item.handledDate = DateTime.Now; item.name = model.Name; item.note = model.Note == null ? "" : model.Note; UserManager.UpdateRoleInfoItem(item); Role.delOaRoleByRoleCode(model.Code); string LinkCodes = Request.Form["Link"].ToString(); //添加数据 using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities()) { if (LinkCodes.IndexOf(",") > -1) { string[] LinkCode = LinkCodes.Split(','); for (int i = 0; i < LinkCode.Length; i++) { BLL.OaRole R = new BLL.OaRole(); R.LinkCode = LinkCode[i].ToString(); R.RoleCode = model.Code.ToString(); Db.OaRole.Add(R); } } else { BLL.OaRole R = new BLL.OaRole(); R.LinkCode = LinkCodes.ToString(); R.RoleCode = model.Code.ToString(); Db.OaRole.Add(R); } Db.SaveChanges(); } BLL.Log.UserLog.AddUserLog("添加修改成功", GetCookie.GetUserCookie().userName + " 成功修改 " + model.Name + " 角色 "); } catch (Exception ex) { BLL.Log.UserLog.AddUserLog("修改角色失败", ex.Message); throw; } return(View("RoleList")); }
/// <summary> ///获取人员分页 /// </summary> /// <param name="pageIndex"></param> /// <param name="strWhere"></param> /// <returns></returns> public ActionResult GetUserList(int pageIndex, string strWhere) { if (SqlToNull.CheckBadWord(strWhere)) { strWhere = SqlToNull.Filter(strWhere); } string SubAgencyCode = "", UserName = ""; if (strWhere != "") { string[] str = strWhere.Split('★'); if (strWhere.IndexOf('★') > -1) { SubAgencyCode = str[0].ToString(); UserName = str[1].ToString(); } else { SubAgencyCode = str[0].ToString(); } } BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); string condition = string.Format(@"[UserType]=1 AND (SELECT SUBSTRING(AgencyCode,1,10) FROM dbo.StaffInfo WHERE Code=[UserCode])='{0}'", U.rootCode); if (!string.IsNullOrEmpty(SubAgencyCode)) { if (string.IsNullOrEmpty(condition)) { condition = string.Format(@"[AgencyName] LIKE N'{0}'", SubAgencyCode); } else { condition += (" AND " + string.Format(@"[AgencyName] LIKE N'{0}'", SubAgencyCode)); } } if (!string.IsNullOrEmpty(UserName)) { if (string.IsNullOrEmpty(condition)) { condition = string.Format(@"[UserName] like '%{0}%'", UserName); } else { condition += (" AND " + string.Format(@"[UserName] like '%{0}%'", UserName)); } } int pageSize = 10; //每页条数 int Count = 0; //总条数 List <BLL.SMSModel.UserInfoList> model = List.GetUserList(pageIndex, pageSize, condition, ref Count); int pageCount = (Count + pageSize - 1) / pageSize; //页码 return(Json(new { model, pageCount, pageIndex }, JsonRequestBehavior.AllowGet)); }
public ActionResult Redir(int Code) { //Cookie 验证 BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); //获取数据 using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities()) { var link = from b in Db.Link where b.Code == Code && b.State == 1 orderby b.sort select b; //假数据模式 //BLL.StringDb Db2 = new BLL.StringDb(); //List<BLL.StringDb.Link> linkDb = Db2.getLink(); //var link = from b in linkDb // where b.Code == Code // select b; foreach (var item in link) { string Url = ""; switch (Code) { case 12: Url = digital.getUrl(item.link, U.userCode, U.userType); return(Redirect("Http://" + Url)); case 2: Url = digital.GetDianUrl(item.link, U.userCode, U.userType); return(Redirect("Http://" + Url)); case 5: //Url = digital.GuangBo("user1", "111111"); return(Redirect("/VidoLogin/Login")); //return Redirect("Http://" + Url); default: break; } //其余直接跳转Url if (item.Code == Code) { return(Redirect("Http://" + item.link)); } } } return(Redirect("~/Home/Index")); }
public bool IsAdmin() { UserRoleInfo item = new UserRoleInfo(); BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); bool A = false; DataSet dt = UserManager.GetUserRoleInfoList("UserCode ='" + U.userCode + "'"); for (int i = 0; i < dt.Tables[0].Rows.Count; i++) { if (dt.Tables[0].Rows[i]["RoleCode"].ToString() == "1001") { A = true; } } return(A); }
public void AddRoleList(string UserCode, string RoleCode, byte UserType, string UserName) { try { BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); //string UserCodeStr = UserCode + "' and SUBSTRING([RoleCode],1,1)='2"; UserManager.DeleteUserRoleInfoItem(UserCode, UserType); if (RoleCode.IndexOf(",") > -1) { string[] RoleCodes = RoleCode.Split(','); for (int i = 0; i < RoleCodes.Length; i++) { EastElite.SMS.Business.UserRoleInfo User = new EastElite.SMS.Business.UserRoleInfo(); User.userCode = UserCode; User.roleCode = RoleCodes[i]; User.userType = UserType; User.note = ""; User.handledID = U.userCode; User.handledDate = DateTime.Now; string RoleInfoName = UserManager.GetRoleInfoName(RoleCodes[i]); UserManager.InsertUserRoleInfoItem(User); BLL.Log.UserLog.AddUserLog("授权成功", GetCookie.GetUserCookie().userName + " 成功授权给 " + UserName + " " + RoleInfoName + "角色 "); } } else { EastElite.SMS.Business.UserRoleInfo User = new EastElite.SMS.Business.UserRoleInfo(); User.userCode = UserCode; User.roleCode = RoleCode; User.userType = UserType; User.note = ""; User.handledID = U.userCode; User.handledDate = DateTime.Now; string RoleInfoName = UserManager.GetRoleInfoName(RoleCode); UserManager.InsertUserRoleInfoItem(User); BLL.Log.UserLog.AddUserLog("授权成功", GetCookie.GetUserCookie().userName + " 成功授权给 " + UserName + " " + RoleInfoName + "角色 "); } } catch (Exception ex) { BLL.Log.UserLog.AddUserLog("授权失败", ex.Message); throw; } }
/// <summary> /// 获取当前人员的角色 /// </summary> /// <param name="Code"></param> /// <returns></returns> public ActionResult GetRole(string Code) { if (SqlToNull.CheckBadWord(Code)) { Code = SqlToNull.Filter(Code); } int Count = 0;//总条数 BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); string condition = string.Format(@"[UserType]=1 AND (SELECT SUBSTRING(AgencyCode,1,10) FROM dbo.StaffInfo WHERE Code=[UserCode])='{0}' and UserCode ='{1}' ", U.rootCode, Code); List <BLL.SMSModel.RoleInfo> model = List.GetPageList(1, 1000, "", ref Count); List <BLL.SMSModel.UserRoleInfoList> UserRole = List.GetUserRoleList(1, 1000, condition, ref Count); string UserRoleStr = ""; for (int i = 0; i < UserRole.Count; i++) { UserRoleStr += UserRole[i].RoleCode + ","; } UserRoleStr = UserRoleStr.Length > 0 ? UserRoleStr.Substring(0, UserRoleStr.Length - 1) : ""; return(Json(new { model, UserRoleStr }, JsonRequestBehavior.AllowGet)); }
public ActionResult Add(BLL.SMSModel.RoleInfo model) { try { string partCode2, newCode; BLL.Cookie.TeUser U = GetCookie.GetUserCookie(); ///系统验证 string LinkCodes = Request.Form["Link"]; if (string.IsNullOrEmpty(LinkCodes)) { return(Content(@"<script language='javascript'> alert('请选择系统权限!');location.href='" + Url.Action("Add") + "'; </script>", "Text/html")); } ///系统验证 if (UserManager.IsContainRoleInfoName(model.Name)) { return(Content(@"<script language='javascript'> alert('该角色已经存在,请不要重复添加!');location.href='" + Url.Action("Add") + "'; </script>", "Text/html")); } ///Role加载 RoleInfo item = new RoleInfo(); int count = UserManager.GetRoleInfoCount("2");//自定义 do { count++; if (count < 10) { partCode2 = "00" + count.ToString(); } else if (count < 100) { partCode2 = "0" + count.ToString(); } else { partCode2 = count.ToString().Substring(count.ToString().Length - 3, 3); } newCode = "2" + partCode2; }while(UserManager.IsContainRoleInfoCode(newCode)); item.code = newCode; item.handledID = U.userCode; item.handledDate = DateTime.Now; item.name = model.Name; item.note = model.Note == null ? "" : model.Note; //添加数据 UserManager.InsertRoleInfoItem(item); //添加数据 if (LinkCodes.ToString().IndexOf(",") > -1) { string[] LinkCode = LinkCodes.ToString().Split(','); for (int i = 0; i < LinkCode.Length; i++) { using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities()) { BLL.OaRole R = new BLL.OaRole(); R.LinkCode = LinkCode[i].ToString(); R.RoleCode = newCode.ToString(); Db.OaRole.Add(R); Db.SaveChanges(); } } } else { using (BLL.NETDISKDBEntities Db = new BLL.NETDISKDBEntities()) { BLL.OaRole R = new BLL.OaRole(); R.LinkCode = LinkCodes.ToString(); R.RoleCode = newCode.ToString(); Db.OaRole.Add(R); Db.SaveChanges(); } } BLL.Log.UserLog.AddUserLog("添加角色成功", GetCookie.GetUserCookie().userName + " 成功创建 " + model.Name + " 角色 "); } catch (Exception ex) { BLL.Log.UserLog.AddUserLog("创建角色失败", ex.Message); throw; } return(View("RoleList")); }
// GET: /Manage/ public ActionResult Index() { BLL.Cookie.TeUser U = new BLL.Cookie.TeUser(); U = GetCookie.GetUserCookie(); return(View(U)); }