public string Save(Model.Organize organizeModel)
 {
     if (!ModelState.IsValid)
     {
         return(Tools.GetValidateErrorMessag(ModelState));
     }
     Business.Organize organize = new Business.Organize();
     if (!"1".Equals(Request.Querys("isadddept")) && Request.Querys("orgid").IsGuid(out Guid guid))
     {
         var    oldModel = organize.Get(guid);
         string oldJSON  = null == oldModel ? "" : oldModel.ToString();
         organize.Update(organizeModel);
         if (organizeModel.Status == 1)
         {
             //如果是冻结了机构,则要向企业微信冻结下面的所有人员
             if (Config.Enterprise_WeiXin_IsUse)
             {
                 var allUsers = new Business.Organize().GetAllUsers(organizeModel.Id, false);
                 Business.EnterpriseWeiXin.Organize wxOrganize = new Business.EnterpriseWeiXin.Organize();
                 foreach (var user in allUsers)
                 {
                     user.Status = 1;
                     wxOrganize.UpdateUser(user);
                 }
             }
         }
         Business.Log.Add("修改了组织机构-" + organizeModel.Name, type: Business.Log.Type.系统管理, oldContents: oldJSON, newContents: organizeModel.ToString());
     }
     else
     {
         organize.Add(organizeModel);
         Business.Log.Add("添加了组织机构-" + organizeModel.Name, organizeModel.ToString(), Business.Log.Type.系统管理);
     }
     return("保存成功!");
 }
示例#2
0
        public string Member_GetNote()
        {
            string id = Request.Querys("id");

            if (id.IsNullOrWhiteSpace())
            {
                return("");
            }
            Business.Organize     organize     = new Business.Organize();
            Business.User         user         = new Business.User();
            Business.OrganizeUser organizeUser = new Business.OrganizeUser();
            if (id.StartsWith(Business.Organize.PREFIX_USER))//人员
            {
                var organizeUserModel = organizeUser.GetMainByUserId(id.RemoveUserPrefix().ToGuid());
                return(organize.GetParentsName(organizeUserModel.OrganizeId) + " \\ " + organize.GetName(organizeUserModel.OrganizeId));
            }
            else if (id.StartsWith(Business.Organize.PREFIX_RELATION))//兼职人员
            {
                var organizeUserModel = organizeUser.Get(id.RemoveUserRelationPrefix().ToGuid());
                return(organize.GetParentsName(organizeUserModel.OrganizeId) + " \\ " + organize.GetName(organizeUserModel.OrganizeId) + "[兼任]");
            }
            else if (id.StartsWith(Business.Organize.PREFIX_WORKGROUP))//工作组
            {
                return("");
            }
            else if (id.IsGuid(out Guid gid))
            {
                return(organize.GetParentsName(gid) + " \\ " + organize.GetName(gid));
            }
            return("");
        }
        public string MoveUser()
        {
            string toOrgId = Request.Forms("toOrgId");
            string isjz    = Request.Forms("isjz");
            string userId  = Request.Querys("userid");

            if (!toOrgId.IsGuid(out Guid toId))
            {
                return("没有选择要调往的组织");
            }
            var organizeModel = new Business.Organize().Get(toId);

            if (null == organizeModel)
            {
                return("没有找到要调往的组织");
            }
            if (!userId.IsGuid(out Guid uId))
            {
                return("人员ID错误");
            }
            Business.OrganizeUser organizeUser = new Business.OrganizeUser();
            if ("1".Equals(isjz))//兼职调动
            {
                Model.OrganizeUser organizeUserModel = new Model.OrganizeUser
                {
                    Id         = Guid.NewGuid(),
                    IsMain     = 0,
                    OrganizeId = toId,
                    UserId     = uId,
                    Sort       = organizeUser.GetMaxSort(organizeModel.ParentId)
                };
                organizeUser.Add(organizeUserModel);
            }
            else //全职
            {
                List <Tuple <Model.OrganizeUser, int> > tuples = new List <Tuple <Model.OrganizeUser, int> >();
                var organizeUsers = organizeUser.GetListByUserId(uId);
                foreach (var organizeUserModel in organizeUsers)
                {
                    if (organizeUserModel.IsMain == 1)
                    {
                        organizeUserModel.OrganizeId = toId;
                        organizeUserModel.Sort       = organizeUser.GetMaxSort(organizeModel.ParentId);
                        tuples.Add(new Tuple <Model.OrganizeUser, int>(organizeUserModel, 2));
                    }
                    else
                    {
                        tuples.Add(new Tuple <Model.OrganizeUser, int>(organizeUserModel, 0));
                    }
                }
                organizeUser.Update(tuples);
                //同步企业微信人员(更新人员所在职务)
                if (Config.Enterprise_WeiXin_IsUse)
                {
                    new Business.EnterpriseWeiXin.Organize().UpdateUser(new Business.User().Get(uId));
                }
            }
            Business.Log.Add("调动了人员-" + uId + ("1".Equals(isjz) ? "-兼任" : "-全职"), toOrgId, Business.Log.Type.系统管理);
            return("调动成功!");
        }
        public string TreeRefresh()
        {
            int    showType  = Request.Querys("showtype").ToString().ToInt(0);
            bool   showUser  = !"0".Equals(Request.Querys("shouser"));
            string refreshId = Request.Querys("refreshid");

            Business.Organize           organize = new Business.Organize();
            Newtonsoft.Json.Linq.JArray jArray   = new Newtonsoft.Json.Linq.JArray();

            #region 显示工作组
            if (1 == showType)
            {
                return("");
            }
            #endregion

            if (refreshId.IsGuid(out Guid guid))
            {
                var childs = organize.GetChilds(guid);
                foreach (var child in childs)
                {
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", child.Id },
                        { "parentID", child.ParentId },
                        { "title", child.Name },
                        { "ico", "" },
                        { "link", "" },
                        { "type", child.Type },
                        { "hasChilds", organize.HasChilds(child.Id) ? 1 : showUser?organize.HasUsers(child.Id) ? 1 : 0 : 0 }
                    };
                    jArray.Add(jObject);
                }
                if (showUser)
                {
                    var users         = organize.GetUsers(guid);
                    var organizeUsers = new Business.OrganizeUser().GetListByOrganizeId(guid);
                    foreach (var userModel in users)
                    {
                        var  organizeUserModel1 = organizeUsers.Find(p => p.UserId == userModel.Id);
                        bool isPartTime         = organizeUserModel1.IsMain != 1;//是否是兼职
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", isPartTime ? organizeUserModel1.Id : userModel.Id },
                            { "parentID", guid },
                            { "title", userModel.Name + (isPartTime ? "<span style='color:#666;'>[兼任]</span>" : "") },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "userID", userModel.Id },
                            { "type", isPartTime ? 6 : 4 },
                            { "hasChilds", 0 }
                        };
                        jArray.Add(jObject);
                    }
                }
            }
            return(jArray.ToString());
        }
示例#5
0
        public IActionResult Member_Index()
        {
            string values       = Request.Method.EqualsIgnoreCase("post") ? Request.Forms("value") : "";
            string eid          = Request.Querys("eid");
            string isunit       = Request.Querys("isunit");
            string isdept       = Request.Querys("isdept");
            string isstation    = Request.Querys("isstation");
            string isuser       = Request.Querys("isuser");
            string ismore       = Request.Querys("ismore");
            string isall        = Request.Querys("isall");
            string isgroup      = Request.Querys("isgroup");
            string isrole       = Request.Querys("isrole");
            string rootid       = Request.Querys("rootid");
            string ischangetype = Request.Querys("ischangetype");
            string isselect     = Request.Querys("isselect");
            string ismobile     = Request.Querys("ismobile");

            Business.Organize organize      = new Business.Organize();
            StringBuilder     stringBuilder = new StringBuilder();

            foreach (string value in values.Split(','))
            {
                if (value.IsNullOrEmpty())
                {
                    continue;
                }
                string name = organize.GetNames(value);
                if (name.IsNullOrEmpty())
                {
                    continue;
                }
                stringBuilder.AppendFormat("<div onclick=\"currentDel=this;showinfo('{0}');\" class=\"selectorDiv\" ondblclick=\"currentDel=this;del();\" value=\"{0}\">", value);
                stringBuilder.Append(name);
                stringBuilder.Append("</div>");
            }

            ViewData["eid"]             = eid;
            ViewData["isunit"]          = isunit;
            ViewData["isdept"]          = isdept;
            ViewData["isstation"]       = isstation;
            ViewData["isuser"]          = isuser;
            ViewData["ismore"]          = ismore;
            ViewData["isall"]           = isall;
            ViewData["isgroup"]         = isgroup;
            ViewData["isrole"]          = isrole;
            ViewData["rootid"]          = rootid;
            ViewData["ischangetype"]    = ischangetype;
            ViewData["isselect"]        = isselect;
            ViewData["values"]          = values;
            ViewData["userprefix"]      = Business.Organize.PREFIX_USER;
            ViewData["relationprefix"]  = Business.Organize.PREFIX_RELATION;
            ViewData["workgroupprefix"] = Business.Organize.PREFIX_WORKGROUP;
            ViewData["defaultValues"]   = stringBuilder.ToString();
            ViewData["ismobile"]        = ismobile;
            return(View());
        }
        public IActionResult Index()
        {
            var rootOrg = new Business.Organize().GetRoot();

            ViewData["queryString"] = Request.UrlQuery();
            ViewData["bodyUrl"]     = null == rootOrg ? string.Empty :
                                      "Body?orgid=" + rootOrg.Id.ToString() + "&orgparentid=" + rootOrg.ParentId.ToString() + "&type=" + rootOrg.Type.ToString()
                                      + "&showtype=0&appid=" + Request.Querys("appid") + "&tabid=" + Request.Querys("tabid");
            return(View());
        }
        public IActionResult UserSort()
        {
            string orgId = Request.Querys("orgparentid");

            Business.Organize organize = new Business.Organize();
            Business.User     user     = new Business.User();
            var users = organize.GetAllUsers(orgId.ToGuid());

            ViewData["queryString"] = Request.UrlQuery();
            ViewData["refreshId"]   = orgId;
            return(View(users));
        }
        public IActionResult Sort()
        {
            string parentId = Request.Querys("orgparentid");
            IEnumerable <Model.Organize> organizes = new List <Model.Organize>();

            if (parentId.IsGuid(out Guid guid))
            {
                organizes = new Business.Organize().GetChilds(guid);
            }
            ViewData["queryString"] = Request.UrlQuery();
            ViewData["refreshId"]   = parentId;
            return(View(organizes));
        }
        public string DeptMove()
        {
            string toOrgId = Request.Forms("toOrgId");
            string orgid   = Request.Querys("orgid");

            if (!toOrgId.IsGuid(out Guid toGuid))
            {
                return("请选择要移动到的组织架构");
            }
            if (!orgid.IsGuid(out Guid orgId))
            {
                return("没有找到当前组织架构");
            }
            if (toGuid == orgId)
            {
                return("不能将自己移动到自己");
            }
            Business.Organize organize = new Business.Organize();
            if (orgId == organize.GetRootId())
            {
                return("不能移动根");
            }
            var org = organize.Get(orgId);

            if (null == org)
            {
                return("没有找到当前组织架构");
            }
            var toOrg = organize.Get(toGuid);

            if (null == toOrg)
            {
                return("没有找到要移动到的组织架构");
            }
            org.ParentId = toGuid;
            org.Sort     = organize.GetMaxSort(toGuid);
            organize.Update(org);
            //同步企业微信人员(更新机构下所有人员的职务)
            if (Config.Enterprise_WeiXin_IsUse)
            {
                var allUsers = new Business.Organize().GetAllUsers(org.Id, false);
                Business.EnterpriseWeiXin.Organize wxOrganize = new Business.EnterpriseWeiXin.Organize();
                foreach (var user in allUsers)
                {
                    wxOrganize.UpdateUser(user);
                }
            }
            Business.Log.Add("移动了组织架构-" + org.Name + "到" + toOrg.Name, org.Id + "&" + toOrg.Id, Business.Log.Type.系统管理);
            return("移动成功!");
        }
示例#10
0
        /// <summary>
        /// 删除机构
        /// </summary>
        /// <returns></returns>
        public string Delete()
        {
            string orgId = Request.Querys("orgid");

            if (!orgId.IsGuid(out Guid guid))
            {
                return("id错误!");
            }
            if (guid == new Business.Organize().GetRootId())
            {
                return("请勿删除组织机构根!");
            }
            int i = new Business.Organize().Delete(guid);

            return(i > 0 ? "删除成功!" : "删除失败!");
        }
示例#11
0
        public string SaveSetMenu()
        {
            string id = Request.Querys("orgid");

            if (id.IsNullOrWhiteSpace())
            {
                id = Request.Querys("workgroupid");
                if (!id.IsNullOrWhiteSpace())
                {
                    id = Business.Organize.PREFIX_WORKGROUP + id;
                }
            }
            if (id.IsNullOrWhiteSpace())
            {
                id = Request.Querys("userid");
                if (!id.IsNullOrWhiteSpace())
                {
                    id = Business.Organize.PREFIX_USER + id;
                }
            }
            Business.MenuUser     menuUser  = new Business.MenuUser();
            Business.Organize     organize  = new Business.Organize();
            string                menuids   = Request.Forms("menuid");
            List <Model.MenuUser> menuUsers = new List <Model.MenuUser>();

            foreach (string menuId in menuids.Split(','))
            {
                if (!menuId.IsGuid(out Guid mid))
                {
                    continue;
                }
                Model.MenuUser menuUserModel = new Model.MenuUser()
                {
                    Id        = Guid.NewGuid(),
                    Buttons   = Request.Forms("button_" + menuId),
                    MenuId    = mid,
                    Organizes = id,
                    Params    = Request.Forms("params_" + menuId)
                };
                menuUsers.Add(menuUserModel);
            }
            int i = menuUser.Update(menuUsers.ToArray(), id);

            Business.Log.Add("设置了组织架构菜单-" + id, "影响行数:" + i.ToString(), Business.Log.Type.系统管理);
            return("设置成功!");
        }
示例#12
0
        public IActionResult Body()
        {
            string orgId     = Request.Querys("orgid");
            string parentId  = Request.Querys("orgparentid");
            string isAddDept = Request.Querys("isadddept");
            string type      = Request.Querys("type");
            string showType  = Request.Querys("showtype");
            string appId     = Request.Querys("appid");
            string tabId     = Request.Querys("tabid");

            Model.Organize    organizeModel = null;
            Business.Organize organize      = new Business.Organize();
            if (orgId.IsGuid(out Guid guid) && !"1".Equals(isAddDept))
            {
                organizeModel = organize.Get(guid);
            }
            if (null == organizeModel)
            {
                organizeModel = new Model.Organize
                {
                    Id       = Guid.NewGuid(),
                    ParentId = orgId.ToGuid(),
                    Sort     = organize.GetMaxSort(orgId.ToGuid())
                };
                organizeModel.IntId     = organizeModel.Id.ToInt();
                ViewData["parentsName"] = "";
            }
            else
            {
                organizeModel.IntId     = organizeModel.Id.ToInt();
                ViewData["parentsName"] = organize.GetParentsName(organizeModel.Id);
            }
            ViewData["orgId"]       = orgId;
            ViewData["isAddDept"]   = isAddDept;
            ViewData["queryString"] = Request.UrlQuery();
            ViewData["refreshId"]   = organizeModel.ParentId;
            ViewData["rootId"]      = organize.GetRootId();
            ViewData["returnUrl"]   = "Body?orgid=" + orgId + "&orgparentid=" + parentId + "&type=" + type + "&showtype=" + showType + "&appid" + appId + "&tabid=" + tabId;
            return(View(organizeModel));
        }
示例#13
0
        public string SaveSort()
        {
            string sorts = Request.Forms("sort");

            Business.Organize     organize  = new Business.Organize();
            List <Model.Organize> organizes = new List <Model.Organize>();
            int i = 0;

            foreach (string sort in sorts.Split(','))
            {
                if (sort.IsGuid(out Guid orgId))
                {
                    var org = organize.Get(orgId);
                    if (null != org)
                    {
                        org.Sort = i += 5;
                        organizes.Add(org);
                    }
                }
            }
            organize.Update(organizes.ToArray());
            return("排序成功!");
        }
示例#14
0
        public string SaveGoTo()
        {
            string taskid = Request.Querys("taskid");
            string steps  = Request.Forms("step");

            if (!taskid.IsGuid(out Guid taskId))
            {
                return("任务ID错误!");
            }
            Business.FlowTask flowTask = new Business.FlowTask();
            var taskModel = flowTask.Get(taskId);

            if (null == taskModel)
            {
                return("未找到当前任务!");
            }
            Dictionary <Guid, List <Model.User> > dicts = new Dictionary <Guid, List <Model.User> >();

            Business.Organize organize = new Business.Organize();
            foreach (string step in steps.Split(','))
            {
                if (!step.IsGuid(out Guid stepId))
                {
                    continue;
                }
                string member = Request.Forms("member_" + step);
                if (member.IsNullOrWhiteSpace())
                {
                    continue;
                }
                dicts.Add(stepId, organize.GetAllUsers(member));
            }
            string msg = new Business.FlowTask().GoTo(taskModel, dicts);

            Business.Log.Add("跳转了任务-" + taskModel.Title, taskModel.ToString() + "-" + msg, Business.Log.Type.流程运行, others: Newtonsoft.Json.JsonConvert.SerializeObject(dicts));
            return("1".Equals(msg) ? "跳转成功!" : msg);
        }
示例#15
0
        public string Tree1()
        {
            int    showType   = Request.Querys("showtype").ToString().ToInt(0);//显示类型 0组织架构 1角色组
            string rootId     = Request.Querys("rootid");
            string searchWord = Request.Querys("searchword");
            bool   showUser   = !"0".Equals(Request.Querys("shouser"));

            Business.Organize     organize     = new Business.Organize();
            Business.User         user         = new Business.User();
            Business.WorkGroup    workGroup    = new Business.WorkGroup();
            Business.OrganizeUser organizeUser = new Business.OrganizeUser();
            var  organizeUserList = organizeUser.GetAll();
            Guid orgRootId        = organize.GetRootId();

            Newtonsoft.Json.Linq.JArray jArray = new Newtonsoft.Json.Linq.JArray();

            #region 搜索
            if (!searchWord.IsNullOrWhiteSpace())
            {
                Guid parentId = Guid.NewGuid();
                if (1 == showType)//搜索工作组
                {
                    var workGroups = workGroup.GetAll().FindAll(p => p.Name.ContainsIgnoreCase(searchWord.Trim()));
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", parentId },
                        { "parentID", Guid.Empty },
                        { "title", "查询“" + searchWord + "”的结果" },
                        { "ico", "fa-search" },
                        { "link", "" },
                        { "type", 1 },
                        { "hasChilds", workGroups.Count }
                    };
                    jArray.Add(jObject);
                    Newtonsoft.Json.Linq.JArray jArray1 = new Newtonsoft.Json.Linq.JArray();
                    foreach (var group in workGroups)
                    {
                        Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", group.Id },
                            { "parentID", parentId },
                            { "title", group.Name },
                            { "ico", "fa-slideshare" },
                            { "link", "" },
                            { "type", 5 },
                            { "hasChilds", 0 }
                        };
                        jArray1.Add(jObject1);
                    }
                    jObject.Add("childs", jArray1);
                }
                else //搜索组织和人员
                {
                    var organizes = organize.GetAll().FindAll(p => p.Name.ContainsIgnoreCase(searchWord.Trim()));
                    var users     = user.GetAll().FindAll(p => p.Name.ContainsIgnoreCase(searchWord.Trim()));
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", parentId },
                        { "parentID", Guid.Empty },
                        { "title", "查询“" + searchWord + "”的结果" },
                        { "ico", "fa-search" },
                        { "link", "" },
                        { "type", 1 },
                        { "hasChilds", organizes.Count + users.Count }
                    };
                    jArray.Add(jObject);
                    Newtonsoft.Json.Linq.JArray jArray1 = new Newtonsoft.Json.Linq.JArray();
                    foreach (var organizeModel in organizes)
                    {
                        Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", organizeModel.Id },
                            { "parentID", parentId },
                            { "title", organizeModel.Name },
                            { "ico", "" },
                            { "link", "" },
                            { "type", organizeModel.Type },
                            { "hasChilds", organize.HasChilds(organizeModel.Id) ? 1 : 0 }
                        };
                        jArray1.Add(jObject1);
                    }
                    foreach (var userModel in users)
                    {
                        Newtonsoft.Json.Linq.JObject jObject1 = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", userModel.Id },
                            { "parentID", parentId },
                            { "title", userModel.Name },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "userID", userModel.Id },
                            { "type", 4 },
                            { "hasChilds", 0 }
                        };
                        jArray1.Add(jObject1);
                    }
                    jObject.Add("childs", jArray1);
                }
                return(jArray.ToString());
            }
            #endregion

            #region 显示角色组
            if (1 == showType)
            {
                var workgroups = workGroup.GetAll();
                foreach (var workgroupModel in workgroups)
                {
                    Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                    {
                        { "id", workgroupModel.Id },
                        { "parentID", Guid.Empty },
                        { "title", workgroupModel.Name },
                        { "ico", "fa-slideshare" },
                        { "link", "" },
                        { "type", 5 },
                        { "hasChilds", 0 }
                    };
                    jArray.Add(jObject);
                }
                return(jArray.ToString());
            }
            #endregion

            if (rootId.IsNullOrWhiteSpace())
            {
                rootId = orgRootId.ToString();
            }
            #region 添加根节点
            string[] rootIdArray = rootId.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string root in rootIdArray)
            {
                if (root.IsGuid(out Guid guid))//组织机构
                {
                    var organizeModel = organize.Get(guid);
                    if (null != organizeModel)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", organizeModel.Id },
                            { "parentID", organizeModel.ParentId },
                            { "title", organizeModel.Name },
                            { "ico", organizeModel.Id == orgRootId ? "fa-sitemap" : "" },
                            { "link", "" },
                            { "type", organizeModel.Type },
                            { "hasChilds", organize.HasChilds(organizeModel.Id) ? 1 : showUser?organize.HasUsers(organizeModel.Id) ? 1 : 0 : 0 }
                        };
                        jArray.Add(jObject);
                    }
                }
                else if (root.StartsWith(Business.Organize.PREFIX_USER))//人员
                {
                    var userModel = user.Get(root.RemoveUserPrefix().ToGuid());
                    if (null != userModel)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", userModel.Id },
                            { "parentID", Guid.Empty },
                            { "title", userModel.Name },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "type", 4 },
                            { "hasChilds", 0 }
                        };
                        jArray.Add(jObject);
                    }
                }
                else if (root.StartsWith(Business.Organize.PREFIX_RELATION))//兼职人员
                {
                    var organizeUserModel = organizeUser.Get(root.RemoveUserRelationPrefix().ToGuid());
                    if (null != organizeUserModel)
                    {
                        var userModel = user.Get(organizeUserModel.UserId);
                        if (null != userModel)
                        {
                            Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                            {
                                { "id", organizeUserModel.Id },
                                { "parentID", Guid.Empty },
                                { "title", userModel.Name + "<span style='color:#666;'>[兼任]</span>" },
                                { "ico", "fa-user" },
                                { "link", "" },
                                { "type", 6 },
                                { "userID", userModel.Id },
                                { "hasChilds", 0 }
                            };
                            jArray.Add(jObject);
                        }
                    }
                }
                else if (root.StartsWith(Business.Organize.PREFIX_WORKGROUP))//工作组
                {
                    var workgroupModel = workGroup.Get(root.RemoveWorkGroupPrefix().ToGuid());
                    if (null != workgroupModel)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", workgroupModel.Id },
                            { "parentID", Guid.Empty },
                            { "title", workgroupModel.Name },
                            { "ico", "fa-slideshare" },
                            { "link", "" },
                            { "type", 5 },
                            { "hasChilds", workGroup.GetAllUsers(workgroupModel.Id).Count }
                        };
                        jArray.Add(jObject);
                    }
                }
            }
            #endregion

            #region 只有一个根时显示二级
            if (rootIdArray.Length == 1)
            {
                string rootIdString = rootIdArray[0];
                if (rootIdString.IsGuid(out Guid guid))
                {
                    var jObject0 = (Newtonsoft.Json.Linq.JObject)jArray[0];
                    Newtonsoft.Json.Linq.JArray jArray0 = new Newtonsoft.Json.Linq.JArray();
                    var childs        = organize.GetChilds(guid);
                    var organizeUser1 = organizeUserList.FindAll(p => p.OrganizeId == guid);
                    foreach (var child in childs)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", child.Id },
                            { "parentID", child.ParentId },
                            { "title", child.Name },
                            { "ico", "" },
                            { "link", "" },
                            { "type", child.Type },
                            { "hasChilds", organize.HasChilds(child.Id) ? 1 : showUser?organize.HasUsers(child.Id) ? 1 : 0 : 0 }
                        };
                        jArray0.Add(jObject);
                    }
                    if (showUser)
                    {
                        var users = organize.GetUsers(guid);
                        foreach (var userModel in users)
                        {
                            var  organizeUserModel1 = organizeUser1.Find(p => p.UserId == userModel.Id);
                            bool isPartTime         = organizeUserModel1.IsMain != 1;//是否是兼职
                            Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                            {
                                { "id", isPartTime ? organizeUserModel1.Id : userModel.Id },
                                { "parentID", guid },
                                { "title", userModel.Name + (isPartTime ? "<span style='color:#666;'>[兼任]</span>" : "") },
                                { "ico", "fa-user" },
                                { "link", "" },
                                { "userID", userModel.Id },
                                { "type", isPartTime ? 6 : 4 },
                                { "hasChilds", 0 }
                            };
                            jArray0.Add(jObject);
                        }
                    }
                    jObject0.Add("childs", jArray0);
                }
                else if (rootIdString.StartsWith(Business.Organize.PREFIX_WORKGROUP))
                {
                    var jObject0 = (Newtonsoft.Json.Linq.JObject)jArray[0];
                    Newtonsoft.Json.Linq.JArray jArray0 = new Newtonsoft.Json.Linq.JArray();
                    var users = workGroup.GetAllUsers(rootIdString.RemoveWorkGroupPrefix().ToGuid());
                    foreach (var userModel in users)
                    {
                        Newtonsoft.Json.Linq.JObject jObject = new Newtonsoft.Json.Linq.JObject()
                        {
                            { "id", userModel.Id },
                            { "parentID", rootIdString.RemoveWorkGroupPrefix() },
                            { "title", userModel.Name },
                            { "ico", "fa-user" },
                            { "link", "" },
                            { "type", 4 },
                            { "hasChilds", 0 }
                        };
                        jArray0.Add(jObject);
                    }
                    jObject0.Add("childs", jArray0);
                }
            }
            #endregion

            return(jArray.ToString());
        }