string pt = String.Empty; // 父模块类型 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); // 用户编辑操作 id = RequestData.Get <string>("id"); pt = RequestData.Get <string>("pt"); SysRole ent = null; if (IsAsyncRequest) { switch (RequestAction) { case RequestActionEnum.Query: case RequestActionEnum.Read: case RequestActionEnum.Default: break; case RequestActionEnum.Create: ent = this.GetPostedData <SysRole>(); ent.Type = 4; ent.DoCreate(); break; case RequestActionEnum.Update: ent = this.GetMergedData <SysRole>(); ent.DoUpdate(); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysRole>(); ent.DoDelete(); break; } } else { if (op != "c") { if (!String.IsNullOrEmpty(id)) { ent = SysRole.Find(id); } } } DataEnum de = SysRoleTypeRule.GetRoleTypeEnum(); this.PageState.Add("RolTypeEnum", de); this.SetFormData(ent); }
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)); } } }
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); }
protected void Page_Load(object sender, EventArgs e) { if (this.IsAsyncRequest) { string where = ""; foreach (CommonSearchCriterionItem item in SearchCriterion.Searches.Searches) { if (!String.IsNullOrEmpty(item.Value.ToString())) { switch (item.PropertyName) { default: where += " and " + item.PropertyName + " like '%" + item.Value + "%' "; break; } } } if (!string.IsNullOrEmpty(RequestData.Get <string>("Rolid") + "")) { string sql = "select * from SYSUSER where USERID in(select USERID from SYSUSERROLE where ROLEID ='" + RequestData.Get <string>("Rolid") + "') and 1=1"; sql = sql.Replace("and 1=1", where); this.PageState.Add("UserList", GetPageData(sql, SearchCriterion)); } } 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; default: if (RequestActionString == "setusers") //添加人员 { bool bol = false; //string get_task = "select * from HD_Task where ENDTIME is null "; //DataTable dt = DataHelper.QueryDataTable(get_task); 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[] users = userIds.Split(','); foreach (string user in users) { if (user != "") { DataHelper.ExecSql(string.Format(insertTpl, user)); } } if (roleId == "fe0464db-1b6e-483d-b983-4352f14cc367") { bol = true; } } 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 == "deleteusers") { string roleId = this.RequestData.Get <string>("id"); string userIds = this.RequestData.Get <string>("userids").TrimEnd(','); string delsql = "delete from SysUserRole where RoleId='" + roleId + "' and UserID in ('" + userIds.Replace(",", "','") + "') "; DataHelper.ExecSql(delsql); } else { DoSelect(); } break; } }