Exemplo n.º 1
0
        /// <summary>
        /// 获取所有的省份和城市列表
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllProvinceCity()
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        pNode    = new EasyTreeData("", "选择记录", "icon-computer");

            treeList.Add(pNode);

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

            foreach (ProvinceInfo info in provinceList)
            {
                //string condition = string.Format("ProvinceID={0}", info.ID);
                EasyTreeData item = new EasyTreeData("", info.ProvinceName, "icon-view");

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

                foreach (CityInfo cityInfo in cityList)
                {
                    //string condition = string.Format("CityID={0}", cityInfo.ID);
                    EasyTreeData subItem = new EasyTreeData(cityInfo.ID, cityInfo.CityName, "icon-view");
                    item.children.Add(subItem);
                }

                pNode.children.Add(item);
            }
            return(ToJsonContent(treeList));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取所有的功能树Json(用于树控件选择)
        /// </summary>
        /// <returns></returns>
        public ActionResult GetFunctionTreeJson()
        {
            List <EasyTreeData>   treeList = new List <EasyTreeData>();
            List <SystemTypeInfo> typeList = BLLFactory <SystemType> .Instance.GetAll();

            foreach (SystemTypeInfo typeInfo in typeList)
            {
                EasyTreeData pNode = new EasyTreeData(typeInfo.OID, typeInfo.Name, "icon-computer");
                treeList.Add(pNode);

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

                foreach (FunctionNodeInfo info in functionList)
                {
                    EasyTreeData item = new EasyTreeData(info.ID, info.Name, "icon-key");
                    pNode.children.Add(item);

                    AddChildNode(info.Children, item);
                }
            }

            return(ToJsonContent(treeList));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化并绑定客户个人分组信息
        /// </summary>
        public ActionResult GetMyContactGroup(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 <EasyTreeData> treeList = new List <EasyTreeData>();

            foreach (ContactGroupNodeInfo nodeInfo in groupList)
            {
                bool         check    = groupIdList.Contains(nodeInfo.ID);
                EasyTreeData treeData = new EasyTreeData(nodeInfo.ID, nodeInfo.Name);
                treeData.Checked = check;

                treeList.Add(treeData);
            }

            return(ToJsonContent(treeList));
        }
Exemplo n.º 4
0
 private void AddChildNode(List <MenuNodeInfo> list, EasyTreeData fnode)
 {
     foreach (MenuNodeInfo info in list)
     {
         EasyTreeData item = new EasyTreeData(info.ID, info.Name, "icon-view");
         fnode.children.Add(item);
         AddChildNode(info.Children, item);
     }
 }
Exemplo n.º 5
0
        private void AddRole(OUInfo ouInfo, EasyTreeData treeNode)
        {
            List <RoleInfo> roleList = BLLFactory <Role> .Instance.GetRolesByCompany(ouInfo.ID.ToString());

            foreach (RoleInfo roleInfo in roleList)
            {
                EasyTreeData roleNode = new EasyTreeData("role" + roleInfo.ID, roleInfo.Name, "icon-group-key");
                treeNode.children.Add(roleNode);
            }
        }
Exemplo n.º 6
0
        private void AddFunctionNode(EasyTreeData node, List <FunctionNodeInfo> list)
        {
            foreach (FunctionNodeInfo info in list)
            {
                EasyTreeData subNode = new EasyTreeData(info.ID, info.Name, info.Children.Count > 0 ? "icon-group-key" : "icon-key");
                node.children.Add(subNode);

                AddFunctionNode(subNode, info.Children);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 获取分组并绑定
        /// </summary>
        private void AddContactGroupTree(List <AddressGroupNodeInfo> nodeList, EasyTreeData treeNode)
        {
            foreach (AddressGroupNodeInfo nodeInfo in nodeList)
            {
                EasyTreeData subNode = new EasyTreeData(nodeInfo.Name, nodeInfo.Name, "icon-view");
                treeNode.children.Add(subNode);

                AddContactGroupTree(nodeInfo.Children, subNode);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 获取分组的树形列表,用作下拉列表
        /// </summary>
        /// <param name="addressType"></param>
        /// <returns></returns>
        public ActionResult GetTreeJson(string addressType)
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        topNode  = new EasyTreeData("", "选择记录", "icon-group");

            treeList.Add(topNode);

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

            AddGroupIDTree(groupList, topNode);

            return(ToJsonContent(treeList));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 获取联系人分组树Json字符串
        /// </summary>
        /// <returns></returns>
        public ActionResult GetGroupTreeJson(string userId)
        {
            //添加一个未分类和全部客户的组别
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        pNode    = new EasyTreeData("", "所有联系人");

            treeList.Insert(0, pNode);
            treeList.Add(new EasyTreeData("", "未分组联系人"));

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

            AddContactGroupTree(groupList, pNode);

            return(ToJsonContent(treeList));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 根据字典类型获取对应的字典数据,方便UI控件的绑定
        /// </summary>
        /// <param name="dictTypeName">字典类型名称</param>
        /// <returns></returns>
        public ActionResult GetDictTreeJson(string dictTypeName)
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        pNode    = new EasyTreeData("", "请选择");

            treeList.Insert(0, pNode);

            Dictionary <string, string> dict = BLLFactory <DictData> .Instance.GetDictByDictType(dictTypeName);

            foreach (string key in dict.Keys)
            {
                treeList.Add(new EasyTreeData(key, dict[key]));
            }
            return(ToJsonContent(treeList));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取所有的省份
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllProvince()
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        pNode    = new EasyTreeData("", "选择记录", "icon-computer");

            treeList.Add(pNode);

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

            foreach (ProvinceInfo info in provinceList)
            {
                EasyTreeData item = new EasyTreeData(info.ID, info.ProvinceName, "icon-view");
                pNode.children.Add(item);
            }
            return(ToJsonContent(treeList));
        }
Exemplo n.º 12
0
        /// <summary>
        /// 根据省份名称获取对应的城市列表
        /// </summary>
        /// <param name="provinceName">省份名称</param>
        /// <returns></returns>
        public ActionResult GetCitysByProvinceName(string provinceName)
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        pNode    = new EasyTreeData("", "选择记录", "icon-computer");

            treeList.Add(pNode);

            List <CityInfo> cityList = BLLFactory <City> .Instance.GetCitysByProvinceName(provinceName);

            foreach (CityInfo info in cityList)
            {
                EasyTreeData item = new EasyTreeData(info.ID, info.CityName, "icon-view");
                pNode.children.Add(item);
            }

            return(ToJsonContent(treeList));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 根据城市ID获取对应的行政区划类别
        /// </summary>
        /// <param name="cityName">城市名称</param>
        /// <returns></returns>
        public ActionResult GetDistrictByCity(string cityId)
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();
            EasyTreeData        pNode    = new EasyTreeData("", "选择记录", "icon-computer");

            treeList.Add(pNode);

            string condition = string.Format("");
            List <DistrictInfo> districtList = BLLFactory <District> .Instance.GetDistrictByCity(cityId);

            foreach (DistrictInfo info in districtList)
            {
                EasyTreeData item = new EasyTreeData(info.ID, info.DistrictName, "icon-view");
                pNode.children.Add(item);
            }

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

            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)
            {
                EasyTreeData parentNode = new EasyTreeData(typeInfo.OID, typeInfo.Name, "icon-organ");

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

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

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

            return(ToJsonContent(treeList));
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取用户的部门角色树结构(分级需要)
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns></returns>
        public ActionResult GetMyRoleTreeJson(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)
                    {
                        EasyTreeData topnode = new EasyTreeData("dept" + groupInfo.ID, groupInfo.Name, GetIconcls(groupInfo.Category));
                        AddRole(groupInfo, topnode);

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

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

                                    AddRole(info, companyNode);
                                }
                            }
                        }

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

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

            return(Content(json));
        }
Exemplo n.º 16
0
        public ActionResult GetAddressGroup(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 <EasyTreeData> treeList = new List <EasyTreeData>();

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

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

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

            foreach (SystemTypeInfo typeInfo in typeList)
            {
                EasyTreeData            parentNode = new EasyTreeData(typeInfo.OID, typeInfo.Name, "icon-organ");
                List <FunctionNodeInfo> list       = BLLFactory <Function> .Instance.GetFunctionNodesByUser(userId, typeInfo.OID);

                AddFunctionNode(parentNode, list);

                treeList.Add(parentNode);
            }

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

            return(ToJsonContent(treeList));
        }
Exemplo n.º 18
0
        public ActionResult GetTreeJson()
        {
            List <EasyTreeData> treeList = new List <EasyTreeData>();

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

            treeList.Add(topNode);

            EasyTreeData companyNode = new EasyTreeData("-2", "所属公司", "");

            treeList.Add(companyNode);

            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);
                }
            }

            string belongCompany = "-1,";

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

                //添加公司节点
                EasyTreeData subNode = new EasyTreeData(info.ID, info.Name, "icon-organ");
                companyNode.children.Add(subNode);

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

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

                EasyTreeData securityNode = new EasyTreeData("Security", "权限管理系统", "icon-key");
                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));
        }