Esempio n. 1
0
 private void SetFileIcon(MenuNodeInfo info, JsTreeData item)
 {
     if (info.Children.Count == 0)
     {
         item.icon = "fa fa-file icon-state-warning icon-lg";
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 获取菜单树Json字符串(Bootstrap的JSTree)
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMenuJsTreeJson()
        {
            List <JsTreeData>     treeList = new List <JsTreeData>();
            List <SystemTypeInfo> typeList = BLLFactory <SystemType> .Instance.GetAll();

            foreach (SystemTypeInfo typeInfo in typeList)
            {
                JsTreeData pNode = new JsTreeData(typeInfo.OID, typeInfo.Name, "fa fa-home icon-state-warning icon-lg");
                treeList.Add(pNode);

                string systemType = typeInfo.OID;//系统标识ID

                //一般情况下,对Ribbon样式而言,一级菜单表示RibbonPage;二级菜单表示PageGroup;三级菜单才是BarButtonItem最终的菜单项。
                List <MenuNodeInfo> menuList = BLLFactory <Menus> .Instance.GetTree(systemType);

                foreach (MenuNodeInfo info in menuList)
                {
                    JsTreeData item = new JsTreeData(info.ID, info.Name);
                    pNode.children.Add(item);
                    SetFileIcon(info, item);

                    AddJsTreeChildNode(info.Children, item);
                }
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 3
0
        /// <summary>
        /// 获取用户的部门树结构(分级需要)(bootstrap的JSTree)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public ActionResult GetMyDeptJsTreeJson(int userId)
        {
            StringBuilder content  = new StringBuilder();
            UserInfo      userInfo = BLLFactory <User> .Instance.FindByID(userId);

            if (userInfo != null)
            {
                List <OUInfo> list = BLLFactory <OU> .Instance.GetMyTopGroup(userId);

                foreach (OUInfo groupInfo in list)
                {
                    if (groupInfo != null && !groupInfo.Deleted)
                    {
                        List <OUNodeInfo> sublist = BLLFactory <OU> .Instance.GetTreeByID(groupInfo.ID);

                        JsTreeData treeData = new JsTreeData(groupInfo.ID, groupInfo.Name, GetBootstrapIcon(groupInfo.Category));
                        GetJsTreeDataWithOUNode(sublist, treeData);

                        content.Append(base.ToJson(treeData));
                    }
                }
            }
            string json = string.Format("[{0}]", content.ToString().Trim(','));

            return(Content(json));
        }
Esempio n. 4
0
        /// <summary>
        /// 获取所有的功能树Json
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllJsTreeJson()
        {
            List <JsTreeData>     treeList = new List <JsTreeData>();
            List <SystemTypeInfo> typeList = BLLFactory <SystemType> .Instance.GetAll();

            foreach (SystemTypeInfo typeInfo in typeList)
            {
                JsTreeData pNode = new JsTreeData(typeInfo.OID, typeInfo.Name);
                treeList.Add(pNode);

                string systemType = typeInfo.OID;//系统标识ID
                //绑定树控件
                List <FunctionNodeInfo> functionList = BLLFactory <Functions> .Instance.GetTree(systemType);

                foreach (FunctionNodeInfo info in functionList)
                {
                    JsTreeData item = new JsTreeData(info.ID, info.Name, "fa fa-key icon-state-danger icon-lg");
                    pNode.children.Add(item);

                    AddJsTreeChildNode(info.Children, item);
                }
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 5
0
        /// <summary>
        /// 获取用户的公司结构(分级需要)(bootstrap的JSTree)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public ActionResult GetMyCompanyJsTreeJson(int userId)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            UserInfo userInfo = BLLFactory <User> .Instance.FindByID(userId);

            if (userInfo != null)
            {
                List <OUNodeInfo> list = new List <OUNodeInfo>();
                if (BLLFactory <User> .Instance.UserInRole(userInfo.Name, RoleInfo.SuperAdminName))
                {
                    list = BLLFactory <OU> .Instance.GetGroupCompanyTree();
                }
                else
                {
                    OUInfo myCompanyInfo = BLLFactory <OU> .Instance.FindByID(userInfo.Company_ID);

                    if (myCompanyInfo != null)
                    {
                        list.Add(new OUNodeInfo(myCompanyInfo));
                    }
                }

                if (list.Count > 0)
                {
                    OUNodeInfo info = list[0];//无论是集团还是公司,节点只有一个
                    JsTreeData node = new JsTreeData(info.ID, info.Name, GetBootstrapIcon(info.Category));
                    GetJsTreeDataWithOUNode(info.Children, node);
                    treeList.Add(node);
                }
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 6
0
        /// <summary>
        /// 初始化并绑定客户个人分组信息
        /// </summary>
        public ActionResult GetMyContactGroupJsTree(string contactId, string userId)
        {
            List <ContactGroupInfo> myGroupList = BLLFactory <ContactGroup> .Instance.GetByContact(contactId);

            List <string> groupIdList = new List <string>();

            foreach (ContactGroupInfo info in myGroupList)
            {
                groupIdList.Add(info.ID);
            }

            List <ContactGroupNodeInfo> groupList = BLLFactory <ContactGroup> .Instance.GetTree(userId);

            List <JsTreeData> treeList = new List <JsTreeData>();

            foreach (ContactGroupNodeInfo nodeInfo in groupList)
            {
                bool       check    = groupIdList.Contains(nodeInfo.ID);
                JsTreeData treeData = new JsTreeData(nodeInfo.ID, nodeInfo.Name);
                treeData.state = new JsTreeState(true, check);

                treeList.Add(treeData);
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 7
0
        /// <summary>
        /// 获取所有的省份和城市列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllProvinceCityJsTree()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();
            JsTreeData        pNode    = new JsTreeData("", "选择记录", "fa fa-home icon-state-warning icon-lg");

            treeList.Add(pNode);

            List <ProvinceInfo> provinceList = BLLFactory <Province> .Instance.GetAll();

            foreach (ProvinceInfo info in provinceList)
            {
                JsTreeData item = new JsTreeData("", info.ProvinceName, "fa fa-file icon-state-warning icon-lg");

                List <CityInfo> cityList = BLLFactory <City> .Instance.GetCitysByProvinceID(info.ID.ToString());

                foreach (CityInfo cityInfo in cityList)
                {
                    JsTreeData subItem = new JsTreeData(cityInfo.ID, cityInfo.CityName, "fa fa-file icon-state-warning icon-lg");
                    item.children.Add(subItem);
                }

                pNode.children.Add(item);
            }
            return(ToJsonContent(treeList));
        }
Esempio n. 8
0
        private void AddJsTreeeFunctionNode(JsTreeData node, List <FunctionNodeInfo> list)
        {
            foreach (FunctionNodeInfo info in list)
            {
                JsTreeData subNode = new JsTreeData(info.ID, info.Name, info.Children.Count > 0 ? "fa fa-users icon-state-info icon-lg" : "fa fa-key icon-state-danger icon-lg");
                node.children.Add(subNode);

                AddJsTreeeFunctionNode(subNode, info.Children);
            }
        }
Esempio n. 9
0
        private void AddJsTreeChildNode(List <FunctionNodeInfo> list, JsTreeData fnode)
        {
            foreach (FunctionNodeInfo info in list)
            {
                JsTreeData item = new JsTreeData(info.ID, info.Name, "fa fa-key icon-state-danger icon-lg");
                fnode.children.Add(item);

                AddJsTreeChildNode(info.Children, item);
            }
        }
Esempio n. 10
0
        private void AddJsRole(OUInfo ouInfo, JsTreeData treeNode)
        {
            List <RoleInfo> roleList = BLLFactory <Role> .Instance.GetRolesByCompany(ouInfo.ID.ToString());

            foreach (RoleInfo roleInfo in roleList)
            {
                JsTreeData roleNode = new JsTreeData("role" + roleInfo.ID, roleInfo.Name, "fa fa-user icon-state-info icon-lg");
                treeNode.children.Add(roleNode);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 获取客户分组并绑定
        /// </summary>
        private void AddContactGroupJsTree(List <ContactGroupNodeInfo> nodeList, JsTreeData treeNode)
        {
            foreach (ContactGroupNodeInfo nodeInfo in nodeList)
            {
                JsTreeData subNode = new JsTreeData(nodeInfo.ID, nodeInfo.Name, "fa fa-user icon-state-warning icon-lg");
                treeNode.children.Add(subNode);

                AddContactGroupJsTree(nodeInfo.Children, subNode);
            }
        }
Esempio n. 12
0
        private void AddJsTreeChildNode(List <MenuNodeInfo> list, JsTreeData fnode)
        {
            foreach (MenuNodeInfo info in list)
            {
                JsTreeData item = new JsTreeData(info.ID, info.Name);
                fnode.children.Add(item);
                SetFileIcon(info, item);

                AddJsTreeChildNode(info.Children, item);
            }
        }
Esempio n. 13
0
        private void GetJsTreeDataWithOUNode(List <OUNodeInfo> list, JsTreeData parent)
        {
            List <JsTreeData> result = new List <JsTreeData>();

            foreach (OUNodeInfo ouInfo in list)
            {
                JsTreeData treeData = new JsTreeData(ouInfo.ID, ouInfo.Name, GetBootstrapIcon(ouInfo.Category));
                GetJsTreeDataWithOUNode(ouInfo.Children, treeData);

                result.Add(treeData);
            }
            parent.children.AddRange(result);
        }
Esempio n. 14
0
        /// <summary>
        /// 获取树形展示数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetJsTreeJson()
        {
            List <JsTreeData>   treeList = new List <JsTreeData>();
            List <DictTypeInfo> typeList = BLLFactory <DictType> .Instance.Find("PID='-1' ");

            foreach (DictTypeInfo info in typeList)
            {
                JsTreeData node = new JsTreeData(info.ID, info.Name, "fa fa-file icon-state-warning icon-lg");
                GetJsTreeJson(info.ID.ToString(), node);

                treeList.Add(node);
            }
            return(ToJsonContent(treeList));
        }
Esempio n. 15
0
        /// <summary>
        /// 递归获取树形信息
        /// </summary>
        /// <returns></returns>
        private void GetJsTreeJson(string PID, JsTreeData treeNode)
        {
            string condition             = string.Format("PID='{0}' ", PID);
            List <DictTypeInfo> nodeList = BLLFactory <DictType> .Instance.Find(condition);

            StringBuilder content = new StringBuilder();

            foreach (DictTypeInfo model in nodeList)
            {
                JsTreeData node = new JsTreeData(model.ID, model.Name, "fa fa-file icon-state-warning icon-lg");
                treeNode.children.Add(node);

                GetJsTreeJson(model.ID.ToString(), node);
            }
        }
Esempio n. 16
0
        /// <summary>
        /// 获取联系人分组树Json字符串
        /// </summary>
        /// <returns></returns>
        public ActionResult GetGroupJsTreeJson(string userId)
        {
            //添加一个未分类和全部客户的组别
            List <JsTreeData> treeList = new List <JsTreeData>();
            JsTreeData        pNode    = new JsTreeData("", "所有联系人", "fa fa-users icon-state-warning icon-lg");

            treeList.Insert(0, pNode);
            treeList.Add(new JsTreeData("", "未分组联系人", "fa fa-users icon-state-warning icon-lg"));

            List <ContactGroupNodeInfo> groupList = BLLFactory <ContactGroup> .Instance.GetTree(userId);

            AddContactGroupJsTree(groupList, pNode);

            return(ToJsonContent(treeList));
        }
Esempio n. 17
0
        /// <summary>
        /// 获取所有的省份
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllProvinceJsTree()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();
            JsTreeData        pNode    = new JsTreeData("", "选择记录", "fa fa-home icon-state-warning icon-lg");

            treeList.Add(pNode);

            List <ProvinceInfo> provinceList = BLLFactory <Province> .Instance.GetAll();

            foreach (ProvinceInfo info in provinceList)
            {
                JsTreeData item = new JsTreeData(info.ID, info.ProvinceName, "fa fa-file icon-state-warning icon-lg");
                pNode.children.Add(item);
            }
            return(ToJsonContent(treeList));
        }
Esempio n. 18
0
        public ActionResult GetGroupJsTree(string addressType)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            JsTreeData topNode = new JsTreeData("all", "所有联系人");

            treeList.Add(topNode);
            treeList.Add(new JsTreeData("ungroup", "未分组联系人"));

            AddressType type = (addressType == "public") ? AddressType.公共 : AddressType.个人;
            List <AddressGroupNodeInfo> groupList = BLLFactory <AddressGroup> .Instance.GetTree(type.ToString());

            AddContactGroupJsTree(groupList, topNode);

            return(ToJsonContent(treeList));
        }
Esempio n. 19
0
        /// <summary>
        /// 根据用户角色获取其对应的所能访问的权限集合
        /// </summary>
        /// <param name="userId">当前用户ID</param>
        /// <returns></returns>
        public ActionResult GetRoleFunctionJsTreeByUser(int userId)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            bool     isSuperAdmin = false;
            UserInfo userInfo     = BLLFactory <User> .Instance.FindByID(userId);

            if (userInfo != null)
            {
                isSuperAdmin = BLLFactory <User> .Instance.UserInRole(userInfo.Name, RoleInfo.SuperAdminName);
            }

            List <SystemTypeInfo> typeList = BLLFactory <SystemType> .Instance.GetAll();

            foreach (SystemTypeInfo typeInfo in typeList)
            {
                JsTreeData parentNode = new JsTreeData(typeInfo.OID, typeInfo.Name);

                //如果是超级管理员,不根据角色获取,否则根据角色获取对应的分配权限
                //也就是说,公司管理员只能分配自己被授权的功能,而超级管理员不受限制
                List <FunctionNodeInfo> allNode = new List <FunctionNodeInfo>();
                if (isSuperAdmin)
                {
                    allNode = BLLFactory <Functions> .Instance.GetTree(typeInfo.OID);
                }
                else
                {
                    allNode = BLLFactory <Functions> .Instance.GetFunctionNodesByUser(userId, typeInfo.OID);
                }

                AddJsTreeeFunctionNode(parentNode, allNode);
                treeList.Add(parentNode);
            }

            if (treeList.Count == 0)
            {
                treeList.Insert(0, new JsTreeData(-1, "无"));
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 20
0
        /// <summary>
        /// 获取用户的部门角色树结构(分级需要)(bootstrap的JSTree)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public ActionResult GetMyRoleJsTreeJson(int userId)
        {
            StringBuilder content  = new StringBuilder();
            UserInfo      userInfo = BLLFactory <User> .Instance.FindByID(userId);

            if (userInfo != null)
            {
                List <OUInfo> list = BLLFactory <OU> .Instance.GetMyTopGroup(CurrentUser.ID);

                foreach (OUInfo groupInfo in list)
                {
                    if (groupInfo != null && !groupInfo.Deleted)
                    {
                        JsTreeData topnode = new JsTreeData("dept" + groupInfo.ID, groupInfo.Name, GetBootstrapIcon(groupInfo.Category));
                        AddJsRole(groupInfo, topnode);

                        if (groupInfo.Category == "集团")
                        {
                            List <OUInfo> sublist = BLLFactory <OU> .Instance.GetAllCompany(groupInfo.ID);

                            foreach (OUInfo info in sublist)
                            {
                                if (!info.Deleted)
                                {
                                    JsTreeData companyNode = new JsTreeData("dept" + info.ID, info.Name, GetBootstrapIcon(info.Category));
                                    topnode.children.Add(companyNode);

                                    AddJsRole(info, companyNode);
                                }
                            }
                        }

                        content.Append(base.ToJson(topnode));
                    }
                }
            }

            string json = string.Format("[{0}]", content.ToString().Trim(','));

            return(Content(json));
        }
Esempio n. 21
0
        public ActionResult GetAddressGroupJsTree(string userId, string contactId, string addressType)
        {
            List <string> groupIdList = new List <string>();

            if (!string.IsNullOrEmpty(contactId))
            {
                List <AddressGroupInfo> myGroupList = BLLFactory <AddressGroup> .Instance.GetByContact(contactId);

                foreach (AddressGroupInfo info in myGroupList)
                {
                    groupIdList.Add(info.ID);
                }
            }

            AddressType type = (addressType == "public") ? AddressType.公共 : AddressType.个人;

            List <AddressGroupNodeInfo> groupList = new List <AddressGroupNodeInfo>();

            if (type == AddressType.个人)
            {
                groupList = BLLFactory <AddressGroup> .Instance.GetTree(type.ToString(), userId);
            }
            else
            {
                groupList = BLLFactory <AddressGroup> .Instance.GetTree(type.ToString());
            }

            List <JsTreeData> treeList = new List <JsTreeData>();

            foreach (AddressGroupNodeInfo nodeInfo in groupList)
            {
                bool       check = groupIdList.Contains(nodeInfo.ID);
                JsTreeData pNode = new JsTreeData(nodeInfo.ID, nodeInfo.Name, "");
                pNode.state = new JsTreeState(true, check);
                treeList.Add(pNode);
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 22
0
        /// <summary>
        /// 根据公司ID获取对应部门的树Json(bootstrap的JSTree)
        /// </summary>
        /// <param name="parentId">父部门ID</param>
        /// <returns></returns>
        public ActionResult GetDeptJsTreeJson(string parentId)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            treeList.Insert(0, new JsTreeData(-1, "无"));

            if (!string.IsNullOrEmpty(parentId) && parentId != "null")
            {
                OUInfo groupInfo = BLLFactory <OU> .Instance.FindByID(parentId);

                if (groupInfo != null)
                {
                    List <OUNodeInfo> list = BLLFactory <OU> .Instance.GetTreeByID(groupInfo.ID);

                    JsTreeData treeData = new JsTreeData(groupInfo.ID, groupInfo.Name, "fa fa-users icon-state-warning icon-lg");
                    GetJsTreeDataWithOUNode(list, treeData);

                    treeList.Add(treeData);
                }
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 23
0
        /// <summary>
        /// 获取用户的可操作功能
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public ActionResult GetFunctionJsTreeJsonByUser(int userId)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            List <SystemTypeInfo> typeList = BLLFactory <SystemType> .Instance.GetAll();

            foreach (SystemTypeInfo typeInfo in typeList)
            {
                JsTreeData parentNode        = new JsTreeData(typeInfo.OID, typeInfo.Name, "fa fa-sitemap  icon-state-warning icon-lg");
                List <FunctionNodeInfo> list = BLLFactory <Functions> .Instance.GetFunctionNodesByUser(userId, typeInfo.OID);

                AddJsTreeeFunctionNode(parentNode, list);

                treeList.Add(parentNode);
            }

            if (treeList.Count == 0)
            {
                treeList.Insert(0, new JsTreeData(-1, "无"));
            }

            return(ToJsonContent(treeList));
        }
Esempio n. 24
0
        /// <summary>
        /// 生成日志左侧系统列表的树结构
        /// </summary>
        /// <returns></returns>
        public ActionResult GetJsTreeJson()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            //添加一个未分类和全部客户的组别
            JsTreeData topNode = new JsTreeData("", "所有记录", "");

            treeList.Add(topNode);

            JsTreeData companyNode = new JsTreeData("", "所属公司", "");

            treeList.Add(companyNode);

            #region 获取机构列表
            List <OUInfo> companyList = new List <OUInfo>();

            /*if (BLLFactory<User>.Instance.UserInRole(CurrentUser.Name, RoleInfo.SuperAdminName))
             * {
             *  List<OUInfo> list = BLLFactory<OU>.Instance.GetMyTopGroup(CurrentUser.Id);
             *  foreach (OUInfo groupInfo in list)
             *  {
             *      companyList.AddRange(BLLFactory<OU>.Instance.GetAllCompany(groupInfo.Id));
             *  }
             * }
             * else
             * {
             *  OUInfo myCompanyInfo = BLLFactory<OU>.Instance.FindByID(CurrentUser.CompanyId);
             *  if (myCompanyInfo != null)
             *  {
             *      companyList.Add(myCompanyInfo);
             *  }
             * } */
            #endregion

            string belongCompany = "-1,";
            foreach (OUInfo info in companyList)
            {
                belongCompany += string.Format("{0},", info.Id);

                //添加公司节点
                JsTreeData subNode = new JsTreeData(info.Id, info.Name, "fa fa-sitemap icon-state-warning icon-lg");
                subNode.Gid = string.Format("CompanyId='{0}' ", info.Id);
                companyNode.children.Add(subNode);

                //下面在添加系统类型节点
                List <SystemTypeInfo> typeList = BLLFactory <SystemType> .Instance.GetAll();

                foreach (SystemTypeInfo typeInfo in typeList)
                {
                    JsTreeData typeNode = new JsTreeData(typeInfo.Gid, typeInfo.Name, "fa fa-home icon-state-danger icon-lg");
                    typeNode.Gid = string.Format("CompanyId='{0}' AND SystemtypeId='{1}' ", info.Id, typeInfo.Gid);
                    subNode.children.Add(typeNode);
                }

                JsTreeData securityNode = new JsTreeData("Security", "权限管理系统", "fa fa-key icon-state-info icon-lg");
                securityNode.Gid = string.Format("CompanyId='{0}' AND SystemtypeId='{1}' ", info.Id, "Security");
                subNode.children.Add(securityNode);
            }
            //修改全部为所属公司的ID
            belongCompany = belongCompany.Trim(',');
            topNode.Gid   = string.Format("CompanyId in ({0})", belongCompany);

            return(ToJsonContent(treeList));
        }