Example #1
0
 private void SetFileIcon(MenuNodeInfo info, JsTreeData item)
 {
     if (info.Children.Count == 0)
     {
         item.icon = "fa fa-file icon-state-warning icon-lg";
     }
 }
Example #2
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));
        }
Example #3
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));
        }
Example #4
0
        public ActionResult GetMyApplyJson()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            //添加一个未分类和全部客户的组别
            var        condition = "";
            JsTreeData addNode   = new JsTreeData("add:", "我发起的", "");

            treeList.Add(addNode);
            var dict_status = EnumHelper.GetMemberKeyValue <ApplyStatus>();

            foreach (string key in dict_status.Keys)
            {
                ApplyStatus status = (ApplyStatus)dict_status[key];

                condition = string.Format("Editor='{0}' AND Status={1}", CurrentUser.ID, (int)status);
                var count = BLLFactory <Apply> .Instance.GetRecordCount(condition);

                var id      = string.Format("add:{0}", (int)status);
                var name    = string.Format("{0}({1})", key, count);
                var subNode = new JsTreeData(id, name, "");
                addNode.children.Add(subNode);
            }

            var dict = BLLFactory <DictData> .Instance.FindByDictType("表单类型");

            JsTreeData todoNode = new JsTreeData("todo:", "我的待办", "");

            treeList.Add(todoNode);
            foreach (var info in dict)
            {
                var applyIdString = BLLFactory <ApplyUser> .Instance.GetApplyIdByUser(CurrentUser.ID);

                condition = string.Format("Category='{0}' AND ID IN ({1})", info.Value, applyIdString);
                var count = BLLFactory <Apply> .Instance.GetRecordCount(condition);

                var id      = string.Format("todo:{0}", info.Value);
                var name    = string.Format("{0}({1})", info.Name, count);
                var subNode = new JsTreeData(id, name, "");
                todoNode.children.Add(subNode);
            }

            JsTreeData doneNode = new JsTreeData("done:", "我的已办", "");

            treeList.Add(doneNode);
            foreach (var info in dict)
            {
                var applyIdString = BLLFactory <ApplyUser> .Instance.GetApplyIdDone(CurrentUser.ID);

                condition = string.Format("Category='{0}' AND ID IN ({1})", info.Value, applyIdString);
                var count = BLLFactory <Apply> .Instance.GetRecordCount(condition);

                var id      = string.Format("done:{0}", info.Value);
                var name    = string.Format("{0}({1})", info.Name, count);
                var subNode = new JsTreeData(id, name, "");
                doneNode.children.Add(subNode);
            }

            return(ToJsonContent(treeList));
        }
Example #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));
        }
Example #6
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));
        }
Example #7
0
        /// <summary>
        /// 获取树形展示数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetJsTreeJson(bool update = false)
        {
            #region 使用MemoryCache缓存提高速度

            System.Reflection.MethodBase method = System.Reflection.MethodBase.GetCurrentMethod();
            string key = string.Format("{0}-{1}-{2}", method.DeclaringType.FullName, method.Name, "");

            if (update)
            {
                MemoryCacheHelper.RemoveItem(key);
            }

            var result = MemoryCacheHelper.GetCacheItem <ActionResult>(key,
                                                                       delegate()
            {
                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, node);

                    treeList.Add(node);
                }
                return(ToJsonContent(treeList));
            },
                                                                       new TimeSpan(0, 30, 0));//30分钟过期

            return(result);

            #endregion
        }
Example #8
0
        /// <summary>
        /// 获取所有的功能树Json
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllJsTreeJson()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();
            SystemTypeInfo    typeInfo = BLLFactory <SystemType> .Instance.FindByOID(ConfigData.SystemType);

            if (typeInfo != null)
            {
                var        pid   = typeInfo.OID;
                JsTreeData pNode = new JsTreeData(pid, typeInfo.Name);
                treeList.Add(pNode);

                string systemType = typeInfo.OID;//系统标识ID
                //绑定树控件
                List <FunctionNodeInfo> functionList = BLLFactory <Function> .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));
        }
Example #9
0
        /// <summary>
        /// 生成日志左侧系统列表的树结构
        /// </summary>
        /// <returns></returns>
        public ActionResult GetJsTreeJson()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

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

            treeList.Add(topNode);

            JsTreeData gradeNode = new JsTreeData("", "表单类型", "");

            treeList.Add(gradeNode);

            var dict = BLLFactory <DictData> .Instance.FindByDictType("表单类型");

            foreach (var info in dict)
            {
                //添加节点
                JsTreeData subNode = new JsTreeData(info.Name, info.Name, "fa fa-sitemap icon-state-warning icon-lg");
                subNode.id = string.Format("Category='{0}' ", info.Value);
                gradeNode.children.Add(subNode);
            }

            return(ToJsonContent(treeList));
        }
Example #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);
            }
        }
Example #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);
            }
        }
Example #12
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);
            }
        }
Example #13
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);
            }
        }
Example #14
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);
            }
        }
Example #15
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);
        }
Example #16
0
        /// <summary>
        /// 获取资产分类
        /// </summary>
        /// <returns></returns>
        public ActionResult GetClassName()
        {
            List <JsTreeData> result = new List <JsTreeData>();
            var dict = BLLFactory <Asset> .Instance.GetFieldList("ClassName");

            foreach (var name in dict)
            {
                JsTreeData treeData = new JsTreeData(name, name);
                result.Add(treeData);
            }

            return(ToJsonContent(result));
        }
Example #17
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, node);
            }
        }
Example #18
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));
        }
Example #19
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));
        }
Example #20
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));
        }
Example #21
0
        /// <summary>
        /// 获取菜单树Json字符串(Bootstrap的JSTree)
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMenuJsTreeJson()
        {
            //如果是超级管理员,不根据角色获取,否则根据角色获取对应的分配权限
            //也就是说,公司管理员只能分配自己被授权的功能,而超级管理员不受限制
            bool isSuperAdmin = BLLFactory <User> .Instance.UserInRole(CurrentUser.Name, RoleInfo.SuperAdminName);

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

            //List<SystemTypeInfo> typeList = BLLFactory<SystemType>.Instance.GetAll();
            //foreach (SystemTypeInfo typeInfo in typeList)
            {
                //仅仅显示本系统的类型的话
                SystemTypeInfo typeInfo = BLLFactory <SystemType> .Instance.FindByOID(ConfigData.SystemType);

                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 = null;
                if (isSuperAdmin)
                {
                    menuList = BLLFactory <Menu> .Instance.GetTree(systemType);
                }
                else
                {
                    menuList = BLLFactory <Menu> .Instance.GetMenuNodesByUser(CurrentUser.ID, typeInfo.OID);
                }

                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));
        }
Example #22
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);
            }

            SystemTypeInfo typeInfo = BLLFactory <SystemType> .Instance.FindByOID(ConfigData.SystemType);

            if (typeInfo != null)
            {
                JsTreeData parentNode = new JsTreeData(typeInfo.OID, typeInfo.Name);

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

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

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

            return(ToJsonContent(treeList));
        }
Example #23
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));
        }
Example #24
0
        public ActionResult GetAllApplyJson()
        {
            List <JsTreeData> treeList = new List <JsTreeData>();
            JsTreeData        topNode  = new JsTreeData("1=1", "所有申请单", "");

            treeList.Add(topNode);

            var dict = BLLFactory <DictData> .Instance.FindByDictType("表单类型");

            var dict_status = EnumHelper.GetMemberKeyValue <ApplyStatus>();
            var condition   = "";

            //表单类型
            foreach (var info in dict)
            {
                condition = string.Format("Category='{0}'", info.Value);
                var count = BLLFactory <Apply> .Instance.GetRecordCount(condition);

                var id      = condition;
                var name    = string.Format("{0}({1})", info.Name, count);
                var subNode = new JsTreeData(id, name, "");
                topNode.children.Add(subNode);

                //表单状态
                foreach (string key in dict_status.Keys)
                {
                    ApplyStatus status = (ApplyStatus)dict_status[key];

                    var subCondition = string.Format("{0} AND Status={1}", condition, (int)status);
                    count = BLLFactory <Apply> .Instance.GetRecordCount(subCondition);

                    id   = subCondition;
                    name = string.Format("{0}({1})", key, count);
                    var statusNode = new JsTreeData(id, name, "");
                    subNode.children.Add(statusNode);
                }
            }

            return(ToJsonContent(treeList));
        }
Example #25
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));
        }
Example #26
0
        /// <summary>
        /// 获取用户的可操作功能
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public ActionResult GetFunctionJsTreeJsonByUser(int userId)
        {
            List <JsTreeData> treeList = new List <JsTreeData>();

            SystemTypeInfo typeInfo = BLLFactory <SystemType> .Instance.FindByOID(ConfigData.SystemType);

            if (typeInfo != null)
            {
                JsTreeData parentNode        = new JsTreeData(typeInfo.OID, typeInfo.Name, "fa fa-sitemap  icon-state-warning icon-lg");
                List <FunctionNodeInfo> list = BLLFactory <Function> .Instance.GetFunctionNodesByUser(userId, typeInfo.OID);

                AddJsTreeeFunctionNode(parentNode, list);

                treeList.Add(parentNode);
            }

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

            return(ToJsonContent(treeList));
        }
Example #27
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));
        }
Example #28
0
        /// <summary>
        /// 获取树形展示数据
        /// </summary>
        /// <returns></returns>
        public ActionResult GetJsTreeJson(string dictTypeName)
        {
            #region 使用MemoryCache缓存提高速度
            System.Reflection.MethodBase method = System.Reflection.MethodBase.GetCurrentMethod();
            string key = string.Format("{0}-{1}-{2}", method.DeclaringType.FullName, method.Name, dictTypeName);

            var result = MemoryCacheHelper.GetCacheItem <List <JsTreeData> >(key,
                                                                             delegate()
            {
                List <JsTreeData> treeList       = new List <JsTreeData>();
                Dictionary <string, string> dict = BLLFactory <DictData> .Instance.GetDictByDictType(dictTypeName);
                foreach (string dictKey in dict.Keys)
                {
                    JsTreeData node = new JsTreeData(dict[dictKey], dictKey, "fa fa-file icon-state-warning icon-lg");
                    treeList.Add(node);
                }
                return(treeList);
            },
                                                                             new TimeSpan(0, 30, 0));//30分钟过期

            #endregion

            return(ToJsonContent(result));
        }
Example #29
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.Company_ID);

                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.id = string.Format("Company_ID='{0}' ", info.ID);
                companyNode.children.Add(subNode);

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

                foreach (SystemTypeInfo typeInfo in typeList)
                {
                    JsTreeData typeNode = new JsTreeData(typeInfo.OID, typeInfo.Name, "fa fa-home icon-state-danger icon-lg");
                    typeNode.id = string.Format("Company_ID='{0}' AND SystemType_ID='{1}' ", info.ID, typeInfo.OID);
                    subNode.children.Add(typeNode);
                }

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

            return(ToJsonContent(treeList));
        }