string type = String.Empty; // 对象类型 #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"); DynamicPermission ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <DynamicPermission>(); ent.DoUpdate(); this.SetMessage("修改成功!"); break; case RequestActionEnum.Create: ent = this.GetPostedData <DynamicPermission>(); ent.CreaterID = UserInfo.UserID; ent.CreaterName = UserInfo.Name; ent.DoCreate(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <DynamicPermission>(); ent.DoDelete(); this.SetMessage("删除成功!"); return; } }
protected void Page_Load(object sender, EventArgs e) { ents = DynamicPermissionRule.FindAll(SearchCriterion); this.PageState.Add("DynamicPermissionList", ents); DynamicPermission ent = null; switch (this.RequestAction) { case RequestActionEnum.Create: ent = this.GetPostedData <DynamicPermission>(); ent.DoCreate(); this.SetMessage("新建成功!"); break; case RequestActionEnum.Update: ent = this.GetMergedData <DynamicPermission>(); ent.DoUpdate(); this.SetMessage("保存成功!"); break; case RequestActionEnum.Delete: ent = this.GetTargetData <DynamicPermission>(); ent.DoDelete(); this.SetMessage("删除成功!"); break; case RequestActionEnum.Custom: IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { if (RequestActionString == "batchdelete") { DynamicPermissionRule.BatchRemoveByPrimaryKeys(idList); } } break; } }
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); } }
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"); switch (RequestAction) { case RequestActionEnum.Default: case RequestActionEnum.Read: case RequestActionEnum.Query: DoSelect(); break; case RequestActionEnum.Custom: if (RequestActionString == "getpermission") { DynamicPermission[] dps = null; if (type == "user") { dps = DynamicPermission.GetOrgPermissions(id, DynamicPermissionCatalog.SysCatalogEnum.SYS_USER); } else if (type == "role") { dps = DynamicPermission.GetOrgPermissions(id, DynamicPermissionCatalog.SysCatalogEnum.SYS_ROLE); } else if (type == "group") { dps = DynamicPermission.GetOrgPermissions(id, DynamicPermissionCatalog.SysCatalogEnum.SYS_GROUP); } else { dps = DynamicPermission.GetPermissionsByCatalogCode(id, type); } PageState.Add("DPList", dps); } break; case RequestActionEnum.Update: IList <string> pids = RequestData.GetList <string>("pidList"); // 权限标识 IList <string> aids = RequestData.GetList <string>("aidList"); // 授权标识 IList <string> ops = RequestData.GetList <string>("opList"); // 操作标识 string pcatalog = RequestData.Get <string>("pcatalog"); string tag = RequestData.Get <string>("tag"); for (int i = 0; i < pids.Count; i++) { var tpid = (pids[i] == null ? pids[i] : pids[i].Trim()); var taid = (aids[i] == null ? aids[i] : aids[i].Trim()); var top = (ops[i] == null ? ops[i] : ops[i].Trim()); if (!String.IsNullOrEmpty(tpid)) { DynamicPermission dp = DynamicPermission.Find(tpid); if (!String.IsNullOrEmpty(top)) { dp.Operation = top; dp.DoUpdate(); } else { dp.DoDelete(); } } else { if (!String.IsNullOrEmpty(taid) && !String.IsNullOrEmpty(top)) { DynamicAuth tauth = DynamicAuth.Find(taid); IList <string> tOpList = top.Split(DynamicOperations.DivChar); if (type == "user") { DynamicPermission.GrantDAuthToUser(tauth, id, tOpList, null, UserInfo.UserID, UserInfo.Name); } else if (type == "role") { DynamicPermission.GrantDAuthToRole(tauth, id, tOpList, null, UserInfo.UserID, UserInfo.Name); } else if (type == "group") { DynamicPermission.GrantDAuthToGroup(tauth, id, tOpList, null, UserInfo.UserID, UserInfo.Name); } else { DynamicPermission.GrantDAuths(new DynamicAuth[] { tauth }, new string[] { id }, tOpList, pcatalog, tag, UserInfo.UserID, UserInfo.Name); } } } } break; } }