Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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);
            }
        }