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);
                }
            }
        }
Beispiel #2
0
        /// <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); // 操作分割符
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SearchCriterion.Orders.Count <= 0)
            {
                SearchCriterion.SetOrder("SortIndex");
                SearchCriterion.SetOrder("CreatedDate");
            }

            ents = DynamicAuthCatalogRule.FindAll(SearchCriterion);

            this.PageState.Add("DynamicAuthCatalogList", ents);

            DynamicAuthCatalog ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Create:
                ent = this.GetPostedData <DynamicAuthCatalog>();
                ent.DoCreate();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Update:
                ent = this.GetMergedData <DynamicAuthCatalog>();
                ent.DoUpdate();
                this.SetMessage("保存成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <DynamicAuthCatalog>();
                ent.DoDelete();
                this.SetMessage("删除成功!");
                break;

            case RequestActionEnum.Custom:
                IList <object> idList = RequestData.GetList <object>("IdList");

                if (idList != null && idList.Count > 0)
                {
                    if (RequestActionString == "batchdelete")
                    {
                        DynamicAuthCatalogRule.BatchRemoveByPrimaryKeys(idList);
                    }
                }
                break;
            }
        }
        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");

            DynamicAuthCatalog ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                ent = this.GetMergedData <DynamicAuthCatalog>();
                if (!this.FormData.ContainsKey("Editable"))
                {
                    ent.Editable = false;
                }

                ent.DoUpdate();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Create:
                ent = this.GetPostedData <DynamicAuthCatalog>();

                ent.CreaterID   = UserInfo.UserID;
                ent.CreaterName = UserInfo.Name;
                ent.DoCreate();
                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <DynamicAuthCatalog>();
                ent.DoDelete();
                this.SetMessage("删除成功!");
                return;
            }

            if (op != "c" && op != "cs")
            {
                if (!String.IsNullOrEmpty(id))
                {
                    ent = DynamicAuthCatalog.Find(id);
                }

                this.SetFormData(ent);
            }
        }
        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);
            }
        }
Beispiel #6
0
        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");

            DynamicAuth ent = null;

            switch (this.RequestAction)
            {
            case RequestActionEnum.Query:
            case RequestActionEnum.Read:
            case RequestActionEnum.Default:
                if (op == "c")
                {
                    DynamicAuthCatalog dacent = DynamicAuthCatalog.Find(id);
                    ent             = new DynamicAuth();
                    ent.CatalogCode = dacent.Code;
                }
                else
                {
                    ent = DynamicAuth.Find(id);
                }
                break;

            case RequestActionEnum.Update:
                ent = this.GetMergedData <DynamicAuth>();
                if (!this.FormData.ContainsKey("Editable"))
                {
                    ent.Editable = false;
                }
                if (!this.FormData.ContainsKey("Grantable"))
                {
                    ent.Grantable = false;
                }
                ent.DoUpdate();
                this.SetMessage("修改成功!");
                break;

            case RequestActionEnum.Create:
                ent             = this.GetPostedData <DynamicAuth>();
                ent.CreaterID   = UserInfo.UserID;
                ent.CreaterName = UserInfo.Name;

                if (this.RequestAction == RequestActionEnum.Create)
                {
                    ent.CreateAsTop(id);
                }
                else
                {
                    ent.CreateAsSub(id);
                }

                this.SetMessage("新建成功!");
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <DynamicAuth>();
                ent.DoDelete();
                this.SetMessage("删除成功!");
                return;
            }

            this.SetFormData(ent);
        }