public ActionResult EditTeacher(int userid, string mode = "edit") { ViewBag.mode = mode; var model = _teacherManager.GetTeacher(userid); var user = SystemUsers.FirstOrDefault(p => p.UserId == userid) ?? new SysUser(); if (model == null) { model = new ResTeacher() { UserInfo = user, UserId = user.UserId }; //model.UserExtend = new SysUserExtend(); //return View(model); } else { model.UserInfo = user; } //model.UserExtend = _userManager.GetUserExtend(userid); //if (model.UserExtend == null) //{ //model.UserExtend = new SysUserExtend(); //model.UserExtend.UserId = model.UserId; //} return(View(model)); }
public JsonResult DeleteUser(string ids) { try { int[] idArray = ids.GetArray(); if (idArray.Length == 0) { return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.DeleteFailed }, JsonRequestBehavior.AllowGet)); } if (_userManager.BatchDeleteUser(idArray)) { foreach (var item in idArray) { var user = SystemUsers.FirstOrDefault(p => p.UserId == item); if (user == null) { continue; } user.Status = 1; } } //RetechWing.BusinessCache.SystemCache.Instance.RemoveCacheUser(1); return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.DeleteSuccess }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.DeleteFailed }, JsonRequestBehavior.AllowGet)); } }
private int GetRelationship(int userId, int userId2) { if (userId == userId2) { return(3); } var user = SystemUsers.First(p => p.UserId == userId); var user2 = SystemUsers.FirstOrDefault(p => p.UserId == userId2); if (user2 == null) { return(1); } //判断领导 if (user2.Leader == userId) { return(0); } //下属 if (user.Leader == userId2) { return(2); } //同事 return(1); }
public ActionResult ChangeLeader(int uid, int leader) { SysUser user = SystemUsers.FirstOrDefault(p => p.UserId == uid); if (user == null) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Usernotfound }, JsonRequestBehavior.AllowGet)); } user.Leader = leader; _userManager.UpdateUser(user); return(Json(new { result = 1, msg = RetechWing.LanguageResources.Common.UpdateSuccess }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 审批拒绝 /// </summary> /// <param name="classIds"></param> /// <param name="comefrom">0 年度计划 1 培训班 2 委外培训 </param> /// <param name="name">审批人</param> /// <param name="reason">审批意见</param> public void SendNoPass(string classIds, int comefrom, string name, string reason) { if (comefrom == 0)//年度计划 { var planList = _planManager.GetClassForSend(" tpc.PlanClassID in (" + classIds + ")"); var emailContent = GetFormworkContent(4); var emailContent2 = GetFormworkContent(8); foreach (var plan in planList) { if (plan.UpdateCount == 0) { var url = Url.RetechAction("YearePlanClass", "Plan", new { area = "Train", planClassId = plan.PlanClassID }); string sendEmail = string.Format(emailContent, plan.Realname, plan.Year, plan.TrainName, name, reason, url); SendMessage("年度计划审批结果通知——审批拒绝", sendEmail, new int[] { plan.CreateUserID }, 0); } else { var url = Url.RetechAction("YearePlanClass", "Plan", new { area = "Train", planClassId = plan.PlanClassID }); string sendEmail = string.Format(emailContent2, plan.Realname, plan.Year, plan.TrainName, name, reason, url); SendMessage("年度计划调整审批结果通知——审批拒绝", sendEmail, new int[] { plan.CreateUserID }, 0); } } } else if (comefrom == 1)//培训班 { var emailContent = GetFormworkContent(12); var classList = _otherManager.GetClassForSend(" tt.ClassId in (" + classIds + ")"); foreach (var item in classList) { var url = Url.RetechAction("ClassView", "Class", new { area = "Train", classId = item.ClassId }); var sendEmail = string.Format(emailContent, item.Realname, item.TrainName, name, reason, url); SendMessage("培训班开班策划审批结果通知——审批拒绝", sendEmail, new int[] { item.CreateUserID }, 0); } } else//委外培训 { var url = Url.RetechAction("OutsourcingTrainManage", "Plan", new { area = "Train" }); var totalCount = 0; var emailContent = GetFormworkContent(25); var outplan = _planManager.GetOuterPlanApproveLogList(out totalCount, " opu.ID in (" + classIds + ")").FirstOrDefault(); var user = SystemUsers.FirstOrDefault(p => p.UserId == outplan.CreateUserID); var sendEmail = string.Format(emailContent, user.Realname, outplan.DeptName, outplan.PostName, outplan.RealName, outplan.PlanName, name, reason, url); SendMessage("委外培训申请审批结果通知——审批拒绝", sendEmail, new int[] { user.UserId }, 0); } }
public JsonResult ResetPwd(int userId) { // SysUser user = _userManager.GetUserById(userId); SysUser user = SystemUsers.FirstOrDefault(p => p.UserId == userId); if (user == null) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Usernotfound }, JsonRequestBehavior.AllowGet)); } user.Password = "******".GetMd5(); _userManager.UpdateUser(user); return(Json(new { result = 1, msg = RetechWing.LanguageResources.SystemManage.Org.Defaultpassword }, JsonRequestBehavior.AllowGet)); }
public ActionResult TeacherDetail(int userid) { var model = _teacherManager.GetTeacher(userid); var user = SystemUsers.FirstOrDefault(p => p.UserId == userid) ?? new SysUser(); if (model == null) { model = new ResTeacher() { UserInfo = user, UserId = user.UserId }; } else { model.UserInfo = user; } return(View(model)); }
public JsonResult FreezeUser(int userId) { SysUser user = SystemUsers.FirstOrDefault(p => p.UserId == userId); if (user == null) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Usernotfound }, JsonRequestBehavior.AllowGet)); } user.Freezed = !user.Freezed; if (!user.Freezed) { user.LoginFailure = 0; } _userManager.UpdateUser(user); return(Json(new { result = 1, msg = user.Freezed ? RetechWing.LanguageResources.Common.YxtFreezerSuccess : RetechWing.LanguageResources.Common.YxtUnFreezerSuccess }, JsonRequestBehavior.AllowGet)); }
public JsonResult FreezeUsers(string ids) { try { var userids = ids.GetArray(); bool flag = _userManager.FreezeUser(userids); if (flag) { foreach (var item in userids) { var user = SystemUsers.FirstOrDefault(p => p.UserId == item); if (user == null) { continue; } user.Freezed = !user.Freezed; if (!user.Freezed) { user.LoginFailure = 0; } } } return(Json(new { result = 1, msg = flag ? RetechWing.LanguageResources.Common.OperationSuccessful : RetechWing.LanguageResources.Common.OperationFailed }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, msg = RetechWing.LanguageResources.Common.OperationFailed }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 年度计划非第一次审批通知 /// </summary> /// <param name="classIds">主键Ids</param> /// <param name="comefrom">0 年度计划 1 培训班 2 委外培训 </param> public void SendApproval2(string classIds, int comefrom) { var firstId = classIds != "" ? Convert.ToInt32(classIds.Split(',')[0]) : 0; //此时为通一个审批批次,查询第一个的下个节点即可 var userId = _planManager.GetNextApprovalUserID(firstId, comefrom); var user = SystemUsers.FirstOrDefault(p => p.UserId == userId); //查询审批流 #region 审批流程 var maxbatch = _planManager.GetMaxBatch(firstId); var approvelist = _planManager.GeTrPlanApproveList(firstId, 0, maxbatch).OrderBy(p => p.Step); var approveStr = ""; foreach (var approve in approvelist) { approveStr += approve.DeptName + "," + approve.PostName + "," + approve.Realname + "(" + approve.ApproveStatuStr + ")——"; } // ViewBag.approvelist = newApprovelist; #endregion if (comefrom == 0)//年度计划 { var emailContent = GetFormworkContent(2); var emailContent2 = GetFormworkContent(6); var planList = _planManager.GetClassForSend(" tpc.PlanClassID in (" + classIds + ")"); var url = Url.RetechAction("PlanApproval", "Approval", new { area = "Train" }); #region 年度计划 int totalCount = planList.Count(p => p.UpdateCount == 0); var htmlbody = new StringBuilder(); var DeptName = ""; var Year = 0; foreach (var plan in planList.Where(p => p.UpdateCount == 0)) { DeptName = plan.DeptName; Year = plan.Year; htmlbody.Append("<tr>"); htmlbody.Append("<td>" + plan.TrainCode + "</td>"); htmlbody.Append("<td>" + plan.TrainName + "</td>"); htmlbody.Append("<td>" + plan.Realname + "</td>"); htmlbody.Append("<td>" + plan.Number + "</td>"); htmlbody.Append("<td>" + plan.StartTimeStr + "至" + plan.EndTimeStr + "</td>"); htmlbody.Append("<td>" + plan.TrainCost + "</td>"); htmlbody.Append("</tr>"); } var sendEmail = string.Format(emailContent, user.Realname, DeptName, Year, totalCount, htmlbody, approveStr.TrimEnd(new char[] { '—', '—' }), url); SendMessage("年度计划审批通知", sendEmail, new int[] { user.UserId }, 0); #endregion #region 年度计划调整 foreach (var item in planList.Where(p => p.UpdateCount > 0)) { var sendEmail2 = string.Format(emailContent2, user.Realname, item.Year, item.TrainName, item.TrainCode, item.TrainName, item.UpdateTypeStr, item.UpdateReason, approveStr.TrimEnd(new char[] { '—', '—' }), url); SendMessage("年度计划调整审批通知", sendEmail2, new int[] { user.UserId }, 0); } #endregion } else if (comefrom == 1)//培训班 { var emailContent = GetFormworkContent(9); var emailContent2 = GetFormworkContent(13); var classList = _otherManager.GetClassForSend(" tt.ClassId in (" + classIds.TrimEnd(',').TrimStart(',') + ")"); var url = Url.RetechAction("ClassApproval", "Approval", new { area = "Train" }); foreach (var item in classList) { if (item.UpdateType == 0)//正常的培训班 { var sendEmail = string.Format(emailContent, user.Realname, item.TrainName, item.Code, item.TrainName, item.Realname, item.StartTimeStr, item.EndTimeStr, item.Number, item.sumCost, url); SendMessage("培训班开班策划审批", sendEmail, new int[] { user.UserId }, 0); } else//调整过后的 { var sendEmail = string.Format(emailContent2, user.Realname, item.TrainName, item.Code, item.TrainName, item.Realname, item.StartTimeStr, item.EndTimeStr, item.Number, item.sumCost, item.UpdateReason, approveStr.TrimEnd(new char[] { '—', '—' }), url); SendMessage("培训班调整审批通知", sendEmail, new int[] { user.UserId }, 0); } } } else//委外培训 { var totalCount = 0; var emailContent = GetFormworkContent(22); var outplanList = _planManager.GetOuterPlanApproveLogList(out totalCount, " opu.ID in (" + classIds + ")"); var url = Url.RetechAction("OuterPlanApprove", "Plan", new { area = "Train" }); foreach (var outplan in outplanList) { var sendEmail = string.Format(emailContent, user.Realname, outplan.DeptName, outplan.PostName, outplan.RealName, outplan.PlanName, outplan.LearnCompany, outplan.LearnAdress, outplan.StartTimeStr, outplan.EndTimeStr, outplan.LearnType, outplan.LearnCost, approveStr.TrimEnd(new char[] { '—', '—' }), url); SendMessage("委外培训审批通知", sendEmail, new int[] { user.UserId }, 0); } } }
public JsonResult SaveUser(string data, string RoleIds) { try { var user = JsonConvert.DeserializeObject <SysUser>(data); if (user == null) { return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet)); } user.Lookup = user.Realname.GetPy(); if (user.UserId == 0) { //add //user.UserCode = _userManager.GetMaxUserCode(CurrentTenant.TenantId); user.Password = "******".GetMd5(2); user.Photo = "~/UploadFiles/UserPhoto/man.png"; if (user.Sex == 2) { user.Photo = "~/UploadFiles/UserPhoto/woman.png"; } user.Phone = ""; user.Level = 1; user.TenantId = CurrentTenant.TenantId; user.Status = 0; user.Freezed = false; user.NamePin = ""; user.UserId = _userManager.AddUser(user); BusinessCache.SystemCache.RemoveCacheUser(); // SystemUsers.Add(user); } else { //edit //SysUser model = _userManager.GetUserById(user.UserId); SysUser model = SystemUsers.FirstOrDefault(p => p.UserId == user.UserId); if (model == null) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Usernotfound }, JsonRequestBehavior.AllowGet)); } if (model.TenantId != CurrentTenant.TenantId) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Usernotfound }, JsonRequestBehavior.AllowGet)); } if (model.Photo == "~/UploadFiles/UserPhoto/man.png" || model.Photo == "~/UploadFiles/UserPhoto/woman.png") { model.Photo = "~/UploadFiles/UserPhoto/man.png"; if (user.Sex == 2) { model.Photo = "~/UploadFiles/UserPhoto/woman.png"; } } model.Realname = user.Realname; model.Email = user.Email; model.Sex = user.Sex; model.JoinTime = user.JoinTime; model.Location = user.Location; if (model.Photo.Contains("woman.png") || model.Photo.Contains("man.png")) { if (model.Sex == 2) { model.Photo = "~/UploadFiles/UserPhoto/woman.png"; } else { model.Photo = "~/UploadFiles/UserPhoto/man.png"; } } var updateflag = model.PostId == user.PostId; model.DeptId = user.DeptId; model.PostId = user.PostId; model.PostName = user.PostName; model.DeptName = user.DeptName; if (user.Leader > 0) { if (user.Leader == user.UserId) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Notyourown }, JsonRequestBehavior.AllowGet)); } IEnumerable <SysUser> userlist = _userManager.GetAllUsers(CurrentTenant.TenantId); var tmpLeader = new List <int> { model.UserId }; while (true) { List <SysUser> tmp = userlist.Where(p => tmpLeader.Contains(p.Leader)).ToList(); if (tmp.Count == 0) { break; } tmpLeader = tmp.Select(p => p.UserId).ToList(); if (tmpLeader.Contains(user.Leader)) { return(Json(new { result = 0, content = RetechWing.LanguageResources.SystemManage.Org.Onyoursubordinates }, JsonRequestBehavior.AllowGet)); } } } model.Leader = user.Leader; model.UserType = user.UserType; _userManager.UpdateUser(model); if (!updateflag) { _userManager.UpdateUserPostPromotion(user.PostId, new int[] { user.UserId }); } if (model.UserId == CurrentUser.UserId) { CurrentUser.Photo = model.Photo; } SystemCache.Instance.ClearUserPermission(model.UserId); } //给用户赋角色 if (!string.IsNullOrEmpty(RoleIds)) { int[] rid = RoleIds.GetArray(); if (rid.Length > 0) { _roleManager.AddUsersToRoles(new[] { user.UserId }, rid); } } else { _roleManager.DeleteRolesToUser(new[] { user.UserId }); } return(Json(new { result = 1, content = RetechWing.LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.AllowGet)); } catch { return(Json(new { result = 0, content = RetechWing.LanguageResources.Common.SaveFailed }, JsonRequestBehavior.AllowGet)); } }