string id = String.Empty; // 对象id protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); // 用户编辑操作 id = RequestData.Get <string>("id"); SysAuth ent = null; if (IsAsyncRequest) { switch (RequestAction) { case RequestActionEnum.Query: case RequestActionEnum.Default: break; case RequestActionEnum.Create: ent = this.GetPostedData <SysAuth>(); ent.CreateAndFlush(); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysAuth>(); ent.DeleteAndFlush(); break; default: if (RequestActionString == "createsub") { ent = this.GetPostedData <SysAuth>(); ent.CreateAsSub(id); } break; } } else { if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = SysAuth.Find(id); } } } DataEnum de = SysAuthTypeRule.GetAuthTypeEnum(); this.PageState.Add("AuthTypeEnum", de); this.SetFormData(ent); }
protected void Page_Load(object sender, EventArgs e) { SearchCriterion.AutoOrder = false; SearchCriterion.SetOrder(SysUser.Prop_WorkNo); string dName = SearchCriterion.GetSearchValue <string>("Name"); if (dName != null && dName.Trim() != "") { string where = "select * from SysUser where " + GetPinyinWhereString("Name", dName); this.PageState.Add("UsrList", DataHelper.QueryDictList(where)); } else { ents = SysUserRule.FindAll(SearchCriterion); this.PageState.Add("UsrList", ents); } if (this.IsAsyncRequest) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { string id = (RequestData.ContainsKey("ID") ? RequestData["ID"].ToString() : String.Empty); string ttype = RequestData["Type"].ToString().ToLower(); if (RequestData.ContainsKey("Type")) { if (ttype == "atype") // 1为入口权限 { SysAuth[] auths = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ?", id); this.PageState.Add("DtList", auths); } } } break; default: break; } } else { SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); this.PageState.Add("DtList", authTypeList); } }
protected void Page_Load(object sender, EventArgs e) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { string id = (RequestData.ContainsKey("ID") ? RequestData["ID"].ToString() : String.Empty); string ttype = RequestData["Type"].ToString().ToLower(); if (RequestData.ContainsKey("Type")) { SysAuth[] ents = null; if (ttype == "atype") // 1为入口权限 { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ? AND ent.ParentID is null", id); } else { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.ParentID = ?", id); } this.PageState.Add("DtList", ents.OrderBy(v => v.SortIndex).ThenBy(v => v.CreateDate)); } } else if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } break; } if (!IsAsyncRequest) { SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); this.PageState.Add("DtList", authTypeList); } }
string type = String.Empty; // 查询类型 protected void Page_Load(object sender, EventArgs e) { id = (RequestData.ContainsKey("id") ? RequestData["id"].ToString() : String.Empty); type = (RequestData.ContainsKey("type") ? RequestData["type"].ToString() : String.Empty).ToLower(); if (this.IsAsyncRequest) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren" || RequestActionString == "querydescendant") { SysModule[] ents = null; if (RequestActionString == "querychildren") { string atype = String.Empty; ents = SysModule.FindAll("FROM SysModule as ent WHERE ent.ParentID = ?", id); } else if (RequestActionString == "querydescendant") { string atype = String.Empty; ents = UserContext.AccessibleModules.Where(tent => tent.Path != null && tent.Path.IndexOf(id) > 0).ToArray(); } string jsonString = JsonHelper.GetJsonString(this.ToExtTreeCollection(ents.OrderBy(v => v.SortIndex).ThenBy(v => v.CreateDate), null)); Response.Write(jsonString); Response.End(); } break; } } else { SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); if (this.Request.QueryString["Role"] != null && this.Request.QueryString["Role"] == "User") { authTypeList = SysAuthType.FindAllByProperties(SysAuthType.Prop_AuthTypeID, 1); } IEnumerable <SysModule> ents = UserContext.AccessibleModules.Where(tent => tent.ApplicationID == id && tent.ParentID == null) .OrderBy(tent => tent.SortIndex); this.PageState.Add("DtList", ents.ToList()); //this.PageState.Add("DtList", authTypeList); } // 获取权限列表 /*if (RequestAction != RequestActionEnum.Custom) * { * this.PageState.Add("EntityID", id); * * IEnumerable<string> authIDs = null; * using (new Castle.ActiveRecord.SessionScope()) * { * if (type == "user" && !String.IsNullOrEmpty(id)) * { * SysUser user = SysUser.Find(id); * if (this.RequestData.Get<string>("Deny") != null && this.RequestData.Get<string>("Deny").Trim() == "Y") * { * authIDs = (user.AuthNo).Select((ent) => { return ent.AuthID; }); * } * else * authIDs = (user.Auth).Select((ent) => { return ent.AuthID; }); * } * else if (type == "group" && !String.IsNullOrEmpty(id)) * { * SysGroup group = SysGroup.Find(id); * authIDs = (group.Auth).Select((ent) => { return ent.AuthID; }); * } * else if (type == "role" && !String.IsNullOrEmpty(id)) * { * SysRole role = SysRole.Find(id); * authIDs = (role.Auth).Select((ent) => { return ent.AuthID; }); * } * * this.PageState.Add("AtList", new List<string>(authIDs)); * } * }*/ }
string type = String.Empty; // 查询类型 protected void Page_Load(object sender, EventArgs e) { id = (RequestData.ContainsKey("id") ? RequestData["id"].ToString() : String.Empty); type = (RequestData.ContainsKey("type") ? RequestData["type"].ToString() : String.Empty).ToLower(); if (this.IsAsyncRequest) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren" || RequestActionString == "querydescendant") { SysAuth[] ents = null; if (RequestActionString == "querychildren") { string atype = String.Empty; if (type == "atype") { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ? AND ent.ParentID IS NULL", id); } else { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.ParentID = ?", id); } } else if (RequestActionString == "querydescendant") { string atype = String.Empty; if (type == "atype") { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ?", id); } else { ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Path LIKE %?%", id); } } string jsonString = JsonHelper.GetJsonString(this.ToExtTreeCollection(ents.OrderBy(v => v.SortIndex).ThenBy(v => v.CreateDate), null)); Response.Write(jsonString); Response.End(); } else if (RequestActionString == "savechanges") { ICollection authAdded = RequestData["added"] as ICollection; ICollection authRemoved = RequestData["removed"] as ICollection; if (type == "user" && !String.IsNullOrEmpty(id)) { SysAuthRule.GrantAuthToUser(authAdded, id); SysAuthRule.RevokeAuthFromUser(authRemoved, id); } else if (type == "group" && !String.IsNullOrEmpty(id)) { SysAuthRule.GrantAuthToGroup(authAdded, id); SysAuthRule.RevokeAuthFromGroup(authRemoved, id); } else if (type == "role" && !String.IsNullOrEmpty(id)) { SysAuthRule.GrantAuthToRole(authAdded, id); SysAuthRule.RevokeAuthFromRole(authRemoved, id); } } break; } } else { SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); this.PageState.Add("DtList", authTypeList); } // 获取权限列表 if (RequestAction != RequestActionEnum.Custom) { this.PageState.Add("EntityID", id); IEnumerable <string> authIDs = null; using (new Castle.ActiveRecord.SessionScope()) { if (type == "user" && !String.IsNullOrEmpty(id)) { SysUser user = SysUser.Find(id); authIDs = (user.Auth).Select((ent) => { return(ent.AuthID); }); } else if (type == "group" && !String.IsNullOrEmpty(id)) { SysGroup group = SysGroup.Find(id); authIDs = (group.Auth).Select((ent) => { return(ent.AuthID); }); } else if (type == "role" && !String.IsNullOrEmpty(id)) { SysRole role = SysRole.Find(id); authIDs = (role.Auth).Select((ent) => { return(ent.AuthID); }); } this.PageState.Add("AtList", new List <string>(authIDs)); } } }
string type = String.Empty; // 查询类型 protected void Page_Load(object sender, EventArgs e) { id = (RequestData.ContainsKey("id") ? RequestData["id"].ToString() : UserInfo.UserID); type = (RequestData.ContainsKey("type") ? RequestData["type"].ToString() : String.Empty).ToLower(); if (this.IsAsyncRequest) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querydescendant") { SysAuth[] ents = null; string atype = String.Empty; //ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ?", id); SysUser user = SysUser.Find(this.UserInfo.UserID); ents = this.UserContext.Auths.OrderBy(ens => ens.SortIndex).ToArray(); //SysAuth.FindAll(Expression.Sql("AuthID in (select AuthID from SysUserPermission where UserID ='" + this.UserInfo.UserID + "')")); //user.Auth.ToArray(); string jsonString = JsonHelper.GetJsonString(this.ToExtTreeCollection(ents.OrderBy(v => v.SortIndex).ThenBy(v => v.CreateDate), null)); Response.Write(jsonString); Response.End(); } else if (RequestActionString == "savechanges") { ICollection authAdded = RequestData["added"] as ICollection; ICollection authRemoved = RequestData["removed"] as ICollection; if (type == "user" && !String.IsNullOrEmpty(id)) { SysAuth[] tAuths = SysAuthRule.GetAuthByIDs(authAdded).ToArray(); foreach (SysAuth auth in tAuths) { MyShortCut cut = new MyShortCut(); cut.CreateId = this.UserInfo.UserID; cut.CreateName = this.UserInfo.Name; cut.CreateTime = DateTime.Now; cut.ModuleUrl = SysModule.Find(auth.ModuleID).Url; cut.AuthId = auth.AuthID; cut.AuthName = auth.Name; cut.IconFileName = "/images/shared/read.gif"; cut.Save(); } if (authRemoved.Count > 0) { ICollection myAuthIDs = null; if (authRemoved is JArray) { JArray arrAuths = authRemoved as JArray; myAuthIDs = new List <string>(arrAuths.Values <string>()); } else { myAuthIDs = authRemoved; } foreach (string s in myAuthIDs) { DataHelper.ExecSql("delete from MyShortCut where AuthId like '%" + s + "%' and CreateId='" + this.UserInfo.UserID + "'", DataHelper.GetCurrentDbConnection(typeof(MyShortCut))); } } //SysAuthRule.GrantAuthToUser(authAdded, id); //SysAuthRule.RevokeAuthFromUser(authRemoved, id); } /*else if (type == "group" && !String.IsNullOrEmpty(id)) * { * SysAuthRule.GrantAuthToGroup(authAdded, id); * SysAuthRule.RevokeAuthFromGroup(authRemoved, id); * } * else if (type == "role" && !String.IsNullOrEmpty(id)) * { * SysAuthRule.GrantAuthToRole(authAdded, id); * SysAuthRule.RevokeAuthFromRole(authRemoved, id); * }*/ } break; } } else { SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); if (this.Request.QueryString["Role"] != null && this.Request.QueryString["Role"] == "User") { authTypeList = SysAuthType.FindAllByProperties(SysAuthType.Prop_AuthTypeID, 1); } this.PageState.Add("DtList", authTypeList); } // 获取权限列表 if (RequestAction != RequestActionEnum.Custom) { this.PageState.Add("EntityID", id); IEnumerable <string> authIDs = null; IList <MyShortCut> mscEnts = MyShortCut.FindAllByProperty(MyShortCut.Prop_CreateId, UserInfo.UserID); authIDs = mscEnts.Select(s => s.AuthId); this.PageState.Add("AtList", new List <string>(authIDs)); //using (new Castle.ActiveRecord.SessionScope()) //{ // if (type == "user" && !String.IsNullOrEmpty(id)) // { // SysUser user = SysUser.Find(id); // if (this.RequestData.Get<string>("Deny") != null && this.RequestData.Get<string>("Deny").Trim() == "Y") // { // authIDs = (user.AuthNo).Select((ent) => { return ent.AuthID; }); // } // else // authIDs = (user.Auth).Select((ent) => { return ent.AuthID; }); // } // else if (type == "group" && !String.IsNullOrEmpty(id)) // { // SysGroup group = SysGroup.Find(id); // authIDs = (group.Auth).Select((ent) => { return ent.AuthID; }); // } // else if (type == "role" && !String.IsNullOrEmpty(id)) // { // SysRole role = SysRole.Find(id); // authIDs = (role.Auth).Select((ent) => { return ent.AuthID; }); // } // this.PageState.Add("AtList", new List<string>(authIDs)); //} } }
protected void Page_Load(object sender, EventArgs e) { //防止多次添加 if (!UserContext.ExtData.ContainsKey("CompanyId")) { //添加公司Id UserContext.ExtData.Add("CompanyId", Session["CompanyId"] + ""); UserContext.ExtData.Add("DeptId", Session["DeptId"] + ""); //公司 SysGroup group = SysGroup.TryFind(Session["CompanyId"] + ""); if (group != null) { UserContext.ExtData.Add("CompanyName", group.Name); } else { UserContext.ExtData.Add("CompanyName", ""); } //部门 group = SysGroup.TryFind(Session["DeptId"] + ""); if (group != null) { UserContext.ExtData.Add("DeptName", group.Name); } else { UserContext.ExtData.Add("DeptName", ""); } } applicationId = RequestData.Get <string>("ApplicationId"); applicationName = Server.UrlDecode(RequestData.Get <string>("Name")); treeContainer.InnerHtml += "<script type='text/javascript'>"; treeContainer.InnerHtml += " d = new dTree('d');"; treeContainer.InnerHtml += "d.add('44b87eec-c353-4e98-82aa-4483a3ed86c9', -1, '招聘系统');"; SysAuthType[] authTypeList = SysAuthTypeRule.FindAll(); if (this.Request.QueryString["Role"] != null && this.Request.QueryString["Role"] == "User") { authTypeList = SysAuthType.FindAllByProperties(SysAuthType.Prop_AuthTypeID, 1);//&& tent.ParentID == null } IList <SysModule> ents = Aim.Portal.PortalService.CurrentUserContext.AccessibleModules.Where(tent => tent.ApplicationID == "f35cb450-cb38-4741-b8d7-9f726094b7ef").ToList(); if (UserContext.ExtData["CompanyId"] != null) { IEnumerable <string> mids = ents.Select(en => en.ModuleID); if (UserContext.ExtData["CompanyId"] + "" == "") { ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true); return; } SysGroup tGroup = SysGroup.Find(UserContext.ExtData["CompanyId"].ToString()); string[] groupIDs = (tGroup.Path + "." + tGroup.GroupID).Split('.'); ICriterion hqlCriterion = Expression.In("GroupID", groupIDs); hqlCriterion = SearchHelper.UnionCriterions(hqlCriterion, Expression.Sql("Path like '%" + tGroup.GroupID + "%' and GroupID in (Select GroupID from SysUserGroup where UserID='" + this.UserInfo.UserID + "' or GroupID='" + Session["DeptId"] + "')")); SysGroup[] groups = SysGroup.FindAll(hqlCriterion); using (new SessionScope()) { SysUser user = SysUser.Find(this.UserInfo.UserID); SysGroup[] grps = user.AllGroup.Where(en => en.Path != null && en.Path.IndexOf(tGroup.GroupID) >= 0 || en.GroupID == tGroup.GroupID).ToArray(); foreach (SysGroup group in grps)//groups) { SysGroup groupS = SysGroup.Find(group.ID); foreach (SysAuth tAuth in groupS.Auth) { if (tAuth.ModuleID != null && !mids.Contains(tAuth.ModuleID)) { ents.Add(SysModule.Find(tAuth.ModuleID)); } } } } } ents = ents.OrderBy(ens => ens.SortIndex).ToList(); foreach (SysModule smEnt in ents) { if (!string.IsNullOrEmpty(smEnt.ParentID)) { treeContainer.InnerHtml += "d.add('" + smEnt.ModuleID + "', '" + smEnt.ParentID + "', '" + smEnt.Name + "','" + smEnt.Url + "', '', 'mainShow');"; } else { treeContainer.InnerHtml += "d.add('" + smEnt.ModuleID + "', 'f35cb450-cb38-4741-b8d7-9f726094b7ef', '" + smEnt.Name + "','" + smEnt.Url + "', '', 'mainShow');"; } } treeContainer.InnerHtml += "document.write(d);"; treeContainer.InnerHtml += "$('.dtree > .dTreeNode:first-child').css({ display: 'none' });"; treeContainer.InnerHtml += "</script>"; }