private void SynchEmpPerformance(string userID, S_P_Performance performance, string role) { var workPerformance = this.entities.Set <T_EmployeeWorkPerformance>().FirstOrDefault(d => d.RelateID == performance.ID && d.UserID == userID); if (workPerformance == null) { workPerformance = new T_EmployeeWorkPerformance(); workPerformance.SynchEmpPerformance(userID, performance, role); this.entities.Set <T_EmployeeWorkPerformance>().Add(workPerformance); } else { workPerformance.ProjectRole += "," + role; } this.entities.SaveChanges(); }
public void SynchEmpPerformance(string userID, S_P_Performance performance, string role) { this.ID = FormulaHelper.CreateGuid(); this.Name = performance.Name; this.Code = performance.Code; this.ProjectClass = performance.ProjectClass; this.ProjectLevel = performance.ProjectLevel; this.ProjectState = performance.ProjectState; this.PlanStartDate = performance.PlanStartDate; this.FactFinishDate = performance.FactFinishDate; this.UserID = userID; this.RelateID = performance.ID; this.ProjectRole = role; var hrEntity = FormulaHelper.GetEntities <HREntities>(); var empInfo = hrEntity.Set <T_Employee>().FirstOrDefault(d => d.UserID == userID && d.IsDeleted == "0"); if (empInfo != null) { this.EmployeeID = empInfo.ID; } }
public string AddPerformanceInfo(string row) { var rowData = JsonHelper.ToObject(row); var performance = new S_P_Performance(); performance.ID = FormulaHelper.CreateGuid(); this.UpdateEntity <S_P_Performance>(performance, rowData); performance.ProjectInfoID = rowData.GetValue("ID"); performance.ChargeUser = rowData.GetValue("ChargeUserID"); this.entities.Set <S_P_Performance>().Add(performance); this.SynchEmpPerformance(performance.ChargeUser, performance, AuditRoles.ProjectManager.ToString()); var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); var rbsUser = projectEntities.Set <S_W_RBS>().Where(d => d.ProjectInfoID == performance.ProjectInfoID && d.WBSType == "Major").ToList(); var majorList = rbsUser.Select(d => d.MajorValue).Distinct(); foreach (var major in majorList) { var rbsInfo = new S_P_Performance_JoinPeople(); rbsInfo.ID = FormulaHelper.CreateGuid(); rbsInfo.S_P_PerformanceID = performance.ID; rbsInfo.Major = major; var rbsList = rbsUser.Where(d => d.MajorValue == major).ToList(); #region 人员添加 //专业负责人 var role = AuditRoles.MajorPrinciple.ToString(); var userList = rbsList.Where(d => d.RoleCode == role).ToList(); var userIDs = userList.Select(d => d.UserID).Distinct().ToList(); rbsInfo.MajorPrinciple = string.Join(",", userIDs); rbsInfo.MajorPrincipleName = string.Join(",", userList.Select(d => d.UserName).Distinct().ToList()); if (userIDs.Count != 0) { foreach (var userID in userIDs) { this.SynchEmpPerformance(userID, performance, role); } } //设计人 role = AuditRoles.Designer.ToString(); userList = rbsList.Where(d => d.RoleCode == role).ToList(); userIDs = userList.Select(d => d.UserID).Distinct().ToList(); rbsInfo.Designer = string.Join(",", userIDs); rbsInfo.DesignerName = string.Join(",", userList.Select(d => d.UserName).Distinct().ToList()); if (userIDs.Count != 0) { foreach (var userID in userIDs) { this.SynchEmpPerformance(userID, performance, role); } } //校核人 role = AuditRoles.Collactor.ToString(); userList = rbsList.Where(d => d.RoleCode == role).ToList(); userIDs = userList.Select(d => d.UserID).Distinct().ToList(); rbsInfo.Collactor = string.Join(",", userIDs); rbsInfo.CollactorName = string.Join(",", userList.Select(d => d.UserName).Distinct().ToList()); if (userIDs.Count != 0) { foreach (var userID in userIDs) { this.SynchEmpPerformance(userID, performance, role); } } //审核人 role = AuditRoles.Auditor.ToString(); userList = rbsList.Where(d => d.RoleCode == role).ToList(); userIDs = userList.Select(d => d.UserID).Distinct().ToList(); rbsInfo.Auditor = string.Join(",", userIDs); rbsInfo.AuditorName = string.Join(",", userList.Select(d => d.UserName).Distinct().ToList()); if (userIDs.Count != 0) { foreach (var userID in userIDs) { this.SynchEmpPerformance(userID, performance, role); } } //审定人 role = AuditRoles.Approver.ToString(); userList = rbsList.Where(d => d.RoleCode == role).ToList(); userIDs = userList.Select(d => d.UserID).Distinct().ToList(); rbsInfo.Approver = string.Join(",", userIDs); rbsInfo.ApproverName = string.Join(",", userList.Select(d => d.UserName).Distinct().ToList()); if (userIDs.Count != 0) { foreach (var userID in userIDs) { this.SynchEmpPerformance(userID, performance, role); } } #endregion this.entities.Set <S_P_Performance_JoinPeople>().Add(rbsInfo); } this.entities.SaveChanges(); return(performance.ID); }