示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op");
            id = RequestData.Get <string>("id");
            string AuthIds = RequestData.Get <string>("AuthIds");

            if (!string.IsNullOrEmpty(id))
            {
                ent = MyShortCut.Find(id);
            }
            switch (RequestActionString)
            {
            case "update":
                ent = GetMergedData <MyShortCut>();
                ent.DoUpdate();
                break;

            case "create":
                ent = GetPostedData <MyShortCut>();
                sql = @"delete from BJKY_IntegratedManage..MyShortCut where CreateId='{0}' and PatIndex('%'+AuthId+'%','{1}')>0";
                sql = string.Format(sql, UserInfo.UserID, ent.AuthId);
                DataHelper.ExecSql(sql);    //删除快捷中已经存在权限模块ID
                if (ent.AuthId.Length > 36)
                {
                    string[] authIdArray   = ent.AuthId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    string[] authNameArray = ent.AuthName.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < authIdArray.Length; i++)
                    {
                        MyShortCut mscEnt = new MyShortCut();
                        mscEnt.AuthId   = authIdArray[i];
                        mscEnt.AuthName = authNameArray[i];
                        SysAuth   saEnt = SysAuth.Find(ent.AuthId);
                        SysModule smEnt = SysModule.Find(saEnt.ModuleID);
                        mscEnt.ModuleUrl    = smEnt.Url;
                        mscEnt.IconFileId   = ent.IconFileId;
                        mscEnt.IconFileName = ent.IconFileName;
                        mscEnt.DoCreate();
                    }
                }
                else
                {
                    SysAuth   saEnt = SysAuth.Find(ent.AuthId);
                    SysModule smEnt = SysModule.Find(saEnt.ModuleID);
                    ent.ModuleUrl = smEnt.Url;
                    ent.DoCreate();
                }
                break;

            default:
                DoSelect();
                break;
            }
        }
示例#2
0
        string pt = String.Empty; // 父模块类型

        protected void Page_Load(object sender, EventArgs e)
        {
            op = RequestData.Get <string>("op"); // 用户编辑操作
            id = RequestData.Get <string>("id");
            pt = RequestData.Get <string>("pt");

            SysModule ent = null;

            if (IsAsyncRequest)
            {
                switch (RequestAction)
                {
                case RequestActionEnum.Query:
                case RequestActionEnum.Read:
                case RequestActionEnum.Default:
                    break;

                case RequestActionEnum.Create:
                    ent = this.GetPostedData <SysModule>();
                    ent.DoCreate();
                    break;

                case RequestActionEnum.Update:
                    ent = this.GetMergedData <SysModule>();
                    ent.DoUpdate();
                    break;

                case RequestActionEnum.Delete:
                    ent = this.GetTargetData <SysModule>();
                    ent.DoDelete();
                    break;

                default:
                    if (RequestActionString == "createsub")
                    {
                        if (!String.IsNullOrEmpty(id))
                        {
                            ent = this.GetPostedData <SysModule>();
                            if (pt == "App")
                            {
                                // 父节点为应用程序时,添加模块
                                ent.ApplicationID = id;
                                ent.CreateAsTop();
                            }
                            else
                            {
                                // 父节点为模块时,添加子模块
                                ent.CreateAsSub(id);
                            }
                        }
                    }
                    break;
                }
            }
            else
            {
                if (op != "c" && op != "cs")
                {
                    if (!String.IsNullOrEmpty(id))
                    {
                        ent = SysModule.Find(id);
                    }
                }

                DataEnum de = SysModuleTypeRule.GetModuleTypeEnum();
                this.PageState.Add("MdlTypeEnum", de);
            }

            this.SetFormData(ent);
        }
示例#3
0
        string type = String.Empty; // 查询类型

        protected void Page_Load(object sender, EventArgs e)
        {
            id   = (RequestData.ContainsKey("id") ? RequestData["id"].ToString() : UserInfo.UserID);
            type = (RequestData.ContainsKey("type") ? RequestData["type"].ToString() : String.Empty).ToLower();
            if (this.IsAsyncRequest)
            {
                switch (this.RequestAction)
                {
                case RequestActionEnum.Custom:
                    if (RequestActionString == "querydescendant")
                    {
                        SysAuth[] ents  = null;
                        string    atype = String.Empty;
                        //ents = SysAuth.FindAll("FROM SysAuth as ent WHERE ent.Type = ?", id);
                        SysUser user = SysUser.Find(this.UserInfo.UserID);
                        ents = this.UserContext.Auths.OrderBy(ens => ens.SortIndex).ToArray();
                        //SysAuth.FindAll(Expression.Sql("AuthID in (select AuthID from SysUserPermission where UserID ='" + this.UserInfo.UserID + "')"));
                        //user.Auth.ToArray();
                        string jsonString = JsonHelper.GetJsonString(this.ToExtTreeCollection(ents.OrderBy(v => v.SortIndex).ThenBy(v => v.CreateDate), null));
                        Response.Write(jsonString);
                        Response.End();
                    }
                    else if (RequestActionString == "savechanges")
                    {
                        ICollection authAdded   = RequestData["added"] as ICollection;
                        ICollection authRemoved = RequestData["removed"] as ICollection;

                        if (type == "user" && !String.IsNullOrEmpty(id))
                        {
                            SysAuth[] tAuths = SysAuthRule.GetAuthByIDs(authAdded).ToArray();
                            foreach (SysAuth auth in tAuths)
                            {
                                MyShortCut cut = new MyShortCut();
                                cut.CreateId     = this.UserInfo.UserID;
                                cut.CreateName   = this.UserInfo.Name;
                                cut.CreateTime   = DateTime.Now;
                                cut.ModuleUrl    = SysModule.Find(auth.ModuleID).Url;
                                cut.AuthId       = auth.AuthID;
                                cut.AuthName     = auth.Name;
                                cut.IconFileName = "/images/shared/read.gif";
                                cut.Save();
                            }
                            if (authRemoved.Count > 0)
                            {
                                ICollection myAuthIDs = null;
                                if (authRemoved is JArray)
                                {
                                    JArray arrAuths = authRemoved as JArray;
                                    myAuthIDs = new List <string>(arrAuths.Values <string>());
                                }
                                else
                                {
                                    myAuthIDs = authRemoved;
                                }
                                foreach (string s in myAuthIDs)
                                {
                                    DataHelper.ExecSql("delete from MyShortCut where AuthId like '%" + s + "%' and CreateId='" + this.UserInfo.UserID + "'", DataHelper.GetCurrentDbConnection(typeof(MyShortCut)));
                                }
                            }
                            //SysAuthRule.GrantAuthToUser(authAdded, id);
                            //SysAuthRule.RevokeAuthFromUser(authRemoved, id);
                        }

                        /*else if (type == "group" && !String.IsNullOrEmpty(id))
                         * {
                         *  SysAuthRule.GrantAuthToGroup(authAdded, id);
                         *  SysAuthRule.RevokeAuthFromGroup(authRemoved, id);
                         * }
                         * else if (type == "role" && !String.IsNullOrEmpty(id))
                         * {
                         *  SysAuthRule.GrantAuthToRole(authAdded, id);
                         *  SysAuthRule.RevokeAuthFromRole(authRemoved, id);
                         * }*/
                    }
                    break;
                }
            }
            else
            {
                SysAuthType[] authTypeList = SysAuthTypeRule.FindAll();
                if (this.Request.QueryString["Role"] != null && this.Request.QueryString["Role"] == "User")
                {
                    authTypeList = SysAuthType.FindAllByProperties(SysAuthType.Prop_AuthTypeID, 1);
                }
                this.PageState.Add("DtList", authTypeList);
            }

            // 获取权限列表
            if (RequestAction != RequestActionEnum.Custom)
            {
                this.PageState.Add("EntityID", id);
                IEnumerable <string> authIDs = null;
                IList <MyShortCut>   mscEnts = MyShortCut.FindAllByProperty(MyShortCut.Prop_CreateId, UserInfo.UserID);

                authIDs = mscEnts.Select(s => s.AuthId);
                this.PageState.Add("AtList", new List <string>(authIDs));
                //using (new Castle.ActiveRecord.SessionScope())
                //{
                //    if (type == "user" && !String.IsNullOrEmpty(id))
                //    {
                //        SysUser user = SysUser.Find(id);
                //        if (this.RequestData.Get<string>("Deny") != null && this.RequestData.Get<string>("Deny").Trim() == "Y")
                //        {
                //            authIDs = (user.AuthNo).Select((ent) => { return ent.AuthID; });
                //        }
                //        else
                //            authIDs = (user.Auth).Select((ent) => { return ent.AuthID; });
                //    }
                //    else if (type == "group" && !String.IsNullOrEmpty(id))
                //    {
                //        SysGroup group = SysGroup.Find(id);
                //        authIDs = (group.Auth).Select((ent) => { return ent.AuthID; });
                //    }
                //    else if (type == "role" && !String.IsNullOrEmpty(id))
                //    {
                //        SysRole role = SysRole.Find(id);
                //        authIDs = (role.Auth).Select((ent) => { return ent.AuthID; });
                //    }
                //    this.PageState.Add("AtList", new List<string>(authIDs));
                //}
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //防止多次添加
            if (!UserContext.ExtData.ContainsKey("CompanyId"))
            {
                //添加公司Id
                UserContext.ExtData.Add("CompanyId", Session["CompanyId"] + "");
                UserContext.ExtData.Add("DeptId", Session["DeptId"] + "");

                //公司
                SysGroup group = SysGroup.TryFind(Session["CompanyId"] + "");
                if (group != null)
                {
                    UserContext.ExtData.Add("CompanyName", group.Name);
                }
                else
                {
                    UserContext.ExtData.Add("CompanyName", "");
                }
                //部门
                group = SysGroup.TryFind(Session["DeptId"] + "");
                if (group != null)
                {
                    UserContext.ExtData.Add("DeptName", group.Name);
                }
                else
                {
                    UserContext.ExtData.Add("DeptName", "");
                }
            }

            applicationId            = RequestData.Get <string>("ApplicationId");
            applicationName          = Server.UrlDecode(RequestData.Get <string>("Name"));
            treeContainer.InnerHtml += "<script type='text/javascript'>";
            treeContainer.InnerHtml += " d = new dTree('d');";
            treeContainer.InnerHtml += "d.add('44b87eec-c353-4e98-82aa-4483a3ed86c9', -1, '招聘系统');";
            SysAuthType[] authTypeList = SysAuthTypeRule.FindAll();
            if (this.Request.QueryString["Role"] != null && this.Request.QueryString["Role"] == "User")
            {
                authTypeList = SysAuthType.FindAllByProperties(SysAuthType.Prop_AuthTypeID, 1);//&& tent.ParentID == null
            }

            IList <SysModule> ents = Aim.Portal.PortalService.CurrentUserContext.AccessibleModules.Where(tent => tent.ApplicationID == "f35cb450-cb38-4741-b8d7-9f726094b7ef").ToList();

            if (UserContext.ExtData["CompanyId"] != null)
            {
                IEnumerable <string> mids = ents.Select(en => en.ModuleID);
                if (UserContext.ExtData["CompanyId"] + "" == "")
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "adsf", "window.parent.location.href='/Login.aspx'", true);
                    return;
                }
                SysGroup tGroup = SysGroup.Find(UserContext.ExtData["CompanyId"].ToString());

                string[]   groupIDs     = (tGroup.Path + "." + tGroup.GroupID).Split('.');
                ICriterion hqlCriterion = Expression.In("GroupID", groupIDs);
                hqlCriterion = SearchHelper.UnionCriterions(hqlCriterion, Expression.Sql("Path like '%" + tGroup.GroupID + "%' and GroupID in (Select GroupID from SysUserGroup where UserID='" + this.UserInfo.UserID + "' or GroupID='" + Session["DeptId"] + "')"));
                SysGroup[] groups = SysGroup.FindAll(hqlCriterion);
                using (new SessionScope())
                {
                    SysUser    user = SysUser.Find(this.UserInfo.UserID);
                    SysGroup[] grps = user.AllGroup.Where(en => en.Path != null && en.Path.IndexOf(tGroup.GroupID) >= 0 || en.GroupID == tGroup.GroupID).ToArray();
                    foreach (SysGroup group in grps)//groups)
                    {
                        SysGroup groupS = SysGroup.Find(group.ID);
                        foreach (SysAuth tAuth in groupS.Auth)
                        {
                            if (tAuth.ModuleID != null && !mids.Contains(tAuth.ModuleID))
                            {
                                ents.Add(SysModule.Find(tAuth.ModuleID));
                            }
                        }
                    }
                }
            }

            ents = ents.OrderBy(ens => ens.SortIndex).ToList();

            foreach (SysModule smEnt in ents)
            {
                if (!string.IsNullOrEmpty(smEnt.ParentID))
                {
                    treeContainer.InnerHtml += "d.add('" + smEnt.ModuleID + "', '" + smEnt.ParentID + "', '" + smEnt.Name + "','" + smEnt.Url + "', '', 'mainShow');";
                }
                else
                {
                    treeContainer.InnerHtml += "d.add('" + smEnt.ModuleID + "', 'f35cb450-cb38-4741-b8d7-9f726094b7ef', '" + smEnt.Name + "','" + smEnt.Url + "', '', 'mainShow');";
                }
            }
            treeContainer.InnerHtml += "document.write(d);";
            treeContainer.InnerHtml += "$('.dtree > .dTreeNode:first-child').css({ display: 'none' });";
            treeContainer.InnerHtml += "</script>";
        }