123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680 |
- 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<IScoreParameterSettingServices> ScoreParameterSettingServices { get; set; }
- public ResultTypeDetailRepository resultTypeDetailRepository { get; set; }
- public ExamsStateSettingRepository examsStateSettingRepository { get; set; }
- /// <summary>
- /// 查询已提交成绩
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="examsCategoryID"></param>
- /// <param name="examinationType"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<StudentScoreView> 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<Func<ER_SubmitedScore, bool>> 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<StudentScoreView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询已提交成绩
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="collegeID"></param>
- /// <param name="departmentID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="courseTypeID"></param>
- /// <param name="examsCategoryID"></param>
- /// <param name="examinationType"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public List<ViewModel.ScoreManage.StudentScoreView> 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<Guid?> submitedScoreIDList)
- {
- Expression<Func<ER_SubmitedScore, bool>> 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();
- }
- /// <summary>
- /// 查询已提交成绩信息
- /// </summary>
- /// <param name="submitedScoreID"></param>
- /// <returns></returns>
- public ViewModel.ScoreManage.StudentScoreView GetStudentScoreView(Guid? submitedScoreID)
- {
- Expression<Func<ER_SubmitedScore, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.SubmitedScoreID == submitedScoreID);
- var query = studentScoreDAL.GetStudentScoreViewQueryable(exp);
- return query.FirstOrDefault();
- }
- /// <summary>
- /// 查询已提交成绩信息
- /// </summary>
- /// <param name="submitedScoreID"></param>
- /// <returns></returns>
- public Entities.ER_SubmitedScore GetSubmitedScore(Guid? submitedScoreID)
- {
- Expression<Func<ER_SubmitedScore, bool>> 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;
- }
- /// <summary>
- /// 添加/修改
- /// </summary>
- /// <param name="studentScoreView"></param>
- public void StudentScoreAdd(ViewModel.ScoreManage.StudentScoreView studentScoreView, List<ExpandoObject> 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<string, object>)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;
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="submitedScoreIDs"></param>
- public void StudentScoreDelete(List<Guid> 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<ER_SubmitedScoreDetail>(x => submitedScoreIDs.Contains(x.SubmitedScoreID.Value));
- UnitOfWork.Delete<ER_SubmitedScore>(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<Guid?> userIDList, int? startTermID)
- {
- Expression<Func<ER_SubmitedScore, bool>> 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<Func<ER_SubmitedScore, bool>> 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<Guid> submitedScoreIDList)
- {
- this.RefreshFinallyScore(x => submitedScoreIDList.Contains(x.SubmitedScoreID));
- }
- private void RefreshFinallyScore(Expression<Func<ER_SubmitedScore, bool>> 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<Guid> submitedScoreIDList)
- {
- this.RefreshFinallyScoreBeforeDelete(x => submitedScoreIDList.Contains(x.SubmitedScoreID));
- }
- public void RefreshFinallyScoreBeforeDelete(Expression<Func<ER_SubmitedScore, bool>> 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<ER_SubmitedScore> lastSubmitedScoreList, IList<ER_FinallyScore> finallyScoreList)
- {
- //var deletedIDList = finallyScoreList.Select(x => x.FinallyScoreID).ToList();
- var insertFinallyScoreList = new List<ER_FinallyScore>();
- var insertFinallyScoreDetailList = new List<ER_FinallyScoreDetail>();
- var finalScoreIDList = finallyScoreList.Select(y => y.FinallyScoreID).ToList();
- var finalScoredetailList = studentScoreDAL.FinallyScoreDetailRepository.GetList(x => finalScoreIDList.Contains(x.FinallyScoreID.Value)).ToList();
- //UnitOfWork.Delete<ER_FinallyScore>(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<ResultTypeDetailView> GetResultTypeDetail(int typeID)
- {
- Expression<Func<ER_ResultTypeDetail, bool>> 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<int?> GetNormalExamsState()
- {
- List<int?> examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList();
- return examsStateList;
- }
- public List<StudentScoreView> GetStarttermList(int? year)
- {
- var StarttermvalueList = studentScoreDAL.DictionaryItemRepository.GetList(x => x.DictionaryCode == "cf_Startterm").Select(x => x.Value).ToList();
- List<StudentScoreView> StarttermList = new List<StudentScoreView>();
- 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<CoursematerialView> GetFinallyScoreCoursematerialViewGrid(ConfiguretView conditionView, Guid userID, int? pageIndex, int? pageSize)
- {
- Expression<Func<ER_FinallyScore, bool>> 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<CoursematerialView>(pageIndex, pageSize);
- }
- public FinallyScoreView GetFinallyScoreView(Guid userID, Guid coursematerialID)
- {
- Expression<Func<ER_FinallyScore, bool>> 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;
- }
- }
- }
|