string code = String.Empty; // 编码 #endregion #region 构造函数 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); code = RequestData.Get <string>("code"); DynamicAuthCatalog dac = null; // 动态权限类型 SearchCriterion sc = new HqlSearchCriterion(); SearchCriterion.SetOrder("SortIndex"); SearchCriterion.SetOrder("CreatedDate"); SearchCriterion.AddSearch("EditStatus", "G", SearchModeEnum.Like); // 只显示允许授权的节点 if (type == "catalog") { if (String.IsNullOrEmpty(code) && !String.IsNullOrEmpty(id)) { dac = DynamicAuthCatalog.Find(id); code = dac.Code; } if (!String.IsNullOrEmpty(code)) { SearchCriterion.AddSearch("CatalogCode", code); SearchCriterion.AddSearch("ParentID", SingleSearchModeEnum.IsNull); ents = DynamicAuthRule.FindAll(SearchCriterion); if (dac == null) { dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", code)); } } } else if (!String.IsNullOrEmpty(id)) { SearchCriterion.AddSearch("ParentID", id); ents = DynamicAuthRule.FindAll(SearchCriterion); DynamicAuth da = DynamicAuth.Find(id); dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", da.CatalogCode)); } this.PageState.Add("EntList", ents); if (!IsAsyncRequest) { if (dac != null) { IList <DynamicPermissionCatalog> dpcs = dac.AllowGrantPermissionCatalog; this.PageState.Add("PCatalogList", dpcs); } } }
/// <summary> /// 选择操作 /// </summary> private void DoSelect() { DynamicAuthCatalog dac = null; // 动态权限类型 SearchCriterion sc = new HqlSearchCriterion(); SearchCriterion.SetOrder("SortIndex"); SearchCriterion.SetOrder("CreatedDate"); SearchCriterion.AddSearch("EditStatus", "G", SearchModeEnum.Like); // 只显示允许授权的节点 if (type == "catalog") { if (String.IsNullOrEmpty(code) && !String.IsNullOrEmpty(id)) { dac = DynamicAuthCatalog.Find(id); code = dac.Code; } if (!String.IsNullOrEmpty(code)) { SearchCriterion.AddSearch("CatalogCode", code); SearchCriterion.AddSearch("ParentID", SingleSearchModeEnum.IsNull); ents = DynamicAuthRule.FindAll(SearchCriterion); if (dac == null) { dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", code)); } } } else if (!String.IsNullOrEmpty(id)) { SearchCriterion.AddSearch("ParentID", id); ents = DynamicAuthRule.FindAll(SearchCriterion); DynamicAuth da = DynamicAuth.Find(id); dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", da.CatalogCode)); } this.PageState.Add("EntList", ents); if (!IsAsyncRequest) { if (dac != null) { IList <DynamicPermissionCatalog> dpcs = dac.AllowGrantPermissionCatalog; this.PageState.Add("PCatalogList", dpcs); this.PageState.Add("AllowOperation", dac.GetAllowOperations()); // 允许的操作 } this.PageState.Add("OpDivChar", DynamicOperations.DivChar); // 操作分割符 } }
protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); type = RequestData.Get <string>("type", 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; SearchCriterion.AddSearch("AuthID", id); SearchCriterion.AddSearch("CatalogCode", DynamicPermissionCatalog.SysCatalogEnum.SYS_USER.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 == "adduser" || RequestActionString == "deluser") { IList <string> userIDs = RequestData.GetList <string>("UserIDs"); if (!String.IsNullOrEmpty(id)) { using (new SessionScope()) { if (RequestActionString == "adduser") { DynamicAuth dauth = DynamicAuth.Find(id); DynamicPermission.GrantDAuthToUsers(dauth, userIDs, null, null, UserInfo.UserID, UserInfo.Name); } else if (RequestActionString == "deluser") { DynamicPermission.RevokeDAuthFromUsers(id, userIDs); } } } } 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); } }