protected void Page_Load(object sender, EventArgs e) { cid = RequestData.Get <string>("cid", String.Empty); type = RequestData.Get <string>("type", String.Empty).ToLower(); ctype = RequestData.Get <string>("ctype", "role").ToLower(); if (RequestActionString == "getData") { string filedVal = this.RequestData.Get("filedVal") + ""; string sql = @"select top 200 A.RoleID,A.Code,A.Description,A.Type,A.SortIndex, A.Name +' ['+ case when B.name is not null then B.Name+'/' else '' end + C.Name + ']' AS Name from Sysrole AS A left join SysGroup As B on A.Pk_corp=B.GroupID left join SysGroup As C on A.pk_deptdoc=C.GroupID where A.Isabort='N' and len(A.Pk_corp)>0 and len(A.pk_deptdoc)>0 and A.Name like '%{0}%' "; sql = sql.Replace("FL_PortalHR", Global.AimPortalDB); sql = string.Format(sql, filedVal); this.PageState.Add("DataList", DataHelper.QueryDictList(sql)); } if (!String.IsNullOrEmpty(cid)) { try { int icid = Convert.ToInt32(cid); SearchCriterion.AddSearch("Type", icid); ents = SysRoleRule.FindAll(SearchCriterion); this.PageState.Add("DtList", ents); } catch { } } else { string sql = @" select top 100 A.RoleID,A.Code,A.Description,A.Type,A.SortIndex, A.Name+' ['+ case when B.name is not null then B.Name+'/' else '' end + C.Name + ']' AS Name from Sysrole AS A left join SysGroup As B on A.Pk_corp=B.GroupID left join SysGroup As C on A.pk_deptdoc=C.GroupID where A.Isabort='N' and len(A.Pk_corp)>0 and len(A.pk_deptdoc)>0"; ents = SysRoleRule.FindAll(SearchCriterion); this.PageState.Add("DtList", DataHelper.QueryDictList(sql)); } }
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") { SysRole[] ents = null; if (RequestActionString == "querychildren" || RequestActionString == "querydescendant") { string atype = String.Empty; if (type == "rtype") { ents = SysRole.FindAll("FROM SysRole as ent WHERE ent.Type = ?", id); } } string jsonString = JsonHelper.GetJsonString(this.ToExtTreeCollection(ents, 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)) { SysRoleRule.GrantRoleToUser(authAdded, id); SysRoleRule.RevokeRoleFromUser(authRemoved, id); } else if (type == "group" && !String.IsNullOrEmpty(id)) { SysRoleRule.GrantRoleToGroup(authAdded, id); SysRoleRule.RevokeRoleFromGroup(authRemoved, id); } } break; } } else { SysRoleType[] typeList = SysRoleTypeRule.FindAll(); this.PageState.Add("EntData", typeList); } // 获取权限列表 if (RequestAction != RequestActionEnum.Custom) { this.PageState.Add("EntityID", id); IEnumerable <string> roleIDs = null; using (new Castle.ActiveRecord.SessionScope()) { if (type == "user" && !String.IsNullOrEmpty(id)) { SysUser user = SysUser.Find(id); roleIDs = (user.Role).Select((ent) => { return(ent.RoleID); }); } else if (type == "group" && !String.IsNullOrEmpty(id)) { SysGroup group = SysGroup.Find(id); roleIDs = (group.Role).Select((ent) => { return(ent.RoleID); }); } this.PageState.Add("EntList", new List <string>(roleIDs)); } } }
protected void Page_Load(object sender, EventArgs e) { if (this.IsAsyncRequest) { SearchCriterion.SetOrder("CreateDate"); SearchCriterion.SetOrder("SortIndex"); ents = SysRoleRule.FindAll(SearchCriterion); this.PageState.Add("RoleList", ents); } SysRole ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SysRole>(); ent.SaveAndFlush(); this.SetMessage("保存成功!"); break; case RequestActionEnum.Create: ent = this.GetPostedData <SysRole>(); ent.CreateAndFlush(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysRole>(); ent.DeleteAndFlush(); this.SetMessage("删除成功!"); break; case RequestActionEnum.Custom: if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } else if (RequestActionString == "getusers") { string uids = ""; string names = ""; using (new SessionScope()) { ent = SysRole.Find(this.RequestData.Get <string>("id")); if (ent.User.Count > 0) { SysUser[] usrs = ent.User.ToArray(); foreach (SysUser usr in usrs) { uids += usr.UserID + ","; names += usr.Name + ","; } } } uids = uids.TrimEnd(','); names = names.TrimEnd(','); this.PageState.Add("UserId", uids); this.PageState.Add("UserName", names); } else if (RequestActionString == "setusers") { string roleId = this.RequestData.Get <string>("id"); string userIds = this.RequestData.Get <string>("userids"); DataHelper.ExecSql("delete from SysUserRole where RoleId='" + roleId + "'"); string insertTpl = "insert into SysUserRole values ('{0}','" + roleId + "')"; string sql = ""; string[] users = userIds.Split(','); foreach (string user in users) { if (user != "") { sql += string.Format(insertTpl, user); } } if (sql.Trim() != "") { DataHelper.ExecSql(sql); } } break; } SysRoleType[] roleTypes = SysRoleTypeRule.FindAll(); this.PageState.Add("RoleTypeList", roleTypes); }