Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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;
                }
            }
        }
Exemple #4
0
        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));
                }
            }
        }