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