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 UserSortSave() { string sort = Request.Forms("sort"); string orgId = Request.Querys("orgparentid"); Business.OrganizeUser organizeUser = new Business.OrganizeUser(); List <Model.OrganizeUser> organizeUsers = organizeUser.GetListByOrganizeId(orgId.ToGuid()); int i = 0; foreach (string id in sort.Split(',')) { if (id.IsGuid(out Guid userId)) { var organizeUserModel = organizeUsers.Find(p => p.UserId == userId); if (null != organizeUserModel) { organizeUserModel.Sort = i += 5; } } } organizeUser.Update(organizeUsers.ToArray()); return("排序成功!"); }