protected void Page_Load(object sender, EventArgs e) { if (this.IsAsyncRequest) { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { string id = (RequestData.ContainsKey("ID") ? RequestData["ID"].ToString() : String.Empty); string type = RequestData["Type"].ToString().ToLower(); if (RequestData.ContainsKey("Type")) { if (type == "gtype") { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ent.Type = ?", id); this.PageState.Add("DtList", ents); } } } break; } } else { SysGroupType[] typeList = SysGroupTypeRule.FindAll(); this.PageState.Add("DtList", typeList); } }
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"); SysGroup ent = null; if (IsAsyncRequest) { switch (RequestAction) { case RequestActionEnum.Query: case RequestActionEnum.Read: case RequestActionEnum.Default: break; case RequestActionEnum.Create: ent = this.GetPostedData <SysGroup>(); ent.Create(); break; case RequestActionEnum.Update: ent = this.GetMergedData <SysGroup>(); ent.DoUpdate(); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysGroup>(); ent.DoDelete(); break; default: if (RequestActionString == "createsub") { ent = this.GetPostedData <SysGroup>(); ent.CreateAsSub(id); } break; } } else { if (op != "c" && op != "cs") { if (!String.IsNullOrEmpty(id)) { ent = SysGroup.Find(id); } } } DataEnum de = SysGroupTypeRule.GetGroupTypeEnum(); this.PageState.Add("GrpTypeEnum", de); this.SetFormData(ent); }
protected void Page_Load(object sender, EventArgs e) { if (IsAsyncRequest) { ents = SysGroupRule.FindAll(SearchCriterion); this.PageState.Add("GrpList", ents); } SysGroup ent = null; switch (this.RequestAction) { case RequestActionEnum.Query: case RequestActionEnum.Default: ent = this.GetTargetData <SysGroup>(); this.SetFormData(ent); break; case RequestActionEnum.Update: ent = this.GetMergedData <SysGroup>(); ent.ParentID = String.IsNullOrEmpty(ent.ParentID) ? null : ent.ParentID; ent.DoUpdate(); this.SetMessage("更新成功!"); break; case RequestActionEnum.Create: ent = this.GetPostedData <SysGroup>(); if (String.IsNullOrEmpty(ent.ParentID)) { ent.CreateAsTop(); } else { ent.CreateAsSub(ent.ParentID); } this.SetMessage("添加模块成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <SysGroup>(); ent.DoDelete(); this.SetMessage("删除成功!"); break; case RequestActionEnum.Custom: if (RequestActionString == "refreshsys") { PortalService.RefreshSysModules(); SetMessage("操作成功!"); } break; } SysGroupType[] grpTypes = SysGroupTypeRule.FindAll(); this.PageState.Add("GrpTypeList", grpTypes); }
protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); // 类型标识 cid = RequestData.Get <string>("cid", String.Empty); type = RequestData.Get <string>("type", String.Empty).ToLower(); ctype = RequestData.Get <string>("ctype", "role").ToLower(); if (!IsAsyncRequest) { cid = "2"; //WGM 13/4/7 默认组织结构 if (!String.IsNullOrEmpty(cid)) { try { int icid = Convert.ToInt32(cid); SearchCriterion.SetOrder("ParentID"); SearchCriterion.SetOrder("SortIndex"); SearchCriterion.SetOrder("CreateDate"); SearchCriterion.AddSearch("Type", icid); ents = SysGroupRule.FindAll(SearchCriterion); } catch { } this.PageState.Add("DtList", ents); } else { SysGroupType[] typeList = SysGroupTypeRule.FindAll(); this.PageState.Add("DtList", typeList); } } else { switch (this.RequestAction) { case RequestActionEnum.Custom: if (RequestActionString == "querychildren") { if (type == "gtype") { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ent.Type = ?", id); this.PageState.Add("DtList", ents); } } break; } } }
protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); type = RequestData.Get <string>("type", String.Empty).ToLower(); gtype = RequestData.Get <string>("gtype", String.Empty).ToLower(); switch (RequestAction) { case RequestActionEnum.Query: case RequestActionEnum.Read: case RequestActionEnum.Default: if (!String.IsNullOrEmpty(id)) { using (new Castle.ActiveRecord.SessionScope()) { SearchCriterion.PageSize = 50; if (!String.IsNullOrEmpty(gtype)) { SearchCriterion.AddSearch("Tag", gtype); } SearchCriterion.AddSearch("AuthID", id); SearchCriterion.AddSearch("CatalogCode", DynamicPermissionCatalog.SysCatalogEnum.SYS_GROUP.ToString()); dps = DynamicPermissionRule.FindAll(SearchCriterion); } } break; case RequestActionEnum.Update: IList <string> entStrList = RequestData.GetList <string>("data"); using (TransactionScope trans = new TransactionScope()) { try { foreach (string entStr in entStrList) { DynamicPermission tent = JsonHelper.GetObject <DynamicPermission>(entStr) as DynamicPermission; tent.DoUpdate(); } trans.VoteCommit(); } catch (Exception ex) { trans.VoteRollBack(); throw ex; } } break; case RequestActionEnum.Custom: if (RequestActionString == "batchadd" || RequestActionString == "batchdel") { IList <string> groupIDs = RequestData.GetList <string>("IDs"); if (!String.IsNullOrEmpty(id)) { using (new SessionScope()) { if (RequestActionString == "batchadd") { DynamicAuth dauth = DynamicAuth.Find(id); DynamicPermission.GrantDAuthToGroups(dauth, groupIDs, null, null, UserInfo.UserID, UserInfo.Name); } else if (RequestActionString == "batchdel") { DynamicPermission.RevokeDAuthFromGroups(id, groupIDs); } } } } break; } this.PageState.Add("EntList", dps); if (!IsAsyncRequest) { if (!String.IsNullOrEmpty(id)) { using (new SessionScope()) { DynamicAuth da = DynamicAuth.Find(id); DynamicAuthCatalog dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", da.CatalogCode)); if (dac != null) { this.PageState.Add("AllowOperation", dac.GetAllowOperations()); } } } this.PageState.Add("OpDivChar", DynamicOperations.DivChar); DataEnum de = SysGroupTypeRule.GetGroupTypeEnum(); this.PageState.Add("GrpTypeEnum", de); } }
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") { SysGroup[] ents = null; if (RequestActionString == "querychildren") { string atype = String.Empty; if (type == "gtype") { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ent.Type = ? AND ent.ParentID IS NULL", id); } else { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ent.ParentID = ?", id); } } else if (RequestActionString == "querydescendant") { string atype = String.Empty; if (type == "gtype") { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ent.Type = ?", id); } else { ents = SysGroup.FindAll("FROM SysGroup as ent WHERE ent.Path LIKE %?%", id); } } string jsonString = JsonHelper.GetJsonString(this.ToExtTreeCollection(ents, null)); Response.Write(jsonString); Response.End(); } else if (RequestActionString == "savechanges") { ICollection added = RequestData["added"] as ICollection; ICollection removed = RequestData["removed"] as ICollection; if (type == "user" && !String.IsNullOrEmpty(id)) { SysGroupRule.GrantGroupToUser(added, id); SysGroupRule.RevokeGroupFromUser(removed, id); } /*else if (type == "role" && !String.IsNullOrEmpty(id)) * { * SysGroupRule.GrantGroupToRole(added, id); * SysGroupRule.RevokeGroupFromRole(removed, id); * }*/ } break; } } else { SysGroupType[] typeList = SysGroupTypeRule.FindAll(); this.PageState.Add("EntData", typeList); } // 获取权限列表 if (RequestAction != RequestActionEnum.Custom) { this.PageState.Add("EntityID", id); IEnumerable <string> grpIDs = null; using (new Castle.ActiveRecord.SessionScope()) { if (type == "user" && !String.IsNullOrEmpty(id)) { SysUser user = SysUser.Find(id); grpIDs = (user.Group).Select((ent) => { return(ent.GroupID); }); } else if (type == "role" && !String.IsNullOrEmpty(id)) { SysRole role = SysRole.Find(id); grpIDs = (role.Group).Select((ent) => { return(ent.GroupID); }); } this.PageState.Add("EntList", new List <string>(grpIDs)); } } }