Exemplo n.º 1
0
        public PartialViewResult MenuOld()
        {
            if (HttpContext.ApplicationInstance.Context.Request.Cookies["UserId"] != null)
            {
                string strUserId = HttpContext.ApplicationInstance.Context.Request.Cookies["UserId"].Value;
                string strOrgId  = HttpContext.ApplicationInstance.Context.Request.Cookies["OrgId"].Value;
                string LoginName = Request.Cookies["LoginName"].Value;
                if (LoginName.ToUpper() == "ADMIN")
                {
                    #region  管理员
                    string Condition = " and orgid='888' and ( ParentID is null or ParentID='') ";
                    IList <SysGroupEntity> groupList = IgroupLogic.LoadAll(Condition, 1000, 1, "groupid");
                    if (groupList.Count > 0)
                    {
                        IList <SysGroupVM> groupvmList = new List <SysGroupVM>();
                        foreach (SysGroupEntity enty in groupList)
                        {
                            SysGroupVM groupvm = new SysGroupVM();
                            groupvm.id           = enty.GroupID;
                            groupvm.text         = enty.GroupName;
                            groupvm.iconCls      = enty.IconCls;
                            groupvm.pid          = enty.ParentID;
                            groupvm.url          = enty.URL;
                            groupvm.HisType      = enty.HisType;
                            groupvm.iconPosition = "top";

                            Condition = " and ParentID = '" + enty.GroupID + "'";
                            IList <SysGroupEntity> itemList = IgroupLogic.LoadAll(Condition, 1000, 1, "groupid");
                            groupvm.subList = new List <SysGroupEntity>();
                            groupvm.subList = itemList;
                            groupvmList.Add(groupvm);
                        }

                        return(PartialView(new MenuModel {
                            Menus = groupvmList
                        }));
                    }
                    #endregion
                }
                else
                {
                    #region
                    UserInfoEntity         usermodel = IUserLogic.Load(LoginName);
                    IList <SysGroupEntity> groupList;
                    string Condition = " and orgid='" + strOrgId + "' and ( ParentID is null or ParentID='') ";
                    if ((usermodel != null) && (usermodel.RoleType == "1"))
                    {
                        groupList = IgroupLogic.LoadAll(" and orgid = '100' and ( ParentID is null or ParentID='') ", 1000, 1, "GroupID");
                    }
                    else
                    {
                        if (strUserId != "3001")
                        {
                            groupList = IgroupLogic.LoadGroupListByUserId(strUserId);
                        }
                        else
                        {
                            groupList = IgroupLogic.LoadGroupListByUserId(strUserId);
                        }
                    }
                    //groupList = IgroupLogic.LoadAll(Condition, 1000, 1, "GroupID");
                    List <SysGroupEntity> groupListNew = new List <SysGroupEntity>();
                    if (groupList.Count > 0)
                    {
                        foreach (SysGroupEntity enty in groupList)
                        {
                            if (string.IsNullOrEmpty(enty.ParentID))
                            {
                                groupListNew.Add(enty);
                            }
                        }
                    }


                    if (groupListNew.Count > 0)
                    {
                        IList <SysGroupVM> groupvmList = new List <SysGroupVM>();
                        foreach (SysGroupEntity enty in groupListNew)
                        {
                            SysGroupVM groupvm = new SysGroupVM();
                            groupvm.id           = enty.GroupID;
                            groupvm.text         = enty.GroupName;
                            groupvm.iconCls      = enty.IconCls;
                            groupvm.pid          = enty.ParentID;
                            groupvm.url          = enty.URL;
                            groupvm.HisType      = enty.HisType;
                            groupvm.iconPosition = "top";

                            Condition = " and ParentID = '" + enty.GroupID + "'";
                            //IList<SysGroupEntity> itemList = IgroupLogic.LoadAll(Condition, 1000, 1, "groupid");
                            if (strUserId != "3001")
                            {
                                Condition = " and UserInfo.userid = '" + strUserId + "' and SysGroup.parentid = '" + enty.GroupID + "'";
                                IList <SysGroupEntity> itemList = IgroupLogic.LoadAllByParentIdAndUserId(Condition, 1000, 1, "groupid");
                                groupvm.subList = new List <SysGroupEntity>();
                                groupvm.subList = itemList;
                                groupvmList.Add(groupvm);
                            }
                            else
                            {
                                IList <SysGroupEntity> itemList = IgroupLogic.LoadAll(Condition, 1000, 1, "groupid");
                                groupvm.subList = new List <SysGroupEntity>();
                                groupvm.subList = itemList;
                                groupvmList.Add(groupvm);
                            }
                        }

                        return(PartialView(new MenuModel {
                            Menus = groupvmList
                        }));
                    }
                    #endregion
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        public PartialViewResult Menu()
        {
            if (HttpContext.ApplicationInstance.Context.Request.Cookies["UserId"] != null)
            {
                string                 strUserId = HttpContext.ApplicationInstance.Context.Request.Cookies["UserId"].Value;
                UserInfoEntity         usermodel = IUserLogic.Load(strUserId);
                string                 Condition = "  and ( ParentID is null or ParentID='') ";
                IList <SysGroupEntity> groupList;
                if ((usermodel != null) && (usermodel.RoleType == "1"))
                {
                    groupList = IgroupLogic.LoadAll("  and ( ParentID is null or ParentID='') ", 1000, 1, "GroupID");
                    IList <SysGroupVM> groupvmList = new List <SysGroupVM>();
                    foreach (SysGroupEntity enty in groupList)
                    {
                        SysGroupVM groupvm = new SysGroupVM();
                        groupvm.id           = enty.GroupID;
                        groupvm.text         = enty.GroupName;
                        groupvm.iconCls      = enty.IconCls;
                        groupvm.pid          = enty.ParentID;
                        groupvm.url          = enty.URL;
                        groupvm.HisType      = enty.HisType;
                        groupvm.iconPosition = "top";

                        Condition = " and ParentID = '" + enty.GroupID + "'";
                        IList <SysGroupEntity> itemList = IgroupLogic.LoadAll(Condition, 1000, 1, "groupid");
                        groupvm.subList = new List <SysGroupEntity>();
                        groupvm.subList = itemList;
                        groupvmList.Add(groupvm);
                    }

                    return(PartialView(new MenuModel {
                        Menus = groupvmList
                    }));
                }
                else
                {
                    groupList = IgroupLogic.LoadGroupListByUserId(strUserId);
                    if (groupList.Count > 0)
                    {
                        List <SysGroupEntity> groupListMenuOne = new List <SysGroupEntity>();
                        if (groupList.Count > 0)
                        {
                            foreach (SysGroupEntity enty in groupList)
                            {
                                if (string.IsNullOrEmpty(enty.ParentID))
                                {
                                    groupListMenuOne.Add(enty);
                                }
                            }
                        }

                        if (groupListMenuOne.Count > 0)
                        {
                            IList <SysGroupVM> groupvmList = new List <SysGroupVM>();
                            foreach (SysGroupEntity enty in groupListMenuOne)
                            {
                                SysGroupVM groupvm = new SysGroupVM();
                                groupvm.id           = enty.GroupID;
                                groupvm.text         = enty.GroupName;
                                groupvm.iconCls      = enty.IconCls;
                                groupvm.pid          = enty.ParentID;
                                groupvm.url          = enty.URL;
                                groupvm.HisType      = enty.HisType;
                                groupvm.iconPosition = "top";

                                Condition = " and ParentID = '" + enty.GroupID + "'";
                                Condition = " and UserInfo.userid = '" + strUserId + "' and SysGroup.parentid = '" + enty.GroupID + "'";
                                IList <SysGroupEntity> itemList = IgroupLogic.LoadAllByParentIdAndUserId(Condition, 1000, 1, "groupid");
                                groupvm.subList = new List <SysGroupEntity>();
                                groupvm.subList = itemList;
                                groupvmList.Add(groupvm);
                            }

                            return(PartialView(new MenuModel {
                                Menus = groupvmList
                            }));
                        }
                    }
                }
                return(null);
            }
            else
            {
                return(null);
            }
        }