using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using System.Text; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.DataLogic.ScoreManage; using EMIS.ViewModel.ScoreManage; using System.Dynamic; using EMIS.Utility; using System.Reflection; using System.Data; using EMIS.ViewModel.CacheManage; using EMIS.CommonLogic.SystemServices; using EMIS.DataLogic.Repositories; using EMIS.ViewModel.WorkflowManage; using System.Transactions; using Bowin.Common.Utility; using System.Text.RegularExpressions; using System.Web; using System.IO; using System.Web.Mvc; using EMIS.ViewModel.SystemView; using EMIS.Utility.FormValidate; using EMIS.DataLogic.ChargeManage.ArrearsSituation; namespace EMIS.CommonLogic.ScoreManage { public class ScoreServices : BaseWorkflowServices, IScoreServices { public ScoreDAL scoreDAL { get; set; } public StudentScoreDAL StudentScoreDAL { get; set; } public MisconductDAL MisconductDAL { get; set; } public Lazy MisconductServices { get; set; } public Lazy ExaminationSuspensionServices { get; set; } public Lazy ExaminationExemptionServices { get; set; } public IUserServices UserServices { get; set; } public Lazy StudentScoreServices { get; set; } public SubmitedScoreRepository SubmitedScoreRepository { get; set; } public SubmitedScoreDetailRepository SubmitedScoreDetailRepository { get; set; } public FinalExaminationStudentRepository FinalExaminationStudentRepository { get; set; } public ExamsStateSettingDAL ExamsStateSettingDAL { get; set; } public ExamsCategorySettingDAL ExamsCategorySettingDAL { get; set; } public FinalExaminationDAL FinalExaminationDAL { get; set; } public ImportScoreDAL ImportScoreDAL { get; set; } public Lazy ScoreParamterCollegeSettingServices { get; set; } public Lazy ParameterServices { get; set; } public CustomScoreFormulaRepository CustomScoreFormulaRepository { get; set; } public ScoreFormulaRepository ScoreFormulaRepository { get; set; } public IScoreConvertByApplyServices scoreConvertByApplyServices { get; set; } public IScoreConvertByReplaceServices scoreConvertByReplaceServices { get; set; } public ArrearsListDAL arrearsListDAL { get; set; } protected Func, IQueryable> DataRangeFunction { get; set; } protected Func>> CollegeExpression { get; set; } public ScoreServices() { DataRangeFunction = (x => this.GetQueryByDataRangeByDepartment(x)); CollegeExpression = (w => (x => x.CF_Department.CF_College.CollegeID == w)); } private List GetInputStatusList(IList statusList, int? startStatus) { var inputStatusList = statusList.Where(x => (!(x.Description ?? "").Contains("[AP]")) && x.ID != startStatus && !(x.Description ?? "").Contains("[PASS]")) .Select(x => x.ID).ToList(); return inputStatusList; } /// /// 获取期末设定 /// /// /// /// /// /// /// /// /// /// /// /// public Bowin.Common.Linq.Entity.IGridResultSet GetFinalExaminationViewGrid(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? approvalStatus, int? gradeYearID, string isCheck, int pageIndex, int pageSize) { var statusList = this.GetStatusViewList(); var startStatus = this.GetStartStatus(); var status = this.GetInputStatusList(statusList, startStatus); var endStatus = statusList.Where(x => x.Description.Contains("[PASS]")).Select(x => x.ID).FirstOrDefault(); Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) exp = exp.And(this.CollegeExpression(collegeID)); if (departmentID.HasValue) exp = exp.And(x => x.DepartmentID == departmentID); 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 (approvalStatus.HasValue) exp = exp.And(x => x.ApprovalStatus == approvalStatus); if (gradeYearID.HasValue) exp = exp.And(x => x.GradeYearID == gradeYearID); if (isCheck == "true") exp = exp.And(x => x.CreatorUserID == EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID); var query = scoreDAL.GetScoreViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); if (isCheck != "true") { query = this.DataRangeFunction(query); } var result = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => { x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name; x.ApprovalEndStatus = endStatus; }); result.rows.ForEach(x => x.IsEntry = status.Contains(x.ApprovalStatus) ? true : false); //控制是否可录入成绩 return result; } /// /// 获取期末设定 /// /// /// /// /// /// /// /// /// /// public List GetFinalExaminationViewList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? approvalStatus, int? gradeYearID, string isCheck, List idList = null) { var statusList = this.GetStatusViewList(); Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) exp = exp.And(this.CollegeExpression(collegeID)); if (departmentID.HasValue) exp = exp.And(x => x.DepartmentID == departmentID); 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 (approvalStatus.HasValue) exp = exp.And(x => x.ApprovalStatus == approvalStatus); if (gradeYearID.HasValue) exp = exp.And(x => x.GradeYearID == gradeYearID); if (isCheck == "true") exp = exp.And(x => x.CreatorUserID == EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID); if (idList != null && idList.Count() > 0) exp = exp.And(x => idList.Contains(x.FinalExaminationID)); var query = scoreDAL.GetScoreViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); if (isCheck != "true") { query = this.DataRangeFunction(query); } var result = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToList(); result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 重置 /// /// public void ScoreResettingDelete(Guid? finalExaminationID) { try { if (finalExaminationID.HasValue) { UnitOfWork.Delete(x => x.ER_Score.FinalExaminationID == finalExaminationID && x.RecordStatus > (int)SYS_STATUS.UNUSABLE); UnitOfWork.Delete(x => x.FinalExaminationID == finalExaminationID && x.RecordStatus == (int)SYS_STATUS.USABLE); } } catch (Exception) { throw; } } /// /// 重置 /// /// public void ScoreDelete(List finalExaminationIDs) { try { var nowTime = DateTime.Now; var curUser = CustomPrincipal.Current; UnitOfWork.Update(x => new ER_FinalExamination { ScoreFormulaID = null, CreditFormulaID = null, GradePointFormulaID = null, ModifyTime = nowTime, ModifyUserID = curUser.UserID }, (x => finalExaminationIDs.Contains(x.FinalExaminationID))); UnitOfWork.Delete(x => finalExaminationIDs.Contains((Guid)x.ER_Score.FinalExaminationID) && x.RecordStatus == (int)SYS_STATUS.USABLE); UnitOfWork.Delete(x =>finalExaminationIDs.Contains((Guid)x.FinalExaminationID)&& x.RecordStatus == (int)SYS_STATUS.USABLE); } catch (Exception) { throw; } } /// /// 学生成绩录入 /// /// /// public IGridResultSet GetStudentScoreInputViewGrid(Guid? finalExaminationID) { #region 获取各种初始化数据 var applyConvertEndStatus = scoreConvertByReplaceServices.GetCorrectEndStatus(); var replaceConvertEndStatus = scoreConvertByReplaceServices.GetCorrectEndStatus(); //获取各流程的结束状态,需要注意的是,不一定所有的高校都有部署全部的流程,所以 如果读不出数据来就留空 var suspensionEndStatusID = ExaminationSuspensionServices.Value.GetEndStatusID(); var misconductEndStatusID = MisconductServices.Value.GetEndStatusID(); var exemptionEndStatusID = ExaminationExemptionServices.Value.GetEndStatusID(); //获取考试性质设置项,用于判断是否需要读取上次考试成绩 var examsCategorySettingList = ExamsCategorySettingDAL.GetExamsCategorySettingView().ToList(); //缓交申请(审核通过) var chargeDelayEndStatusID = WorkflowServices.Value.GetCorrectEndStatus("EC_ChargeDelay") ?? null; var statusList = this.GetStatusViewList(); var startStatus = this.GetStartStatus(); var inputStatusList = this.GetInputStatusList(statusList, startStatus); var canInputStatus = statusList.Where(x => x.Description.Contains("[ENTRY]")).Select(x => x.ID).FirstOrDefault(); //获取缴费控制项 var isChargeControl = ParameterServices.Value.GetParameterValue(CF_ParameterType.IsScoreEditControlForCharge); var importScoreList = new List(); var lastPassScoreList = new List(); var scoreTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType).ToList(); #endregion var finalExamination = FinalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID); var ResultTypeList = scoreDAL.ResultTypeDetailRepository.GetList(x => x.ResultTypeID == finalExamination.ResultTypeID).ToList(); var collegeScoreParameterSetting = this.ScoreParamterCollegeSettingServices.Value.GetScoreParameterCollegeSettingView(finalExamination.CollegeID, finalExamination.GradeYearID); var query = scoreDAL.GetStudentScoreInputViewQuqeryable(finalExaminationID, suspensionEndStatusID, misconductEndStatusID, exemptionEndStatusID, chargeDelayEndStatusID, isChargeControl ?? false, applyConvertEndStatus, replaceConvertEndStatus); var resultList = query.OrderBy(x => x.LoginID).ToGridResultSet(); var detailList = scoreDAL.GetStudentScoreInputDetailViewQuqeryable(finalExaminationID).ToList(); //当期末设定处于可录入和重新录入两个状态下就刷新平时成绩(如果有的话) bool isGetImportScore = inputStatusList.Contains(finalExamination.ApprovalStatus) && finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && collegeScoreParameterSetting != null && collegeScoreParameterSetting.ScoreTypeID != null; bool isLoadScore = (examsCategorySettingList.Any(x => x.ExamsCategoryID == finalExamination.ExamsCategoryID && x.IsReadHistory) && finalExamination.ApprovalStatus == canInputStatus); if (isGetImportScore) { importScoreList = this.ImportScoreDAL.GetImportScoreViewQueryableByFinalExaminationID(finalExamination.FinalExaminationID).ToList(); } if (isLoadScore) { lastPassScoreList = this.scoreDAL.GetLastPassedStudentScoreForResit(finalExamination.FinalExaminationID).ToList(); } for (int i = 0; i < resultList.rows.Count; i ++ ) { resultList.rows[i].No = i + 1; resultList.rows[i].ScoreDetail = (from scoreType in scoreTypeList join detail in detailList.Where(x => x.UserID == resultList.rows[i].UserID) on scoreType.Value equals detail.ScoreTypeID into ddetail from detail in ddetail.DefaultIfEmpty() select new StudentScoreInputDetailView { ScoreTypeID = scoreType.Value, UserID = resultList.rows[i].UserID, Score = (detail == null ? ( (collegeScoreParameterSetting != null && finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && collegeScoreParameterSetting.ScoreTypeID == (int)CF_ScoreType.Peacetime && scoreType.Value == (int)CF_ScoreType.Peacetime) ? (int?)0 : null ) : detail.Score), IsCanEdit = (detail == null ? (collegeScoreParameterSetting == null || collegeScoreParameterSetting.ScoreTypeID != scoreType.Value || finalExamination.ExamsCategoryID != (int)CF_ExamsCategory.FinalExam) : detail.IsCanEdit), RecordStatus = (detail == null ? (int)SYS_STATUS.USABLE : detail.RecordStatus) }) .ToDictionary(x => x.ScoreTypeID.ToString()); //读取导入的平时成绩 if (isGetImportScore && resultList.rows[i].RecordStatus > (int)SYS_STATUS.UNUSABLE) { var importScore = importScoreList.FirstOrDefault(x => x.UserID == resultList.rows[i].UserID); if (importScore != null) { if (!resultList.rows[i].ScoreDetail.ContainsKey(collegeScoreParameterSetting.ScoreTypeID.ToString())) { resultList.rows[i].ScoreDetail.Add(collegeScoreParameterSetting.ScoreTypeID.ToString(), new StudentScoreInputDetailView { ScoreTypeID = collegeScoreParameterSetting.ScoreTypeID, UserID = importScore.UserID, RecordStatus = (int)SYS_STATUS.USABLE }); } resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].Score = importScore.Score; resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].IsCanEdit = false; } else { //如果有个性设定,但是没有导入成绩 resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].Score = null; resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].IsCanEdit = false; } } //读取上一次期末考试合格的分数 if (isLoadScore && resultList.rows[i].RecordStatus > (int)SYS_STATUS.UNUSABLE) { var lastPassScore = lastPassScoreList.Where(x => x.UserID == resultList.rows[i].UserID).ToList(); lastPassScore.ForEach(x => { if (!resultList.rows[i].ScoreDetail.ContainsKey(x.ScoreTypeID.ToString())) { resultList.rows[i].ScoreDetail.Add(x.ScoreTypeID.ToString(), new StudentScoreInputDetailView { ScoreTypeID = x.ScoreTypeID, UserID = x.UserID, RecordStatus = (int)SYS_STATUS.USABLE, IsCanEdit = true }); } resultList.rows[i].ScoreDetail[x.ScoreTypeID.ToString()].Score = x.Score; }); } //如果整行都不能编辑,那这里面的明细也不能编辑 if (!resultList.rows[i].IsCanEdit) { resultList.rows[i].ScoreDetail.ForEach(x => x.Value.IsCanEdit = false); } } return resultList; } /// /// 获取成绩录入 /// /// /// public List GetScoreList(Guid? finalExaminationID) { try { List scoreList = scoreDAL.ScoreRepository.GetList(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_ScoreDetail), (x => x.CF_Student.Sys_User), (x => x.CF_Student.CF_DifferentDynamic)).ToList(); scoreList.ForEach(x => { x.TotalScore = Math.Round(x.TotalScore ?? 0, 0, MidpointRounding.AwayFromZero); }); return scoreList; } catch (Exception ex) { throw new Exception(ex.Message); } } public void ScoreSave(FinalExaminationView finalExaminationView, IList scoreViewList) { var startStatus = this.GetStartStatus(); var statusList = this.GetStatusViewList(); var inputStatusList = this.GetInputStatusList(statusList, startStatus); ER_FinalExamination finalExamination = scoreDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationView.FinalExaminationID); if (!inputStatusList.Contains(finalExamination.ApprovalStatus)) { return; } finalExamination.ScoreFormulaID = finalExaminationView.ScoreFormulaID; finalExamination.CreditFormulaID = finalExaminationView.CreditFormulaID; finalExamination.GradePointFormulaID = finalExaminationView.GradePointFormulaID; finalExamination.Comment = finalExaminationView.Comment; var insertDetailList = scoreViewList.Where(x => //重录时需要过滤掉无需重录的学生 (x.RecordStatus ?? (int)SYS_STATUS.USABLE) > (int)SYS_STATUS.UNUSABLE //过滤总成绩为null的行,一般只有空行会是null && x.TotalScore != null) .ToList(); var reEnterDetailList = scoreViewList.Where(x => //重录时需要过滤掉无需重录的学生 (x.RecordStatus ?? (int)SYS_STATUS.USABLE) > (int)SYS_STATUS.UNUSABLE) .ToList(); //重录时只删除重录的数据再插入 var userIDList = reEnterDetailList.Select(x => x.UserID).ToList(); if (userIDList.Count > 0) { UnitOfWork.Delete(x => x.ER_Score.FinalExaminationID == finalExamination.FinalExaminationID && userIDList.Contains(x.ER_Score.UserID) && x.RecordStatus > (int)SYS_STATUS.UNUSABLE); UnitOfWork.Delete(x => x.FinalExaminationID == finalExamination.FinalExaminationID && userIDList.Contains(x.UserID) && x.RecordStatus > (int)SYS_STATUS.UNUSABLE); } foreach (var scoreView in reEnterDetailList) { ER_Score score = new ER_Score(); score.ScoreID = Guid.NewGuid(); score.UserID = scoreView.UserID; score.FinalExaminationID = scoreView.FinalExaminationID; score.ExamsStateID = scoreView.ExamsStateID; score.TotalScore = scoreView.TotalScore; score.Credit = scoreView.Credit; score.GradePoint = scoreView.GradePoint; score.Remark = scoreView.Remarks; SetNewStatus(score); score.RecordStatus = Convert.ToInt32(scoreView.RecordStatus); UnitOfWork.Add(score); foreach (var scoreDetailView in scoreView.ScoreDetail) { ER_ScoreDetail scoreDetail = new ER_ScoreDetail(); scoreDetail.ScoreDetailID = Guid.NewGuid(); scoreDetail.ScoreID = score.ScoreID; scoreDetail.ScoreTypeID = Convert.ToInt32(scoreDetailView.Key); scoreDetail.Score = scoreDetailView.Value.Score; SetNewStatus(scoreDetail); UnitOfWork.Add(scoreDetail); } } UnitOfWork.Commit(); } private List GetRequiredScoreTypeList(FinalExaminationView finalExaminationView, IList scoreViewList) { var customScoreFormulaList = this.CustomScoreFormulaRepository.Entities.ToList(); if (customScoreFormulaList.Count > 0) { var scoreTypesList = scoreViewList.SelectMany(x => x.ScoreDetail) .Where(x => x.Value.Score != null) .Select(x => x.Value.ScoreTypeID).Distinct().ToList(); //创建空结构 var groups = customScoreFormulaList.Where(x => false).Select(x => new { Total = 0, Detail = new List {x} }).ToList(); scoreTypesList.ForEach(scoreType => { customScoreFormulaList.ForEach(scoreFormula => { var mateResultList = groups.Where(x => x.Detail.Any(w => w.ScoreType == scoreFormula.ScoreType)).ToList(); mateResultList.ForEach(mateResult => { var item = new { Total = mateResult.Total + (scoreFormula.Percentage ?? 0), Detail = mateResult.Detail.Where(x => x.ScoreType != scoreFormula.ScoreType).ToList() }; item.Detail.Add(scoreFormula); groups.Add(item); }); if (mateResultList.Count == 0) { groups.ForEach(x => x = new { Total = x.Total + (scoreFormula.Percentage ?? 0), Detail = x.Detail.Concat(new List { scoreFormula }).ToList() }); groups.Add(new { Total = (scoreFormula.Percentage ?? 0), Detail = new List { scoreFormula } }); } }); }); return groups.Where(x => x.Total == 100).SelectMany(x => x.Detail).Select(x => x.ScoreType).Distinct().ToList(); } else { var scoreFormula = ScoreFormulaRepository.GetSingle(x => x.ScoreFormulaID == finalExaminationView.ScoreFormulaID, (x => x.ER_ScoreFormulaDetail)); return scoreFormula.ER_ScoreFormulaDetail.Where(x => x.Percentage > 0).Select(x => x.ScoreType).Distinct().ToList(); } } public void Submit(FinalExaminationView finalExaminationView, IList scoreViewList) { var normalStateID = ExamsStateSettingDAL.GetNormalID(); var examinationSuspensionID = ExamsStateSettingDAL.GetExaminationSuspensionID(); var examinationExemptionID = ExamsStateSettingDAL.GetExaminationExemptionID(); var misconductIDList = ExamsStateSettingDAL.GetMisconductIDList(); //缓交申请(审核通过) var chargeDelayEndStatusID = WorkflowServices.Value.GetCorrectEndStatus("EC_ChargeDelay") ?? null; //获取缴费控制项 var isChargeControl = ParameterServices.Value.GetParameterValue(CF_ParameterType.IsScoreEditControlForCharge); var userIDList = scoreViewList.Select(x => x.UserID).ToList(); Expression> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expStudentCharge = expStudentCharge.And(x => userIDList.Contains(x.UserID)); var arrearList = arrearsListDAL.GetArrearListViewAble(expStudentCharge, x => x.RecordStatus == chargeDelayEndStatusID); this.ScoreSave(finalExaminationView, scoreViewList); var requireScoreTypeList = this.GetRequiredScoreTypeList(finalExaminationView, scoreViewList); //有欠费控制并且欠费的不让提交 if (arrearList != null && isChargeControl.HasValue) { if (arrearList.Count() > 0 && isChargeControl.Value) { throw new Exception("存在欠费的学生无法提交,请检查。"); } } if (scoreViewList.Any(x => x.ExamsStateID != examinationSuspensionID && x.ExamsStateID != examinationExemptionID && !misconductIDList.Contains(x.ExamsStateID) && x.ScoreDetail.Any(w => requireScoreTypeList.Contains(w.Value.ScoreTypeID) && w.Value.Score == null)))//&& x.IsConvert == false { throw new Exception("学生成绩录入未完整,请检查。"); } var actionList = this.GetActionView(finalExaminationView.FinalExaminationID.Value, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID).ToList(); var actionID = actionList.Where(x => x.ActionName == "提交").Select(w => w.ActionID).FirstOrDefault(); if (actionID != null) { Approve(new List { finalExaminationView.FinalExaminationID.Value }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionID, null); } } /// /// 提交以及保存 /// /// /// public void ScoreAdd(FinalExaminationView finalExaminationView, List listExpandoObject, int? approvalStatus) { try { var normalStateID = ExamsStateSettingDAL.GetNormalID(); var suspensionID = ExamsStateSettingDAL.GetExaminationSuspensionID(); var exemptionID = ExamsStateSettingDAL.GetExaminationExemptionID(); var misconductStateList = ExamsStateSettingDAL.GetMisconductIDList(); var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); ER_FinalExamination finalExamination = scoreDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationView.FinalExaminationID); List suspensionList = ExaminationSuspensionServices.Value.GetExaminationSuspensionViewListByFinalExamination(finalExaminationView.FinalExaminationID); List exemptionList = ExaminationExemptionServices.Value.GetExaminationExemptionViewListByFinalExamination(finalExaminationView.FinalExaminationID); List misconductList = MisconductServices.Value.GetMisconductViewListByFinalExamination(finalExaminationView.FinalExaminationID); if (finalExamination == null) throw new Exception("未找到相对应的设定!"); //if (approvalStatus.HasValue) // finalExamination.ApprovalStatus = approvalStatus; finalExamination.ScoreFormulaID = finalExaminationView.ScoreFormulaID; finalExamination.CreditFormulaID = finalExaminationView.CreditFormulaID; finalExamination.GradePointFormulaID = finalExaminationView.GradePointFormulaID; finalExamination.Comment = finalExaminationView.Comment; if (listExpandoObject != null) { UnitOfWork.Delete(x => x.ER_Score.FinalExaminationID == finalExamination.FinalExaminationID); UnitOfWork.Delete(x => x.FinalExaminationID == finalExamination.FinalExaminationID); foreach (dynamic item in listExpandoObject) { Guid ScoreID = item.ScoreID == "" || item.ScoreID == null ? Guid.Empty : new Guid(item.ScoreID); ER_Score score = new ER_Score(); decimal totalScoreNum = Convert.ToDecimal(item.TotalScore); score.ScoreID = Guid.NewGuid(); score.UserID = new Guid(item.UserID); score.FinalExaminationID = new Guid(item.FinalExaminationID); score.ExamsStateID = Convert.ToInt32(item.ExamsStateID); var suspension = suspensionList.FirstOrDefault(x => x.UserID == new Guid(item.UserID)); var exemption = exemptionList.FirstOrDefault(x => x.UserID == new Guid(item.UserID)); var misconduct = misconductList.FirstOrDefault(x => x.UserID == new Guid(item.UserID)); if (misconduct != null) { score.ExamsStateID = misconduct.ExamsStateID; score.TotalScore = 0; score.Credit = 0; score.GradePoint = 0; } else if (exemption != null) { score.ExamsStateID = exemptionID; score.TotalScore = 0; score.Credit = 0; score.GradePoint = 0; } else if (suspension != null) { score.ExamsStateID = suspensionID; score.TotalScore = 0; score.Credit = 0; score.GradePoint = 0; } else { score.ExamsStateID = normalStateID; if (Convert.ToInt32(item.ExamsStateID) != normalStateID) { score.ExamsStateID = Convert.ToInt32(item.ExamsStateID); } score.TotalScore = totalScoreNum > 0 ? Math.Round(totalScoreNum, 0, MidpointRounding.AwayFromZero) : totalScoreNum; score.Credit = Convert.ToDecimal(item.Credit); score.GradePoint = Convert.ToDecimal(item.GradePoint); } score.Remark = item.Remarks; SetNewStatus(score); score.RecordStatus = Convert.ToInt32(item.RecordStatus); UnitOfWork.Add(score); foreach (var scoreDynamicType in scoreDynamicTypes) { var dic = (IDictionary)item; var formulascore = dic["Formula_" + scoreDynamicType.Value]; ER_ScoreDetail scoreDetail = new ER_ScoreDetail(); scoreDetail.ScoreDetailID = Guid.NewGuid(); scoreDetail.ScoreID = score.ScoreID; scoreDetail.ScoreTypeID = scoreDynamicType.Value; //if (scoreDetail.ScoreTypeID != (int)CF_ScoreType.Peacetime // && (score.ExamsStateID == suspensionID || score.ExamsStateID == exemptionID // || misconductStateList.Contains(score.ExamsStateID))) //{ // scoreDetail.Score = null; //} //else //{ if (formulascore == "") { formulascore = null; } if (formulascore != null) { scoreDetail.Score = Convert.ToDecimal(formulascore); } else { scoreDetail.Score = null; } //} SetNewStatus(scoreDetail); UnitOfWork.Add(scoreDetail); } } } UnitOfWork.Commit(); //因为成绩保存和提交调用同样的方法,参数传1表示成绩提交,调用工作流 if (approvalStatus == 1) { var actionList = WorkflowServices.Value.GetActionView("ER_FinalExamination", finalExamination.FinalExaminationID, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID).ToList(); var actionID = actionList.Where(x => x.ActionName == "提交").Select(w => w.ActionID).FirstOrDefault(); Approve(new List { finalExamination.FinalExaminationID }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionID, null); //UnitOfWork.Commit(); } } catch (Exception ex) { throw; } } /// /// 查询未审核期末设定 /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetFinalExaminationScoreAuditViewGrid(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? gradeYearID, int? approvalStatus, int pageIndex, int pageSize) { //List list = new List(); //list.Add((int)EMIS.ViewModel.CF_ScoreState.Submitted); var statusList = this.GetStatusViewList(); //获取工作流列表 var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(x => x.ID); //审核中的节点的Description标识为[AP] Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) exp = exp.And(this.CollegeExpression(collegeID)); if (departmentID.HasValue) exp = exp.And(x => x.DepartmentID == departmentID); 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 (gradeYearID.HasValue) exp = exp.And(x => x.GradeYearID == gradeYearID); if (approvalStatus.HasValue) exp = exp.And(x => x.ApprovalStatus == approvalStatus); //if (status.Count() > 0) // // exp = exp.And(x => status.Contains((int)x.ApprovalStatus)); //exp = exp.And(x => list.Contains((int)x.ApprovalStatus)); var query = scoreDAL.GetScoreViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// //获取录入状态 /// /// public int? ApprovalStatus() { var statusList = this.GetStatusViewList(); //获取工作流列表 var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(x => x.ID).FirstOrDefault(); return status; } /// ///检查是否能被审核 /// public void CheckApprovalStatus(List ApprovalStatus) { try { var statusList = this.GetStatusViewList(); //获取工作流列表 var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(w => w.ID).ToList(); List okNo = new List(); foreach (var s in status) { for (int i = 0; i < ApprovalStatus.Count(); i++) { if (ApprovalStatus[i] == s) { okNo.Add(ApprovalStatus[i]); } } } if (okNo.Count() != ApprovalStatus.Count()) { throw new Exception("只能操作待审核和重录待审的数据!"); } } catch (Exception) { throw; } } /// /// 查询期末设定 /// /// /// /// /// /// /// /// /// /// /// public List GetFinalExaminationScoreAuditViewList(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? gradeYearID, int? status) { //List list = new List(); //list.Add((int)EMIS.ViewModel.CF_ScoreState.Submitted); var statusList = this.GetStatusViewList(); //获取工作流列表 //var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(x => x.ID); //审核中的节点的Description标识为[AP] Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (collegeID.HasValue) exp = exp.And(this.CollegeExpression(collegeID)); if (departmentID.HasValue) exp = exp.And(x => x.DepartmentID == departmentID); 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 (gradeYearID.HasValue) exp = exp.And(x => x.GradeYearID == gradeYearID); //exp = exp.And(x => list.Contains((int)x.ApprovalStatus)); if (status.HasValue) exp = exp.And(x => x.ApprovalStatus == status); var query = scoreDAL.GetScoreViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToList(); result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } /// /// 申请撤销成绩 /// /// /// public void Rebut(List listUserID, Guid? FinalExaminationID) { try { //ModifyProcessState(FinalExaminationID.Value, "A", null); var statusList = this.GetStatusViewList(); var endStatus = statusList.Where(x => (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).FirstOrDefault(); var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current; var curUserID = curUser.UserID; var action = GetActionView(FinalExaminationID.Value, curUserID); var finalExamination = scoreDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == FinalExaminationID, (x => x.CF_Schoolyear), x => x.ER_FinalExaminationStudent); if (finalExamination.ApprovalStatus != endStatus) throw new Exception("只能选择已审核通过的成绩进行撤销"); var queryScore = scoreDAL.ScoreRepository.GetList(x => x.FinalExaminationID == FinalExaminationID, (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList(); var listScore = queryScore.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID && !listUserID.Contains(x.UserID.Value)).ToList(); var studentList = scoreDAL.userRepository.GetList(x => listUserID.Contains(x.UserID)); string studentNames = ""; var count = 0; foreach (Sys_User user in studentList) { studentNames = studentNames + user.Name + "、"; count++; if (count > 10) { break; } } studentNames = studentNames.Substring(0, studentNames.Length - 1); string comment = ""; if (studentList.Count() > 10) { comment = "意见:" + studentNames + "... 共" + studentList.Count() + "位学生成绩申请重录"; } else { comment = "意见:" + studentNames + "共" + studentList.Count() + "位学生成绩申请重录"; } foreach (var score in listScore) { //申请撤销成绩时,将ER_Score表没有勾选的数据的RecordStatus标识为false,成绩再次录入时,这些成绩不可编辑修改,只能修改申请撤销时选中的数据 score.RecordStatus = (int)SYS_STATUS.UNUSABLE; score.CreateUserID = curUserID; score.ModifyUserID = curUserID; score.ModifyTime = score.CreateTime = DateTime.Now; } UnitOfWork.BatchUpdate(listScore); //删除所勾选的提交成绩表 var SubmitedScoreIDs = scoreDAL.GetDeleteSubmittedScore(finalExamination.FinalExaminationID, listUserID).Select(x => x.SubmitedScoreID).ToList(); if (SubmitedScoreIDs.Count > 0) { //先刷新最终成绩在删除已提交成绩,否则会找不到最终成绩 StudentScoreServices.Value.RefreshFinallyScoreBeforeDelete(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID)); UnitOfWork.Delete(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID)); UnitOfWork.Delete(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID)); } Approve(new List { FinalExaminationID.Value }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, Guid.Empty, comment); //UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 根据当前环节ID获取下一步审批动作 /// /// 表单ID /// 当前用户ID /// public List GetAuditingActionView(Guid formID, Guid userID) { try { List listAction = GetActionView(formID, userID); return listAction; } catch (Exception) { throw; } } public void SubmitedScoreDelete(Guid finalExaminationID, Guid userID) { var finalExamination = scoreDAL.finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID, x => x.ER_Score).FirstOrDefault(); if (finalExamination != null) { var userList = finalExamination.ER_Score.Select(x => x.UserID); UnitOfWork.Delete(x => x.ER_SubmitedScore.SchoolyearID == finalExamination.SchoolyearID && x.ER_SubmitedScore.CoursematerialID == finalExamination.CoursematerialID && x.ER_SubmitedScore.ExamsCategoryID == finalExamination.ExamsCategoryID && userList.Contains(x.ER_SubmitedScore.UserID)); UnitOfWork.Delete(x => x.SchoolyearID == finalExamination.SchoolyearID && x.CoursematerialID == finalExamination.CoursematerialID && x.ExamsCategoryID == finalExamination.ExamsCategoryID && userList.Contains(x.UserID)); } } /// /// 审核通过后执行方法 /// /// /// public void FinalExaminationApproved(List finalExaminationIDList, Guid userID) { try { List listSubmitedScore = new List(); List listSubmitedScoreDetail = new List(); var finalExaminationList = scoreDAL.finalExaminationRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID), (x => x.CF_Schoolyear), x => x.ER_FinalExaminationStudent).ToList(); var queryScore = scoreDAL.ScoreRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty) && x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE, (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList(); var userList = queryScore.Select(x => x.UserID).ToList(); var queryFinalExaminationStudentList = scoreDAL.finalExaminationRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID), (x => x.ER_FinalExaminationStudent.Select(w => w.CF_Student.CF_Classmajor.CF_Grademajor))) .ToList().SelectMany(x => x.ER_FinalExaminationStudent).ToList().Where(x => userList.Contains(x.UserID)); var listUserID = queryFinalExaminationStudentList.Select(x => x.UserID).Distinct().ToList(); var listScore = queryScore.Where(x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty)).ToList(); var listFinalExaminationStudentList = queryFinalExaminationStudentList.Where(x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty)).ToList(); using (TransactionScope ts = new TransactionScope()) { //删除提交成绩表 var SubmitedScoreIDs = scoreDAL.GetDeleteSubmittedScore(finalExaminationIDList, listUserID).Select(x => x.SubmitedScoreID).ToList(); if (SubmitedScoreIDs.Count > 0) { UnitOfWork.Delete(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID)); UnitOfWork.Delete(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID)); } //UnitOfWork.Remove(x => x.SchoolyearID == finalExamination.SchoolyearID // && x.CoursematerialID == finalExamination.CoursematerialID // && x.ExamsCategoryID == finalExamination.ExamsCategoryID); //UnitOfWork.Commit(); ts.Complete(); } foreach (var score in listScore) { if (score.RecordStatus == (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE) continue; //当ER_Score表RecordStatus禁用状态时,表明本次更新不更新该成绩,所以不新增或修改成绩 var finalExaminationStudent = listFinalExaminationStudentList.Where(x => x.UserID == score.UserID && x.FinalExaminationID == score.FinalExaminationID).FirstOrDefault(); if (finalExaminationStudent == null) { continue; } var finalExamination = finalExaminationList.FirstOrDefault(x => x.FinalExaminationID == score.FinalExaminationID); if (finalExamination == null) { continue; } ER_SubmitedScore submitedScore = new ER_SubmitedScore(); submitedScore.SubmitedScoreID = Guid.NewGuid(); submitedScore.SchoolyearID = finalExamination.SchoolyearID; submitedScore.SchoolyearNumID = finalExaminationStudent.SchoolyearNumID; submitedScore.FinalExaminationID = finalExamination.FinalExaminationID; submitedScore.DepartmentID = finalExamination.DepartmentID; submitedScore.ClassName = finalExamination.ClassName; submitedScore.CoursematerialID = finalExamination.CoursematerialID; submitedScore.CourseTypeID = finalExamination.CourseTypeID; submitedScore.ExamsCategoryID = finalExamination.ExamsCategoryID; submitedScore.ExaminationModeID = finalExamination.ExaminationModeID; submitedScore.Credit = finalExamination.Credit; submitedScore.ExamsDatetime = finalExamination.ExamsDatetime; submitedScore.ResultTypeID = finalExamination.ResultTypeID; submitedScore.CreatorUserID = finalExamination.CreatorUserID; submitedScore.EntryDeadlineTime = finalExamination.EntryDeadlineTime; submitedScore.IsEntry = finalExamination.IsEntry; submitedScore.ExaminationType = finalExamination.ExaminationType; submitedScore.StarttermID = finalExaminationStudent.StarttermID; submitedScore.UserID = score.UserID; submitedScore.ExamsStateID = score.ExamsStateID; submitedScore.TotalScore = score.TotalScore; submitedScore.ScoreCredit = score.Credit; submitedScore.GradePoint = score.GradePoint; submitedScore.Remark = score.Remark; //在期末设定、已提交成绩、最终成绩增加总学时字段,已提交成绩总学时来源于期末设定 submitedScore.TotalHours = finalExamination.TotalHours; SetNewStatus(submitedScore); listSubmitedScore.Add(submitedScore); //详细表 foreach (var scoreDetail in score.ER_ScoreDetail) { //已提交成绩录入分数表 ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail(); submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid(); submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID; submitedScoreDetail.ScoreTypeID = scoreDetail.ScoreTypeID; submitedScoreDetail.Score = scoreDetail.Score; SetNewStatus(submitedScoreDetail); listSubmitedScoreDetail.Add(submitedScoreDetail); } } //query.ForEach(x => x.ApprovalStatus = approvalStatus); //query.ForEach(x => x.Remark = opinioncomment); UnitOfWork.BulkInsert(listSubmitedScore); UnitOfWork.BulkInsert(listSubmitedScoreDetail); StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(listSubmitedScore.Select(x => x.SubmitedScoreID).ToList()); //当成绩更新完时,ER_Score表RecordStatus恢复可用状态,因为RecordStatus只用于标识本次不更新该成绩 UnitOfWork.Update(x => new ER_Score { RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.USABLE }, x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty)); //UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 审核不同意撤销成绩后执行方法 /// /// /// //public void FinalExaminationRebutDisAgree(Guid finalExaminationID, Guid userID) //{ // try // { // var queryScore = scoreDAL.scoreRepository.GetList(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList(); // //当不同意撤销成绩时,ER_Score表RecordStatus恢复可用状态,因为RecordStatus用于标识撤销成绩时不更新的成绩 // queryScore.ForEach(x => x.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.USABLE); // UnitOfWork.Commit(); // } // catch (Exception) // { // throw; // } //} // 申请撤销成绩时驳回后执行方法 public void FinalExaminationRebutDisAgree(List finalExaminationIDList, Guid userID) { try { this.FinalExaminationApproved(finalExaminationIDList, userID); } catch (Exception) { throw; } } ///// ///// 审核 ///// ///// ///// //public void GetFinalExaminationApprovalStatus(List listFinalExaminationID, int? approvalStatus, string opinioncomment) //{ // try // { // List listSubmitedScore = new List(); // List listSubmitedScoreDetail = new List(); // var query = scoreDAL.finalExaminationRepository.GetList(x => listFinalExaminationID.Contains(x.FinalExaminationID), (x => x.CF_Schoolyear)).ToList(); // var schoolyearIDs = query.Select(x => x.SchoolyearID).ToList(); //获取学年学期 // var coursematerialIDs = query.Select(x => x.CoursematerialID).ToList(); //获取课程 // var queryScore = scoreDAL.scoreRepository.GetList(x => listFinalExaminationID.Contains((Guid)x.FinalExaminationID), (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList(); // var queryFinalExaminationStudentList = scoreDAL.finalExaminationRepository.GetList(x => listFinalExaminationID.Contains((Guid)x.FinalExaminationID), (x => x.ER_FinalExaminationStudent.Select(w => w.CF_Student.CF_Classmajor.CF_Grademajor))) // .ToList().SelectMany(x => x.ER_FinalExaminationStudent).ToList(); // var userIDs = queryScore.Select(x => x.UserID).ToList(); // foreach (var finalExamination in query) // { // var listScore = queryScore.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID).ToList(); // var listFinalExaminationStudentList = queryFinalExaminationStudentList.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID).ToList(); // if (approvalStatus == (int)EMIS.ViewModel.CF_ScoreState.Approved) // { // foreach (var score in listScore) // { // var finalExaminationStudent = listFinalExaminationStudentList.Where(x => x.UserID == score.UserID).FirstOrDefault(); // if (finalExaminationStudent == null) // { // continue; // } // //已提交成绩 // ER_SubmitedScore submitedScore = new ER_SubmitedScore(); // submitedScore.SubmitedScoreID = Guid.NewGuid(); // submitedScore.SchoolyearID = finalExamination.SchoolyearID; // submitedScore.SchoolyearNumID = finalExaminationStudent.SchoolyearNumID; // submitedScore.DepartmentID = finalExamination.DepartmentID; // submitedScore.ClassName = finalExamination.ClassName; // submitedScore.CoursematerialID = finalExamination.CoursematerialID; // submitedScore.CourseTypeID = finalExamination.CourseTypeID; // submitedScore.ExamsCategoryID = finalExamination.ExamsCategoryID; // submitedScore.ExaminationModeID = finalExamination.ExaminationModeID; // submitedScore.Credit = finalExamination.Credit; // submitedScore.ExamsDatetime = finalExamination.ExamsDatetime; // submitedScore.ResultTypeID = finalExamination.ResultTypeID; // submitedScore.CreatorUserID = finalExamination.CreatorUserID; // submitedScore.EntryDeadlineTime = finalExamination.EntryDeadlineTime; // submitedScore.IsEntry = finalExamination.IsEntry; // submitedScore.ExaminationType = finalExamination.ExaminationType; // submitedScore.StarttermID = finalExaminationStudent.StarttermID; // submitedScore.UserID = score.UserID; // submitedScore.ExamsStateID = score.ExamsStateID; // submitedScore.TotalScore = score.TotalScore; // submitedScore.ScoreCredit = score.Credit; // submitedScore.GradePoint = score.GradePoint; // submitedScore.Remark = score.Remark; // SetNewStatus(submitedScore); // listSubmitedScore.Add(submitedScore); //已提交成绩 // //详细表 // foreach (var scoreDetail in score.ER_ScoreDetail) // { // //已提交成绩录入分数表 // ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail(); // submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid(); // submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID; // submitedScoreDetail.ScoreTypeID = scoreDetail.ScoreTypeID; // submitedScoreDetail.Score = scoreDetail.Score; // SetNewStatus(submitedScoreDetail); // listSubmitedScoreDetail.Add(submitedScoreDetail); // } // } // } // } // query.ForEach(x => x.ApprovalStatus = approvalStatus); // query.ForEach(x => x.Remark = opinioncomment); // UnitOfWork.BulkInsert(listSubmitedScore); // UnitOfWork.BulkInsert(listSubmitedScoreDetail); // foreach (var finalExamination in query) // { // var userList = queryScore.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID).Select(x => x.UserID).ToList(); // StudentScoreServices.Value.RefreshFinallyScore(finalExamination.CoursematerialID ?? Guid.Empty, userList, null); // } // UnitOfWork.Commit(); // } // catch (Exception) // { // throw; // } //} public void RefreshExaminationSuspensionState(IList examinationSuspensionIDList) { var suspensionID = ExamsStateSettingDAL.GetExaminationSuspensionID(); var statusList = this.GetStatusViewList(); //获取工作流列表 //审核中的数据(节点的Description为[AP])和end的节点不能修改 var approvedFinalExaminationState = statusList.Where(x => (x.Description ?? "").Contains("[AP]") && (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList(); //List approvedFinalExaminationState = new List { (int)CF_ScoreState.Approved, (int)CF_ScoreState.Submitted }; var submitedFinalExaminationList = this.scoreDAL.GetFinalExaminationByExaminationSuspension( (x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)), (x => approvedFinalExaminationState.Contains(x.ApprovalStatus)) ).ToList(); if (submitedFinalExaminationList.Count > 0) { throw new Exception("该课程的期末考试成绩已经提交,无法更新缓考状态。"); } var scoreList = this.scoreDAL.GetScoreByExaminationSuspension((x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID))) .Include(x => x.ER_ScoreDetail).ToList(); foreach (var score in scoreList) { score.ExamsStateID = suspensionID; score.TotalScore = null; score.Credit = null; score.GradePoint = null; foreach (var detail in score.ER_ScoreDetail) { detail.Score = null; } } this.UnitOfWork.Commit(); } public void RefreshCancelExaminationSuspensionState(IList examinationSuspensionIDList) { var normalStateID = ExamsStateSettingDAL.GetNormalID(); List approvedFinalExaminationState = new List { (int)CF_ScoreState.Approved, (int)CF_ScoreState.Submitted }; var submitedFinalExaminationList = this.scoreDAL.GetFinalExaminationByExaminationSuspension( (x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)), (x => approvedFinalExaminationState.Contains(x.ApprovalStatus)) ).ToList(); if (submitedFinalExaminationList.Count > 0) { throw new Exception("该课程的期末考试成绩已经提交,无法更新缓考状态。"); } var scoreList = this.scoreDAL.GetScoreByExaminationSuspension((x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID))) .Include(x => x.ER_ScoreDetail).ToList(); foreach (var score in scoreList) { score.ExamsStateID = normalStateID; score.TotalScore = null; score.Credit = null; score.GradePoint = null; foreach (var detail in score.ER_ScoreDetail) { detail.Score = null; } } this.UnitOfWork.Commit(); } public void RefreshExaminationExemptionState(IList examinationExemptionIDList) { var exemptionID = ExamsStateSettingDAL.GetExaminationExemptionID(); var scoreList = this.scoreDAL.GetScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)) .Include(x => x.ER_ScoreDetail) .Include(x => x.ER_FinalExamination) .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList(); var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)) .Include(x => x.ER_SubmitedScoreDetail).ToList(); foreach (var score in scoreList) { score.ExamsStateID = exemptionID; score.TotalScore = null; score.Credit = null; score.GradePoint = null; foreach (var detail in score.ER_ScoreDetail) { detail.Score = null; } var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID); if (finalExaminationStudent != null) { var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID); if (submittedScore != null) { submittedScore.ExamsStateID = exemptionID; submittedScore.TotalScore = null; submittedScore.Credit = null; submittedScore.GradePoint = null; foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail) { submitedScoreDetail.Score = null; } } } } this.UnitOfWork.Commit(); var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList(); this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList); this.UnitOfWork.Commit(); } public void RefreshCancelExaminationExemptionState(IList examinationExemptionIDList) { var normalStateID = ExamsStateSettingDAL.GetNormalID(); var scoreList = this.scoreDAL.GetScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)) .Include(x => x.ER_ScoreDetail) .Include(x => x.ER_FinalExamination) .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList(); var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)) .Include(x => x.ER_SubmitedScoreDetail).ToList(); foreach (var score in scoreList) { score.ExamsStateID = normalStateID; score.TotalScore = null; score.Credit = null; score.GradePoint = null; foreach (var detail in score.ER_ScoreDetail) { detail.Score = null; } var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID); if (finalExaminationStudent != null) { var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID); if (submittedScore != null) { submittedScore.ExamsStateID = normalStateID; submittedScore.TotalScore = null; submittedScore.Credit = null; submittedScore.GradePoint = null; foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail) { submitedScoreDetail.Score = null; } } } } this.UnitOfWork.Commit(); var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList(); this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList); this.UnitOfWork.Commit(); } #region 免修刷成绩注释 //public void RefreshExaminationExemptionState(IList examinationExemptionIDList) //{ // var exemptionID = ExamsStateSettingDAL.GetExaminationExemptionID(); // var exemptionScore = ExamsStateSettingDAL.GetExemptionScore(); // var scoreList = this.scoreDAL.GetScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)) // .Include(x => x.ER_ScoreDetail) // .Include(x => x.ER_FinalExamination) // .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList(); // var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)) // .Include(x => x.ER_SubmitedScoreDetail).ToList(); // if (scoreList.Count > 0) // { // foreach (var score in scoreList) // { // score.ExamsStateID = exemptionID; // score.TotalScore = null; // score.Credit = null; // score.GradePoint = null; // foreach (var detail in score.ER_ScoreDetail) // { // detail.Score = null; // } // var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID); // if (finalExaminationStudent != null) // { // var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID // && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID); // if (submittedScore != null) // { // submittedScore.ExamsStateID = exemptionID; // submittedScore.TotalScore = null; // submittedScore.Credit = null; // submittedScore.GradePoint = null; // foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail) // { // submitedScoreDetail.Score = null; // } // } // } // } // this.UnitOfWork.Commit(); // var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList(); // this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList); // this.UnitOfWork.Commit(); // } // else // { // List listSubmitedScore = new List(); // List listSubmitedScoreDetail = new List(); // //查询该课程来源是否为期末设定 // var examinationExemptionFromFinalExamination = scoreDAL.GetExaminationExemptionFromFinalExamination(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)).FirstOrDefault(); // var examinationExemptionFromEducationMission = scoreDAL.GetExaminationExemptionFromFinalExamination(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)).FirstOrDefault(); // if (examinationExemptionFromFinalExamination != null) // { // List SubmitedScoreIDList = new List(); // var GradePoint = this.StudentScoreServices.Value.GetGradePoint(examinationExemptionFromFinalExamination.CollegeID, examinationExemptionFromFinalExamination.GradeYearID, examinationExemptionFromFinalExamination.ExamsCategoryID, examinationExemptionFromFinalExamination.CourseTypeID, exemptionScore); // ER_SubmitedScore submitedScore = new ER_SubmitedScore(); // submitedScore.SubmitedScoreID = Guid.NewGuid(); // submitedScore.SchoolyearID = examinationExemptionFromFinalExamination.SchoolyearID; // submitedScore.SchoolyearNumID = examinationExemptionFromFinalExamination.SchooolYearNumID; // submitedScore.FinalExaminationID = examinationExemptionFromFinalExamination.FinalExaminationID; // submitedScore.DepartmentID = examinationExemptionFromFinalExamination.DepartmentID; // submitedScore.ClassName = examinationExemptionFromFinalExamination.ClassName; // submitedScore.CoursematerialID = examinationExemptionFromFinalExamination.CoursematerialID; // submitedScore.CourseTypeID = examinationExemptionFromFinalExamination.CourseTypeID; // submitedScore.ExamsCategoryID = examinationExemptionFromFinalExamination.ExamsCategoryID; // submitedScore.ExaminationModeID = examinationExemptionFromFinalExamination.ExaminationModeID; // submitedScore.Credit = examinationExemptionFromFinalExamination.Credit; // submitedScore.ExamsDatetime = examinationExemptionFromFinalExamination.ExamsDatetime; // submitedScore.ResultTypeID = examinationExemptionFromFinalExamination.ResultTypeID; // submitedScore.CreatorUserID = examinationExemptionFromFinalExamination.CreatorUserID; // submitedScore.EntryDeadlineTime = examinationExemptionFromFinalExamination.EntryDeadlineTime; // submitedScore.IsEntry = examinationExemptionFromFinalExamination.IsEntry; // submitedScore.ExaminationType = examinationExemptionFromFinalExamination.ExaminationType; // submitedScore.StarttermID = examinationExemptionFromFinalExamination.StarttermID; // submitedScore.UserID = examinationExemptionFromFinalExamination.UserID; // submitedScore.ExamsStateID = exemptionID; // submitedScore.TotalScore = exemptionScore; // submitedScore.ScoreCredit = examinationExemptionFromFinalExamination.Credit; // submitedScore.GradePoint = GradePoint; // submitedScore.Remark = null; // //在期末设定、已提交成绩、最终成绩增加总学时字段,已提交成绩总学时来源于期末设定 // submitedScore.TotalHours = examinationExemptionFromFinalExamination.TotalHours; // SetNewStatus(submitedScore); // listSubmitedScore.Add(submitedScore); // var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); // //详细表 // foreach (var scoreDetail in scoreDynamicTypes) // { // //已提交成绩录入分数表 // ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail(); // submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid(); // submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID; // submitedScoreDetail.ScoreTypeID = scoreDetail.Value; // submitedScoreDetail.Score = null; // SetNewStatus(submitedScoreDetail); // listSubmitedScoreDetail.Add(submitedScoreDetail); // } // SubmitedScoreIDList.Add(submitedScore.SubmitedScoreID); // UnitOfWork.BulkInsert(listSubmitedScore); // UnitOfWork.BulkInsert(listSubmitedScoreDetail); // this.UnitOfWork.Commit(); // this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(SubmitedScoreIDList); // } // //查询该课程来源是否为教学任务 // //查询该课程来源是否为执行计划 // } //} #endregion public void RefreshMisconductState(IList misconductIDList) { var scoreList = this.scoreDAL.GetScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID)) .Include(x => x.ER_ScoreDetail) .Include(x => x.ER_FinalExamination) .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList(); var misconductViewList = this.MisconductDAL.GetMisconductViewQueryable(x => misconductIDList.Contains(x.MisconductID)).ToList(); var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID)) .Include(x => x.ER_SubmitedScoreDetail).ToList(); foreach (var score in scoreList) { var finalExamination = score.ER_FinalExamination; var misconductView = misconductViewList.FirstOrDefault(x => x.SchoolyearID == finalExamination.SchoolyearID && x.CoursematerialID == finalExamination.CoursematerialID && x.ExamsCategoryID == finalExamination.ExamsCategoryID && x.UserID == score.UserID); score.ExamsStateID = misconductView.ExamsStateID; score.TotalScore = null; score.Credit = null; score.GradePoint = null; foreach (var detail in score.ER_ScoreDetail) { detail.Score = null; } var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID); if (finalExaminationStudent != null) { var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == misconductView.CoursematerialID && x.UserID == misconductView.UserID && x.StarttermID == finalExaminationStudent.StarttermID); if (submittedScore != null) { submittedScore.ExamsStateID = misconductView.ExamsStateID; submittedScore.TotalScore = null; submittedScore.Credit = null; submittedScore.GradePoint = null; foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail) { submitedScoreDetail.Score = null; } } } } this.UnitOfWork.Commit(); var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList(); this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList); this.UnitOfWork.Commit(); } public void RefreshCancelMisconductState(IList misconductIDList) { var normalStateID = ExamsStateSettingDAL.GetNormalID(); var scoreList = this.scoreDAL.GetScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID)) .Include(x => x.ER_ScoreDetail) .Include(x => x.ER_FinalExamination) .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList(); var misconductViewList = this.MisconductDAL.GetMisconductViewQueryable(x => misconductIDList.Contains(x.MisconductID)).ToList(); var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID)) .Include(x => x.ER_SubmitedScoreDetail).ToList(); foreach (var score in scoreList) { score.ExamsStateID = normalStateID; score.TotalScore = null; score.Credit = null; score.GradePoint = null; foreach (var detail in score.ER_ScoreDetail) { detail.Score = null; } var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID); if (finalExaminationStudent != null) { var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID); if (submittedScore != null) { submittedScore.ExamsStateID = normalStateID; submittedScore.TotalScore = null; submittedScore.Credit = null; submittedScore.GradePoint = null; foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail) { submitedScoreDetail.Score = null; } } } } this.UnitOfWork.Commit(); var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList(); this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList); this.UnitOfWork.Commit(); } private List GetImportColumns() { List cellheader = new List { "学号", "姓名", "考试性质" }; var scoreTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); scoreTypeList.ForEach(x => { cellheader.Add(x.Name); }); return cellheader; } private void CheckColumns(List cellheader, DataTable data) { List missColumn = new List(); cellheader.ForEach(x => { if (data.Columns.IndexOf(x) < 0) { missColumn.Add(x); } }); if (missColumn.Count > 0) { throw new Exception("导入模板中缺少" + string.Join("、", missColumn) + "列的信息。"); } } private object[] GetErrorMessageData(int rowIndex, DataRow row, string message) { var result = row.ItemArray; result = (new object[] { (object)(rowIndex + 1) }) .Concat(result) .Concat(new object[] { (object)("第" + (rowIndex + 1).ToString() + "行数据错误:" + message) }).ToArray(); return result; } private IEnumerable GetErrorCellHeader(IList cellheader) { return new List { "行号" } .Concat(cellheader) .Concat(new List { "错误提示" }); } private DataTable CheckValues(IList cellheader, DataTable data, IList userList, IList examStudentList, IList correctList) { var errorColumnList = GetErrorCellHeader(cellheader); var scoreTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType); var errorTable = new DataTable(); errorColumnList.ForEach(x => errorTable.Columns.Add(x)); List errorStack = new List(); var dupRows = data.AsEnumerable() .GroupBy(key => key.Field("学号")) .Where(w => w.Count() > 1) .SelectMany(s => s) .ToArray(); for (int i = data.Rows.Count - 1; i >= 0; i--) { DataRow row = data.Rows[i]; var allNull = true; var rowErrorMessage = ""; foreach (var columnName in cellheader) { if (!string.IsNullOrEmpty(row[columnName] as string)) { allNull = false; } } if (allNull) { continue; } var importRow = new StudentScoreImportView(); var loginID = row["学号"] as string; var userName = row["姓名"] as string; if (string.IsNullOrEmpty(loginID)) { rowErrorMessage += "学号不能为空;"; } else { if (dupRows.Any(x => x.Field("学号") == loginID)) { rowErrorMessage += "学号重复;"; } var user = userList.FirstOrDefault(x => x.LoginID == loginID); if (user == null) { rowErrorMessage += "系统中找不到对应的学生;"; } else if (!examStudentList.Contains(user.UserID)) { rowErrorMessage += "该学号不存在当前录入班级,请检查;"; } else { importRow.LoginID = loginID; importRow.UserName = userName; importRow.UserID = user.UserID; } } importRow.ScoreDetail = new Dictionary(); scoreTypeList.ForEach(x => { var score = row[x.Name]; if (score == null || score.ToString().Trim() == "") { importRow.ScoreDetail.Add(x.Value, null); } else if (!Regex.IsMatch(score.ToString(), @"^\d+(\.\d{1,2})?$")) { rowErrorMessage += x.Name + "必须为保留最多两位小数的数字;"; } else { importRow.ScoreDetail.Add(x.Value, Convert.ToDecimal(score)); } }); if (!string.IsNullOrEmpty(rowErrorMessage)) { errorStack.Add(this.GetErrorMessageData(i, row, rowErrorMessage)); } else { correctList.Add(importRow); } } errorStack.OrderBy(x => x[0]).ForEach(x => errorTable.Rows.Add(x)); return errorTable; } private string WriteErrorFile(NpoiExcelHelper excel, IEnumerable errorCellheader, DataTable errorTable) { var errorExcelBuff = excel.ExportMemoryStream(errorTable, "", errorCellheader.ToArray()); var logicalPath = Const.LOCAL_SETTING_UPLOAD_FILEPATH + "/" + Guid.NewGuid().ToString() + ".xls"; var physicalPath = HttpContext.Current.Server.MapPath(logicalPath); var fs = File.Create(physicalPath); fs.Write(errorExcelBuff, 0, errorExcelBuff.Length); fs.Flush(); fs.Close(); return UrlHelper.GenerateContentUrl(logicalPath, HttpContext.Current.Request.RequestContext.HttpContext); } public ExcelImportResult ScoreImport(string filePath, Guid? finalExaminationID) { var result = new ExcelImportResult(); var excel = new NpoiExcelHelper(); List cellheader = GetImportColumns(); var dt = excel.ImpotColumns(filePath); System.IO.File.Delete(filePath);//删除本地缓存文件 this.CheckColumns(cellheader, dt); #region 准备校验数据 var loginIDList = dt.AsEnumerable().Select(x => x.Field("学号")).Distinct(); var userList = this.ImportScoreDAL.UserRepository.GetList(x => loginIDList.Contains(x.LoginID)).ToList(); var examStudentList = this.FinalExaminationStudentRepository.GetList(x => x.FinalExaminationID == finalExaminationID) .Select(x => x.UserID).ToList(); #endregion var correctList = new List(); var errorTable = this.CheckValues(cellheader, dt, userList, examStudentList, correctList); result.SuccessCount = correctList.Count; result.ErrorCount = errorTable.Rows.Count; if (errorTable.Rows.Count > 0) { result.IsAllSuccess = false; var errorCellHeader = this.GetErrorCellHeader(cellheader).ToArray(); result.ErrorFilePath = this.WriteErrorFile(excel, this.GetErrorCellHeader(cellheader), errorTable); result.Message = string.Format("导入失败,详情请点击错误数据下载查看。"); } else { result.IsAllSuccess = true; result.Data = correctList; } return result; } public int? GetNormalExamsID() { return this.ExamsStateSettingDAL.GetNormalID(); } public int? GetExaminationSuspensionID() { return this.ExamsStateSettingDAL.GetExaminationSuspensionID(); } public int? GetExaminationExemptionID() { return this.ExamsStateSettingDAL.GetExaminationExemptionID(); } public List GetMisconductIDList() { return this.ExamsStateSettingDAL.GetMisconductIDList(); } public List GetScoreType(Guid? finalExaminationIDs) { var finalExamination=scoreDAL.finalExaminationRepository.Entities.Where(x => x.FinalExaminationID == finalExaminationIDs).FirstOrDefault(); return scoreDAL.ResultTypeDetailRepository.GetList(x=>x.ResultTypeID==finalExamination.ResultTypeID).ToList(); } public List GetExamsStateSettingList() { return this.ExamsStateSettingDAL.ExamsStateSettingRepository.Entities.ToList(); } public List GetScoreFormulaList() { var query = ScoreFormulaRepository.Entities.ToList(); return query; } } }