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("移动成功!");
        }
        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));
        }
        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());
        }