using System; using System.Collections.Generic; using System.Linq; using System.Data.Entity; using System.Text; using System.Linq.Expressions; using EMIS.Entities; using EMIS.DataLogic.ScoreManage; using EMIS.ViewModel; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.ViewModel.ScoreManage; using EMIS.ViewModel.Students; using System.Dynamic; using EMIS.Utility; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.Cultureplan; using System.Transactions; namespace EMIS.CommonLogic.ScoreManage { public class StudentScoreServices : BaseServices, IStudentScoreServices { public StudentScoreDAL studentScoreDAL { get; set; } public ResultTypeDetailDAL resultTypeDetailDAL { get; set; } public FinallyScoreRepository FinallyScoreRepository { get; set; } public SubmitedScoreRepository SubmitedScoreRepository { get; set; } public ScoreParameterSettingDAL scoreParameterSettingDAL { get; set; } public GradePointFormulaRepository gradePointFormulaRepository { get; set; } public Lazy ScoreParameterSettingServices { get; set; } public ResultTypeDetailRepository resultTypeDetailRepository { get; set; } public ExamsStateSettingRepository examsStateSettingRepository { get; set; } /// /// 查询已提交成绩 /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetStudentScoreViewGrid(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? standardID, Guid? classmajorID, int? starttermBegin, int? starttermEnd, int? yearID, int? learningformID, int? handleModeID, int? education, string LearnSystem, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); if (departmentID.HasValue) exp = exp.And(x => x.DepartmentID == departmentID); if (yearID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == yearID); if (standardID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID); if (classmajorID.HasValue) exp = exp.And(x => x.CF_Student.ClassmajorID == classmajorID); if (schoolyearID.HasValue) exp = exp.And(x => x.SchoolyearID == schoolyearID); if (coursematerialID.HasValue) exp = exp.And(x => x.CoursematerialID == coursematerialID); if (courseTypeID.HasValue) exp = exp.And(x => x.CourseTypeID == courseTypeID); if (examsCategoryID.HasValue) exp = exp.And(x => x.ExamsCategoryID == examsCategoryID); if (learningformID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (handleModeID.HasValue) exp = exp.And(x => x.HandleModeID == handleModeID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { exp = exp.And(x =>x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } if (starttermBegin.HasValue && starttermEnd.HasValue) { exp = exp.And(x => x.StarttermID >= starttermBegin && x.StarttermID <= starttermEnd); } var query = studentScoreDAL.GetStudentScoreViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); return this.GetQueryByAssistant(query, (x => x.ClassmajorID),this.GetQueryByDataRangeByCollege(query)).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CourseName) .ThenBy(x => x.ExamsCategoryID).ThenBy(x => x.ClassName).ThenBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } /// /// 查询已提交成绩 /// /// /// /// /// /// /// /// /// /// /// /// public List GetStudentScoreViewList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID , Guid? grademajorID, Guid? classmajorID, int? yearID, int? learningformID, int? education, string LearnSystem, List submitedScoreIDList) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (submitedScoreIDList != null) { exp = exp.And(x => submitedScoreIDList.Contains(x.SubmitedScoreID)); } if (collegeID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID); if (departmentID.HasValue) exp = exp.And(x => x.DepartmentID == departmentID); if (yearID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == yearID); if (grademajorID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.GrademajorID == grademajorID); if (classmajorID.HasValue) exp = exp.And(x => x.CF_Student.ClassmajorID == classmajorID); if (schoolyearID.HasValue) exp = exp.And(x => x.SchoolyearID == schoolyearID); if (coursematerialID.HasValue) exp = exp.And(x => x.CoursematerialID == coursematerialID); if (courseTypeID.HasValue) exp = exp.And(x => x.CourseTypeID == courseTypeID); if (examsCategoryID.HasValue) exp = exp.And(x => x.ExamsCategoryID == examsCategoryID); if (learningformID.HasValue) exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems); } if (education.HasValue) { exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.EducationID == education.Value); } var query = studentScoreDAL.GetStudentScoreViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.CourseName) .ThenBy(x => x.ExamsCategoryID).ThenBy(x => x.ClassName).ThenBy(x => x.LoginID).ToList(); } /// /// 查询已提交成绩信息 /// /// /// public ViewModel.ScoreManage.StudentScoreView GetStudentScoreView(Guid? submitedScoreID) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SubmitedScoreID == submitedScoreID); var query = studentScoreDAL.GetStudentScoreViewQueryable(exp); return query.FirstOrDefault(); } /// /// 查询已提交成绩信息 /// /// /// public Entities.ER_SubmitedScore GetSubmitedScore(Guid? submitedScoreID) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SubmitedScoreID == submitedScoreID); return studentScoreDAL.submitedScoreRepository.GetSingle(exp, (x => x.CF_Student.Sys_User), (x => x.ER_SubmitedScoreDetail)); } //计算绩点 public decimal? GetGradePoint(Guid? collegeID, int? year, int? examsCategoryID, int? courseTypeID, decimal? totalScore) { decimal? GradePoint = 0; var scoreParameterSetting = ScoreParameterSettingServices.Value.GetScoreParameterSettingList(collegeID, year, examsCategoryID, courseTypeID); if (scoreParameterSetting != null) { ER_GradePointFormula gradePointFormula = gradePointFormulaRepository.GetSingle(x => x.GradePointFormulaID == scoreParameterSetting.GradePointFormulaID); if (gradePointFormula != null) { if (totalScore >= gradePointFormula.GradePointlimit) { GradePoint = 1; int tscore = (int)totalScore; if (tscore > gradePointFormula.GradePointlimit) { GradePoint += (tscore - gradePointFormula.GradePointlimit) * gradePointFormula.GradePointFloor; } } } } return GradePoint; } /// /// 添加/修改 /// /// public void StudentScoreAdd(ViewModel.ScoreManage.StudentScoreView studentScoreView, List listExpandoObject) { try { //ER_ScoreParameterSetting scoreParameterSetting = GetGradePoint(studentScoreView.ExamsCategoryID, studentScoreView.CourseTypeID); var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); var student = this.studentScoreDAL.studentRepository.GetSingle(x => x.UserID == studentScoreView.UserID, (x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor)); Guid? collegeID; int? year; try { collegeID = student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID; year = student.CF_Classmajor.CF_Grademajor.GradeID; } catch { throw new Exception("该学生没有对应的班级信息,无法录入。"); } ER_SubmitedScore submitedScoreEntity = SubmitedScoreRepository.GetSingle(x => x.SubmitedScoreID == studentScoreView.SubmitedScoreID); ER_SubmitedScore submitedScore = null; if (studentScoreView.Remarks == "Add") { //学年学期-学号-课程代码-考试性质 //ER_SubmitedScore DBsubmitedScore = SubmitedScoreRepository.GetSingle(x => x.SchoolyearID == studentScoreView.SchoolyearID && x.UserID == studentScoreView.UserID && x.CoursematerialID == studentScoreView.CoursematerialID && x.ExamsCategoryID == studentScoreView.ExamsCategoryID); //if (DBsubmitedScore != null) //{ // throw new Exception("该学生在该学期已经有相同课程的考试,考试性质也相同。不能重复添加!"); //} //复制型新增 studentScoreView.SubmitedScoreID = null; } if (studentScoreView.SubmitedScoreID == null || studentScoreView.SubmitedScoreID == Guid.Empty) { submitedScore = new ER_SubmitedScore(); submitedScore.SubmitedScoreID = Guid.NewGuid(); submitedScore.SchoolyearID = studentScoreView.SchoolyearID; submitedScore.SchoolyearNumID = studentScoreView.SchoolyearNumID; submitedScore.DepartmentID = studentScoreView.DepartmentID; submitedScore.ClassName = studentScoreView.ClassName; submitedScore.CoursematerialID = studentScoreView.CoursematerialID; submitedScore.CourseTypeID = studentScoreView.CourseTypeID; submitedScore.ExamsCategoryID = studentScoreView.ExamsCategoryID; submitedScore.ExaminationModeID = studentScoreView.ExaminationModeID; submitedScore.Credit = studentScoreView.Credit; submitedScore.ExamsDatetime = studentScoreView.ExamsDatetime; submitedScore.ResultTypeID = studentScoreView.ResultTypeID == null ? (int)CF_ResultType.Percentage : studentScoreView.ResultTypeID; submitedScore.CreatorUserID = studentScoreView.CreatorUserID; submitedScore.EntryDeadlineTime = studentScoreView.EntryDeadlineTime; submitedScore.IsEntry = true; submitedScore.ExaminationType = studentScoreView.ExaminationType; submitedScore.StarttermID = studentScoreView.StarttermID; submitedScore.UserID = studentScoreView.UserID; submitedScore.ExamsStateID = studentScoreView.ExamsStateID; //暂时按此种逻辑处理。。后续优化(廖兵良) if (studentScoreView.ExamsStateID != (int)CF_ExamsState.NormalExams && studentScoreView.ExamsStateID != 10) { submitedScore.TotalScore = studentScoreDAL.examsStateSettingRepository.GetSingle(x => x.ExamsStateID == studentScoreView.ExamsStateID).Score; } else { submitedScore.TotalScore = studentScoreView.TotalScore; } submitedScore.ScoreCredit = submitedScore.TotalScore >= 60 ? studentScoreView.Credit : 0; submitedScore.GradePoint = GetGradePoint(collegeID, year, studentScoreView.ExamsCategoryID, studentScoreView.CourseTypeID, studentScoreView.TotalScore); //submitedScore.GradePoint = studentScoreView.GradePoint; submitedScore.Remark = studentScoreView.StudentScoreRemark; SetNewStatus(submitedScore); UnitOfWork.Add(submitedScore); foreach (dynamic expandoObject in listExpandoObject) { var dic = (IDictionary)expandoObject; ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail(); submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid(); submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID; submitedScoreDetail.ScoreTypeID = expandoObject.ScoreTypeID; submitedScoreDetail.Score = expandoObject.Score == "" ? null : Convert.ToDecimal(expandoObject.Score); SetNewStatus(submitedScoreDetail); UnitOfWork.Add(submitedScoreDetail); } } else { submitedScore = GetSubmitedScore(studentScoreView.SubmitedScoreID); var oldCoursematerialID = submitedScore.CoursematerialID; var oldUserID = submitedScore.UserID; var oldStartTerm = submitedScore.StarttermID; if (submitedScore == null) throw new Exception("未找到相对应的数据!"); submitedScore.SchoolyearID = studentScoreView.SchoolyearID; submitedScore.SchoolyearNumID = studentScoreView.SchoolyearNumID; submitedScore.DepartmentID = studentScoreView.DepartmentID; submitedScore.ClassName = studentScoreView.ClassName; submitedScore.CoursematerialID = studentScoreView.CoursematerialID; submitedScore.CourseTypeID = studentScoreView.CourseTypeID; submitedScore.ExamsCategoryID = studentScoreView.ExamsCategoryID; submitedScore.ExaminationModeID = studentScoreView.ExaminationModeID; submitedScore.Credit = studentScoreView.Credit; submitedScore.ExamsDatetime = studentScoreView.ExamsDatetime; submitedScore.ResultTypeID = studentScoreView.ResultTypeID == null ? (int)CF_ResultType.Percentage : studentScoreView.ResultTypeID; submitedScore.CreatorUserID = studentScoreView.CreatorUserID; submitedScore.EntryDeadlineTime = studentScoreView.EntryDeadlineTime; submitedScore.ExaminationType = studentScoreView.ExaminationType; submitedScore.StarttermID = studentScoreView.StarttermID; submitedScore.UserID = studentScoreView.UserID; submitedScore.ExamsStateID = studentScoreView.ExamsStateID; //暂时按此种逻辑处理。。后续优化(廖兵良) if (studentScoreView.ExamsStateID != (int)CF_ExamsState.NormalExams && studentScoreView.ExamsStateID != 10) { submitedScore.TotalScore = studentScoreDAL.examsStateSettingRepository.GetSingle(x => x.ExamsStateID == studentScoreView.ExamsStateID).Score; } else { submitedScore.TotalScore = studentScoreView.TotalScore; } submitedScore.ScoreCredit = submitedScore.TotalScore >= 60 ? studentScoreView.Credit : 0; //submitedScore.ScoreCredit = studentScoreView.ScoreCredit; submitedScore.GradePoint = GetGradePoint(collegeID, year, studentScoreView.ExamsCategoryID, studentScoreView.CourseTypeID, studentScoreView.TotalScore); //submitedScore.GradePoint = studentScoreView.GradePoint; submitedScore.Remark = studentScoreView.StudentScoreRemark; SetModifyStatus(submitedScore); foreach (dynamic expandoObject in listExpandoObject) { int scoreTypeID = expandoObject.ScoreTypeID; ER_SubmitedScoreDetail submitedScoreDetail = submitedScore.ER_SubmitedScoreDetail.Where(x => x.ScoreTypeID == scoreTypeID).FirstOrDefault(); submitedScoreDetail.ScoreTypeID = expandoObject.ScoreTypeID; submitedScoreDetail.Score = expandoObject.Score == "" ? null : Convert.ToDecimal(expandoObject.Score); SetModifyStatus(submitedScoreDetail); } if (oldUserID != studentScoreView.UserID || oldCoursematerialID != studentScoreView.CoursematerialID || oldStartTerm != studentScoreView.StarttermID) { this.RefreshFinallyScore(oldCoursematerialID ?? Guid.Empty, oldUserID, oldStartTerm); } } UnitOfWork.Commit(); this.RefreshFinallyScore(studentScoreView.CoursematerialID ?? Guid.Empty, studentScoreView.UserID, studentScoreView.StarttermID); UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 删除 /// /// public void StudentScoreDelete(List submitedScoreIDs) { try { if (submitedScoreIDs.Count > 0) { var submitedScoreSelectList = SubmitedScoreRepository.GetList(x => submitedScoreIDs.Contains(x.SubmitedScoreID)).Select(p => new { p.StarttermID, p.DepartmentID, p.CoursematerialID, p.UserID }).ToList(); this.RefreshFinallyScoreBeforeDelete(x => submitedScoreIDs.Contains(x.SubmitedScoreID)); UnitOfWork.Delete(x => submitedScoreIDs.Contains(x.SubmitedScoreID.Value)); UnitOfWork.Delete(x => submitedScoreIDs.Contains(x.SubmitedScoreID)); //if (submitedScoreSelectList != null && submitedScoreSelectList.Count > 0) //{ // var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); // submitedScoreSelectList.ForEach(x => // { // //1.0 用同一开课学期,教研室,课程,学生 取已提交最大的考试性质 // /************************************************************************************************************************/ // int? ExamsCategoryIDMax = SubmitedScoreRepository.GetList(w => w.StarttermID == w.StarttermID // && w.DepartmentID == x.DepartmentID // && w.CoursematerialID == x.CoursematerialID // && w.UserID == x.UserID).Max(w => w.ExamsCategoryID).Value; // //2.0 查询同一开课学期,教研室,课程,学生,拿已提交最大的考试性质信息 // /************************************************************************************************************************/ // ER_SubmitedScore SubEntity = SubmitedScoreRepository.GetSingle(w => w.StarttermID == w.StarttermID // && w.DepartmentID == x.DepartmentID // && w.CoursematerialID == x.CoursematerialID // && w.UserID == x.UserID // && w.ExamsCategoryID == ExamsCategoryIDMax, ((w => w.ER_SubmitedScoreDetail))); // //3.0 查询同一开课学期,教研室,课程,学生,拿最终成绩最大的考试性质信息 // /************************************************************************************************************************/ // ER_FinallyScore Fllentity = FinallyScoreRepository.GetSingle(w => x.StarttermID == x.StarttermID // && w.DepartmentID == x.DepartmentID // && w.CoursematerialID == x.CoursematerialID // && w.UserID == x.UserID, (w => w.ER_FinallyScoreDetail)); // //4.0更新以上子级表信息 // /************************************************************************************************************************/ // foreach (var scoreDynamicType in scoreDynamicTypes) // { // ER_SubmitedScoreDetail submitedScoreDetail = SubEntity.ER_SubmitedScoreDetail.Where(w => w.ScoreTypeID == scoreDynamicType.Value).FirstOrDefault(); // ER_FinallyScoreDetail finallyScoreDetail = Fllentity.ER_FinallyScoreDetail.Where(w => w.ScoreTypeID == scoreDynamicType.Value).FirstOrDefault(); // finallyScoreDetail.ScoreTypeID = submitedScoreDetail.ScoreTypeID; // finallyScoreDetail.Score = submitedScoreDetail.Score; // SetModifyStatus(finallyScoreDetail); // } // /************************************************************************************************************************/ // if (Fllentity != null) // { // Fllentity.TotalScore = Math.Round(SubEntity.TotalScore ?? 0, 0); // Fllentity.ExamsCategoryID = ExamsCategoryIDMax; // SetModifyStatus(Fllentity); // UnitOfWork.Update(Fllentity); // } // /***********************************************************End*************************************************************/ // }); //} UnitOfWork.Commit(); } } catch (Exception) { throw; } } public void ValidateDuplicate(Guid? submitedScoreID, Guid? userID, Guid? coursematerialID, int? examsCategoryID, int? startTermID) { //学号-课程代码-学年数-考试性质-开课学期 if (SubmitedScoreRepository.GetList(x => x.UserID == userID && x.CoursematerialID == coursematerialID && x.ExamsCategoryID == examsCategoryID && x.StarttermID == startTermID && x.SubmitedScoreID != submitedScoreID).Count() > 0) { throw new Exception("该学生在该学期已经有相同课程的考试,考试性质也相同,是否继续操作?如果确认添加,毕业成绩将按照新的成绩计算。"); } } public void RefreshFinallyScore(Guid coursematerialID, IList userIDList, int? startTermID) { Expression> exp = (x => x.CoursematerialID == coursematerialID); if (userIDList != null) { exp = exp.And(x => userIDList.Contains(x.UserID)); } if (startTermID.HasValue) { exp = exp.And(x => x.StarttermID == startTermID); } RefreshFinallyScore(exp); } public void RefreshFinallyScore(Guid coursematerialID, Guid? userID, int? startTermID) { Expression> exp = (x => x.CoursematerialID == coursematerialID); if (userID.HasValue) { exp = exp.And(x => x.UserID == userID); } if (startTermID.HasValue) { exp = exp.And(x => x.StarttermID == startTermID); } RefreshFinallyScore(exp); } public void RefreshFinallyScoreBySubmitedScoreID(IList submitedScoreIDList) { this.RefreshFinallyScore(x => submitedScoreIDList.Contains(x.SubmitedScoreID)); } private void RefreshFinallyScore(Expression> exp) { UnitOfWork.Configuration.ProxyCreationEnabled = true; UnitOfWork.Configuration.LazyLoadingEnabled = true; var lastSubmitedScoreList = this.studentScoreDAL.GetLastSubmittedScore(exp).ToList(); var detailList = lastSubmitedScoreList.SelectMany(x => x.ER_SubmitedScoreDetail).ToList(); var finallyScoreList = this.studentScoreDAL.GetFinallyScoreBySubmittedScore(exp).ToList(); UnitOfWork.Configuration.LazyLoadingEnabled = false; UnitOfWork.Configuration.ProxyCreationEnabled = false; RefreshFinallyScore(lastSubmitedScoreList, finallyScoreList); } public void RefreshFinallyScoreBySubmitedBeforeDeleteScoreID(IList submitedScoreIDList) { this.RefreshFinallyScoreBeforeDelete(x => submitedScoreIDList.Contains(x.SubmitedScoreID)); } public void RefreshFinallyScoreBeforeDelete(Expression> exp) { UnitOfWork.Configuration.ProxyCreationEnabled = true; UnitOfWork.Configuration.LazyLoadingEnabled = true; var lastSubmitedScoreList = this.studentScoreDAL.GetLastSubmittedScoreBeforDelete(exp).ToList(); var detailList = lastSubmitedScoreList.SelectMany(x => x.ER_SubmitedScoreDetail).ToList(); var finallyScoreList = this.studentScoreDAL.GetFinallyScoreBySubmittedScore(exp).ToList(); UnitOfWork.Configuration.LazyLoadingEnabled = false; UnitOfWork.Configuration.ProxyCreationEnabled = false; RefreshFinallyScore(lastSubmitedScoreList, finallyScoreList); } private void RefreshFinallyScore(IList lastSubmitedScoreList, IList finallyScoreList) { //var deletedIDList = finallyScoreList.Select(x => x.FinallyScoreID).ToList(); var insertFinallyScoreList = new List(); var insertFinallyScoreDetailList = new List(); var finalScoreIDList = finallyScoreList.Select(y => y.FinallyScoreID).ToList(); var finalScoredetailList = studentScoreDAL.FinallyScoreDetailRepository.GetList(x => finalScoreIDList.Contains(x.FinallyScoreID.Value)).ToList(); //UnitOfWork.Delete(x => deletedIDList.Contains(x.FinallyScoreID)); UnitOfWork.Delete(finalScoredetailList); UnitOfWork.Delete(finallyScoreList); //this.UnitOfWork.Commit(); foreach (var lastSubmitedScore in lastSubmitedScoreList) { ER_FinallyScore finallyScore = new ER_FinallyScore(); finallyScore.FinallyScoreID = Guid.NewGuid(); finallyScore.SchoolyearID = lastSubmitedScore.SchoolyearID; finallyScore.SchoolyearNumID = lastSubmitedScore.SchoolyearNumID; finallyScore.DepartmentID = lastSubmitedScore.DepartmentID; finallyScore.ClassName = lastSubmitedScore.ClassName; finallyScore.CoursematerialID = lastSubmitedScore.CoursematerialID; finallyScore.CourseTypeID = lastSubmitedScore.CourseTypeID; finallyScore.ExamsCategoryID = lastSubmitedScore.ExamsCategoryID; finallyScore.ExaminationModeID = lastSubmitedScore.ExaminationModeID; finallyScore.HandleModeID = lastSubmitedScore.HandleModeID; finallyScore.Credit = lastSubmitedScore.Credit; finallyScore.ExamsDatetime = lastSubmitedScore.ExamsDatetime; finallyScore.ResultTypeID = lastSubmitedScore.ResultTypeID; finallyScore.CreatorUserID = lastSubmitedScore.CreatorUserID; finallyScore.EntryDeadlineTime = lastSubmitedScore.EntryDeadlineTime; finallyScore.IsEntry = true; finallyScore.ExaminationType = lastSubmitedScore.ExaminationType; finallyScore.StarttermID = lastSubmitedScore.StarttermID; finallyScore.UserID = lastSubmitedScore.UserID; finallyScore.ExamsStateID = lastSubmitedScore.ExamsStateID; //媚姐说所有的学校录成绩都不用四舍五入了 //finallyScore.TotalScore = Math.Round(lastSubmitedScore.TotalScore ?? 0, 0); finallyScore.TotalScore = lastSubmitedScore.TotalScore; finallyScore.ScoreCredit = lastSubmitedScore.ScoreCredit; finallyScore.GradePoint = lastSubmitedScore.GradePoint; //在期末设定、已提交成绩、最终成绩增加总学时字段,最终成绩总学时来源于已提交成绩 finallyScore.TotalHours = lastSubmitedScore.TotalHours; SetNewStatus(finallyScore); insertFinallyScoreList.Add(finallyScore); foreach (var scoreDetail in lastSubmitedScore.ER_SubmitedScoreDetail) { ER_FinallyScoreDetail finallyScoreDetail = new ER_FinallyScoreDetail(); finallyScoreDetail.FinallyScoreDetailID = Guid.NewGuid(); finallyScoreDetail.FinallyScoreID = finallyScore.FinallyScoreID; finallyScoreDetail.ScoreTypeID = scoreDetail.ScoreTypeID; finallyScoreDetail.Score = scoreDetail.Score; SetNewStatus(finallyScoreDetail); insertFinallyScoreDetailList.Add(finallyScoreDetail); } } UnitOfWork.BulkInsert(insertFinallyScoreList); UnitOfWork.BulkInsert(insertFinallyScoreDetailList); } public string GetClassByUserID(Guid userID) { CF_Student student = studentScoreDAL.studentRepository.GetSingle(x => x.UserID == userID); CF_Classmajor classmajor = studentScoreDAL.classmajorRepository.GetSingle(x => x.ClassmajorID == student.ClassmajorID); string className = classmajor.Name; return className; } public List GetResultTypeDetail(int typeID) { Expression> exp = x => x.ResultTypeID == typeID; var query = resultTypeDetailDAL.GetResultsTypeDetailView(exp); //.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); return query.OrderByDescending(x => x.Score).ToList(); } public ER_ResultTypeDetail GetResultTypeDetailByDetaliID(Guid resultTypedetailID) { return resultTypeDetailRepository.GetSingle(x => x.ResultTypeDetailID == resultTypedetailID); } public ER_ResultTypeDetail GetResultTypeDetailByIDandScore(int typeID, decimal Score) { return resultTypeDetailRepository.GetSingle(x => x.ResultTypeID == typeID && x.Score == Score); } public Guid? GetDepartmentByUserID(Guid UserID) { if (studentScoreDAL.staffRepository.GetSingle(x => x.UserID == UserID) != null) { return studentScoreDAL.staffRepository.GetSingle(x => x.UserID == UserID).DepartmentID.Value; } else { return null; } } public List GetNormalExamsState() { List examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList(); return examsStateList; } public List GetStarttermList(int? year) { var StarttermvalueList = studentScoreDAL.DictionaryItemRepository.GetList(x => x.DictionaryCode == "cf_Startterm").Select(x => x.Value).ToList(); List StarttermList = new List(); if (year != null) { for (int i = 0; i <= 1; i++) { StudentScoreView Startterm = new StudentScoreView(); Startterm.StarttermID = (year.Value*2-1) + i; if (StarttermvalueList.Contains(Startterm.StarttermID)) { StarttermList.Add(Startterm); } } } else { var SchoolyearNum=studentScoreDAL.DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_SchoolyearNum").Select(x=>x.Value).ToList(); int num = (int)SchoolyearNum.Max()*2; for (int i = 0; i < num; i++) { StudentScoreView Startterm = new StudentScoreView(); Startterm.StarttermID = i+1; if (StarttermvalueList.Contains(Startterm.StarttermID)) { StarttermList.Add(Startterm); } } } return StarttermList; } public IGridResultSet GetFinallyScoreCoursematerialViewGrid(ConfiguretView conditionView, Guid userID, int? pageIndex, int? pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); exp = exp.And(x => x.UserID == userID); var query = studentScoreDAL.GetCoursematerialViewQueryableByFinallyScore(exp); if (!string.IsNullOrEmpty(conditionView.ConditionValue)) { query = query.DynamicWhere(conditionView.Attribute, conditionView.Condition, conditionView.ConditionValue.Trim()); } query = query.OrderByDescending(x => x.CourseCode).ThenBy(x => x.CourseName); return query.ToGridResultSet(pageIndex, pageSize); } public FinallyScoreView GetFinallyScoreView(Guid userID, Guid coursematerialID) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.UserID == userID && x.CoursematerialID == coursematerialID); var finallyScoreView = this.studentScoreDAL.GetFinallyScoreViewQueryable(exp).OrderByDescending(x => x.TotalScore).FirstOrDefault(); return finallyScoreView; } } }