ScoreServices.cs 96 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Linq;
  5. using System.Text;
  6. using EMIS.ViewModel;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using Bowin.Common.Linq.Entity;
  10. using Bowin.Common.Linq;
  11. using EMIS.DataLogic.ScoreManage;
  12. using EMIS.ViewModel.ScoreManage;
  13. using System.Dynamic;
  14. using EMIS.Utility;
  15. using System.Reflection;
  16. using System.Data;
  17. using EMIS.ViewModel.CacheManage;
  18. using EMIS.CommonLogic.SystemServices;
  19. using EMIS.DataLogic.Repositories;
  20. using EMIS.ViewModel.WorkflowManage;
  21. using System.Transactions;
  22. using Bowin.Common.Utility;
  23. using System.Text.RegularExpressions;
  24. using System.Web;
  25. using System.IO;
  26. using System.Web.Mvc;
  27. using EMIS.ViewModel.SystemView;
  28. using EMIS.Utility.FormValidate;
  29. using EMIS.DataLogic.ChargeManage.ArrearsSituation;
  30. namespace EMIS.CommonLogic.ScoreManage
  31. {
  32. public class ScoreServices : BaseWorkflowServices<ER_FinalExamination>, IScoreServices
  33. {
  34. public ScoreDAL scoreDAL { get; set; }
  35. public StudentScoreDAL StudentScoreDAL { get; set; }
  36. public MisconductDAL MisconductDAL { get; set; }
  37. public Lazy<IMisconductServices> MisconductServices { get; set; }
  38. public Lazy<IExaminationSuspensionServices> ExaminationSuspensionServices { get; set; }
  39. public Lazy<IExaminationExemptionServices> ExaminationExemptionServices { get; set; }
  40. public IUserServices UserServices { get; set; }
  41. public Lazy<IStudentScoreServices> StudentScoreServices { get; set; }
  42. public SubmitedScoreRepository SubmitedScoreRepository { get; set; }
  43. public SubmitedScoreDetailRepository SubmitedScoreDetailRepository { get; set; }
  44. public FinalExaminationStudentRepository FinalExaminationStudentRepository { get; set; }
  45. public ExamsStateSettingDAL ExamsStateSettingDAL { get; set; }
  46. public ExamsCategorySettingDAL ExamsCategorySettingDAL { get; set; }
  47. public FinalExaminationDAL FinalExaminationDAL { get; set; }
  48. public ImportScoreDAL ImportScoreDAL { get; set; }
  49. public Lazy<IScoreParamterCollegeSettingServices> ScoreParamterCollegeSettingServices { get; set; }
  50. public Lazy<IParameterServices> ParameterServices { get; set; }
  51. public CustomScoreFormulaRepository CustomScoreFormulaRepository { get; set; }
  52. public ScoreFormulaRepository ScoreFormulaRepository { get; set; }
  53. public IScoreConvertByApplyServices scoreConvertByApplyServices { get; set; }
  54. public IScoreConvertByReplaceServices scoreConvertByReplaceServices { get; set; }
  55. public ArrearsListDAL arrearsListDAL { get; set; }
  56. protected Func<IQueryable<FinalExaminationView>, IQueryable<FinalExaminationView>> DataRangeFunction { get; set; }
  57. protected Func<Guid?, Expression<Func<ER_FinalExamination, bool>>> CollegeExpression { get; set; }
  58. public ScoreServices()
  59. {
  60. DataRangeFunction = (x => this.GetQueryByDataRangeByDepartment(x));
  61. CollegeExpression = (w => (x => x.CF_Department.CF_College.CollegeID == w));
  62. }
  63. private List<int?> GetInputStatusList(IList<WorkflowStatusView> statusList, int? startStatus)
  64. {
  65. var inputStatusList = statusList.Where(x => (!(x.Description ?? "").Contains("[AP]"))
  66. && x.ID != startStatus && !(x.Description ?? "").Contains("[PASS]"))
  67. .Select(x => x.ID).ToList();
  68. return inputStatusList;
  69. }
  70. /// <summary>
  71. /// 获取期末设定
  72. /// </summary>
  73. /// <param name="configuretView"></param>
  74. /// <param name="collegeID"></param>
  75. /// <param name="departmentID"></param>
  76. /// <param name="schoolyearID"></param>
  77. /// <param name="coursematerialID"></param>
  78. /// <param name="courseTypeID"></param>
  79. /// <param name="examsCategoryID"></param>
  80. /// <param name="examinationType"></param>
  81. /// <param name="pageIndex"></param>
  82. /// <param name="pageSize"></param>
  83. /// <returns></returns>
  84. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.ScoreManage.FinalExaminationView> 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)
  85. {
  86. var statusList = this.GetStatusViewList();
  87. var startStatus = this.GetStartStatus();
  88. var status = this.GetInputStatusList(statusList, startStatus);
  89. var endStatus = statusList.Where(x => x.Description.Contains("[PASS]")).Select(x => x.ID).FirstOrDefault();
  90. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  91. if (collegeID.HasValue)
  92. exp = exp.And(this.CollegeExpression(collegeID));
  93. if (departmentID.HasValue)
  94. exp = exp.And(x => x.DepartmentID == departmentID);
  95. if (schoolyearID.HasValue)
  96. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  97. if (coursematerialID.HasValue)
  98. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  99. if (courseTypeID.HasValue)
  100. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  101. if (examsCategoryID.HasValue)
  102. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  103. if (approvalStatus.HasValue)
  104. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  105. if (gradeYearID.HasValue)
  106. exp = exp.And(x => x.GradeYearID == gradeYearID);
  107. if (isCheck == "true")
  108. exp = exp.And(x => x.CreatorUserID == EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID);
  109. var query = scoreDAL.GetScoreViewQueryable(exp);
  110. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  111. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  112. if (isCheck != "true")
  113. {
  114. query = this.DataRangeFunction(query);
  115. }
  116. var result = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToGridResultSet<FinalExaminationView>(pageIndex, pageSize);
  117. result.rows.ForEach(x => { x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name; x.ApprovalEndStatus = endStatus; });
  118. result.rows.ForEach(x => x.IsEntry = status.Contains(x.ApprovalStatus) ? true : false); //控制是否可录入成绩
  119. return result;
  120. }
  121. /// <summary>
  122. /// 获取期末设定
  123. /// </summary>
  124. /// <param name="configuretView"></param>
  125. /// <param name="collegeID"></param>
  126. /// <param name="departmentID"></param>
  127. /// <param name="schoolyearID"></param>
  128. /// <param name="coursematerialID"></param>
  129. /// <param name="courseTypeID"></param>
  130. /// <param name="examsCategoryID"></param>
  131. /// <param name="examinationType"></param>
  132. /// <returns></returns>
  133. public List<ViewModel.ScoreManage.FinalExaminationView> GetFinalExaminationViewList(ViewModel.ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? approvalStatus, int? gradeYearID, string isCheck, List<Guid?> idList = null)
  134. {
  135. var statusList = this.GetStatusViewList();
  136. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  137. if (collegeID.HasValue)
  138. exp = exp.And(this.CollegeExpression(collegeID));
  139. if (departmentID.HasValue)
  140. exp = exp.And(x => x.DepartmentID == departmentID);
  141. if (schoolyearID.HasValue)
  142. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  143. if (coursematerialID.HasValue)
  144. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  145. if (courseTypeID.HasValue)
  146. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  147. if (examsCategoryID.HasValue)
  148. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  149. if (approvalStatus.HasValue)
  150. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  151. if (gradeYearID.HasValue)
  152. exp = exp.And(x => x.GradeYearID == gradeYearID);
  153. if (isCheck == "true")
  154. exp = exp.And(x => x.CreatorUserID == EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID);
  155. if (idList != null && idList.Count() > 0)
  156. exp = exp.And(x => idList.Contains(x.FinalExaminationID));
  157. var query = scoreDAL.GetScoreViewQueryable(exp);
  158. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  159. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  160. if (isCheck != "true")
  161. {
  162. query = this.DataRangeFunction(query);
  163. }
  164. var result = query.OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToList();
  165. result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  166. return result;
  167. }
  168. /// <summary>
  169. /// 重置
  170. /// </summary>
  171. /// <param name="finalExaminationID"></param>
  172. public void ScoreResettingDelete(Guid? finalExaminationID)
  173. {
  174. try
  175. {
  176. if (finalExaminationID.HasValue)
  177. {
  178. UnitOfWork.Delete<ER_ScoreDetail>(x => x.ER_Score.FinalExaminationID == finalExaminationID && x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  179. UnitOfWork.Delete<ER_Score>(x => x.FinalExaminationID == finalExaminationID && x.RecordStatus == (int)SYS_STATUS.USABLE);
  180. }
  181. }
  182. catch (Exception)
  183. {
  184. throw;
  185. }
  186. }
  187. /// <summary>
  188. /// 重置
  189. /// </summary>
  190. /// <param name="finalExaminationID"></param>
  191. public void ScoreDelete(List<Guid> finalExaminationIDs)
  192. {
  193. try
  194. {
  195. var nowTime = DateTime.Now;
  196. var curUser = CustomPrincipal.Current;
  197. UnitOfWork.Update<ER_FinalExamination>(x => new ER_FinalExamination { ScoreFormulaID = null, CreditFormulaID = null, GradePointFormulaID = null, ModifyTime = nowTime, ModifyUserID = curUser.UserID },
  198. (x => finalExaminationIDs.Contains(x.FinalExaminationID)));
  199. UnitOfWork.Delete<ER_ScoreDetail>(x => finalExaminationIDs.Contains((Guid)x.ER_Score.FinalExaminationID) && x.RecordStatus == (int)SYS_STATUS.USABLE);
  200. UnitOfWork.Delete<ER_Score>(x =>finalExaminationIDs.Contains((Guid)x.FinalExaminationID)&& x.RecordStatus == (int)SYS_STATUS.USABLE);
  201. }
  202. catch (Exception)
  203. {
  204. throw;
  205. }
  206. }
  207. /// <summary>
  208. /// 学生成绩录入
  209. /// </summary>
  210. /// <param name="finalExaminationID"></param>
  211. /// <returns></returns>
  212. public IGridResultSet<StudentScoreInputView> GetStudentScoreInputViewGrid(Guid? finalExaminationID)
  213. {
  214. #region 获取各种初始化数据
  215. var applyConvertEndStatus = scoreConvertByReplaceServices.GetCorrectEndStatus();
  216. var replaceConvertEndStatus = scoreConvertByReplaceServices.GetCorrectEndStatus();
  217. //获取各流程的结束状态,需要注意的是,不一定所有的高校都有部署全部的流程,所以 如果读不出数据来就留空
  218. var suspensionEndStatusID = ExaminationSuspensionServices.Value.GetEndStatusID();
  219. var misconductEndStatusID = MisconductServices.Value.GetEndStatusID();
  220. var exemptionEndStatusID = ExaminationExemptionServices.Value.GetEndStatusID();
  221. //获取考试性质设置项,用于判断是否需要读取上次考试成绩
  222. var examsCategorySettingList = ExamsCategorySettingDAL.GetExamsCategorySettingView().ToList();
  223. //缓交申请(审核通过)
  224. var chargeDelayEndStatusID = WorkflowServices.Value.GetCorrectEndStatus("EC_ChargeDelay") ?? null;
  225. var statusList = this.GetStatusViewList();
  226. var startStatus = this.GetStartStatus();
  227. var inputStatusList = this.GetInputStatusList(statusList, startStatus);
  228. var canInputStatus = statusList.Where(x => x.Description.Contains("[ENTRY]")).Select(x => x.ID).FirstOrDefault();
  229. //获取缴费控制项
  230. var isChargeControl = ParameterServices.Value.GetParameterValue<bool>(CF_ParameterType.IsScoreEditControlForCharge);
  231. var importScoreList = new List<ImportScoreView>();
  232. var lastPassScoreList = new List<StudentScoreInputDetailView>();
  233. var scoreTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType).ToList();
  234. #endregion
  235. var finalExamination = FinalExaminationDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationID);
  236. var ResultTypeList = scoreDAL.ResultTypeDetailRepository.GetList(x => x.ResultTypeID == finalExamination.ResultTypeID).ToList();
  237. var collegeScoreParameterSetting = this.ScoreParamterCollegeSettingServices.Value.GetScoreParameterCollegeSettingView(finalExamination.CollegeID, finalExamination.GradeYearID);
  238. var query = scoreDAL.GetStudentScoreInputViewQuqeryable(finalExaminationID, suspensionEndStatusID, misconductEndStatusID, exemptionEndStatusID, chargeDelayEndStatusID, isChargeControl ?? false, applyConvertEndStatus, replaceConvertEndStatus);
  239. var resultList = query.OrderBy(x => x.LoginID).ToGridResultSet();
  240. var detailList = scoreDAL.GetStudentScoreInputDetailViewQuqeryable(finalExaminationID).ToList();
  241. //当期末设定处于可录入和重新录入两个状态下就刷新平时成绩(如果有的话)
  242. bool isGetImportScore = inputStatusList.Contains(finalExamination.ApprovalStatus)
  243. && finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam
  244. && collegeScoreParameterSetting != null && collegeScoreParameterSetting.ScoreTypeID != null;
  245. bool isLoadScore = (examsCategorySettingList.Any(x => x.ExamsCategoryID == finalExamination.ExamsCategoryID && x.IsReadHistory)
  246. && finalExamination.ApprovalStatus == canInputStatus);
  247. if (isGetImportScore)
  248. {
  249. importScoreList = this.ImportScoreDAL.GetImportScoreViewQueryableByFinalExaminationID(finalExamination.FinalExaminationID).ToList();
  250. }
  251. if (isLoadScore)
  252. {
  253. lastPassScoreList = this.scoreDAL.GetLastPassedStudentScoreForResit(finalExamination.FinalExaminationID).ToList();
  254. }
  255. for (int i = 0; i < resultList.rows.Count; i ++ )
  256. {
  257. resultList.rows[i].No = i + 1;
  258. resultList.rows[i].ScoreDetail = (from scoreType in scoreTypeList
  259. join detail in detailList.Where(x => x.UserID == resultList.rows[i].UserID)
  260. on scoreType.Value equals detail.ScoreTypeID into ddetail
  261. from detail in ddetail.DefaultIfEmpty()
  262. select new StudentScoreInputDetailView
  263. {
  264. ScoreTypeID = scoreType.Value,
  265. UserID = resultList.rows[i].UserID,
  266. Score = (detail == null ?
  267. (
  268. (collegeScoreParameterSetting != null
  269. && finalExamination.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam
  270. && collegeScoreParameterSetting.ScoreTypeID == (int)CF_ScoreType.Peacetime
  271. && scoreType.Value == (int)CF_ScoreType.Peacetime) ?
  272. (int?)0 :
  273. null
  274. ) : detail.Score),
  275. IsCanEdit = (detail == null ?
  276. (collegeScoreParameterSetting == null || collegeScoreParameterSetting.ScoreTypeID != scoreType.Value || finalExamination.ExamsCategoryID != (int)CF_ExamsCategory.FinalExam)
  277. : detail.IsCanEdit),
  278. RecordStatus = (detail == null ? (int)SYS_STATUS.USABLE : detail.RecordStatus)
  279. })
  280. .ToDictionary(x => x.ScoreTypeID.ToString());
  281. //读取导入的平时成绩
  282. if (isGetImportScore && resultList.rows[i].RecordStatus > (int)SYS_STATUS.UNUSABLE)
  283. {
  284. var importScore = importScoreList.FirstOrDefault(x => x.UserID == resultList.rows[i].UserID);
  285. if (importScore != null)
  286. {
  287. if (!resultList.rows[i].ScoreDetail.ContainsKey(collegeScoreParameterSetting.ScoreTypeID.ToString()))
  288. {
  289. resultList.rows[i].ScoreDetail.Add(collegeScoreParameterSetting.ScoreTypeID.ToString(), new StudentScoreInputDetailView
  290. {
  291. ScoreTypeID = collegeScoreParameterSetting.ScoreTypeID,
  292. UserID = importScore.UserID,
  293. RecordStatus = (int)SYS_STATUS.USABLE
  294. });
  295. }
  296. resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].Score = importScore.Score;
  297. resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].IsCanEdit = false;
  298. }
  299. else {
  300. //如果有个性设定,但是没有导入成绩
  301. resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].Score = null;
  302. resultList.rows[i].ScoreDetail[collegeScoreParameterSetting.ScoreTypeID.ToString()].IsCanEdit = false;
  303. }
  304. }
  305. //读取上一次期末考试合格的分数
  306. if (isLoadScore && resultList.rows[i].RecordStatus > (int)SYS_STATUS.UNUSABLE)
  307. {
  308. var lastPassScore = lastPassScoreList.Where(x => x.UserID == resultList.rows[i].UserID).ToList();
  309. lastPassScore.ForEach(x =>
  310. {
  311. if (!resultList.rows[i].ScoreDetail.ContainsKey(x.ScoreTypeID.ToString()))
  312. {
  313. resultList.rows[i].ScoreDetail.Add(x.ScoreTypeID.ToString(), new StudentScoreInputDetailView
  314. {
  315. ScoreTypeID = x.ScoreTypeID,
  316. UserID = x.UserID,
  317. RecordStatus = (int)SYS_STATUS.USABLE,
  318. IsCanEdit = true
  319. });
  320. }
  321. resultList.rows[i].ScoreDetail[x.ScoreTypeID.ToString()].Score = x.Score;
  322. });
  323. }
  324. //如果整行都不能编辑,那这里面的明细也不能编辑
  325. if (!resultList.rows[i].IsCanEdit)
  326. {
  327. resultList.rows[i].ScoreDetail.ForEach(x => x.Value.IsCanEdit = false);
  328. }
  329. }
  330. return resultList;
  331. }
  332. /// <summary>
  333. /// 获取成绩录入
  334. /// </summary>
  335. /// <param name="finalExaminationIDs"></param>
  336. /// <returns></returns>
  337. public List<ER_Score> GetScoreList(Guid? finalExaminationID)
  338. {
  339. try
  340. {
  341. List<ER_Score> 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();
  342. scoreList.ForEach(x => { x.TotalScore = Math.Round(x.TotalScore ?? 0, 0, MidpointRounding.AwayFromZero); });
  343. return scoreList;
  344. }
  345. catch (Exception ex)
  346. {
  347. throw new Exception(ex.Message);
  348. }
  349. }
  350. public void ScoreSave(FinalExaminationView finalExaminationView, IList<StudentScoreInputView> scoreViewList)
  351. {
  352. var startStatus = this.GetStartStatus();
  353. var statusList = this.GetStatusViewList();
  354. var inputStatusList = this.GetInputStatusList(statusList, startStatus);
  355. ER_FinalExamination finalExamination = scoreDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationView.FinalExaminationID);
  356. if (!inputStatusList.Contains(finalExamination.ApprovalStatus))
  357. {
  358. return;
  359. }
  360. finalExamination.ScoreFormulaID = finalExaminationView.ScoreFormulaID;
  361. finalExamination.CreditFormulaID = finalExaminationView.CreditFormulaID;
  362. finalExamination.GradePointFormulaID = finalExaminationView.GradePointFormulaID;
  363. finalExamination.Comment = finalExaminationView.Comment;
  364. var insertDetailList = scoreViewList.Where(x =>
  365. //重录时需要过滤掉无需重录的学生
  366. (x.RecordStatus ?? (int)SYS_STATUS.USABLE) > (int)SYS_STATUS.UNUSABLE
  367. //过滤总成绩为null的行,一般只有空行会是null
  368. && x.TotalScore != null)
  369. .ToList();
  370. var reEnterDetailList = scoreViewList.Where(x =>
  371. //重录时需要过滤掉无需重录的学生
  372. (x.RecordStatus ?? (int)SYS_STATUS.USABLE) > (int)SYS_STATUS.UNUSABLE)
  373. .ToList();
  374. //重录时只删除重录的数据再插入
  375. var userIDList = reEnterDetailList.Select(x => x.UserID).ToList();
  376. if (userIDList.Count > 0)
  377. {
  378. UnitOfWork.Delete<ER_ScoreDetail>(x => x.ER_Score.FinalExaminationID == finalExamination.FinalExaminationID && userIDList.Contains(x.ER_Score.UserID) && x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  379. UnitOfWork.Delete<ER_Score>(x => x.FinalExaminationID == finalExamination.FinalExaminationID && userIDList.Contains(x.UserID) && x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  380. }
  381. foreach (var scoreView in reEnterDetailList)
  382. {
  383. ER_Score score = new ER_Score();
  384. score.ScoreID = Guid.NewGuid();
  385. score.UserID = scoreView.UserID;
  386. score.FinalExaminationID = scoreView.FinalExaminationID;
  387. score.ExamsStateID = scoreView.ExamsStateID;
  388. score.TotalScore = scoreView.TotalScore;
  389. score.Credit = scoreView.Credit;
  390. score.GradePoint = scoreView.GradePoint;
  391. score.Remark = scoreView.Remarks;
  392. SetNewStatus(score);
  393. score.RecordStatus = Convert.ToInt32(scoreView.RecordStatus);
  394. UnitOfWork.Add(score);
  395. foreach (var scoreDetailView in scoreView.ScoreDetail)
  396. {
  397. ER_ScoreDetail scoreDetail = new ER_ScoreDetail();
  398. scoreDetail.ScoreDetailID = Guid.NewGuid();
  399. scoreDetail.ScoreID = score.ScoreID;
  400. scoreDetail.ScoreTypeID = Convert.ToInt32(scoreDetailView.Key);
  401. scoreDetail.Score = scoreDetailView.Value.Score;
  402. SetNewStatus(scoreDetail);
  403. UnitOfWork.Add(scoreDetail);
  404. }
  405. }
  406. UnitOfWork.Commit();
  407. }
  408. private List<int?> GetRequiredScoreTypeList(FinalExaminationView finalExaminationView, IList<StudentScoreInputView> scoreViewList)
  409. {
  410. var customScoreFormulaList = this.CustomScoreFormulaRepository.Entities.ToList();
  411. if (customScoreFormulaList.Count > 0)
  412. {
  413. var scoreTypesList = scoreViewList.SelectMany(x => x.ScoreDetail)
  414. .Where(x => x.Value.Score != null)
  415. .Select(x => x.Value.ScoreTypeID).Distinct().ToList();
  416. //创建空结构
  417. var groups = customScoreFormulaList.Where(x => false).Select(x => new { Total = 0, Detail = new List<ER_CustomScoreFormula> {x} }).ToList();
  418. scoreTypesList.ForEach(scoreType => {
  419. customScoreFormulaList.ForEach(scoreFormula => {
  420. var mateResultList = groups.Where(x => x.Detail.Any(w => w.ScoreType == scoreFormula.ScoreType)).ToList();
  421. mateResultList.ForEach(mateResult => {
  422. var item = new { Total = mateResult.Total + (scoreFormula.Percentage ?? 0), Detail = mateResult.Detail.Where(x => x.ScoreType != scoreFormula.ScoreType).ToList() };
  423. item.Detail.Add(scoreFormula);
  424. groups.Add(item);
  425. });
  426. if (mateResultList.Count == 0)
  427. {
  428. groups.ForEach(x => x = new { Total = x.Total + (scoreFormula.Percentage ?? 0), Detail = x.Detail.Concat(new List<ER_CustomScoreFormula> { scoreFormula }).ToList() });
  429. groups.Add(new { Total = (scoreFormula.Percentage ?? 0), Detail = new List<ER_CustomScoreFormula> { scoreFormula } });
  430. }
  431. });
  432. });
  433. return groups.Where(x => x.Total == 100).SelectMany(x => x.Detail).Select(x => x.ScoreType).Distinct().ToList();
  434. }
  435. else
  436. {
  437. var scoreFormula = ScoreFormulaRepository.GetSingle(x => x.ScoreFormulaID == finalExaminationView.ScoreFormulaID, (x => x.ER_ScoreFormulaDetail));
  438. return scoreFormula.ER_ScoreFormulaDetail.Where(x => x.Percentage > 0).Select(x => x.ScoreType).Distinct().ToList();
  439. }
  440. }
  441. public void Submit(FinalExaminationView finalExaminationView, IList<StudentScoreInputView> scoreViewList)
  442. {
  443. var normalStateID = ExamsStateSettingDAL.GetNormalID();
  444. var examinationSuspensionID = ExamsStateSettingDAL.GetExaminationSuspensionID();
  445. var examinationExemptionID = ExamsStateSettingDAL.GetExaminationExemptionID();
  446. var misconductIDList = ExamsStateSettingDAL.GetMisconductIDList();
  447. //缓交申请(审核通过)
  448. var chargeDelayEndStatusID = WorkflowServices.Value.GetCorrectEndStatus("EC_ChargeDelay") ?? null;
  449. //获取缴费控制项
  450. var isChargeControl = ParameterServices.Value.GetParameterValue<bool>(CF_ParameterType.IsScoreEditControlForCharge);
  451. var userIDList = scoreViewList.Select(x => x.UserID).ToList();
  452. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  453. expStudentCharge = expStudentCharge.And(x => userIDList.Contains(x.UserID));
  454. var arrearList = arrearsListDAL.GetArrearListViewAble(expStudentCharge, x => x.RecordStatus == chargeDelayEndStatusID);
  455. this.ScoreSave(finalExaminationView, scoreViewList);
  456. var requireScoreTypeList = this.GetRequiredScoreTypeList(finalExaminationView, scoreViewList);
  457. //有欠费控制并且欠费的不让提交
  458. if (arrearList != null && isChargeControl.HasValue)
  459. {
  460. if (arrearList.Count() > 0 && isChargeControl.Value)
  461. {
  462. throw new Exception("存在欠费的学生无法提交,请检查。");
  463. }
  464. }
  465. if (scoreViewList.Any(x =>
  466. x.ExamsStateID != examinationSuspensionID && x.ExamsStateID != examinationExemptionID && !misconductIDList.Contains(x.ExamsStateID)
  467. && x.ScoreDetail.Any(w => requireScoreTypeList.Contains(w.Value.ScoreTypeID) && w.Value.Score == null)))//&& x.IsConvert == false
  468. {
  469. throw new Exception("学生成绩录入未完整,请检查。");
  470. }
  471. var actionList = this.GetActionView(finalExaminationView.FinalExaminationID.Value, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID).ToList();
  472. var actionID = actionList.Where(x => x.ActionName == "提交").Select(w => w.ActionID).FirstOrDefault();
  473. if (actionID != null)
  474. {
  475. Approve(new List<Guid> { finalExaminationView.FinalExaminationID.Value }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionID, null);
  476. }
  477. }
  478. /// <summary>
  479. /// 提交以及保存
  480. /// </summary>
  481. /// <param name="finalExaminationID"></param>
  482. /// <param name="listExpandoObject"></param>
  483. public void ScoreAdd(FinalExaminationView finalExaminationView, List<ExpandoObject> listExpandoObject, int? approvalStatus)
  484. {
  485. try
  486. {
  487. var normalStateID = ExamsStateSettingDAL.GetNormalID();
  488. var suspensionID = ExamsStateSettingDAL.GetExaminationSuspensionID();
  489. var exemptionID = ExamsStateSettingDAL.GetExaminationExemptionID();
  490. var misconductStateList = ExamsStateSettingDAL.GetMisconductIDList();
  491. var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  492. ER_FinalExamination finalExamination = scoreDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == finalExaminationView.FinalExaminationID);
  493. List<ExaminationSuspensionView> suspensionList = ExaminationSuspensionServices.Value.GetExaminationSuspensionViewListByFinalExamination(finalExaminationView.FinalExaminationID);
  494. List<ExaminationExemptionView> exemptionList = ExaminationExemptionServices.Value.GetExaminationExemptionViewListByFinalExamination(finalExaminationView.FinalExaminationID);
  495. List<MisconductView> misconductList = MisconductServices.Value.GetMisconductViewListByFinalExamination(finalExaminationView.FinalExaminationID);
  496. if (finalExamination == null)
  497. throw new Exception("未找到相对应的设定!");
  498. //if (approvalStatus.HasValue)
  499. // finalExamination.ApprovalStatus = approvalStatus;
  500. finalExamination.ScoreFormulaID = finalExaminationView.ScoreFormulaID;
  501. finalExamination.CreditFormulaID = finalExaminationView.CreditFormulaID;
  502. finalExamination.GradePointFormulaID = finalExaminationView.GradePointFormulaID;
  503. finalExamination.Comment = finalExaminationView.Comment;
  504. if (listExpandoObject != null)
  505. {
  506. UnitOfWork.Delete<ER_ScoreDetail>(x => x.ER_Score.FinalExaminationID == finalExamination.FinalExaminationID);
  507. UnitOfWork.Delete<ER_Score>(x => x.FinalExaminationID == finalExamination.FinalExaminationID);
  508. foreach (dynamic item in listExpandoObject)
  509. {
  510. Guid ScoreID = item.ScoreID == "" || item.ScoreID == null ? Guid.Empty : new Guid(item.ScoreID);
  511. ER_Score score = new ER_Score();
  512. decimal totalScoreNum = Convert.ToDecimal(item.TotalScore);
  513. score.ScoreID = Guid.NewGuid();
  514. score.UserID = new Guid(item.UserID);
  515. score.FinalExaminationID = new Guid(item.FinalExaminationID);
  516. score.ExamsStateID = Convert.ToInt32(item.ExamsStateID);
  517. var suspension = suspensionList.FirstOrDefault(x => x.UserID == new Guid(item.UserID));
  518. var exemption = exemptionList.FirstOrDefault(x => x.UserID == new Guid(item.UserID));
  519. var misconduct = misconductList.FirstOrDefault(x => x.UserID == new Guid(item.UserID));
  520. if (misconduct != null)
  521. {
  522. score.ExamsStateID = misconduct.ExamsStateID;
  523. score.TotalScore = 0;
  524. score.Credit = 0;
  525. score.GradePoint = 0;
  526. }
  527. else if (exemption != null)
  528. {
  529. score.ExamsStateID = exemptionID;
  530. score.TotalScore = 0;
  531. score.Credit = 0;
  532. score.GradePoint = 0;
  533. }
  534. else if (suspension != null)
  535. {
  536. score.ExamsStateID = suspensionID;
  537. score.TotalScore = 0;
  538. score.Credit = 0;
  539. score.GradePoint = 0;
  540. }
  541. else
  542. {
  543. score.ExamsStateID = normalStateID;
  544. if (Convert.ToInt32(item.ExamsStateID) != normalStateID)
  545. {
  546. score.ExamsStateID = Convert.ToInt32(item.ExamsStateID);
  547. }
  548. score.TotalScore = totalScoreNum > 0 ? Math.Round(totalScoreNum, 0, MidpointRounding.AwayFromZero) : totalScoreNum;
  549. score.Credit = Convert.ToDecimal(item.Credit);
  550. score.GradePoint = Convert.ToDecimal(item.GradePoint);
  551. }
  552. score.Remark = item.Remarks;
  553. SetNewStatus(score);
  554. score.RecordStatus = Convert.ToInt32(item.RecordStatus);
  555. UnitOfWork.Add(score);
  556. foreach (var scoreDynamicType in scoreDynamicTypes)
  557. {
  558. var dic = (IDictionary<string, object>)item;
  559. var formulascore = dic["Formula_" + scoreDynamicType.Value];
  560. ER_ScoreDetail scoreDetail = new ER_ScoreDetail();
  561. scoreDetail.ScoreDetailID = Guid.NewGuid();
  562. scoreDetail.ScoreID = score.ScoreID;
  563. scoreDetail.ScoreTypeID = scoreDynamicType.Value;
  564. //if (scoreDetail.ScoreTypeID != (int)CF_ScoreType.Peacetime
  565. // && (score.ExamsStateID == suspensionID || score.ExamsStateID == exemptionID
  566. // || misconductStateList.Contains(score.ExamsStateID)))
  567. //{
  568. // scoreDetail.Score = null;
  569. //}
  570. //else
  571. //{
  572. if (formulascore == "")
  573. {
  574. formulascore = null;
  575. }
  576. if (formulascore != null)
  577. {
  578. scoreDetail.Score = Convert.ToDecimal(formulascore);
  579. }
  580. else
  581. {
  582. scoreDetail.Score = null;
  583. }
  584. //}
  585. SetNewStatus(scoreDetail);
  586. UnitOfWork.Add(scoreDetail);
  587. }
  588. }
  589. }
  590. UnitOfWork.Commit();
  591. //因为成绩保存和提交调用同样的方法,参数传1表示成绩提交,调用工作流
  592. if (approvalStatus == 1)
  593. {
  594. var actionList = WorkflowServices.Value.GetActionView("ER_FinalExamination", finalExamination.FinalExaminationID, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID).ToList();
  595. var actionID = actionList.Where(x => x.ActionName == "提交").Select(w => w.ActionID).FirstOrDefault();
  596. Approve(new List<Guid> { finalExamination.FinalExaminationID }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, actionID, null);
  597. //UnitOfWork.Commit();
  598. }
  599. }
  600. catch (Exception ex)
  601. {
  602. throw;
  603. }
  604. }
  605. /// <summary>
  606. /// 查询未审核期末设定
  607. /// </summary>
  608. /// <param name="configuretView"></param>
  609. /// <param name="collegeID"></param>
  610. /// <param name="departmentID"></param>
  611. /// <param name="schoolyearID"></param>
  612. /// <param name="coursematerialID"></param>
  613. /// <param name="courseTypeID"></param>
  614. /// <param name="courseQualityID"></param>
  615. /// <param name="pageIndex"></param>
  616. /// <param name="pageSize"></param>
  617. /// <returns></returns>
  618. public IGridResultSet<FinalExaminationView> GetFinalExaminationScoreAuditViewGrid(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? gradeYearID, int? approvalStatus, int pageIndex, int pageSize)
  619. {
  620. //List<int> list = new List<int>();
  621. //list.Add((int)EMIS.ViewModel.CF_ScoreState.Submitted);
  622. var statusList = this.GetStatusViewList(); //获取工作流列表
  623. var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(x => x.ID); //审核中的节点的Description标识为[AP]
  624. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  625. if (collegeID.HasValue)
  626. exp = exp.And(this.CollegeExpression(collegeID));
  627. if (departmentID.HasValue)
  628. exp = exp.And(x => x.DepartmentID == departmentID);
  629. if (schoolyearID.HasValue)
  630. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  631. if (coursematerialID.HasValue)
  632. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  633. if (courseTypeID.HasValue)
  634. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  635. if (examsCategoryID.HasValue)
  636. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  637. if (gradeYearID.HasValue)
  638. exp = exp.And(x => x.GradeYearID == gradeYearID);
  639. if (approvalStatus.HasValue)
  640. exp = exp.And(x => x.ApprovalStatus == approvalStatus);
  641. //if (status.Count() > 0) //
  642. // exp = exp.And(x => status.Contains((int)x.ApprovalStatus));
  643. //exp = exp.And(x => list.Contains((int)x.ApprovalStatus));
  644. var query = scoreDAL.GetScoreViewQueryable(exp);
  645. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  646. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  647. var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToGridResultSet<FinalExaminationView>(pageIndex, pageSize);
  648. result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  649. return result;
  650. }
  651. /// <summary>
  652. /// //获取录入状态
  653. /// </summary>
  654. /// <returns></returns>
  655. public int? ApprovalStatus()
  656. {
  657. var statusList = this.GetStatusViewList(); //获取工作流列表
  658. var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(x => x.ID).FirstOrDefault();
  659. return status;
  660. }
  661. ///<summary>
  662. ///检查是否能被审核
  663. ///</summary>
  664. public void CheckApprovalStatus(List<int?> ApprovalStatus)
  665. {
  666. try
  667. {
  668. var statusList = this.GetStatusViewList(); //获取工作流列表
  669. var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(w => w.ID).ToList();
  670. List<int?> okNo = new List<int?>();
  671. foreach (var s in status)
  672. {
  673. for (int i = 0; i < ApprovalStatus.Count(); i++)
  674. {
  675. if (ApprovalStatus[i] == s)
  676. {
  677. okNo.Add(ApprovalStatus[i]);
  678. }
  679. }
  680. }
  681. if (okNo.Count() != ApprovalStatus.Count())
  682. {
  683. throw new Exception("只能操作待审核和重录待审的数据!");
  684. }
  685. }
  686. catch (Exception)
  687. {
  688. throw;
  689. }
  690. }
  691. /// <summary>
  692. /// 查询期末设定
  693. /// </summary>
  694. /// <param name="configuretView"></param>
  695. /// <param name="collegeID"></param>
  696. /// <param name="departmentID"></param>
  697. /// <param name="schoolyearID"></param>
  698. /// <param name="coursematerialID"></param>
  699. /// <param name="courseTypeID"></param>
  700. /// <param name="courseQualityID"></param>
  701. /// <param name="pageIndex"></param>
  702. /// <param name="pageSize"></param>
  703. /// <returns></returns>
  704. public List<FinalExaminationView> GetFinalExaminationScoreAuditViewList(ConfiguretView configuretView, Guid? collegeID, Guid? departmentID, Guid? schoolyearID, Guid? coursematerialID, int? courseTypeID, int? examsCategoryID, int? gradeYearID, int? status)
  705. {
  706. //List<int> list = new List<int>();
  707. //list.Add((int)EMIS.ViewModel.CF_ScoreState.Submitted);
  708. var statusList = this.GetStatusViewList(); //获取工作流列表
  709. //var status = statusList.Where(x => (x.Description ?? "").Contains("[AP]")).Select(x => x.ID); //审核中的节点的Description标识为[AP]
  710. Expression<Func<ER_FinalExamination, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  711. if (collegeID.HasValue)
  712. exp = exp.And(this.CollegeExpression(collegeID));
  713. if (departmentID.HasValue)
  714. exp = exp.And(x => x.DepartmentID == departmentID);
  715. if (schoolyearID.HasValue)
  716. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  717. if (coursematerialID.HasValue)
  718. exp = exp.And(x => x.CoursematerialID == coursematerialID);
  719. if (courseTypeID.HasValue)
  720. exp = exp.And(x => x.CourseTypeID == courseTypeID);
  721. if (examsCategoryID.HasValue)
  722. exp = exp.And(x => x.ExamsCategoryID == examsCategoryID);
  723. if (gradeYearID.HasValue)
  724. exp = exp.And(x => x.GradeYearID == gradeYearID);
  725. //exp = exp.And(x => list.Contains((int)x.ApprovalStatus));
  726. if (status.HasValue)
  727. exp = exp.And(x => x.ApprovalStatus == status);
  728. var query = scoreDAL.GetScoreViewQueryable(exp);
  729. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  730. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  731. var result = this.DataRangeFunction(query).OrderByDescending(x => x.SchoolyearCode).ThenByDescending(x => x.CourseName).ThenByDescending(x => x.CreateTime).ThenByDescending(x => x.ApprovalStatus).ToList();
  732. result.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  733. return result;
  734. }
  735. /// <summary>
  736. /// 申请撤销成绩
  737. /// </summary>
  738. /// <param name="listUserID"></param>
  739. /// <param name="FinalExaminationID"></param>
  740. public void Rebut(List<Guid?> listUserID, Guid? FinalExaminationID)
  741. {
  742. try
  743. {
  744. //ModifyProcessState(FinalExaminationID.Value, "A", null);
  745. var statusList = this.GetStatusViewList();
  746. var endStatus = statusList.Where(x => (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).FirstOrDefault();
  747. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  748. var curUserID = curUser.UserID;
  749. var action = GetActionView(FinalExaminationID.Value, curUserID);
  750. var finalExamination = scoreDAL.finalExaminationRepository.GetSingle(x => x.FinalExaminationID == FinalExaminationID, (x => x.CF_Schoolyear), x => x.ER_FinalExaminationStudent);
  751. if (finalExamination.ApprovalStatus != endStatus)
  752. throw new Exception("只能选择已审核通过的成绩进行撤销");
  753. var queryScore = scoreDAL.ScoreRepository.GetList(x => x.FinalExaminationID == FinalExaminationID, (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList();
  754. var listScore = queryScore.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID
  755. && !listUserID.Contains(x.UserID.Value)).ToList();
  756. var studentList = scoreDAL.userRepository.GetList(x => listUserID.Contains(x.UserID));
  757. string studentNames = "";
  758. var count = 0;
  759. foreach (Sys_User user in studentList)
  760. {
  761. studentNames = studentNames + user.Name + "、";
  762. count++;
  763. if (count > 10)
  764. {
  765. break;
  766. }
  767. }
  768. studentNames = studentNames.Substring(0, studentNames.Length - 1);
  769. string comment = "";
  770. if (studentList.Count() > 10)
  771. {
  772. comment = "意见:" + studentNames + "... 共" + studentList.Count() + "位学生成绩申请重录";
  773. }
  774. else
  775. {
  776. comment = "意见:" + studentNames + "共" + studentList.Count() + "位学生成绩申请重录";
  777. }
  778. foreach (var score in listScore)
  779. {
  780. //申请撤销成绩时,将ER_Score表没有勾选的数据的RecordStatus标识为false,成绩再次录入时,这些成绩不可编辑修改,只能修改申请撤销时选中的数据
  781. score.RecordStatus = (int)SYS_STATUS.UNUSABLE;
  782. score.CreateUserID = curUserID;
  783. score.ModifyUserID = curUserID;
  784. score.ModifyTime = score.CreateTime = DateTime.Now;
  785. }
  786. UnitOfWork.BatchUpdate<ER_Score>(listScore);
  787. //删除所勾选的提交成绩表
  788. var SubmitedScoreIDs = scoreDAL.GetDeleteSubmittedScore(finalExamination.FinalExaminationID, listUserID).Select(x => x.SubmitedScoreID).ToList();
  789. if (SubmitedScoreIDs.Count > 0)
  790. {
  791. //先刷新最终成绩在删除已提交成绩,否则会找不到最终成绩
  792. StudentScoreServices.Value.RefreshFinallyScoreBeforeDelete(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID));
  793. UnitOfWork.Delete<ER_SubmitedScoreDetail>(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID));
  794. UnitOfWork.Delete<ER_SubmitedScore>(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID));
  795. }
  796. Approve(new List<Guid> { FinalExaminationID.Value }, EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID, Guid.Empty, comment);
  797. //UnitOfWork.Commit();
  798. }
  799. catch (Exception)
  800. {
  801. throw;
  802. }
  803. }
  804. /// <summary>
  805. /// 根据当前环节ID获取下一步审批动作
  806. /// </summary>
  807. /// <param name="formID">表单ID</param>
  808. /// <param name="userID">当前用户ID</param>
  809. /// <returns></returns>
  810. public List<ActionView> GetAuditingActionView(Guid formID, Guid userID)
  811. {
  812. try
  813. {
  814. List<ActionView> listAction = GetActionView(formID, userID);
  815. return listAction;
  816. }
  817. catch (Exception)
  818. {
  819. throw;
  820. }
  821. }
  822. public void SubmitedScoreDelete(Guid finalExaminationID, Guid userID)
  823. {
  824. var finalExamination = scoreDAL.finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID, x => x.ER_Score).FirstOrDefault();
  825. if (finalExamination != null)
  826. {
  827. var userList = finalExamination.ER_Score.Select(x => x.UserID);
  828. UnitOfWork.Delete<ER_SubmitedScoreDetail>(x => x.ER_SubmitedScore.SchoolyearID == finalExamination.SchoolyearID
  829. && x.ER_SubmitedScore.CoursematerialID == finalExamination.CoursematerialID
  830. && x.ER_SubmitedScore.ExamsCategoryID == finalExamination.ExamsCategoryID
  831. && userList.Contains(x.ER_SubmitedScore.UserID));
  832. UnitOfWork.Delete<ER_SubmitedScore>(x => x.SchoolyearID == finalExamination.SchoolyearID
  833. && x.CoursematerialID == finalExamination.CoursematerialID
  834. && x.ExamsCategoryID == finalExamination.ExamsCategoryID
  835. && userList.Contains(x.UserID));
  836. }
  837. }
  838. /// <summary>
  839. /// 审核通过后执行方法
  840. /// </summary>
  841. /// <param name="finalExaminationID"></param>
  842. /// <param name="userID"></param>
  843. public void FinalExaminationApproved(List<Guid> finalExaminationIDList, Guid userID)
  844. {
  845. try
  846. {
  847. List<ER_SubmitedScore> listSubmitedScore = new List<ER_SubmitedScore>();
  848. List<ER_SubmitedScoreDetail> listSubmitedScoreDetail = new List<ER_SubmitedScoreDetail>();
  849. var finalExaminationList = scoreDAL.finalExaminationRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID), (x => x.CF_Schoolyear), x => x.ER_FinalExaminationStudent).ToList();
  850. var queryScore = scoreDAL.ScoreRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty)
  851. && x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE, (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList();
  852. var userList = queryScore.Select(x => x.UserID).ToList();
  853. var queryFinalExaminationStudentList = scoreDAL.finalExaminationRepository.GetList(x => finalExaminationIDList.Contains(x.FinalExaminationID), (x => x.ER_FinalExaminationStudent.Select(w => w.CF_Student.CF_Classmajor.CF_Grademajor)))
  854. .ToList().SelectMany(x => x.ER_FinalExaminationStudent).ToList().Where(x => userList.Contains(x.UserID));
  855. var listUserID = queryFinalExaminationStudentList.Select(x => x.UserID).Distinct().ToList();
  856. var listScore = queryScore.Where(x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty)).ToList();
  857. var listFinalExaminationStudentList = queryFinalExaminationStudentList.Where(x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty)).ToList();
  858. using (TransactionScope ts = new TransactionScope())
  859. {
  860. //删除提交成绩表
  861. var SubmitedScoreIDs = scoreDAL.GetDeleteSubmittedScore(finalExaminationIDList, listUserID).Select(x => x.SubmitedScoreID).ToList();
  862. if (SubmitedScoreIDs.Count > 0)
  863. {
  864. UnitOfWork.Delete<ER_SubmitedScoreDetail>(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID));
  865. UnitOfWork.Delete<ER_SubmitedScore>(x => SubmitedScoreIDs.Contains(x.SubmitedScoreID));
  866. }
  867. //UnitOfWork.Remove<ER_SubmitedScore>(x => x.SchoolyearID == finalExamination.SchoolyearID
  868. // && x.CoursematerialID == finalExamination.CoursematerialID
  869. // && x.ExamsCategoryID == finalExamination.ExamsCategoryID);
  870. //UnitOfWork.Commit();
  871. ts.Complete();
  872. }
  873. foreach (var score in listScore)
  874. {
  875. if (score.RecordStatus == (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE)
  876. continue; //当ER_Score表RecordStatus禁用状态时,表明本次更新不更新该成绩,所以不新增或修改成绩
  877. var finalExaminationStudent = listFinalExaminationStudentList.Where(x => x.UserID == score.UserID && x.FinalExaminationID == score.FinalExaminationID).FirstOrDefault();
  878. if (finalExaminationStudent == null)
  879. {
  880. continue;
  881. }
  882. var finalExamination = finalExaminationList.FirstOrDefault(x => x.FinalExaminationID == score.FinalExaminationID);
  883. if (finalExamination == null)
  884. {
  885. continue;
  886. }
  887. ER_SubmitedScore submitedScore = new ER_SubmitedScore();
  888. submitedScore.SubmitedScoreID = Guid.NewGuid();
  889. submitedScore.SchoolyearID = finalExamination.SchoolyearID;
  890. submitedScore.SchoolyearNumID = finalExaminationStudent.SchoolyearNumID;
  891. submitedScore.FinalExaminationID = finalExamination.FinalExaminationID;
  892. submitedScore.DepartmentID = finalExamination.DepartmentID;
  893. submitedScore.ClassName = finalExamination.ClassName;
  894. submitedScore.CoursematerialID = finalExamination.CoursematerialID;
  895. submitedScore.CourseTypeID = finalExamination.CourseTypeID;
  896. submitedScore.ExamsCategoryID = finalExamination.ExamsCategoryID;
  897. submitedScore.ExaminationModeID = finalExamination.ExaminationModeID;
  898. submitedScore.Credit = finalExamination.Credit;
  899. submitedScore.ExamsDatetime = finalExamination.ExamsDatetime;
  900. submitedScore.ResultTypeID = finalExamination.ResultTypeID;
  901. submitedScore.CreatorUserID = finalExamination.CreatorUserID;
  902. submitedScore.EntryDeadlineTime = finalExamination.EntryDeadlineTime;
  903. submitedScore.IsEntry = finalExamination.IsEntry;
  904. submitedScore.ExaminationType = finalExamination.ExaminationType;
  905. submitedScore.StarttermID = finalExaminationStudent.StarttermID;
  906. submitedScore.UserID = score.UserID;
  907. submitedScore.ExamsStateID = score.ExamsStateID;
  908. submitedScore.TotalScore = score.TotalScore;
  909. submitedScore.ScoreCredit = score.Credit;
  910. submitedScore.GradePoint = score.GradePoint;
  911. submitedScore.Remark = score.Remark;
  912. //在期末设定、已提交成绩、最终成绩增加总学时字段,已提交成绩总学时来源于期末设定
  913. submitedScore.TotalHours = finalExamination.TotalHours;
  914. SetNewStatus(submitedScore);
  915. listSubmitedScore.Add(submitedScore);
  916. //详细表
  917. foreach (var scoreDetail in score.ER_ScoreDetail)
  918. {
  919. //已提交成绩录入分数表
  920. ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail();
  921. submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid();
  922. submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID;
  923. submitedScoreDetail.ScoreTypeID = scoreDetail.ScoreTypeID;
  924. submitedScoreDetail.Score = scoreDetail.Score;
  925. SetNewStatus(submitedScoreDetail);
  926. listSubmitedScoreDetail.Add(submitedScoreDetail);
  927. }
  928. }
  929. //query.ForEach(x => x.ApprovalStatus = approvalStatus);
  930. //query.ForEach(x => x.Remark = opinioncomment);
  931. UnitOfWork.BulkInsert(listSubmitedScore);
  932. UnitOfWork.BulkInsert(listSubmitedScoreDetail);
  933. StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(listSubmitedScore.Select(x => x.SubmitedScoreID).ToList());
  934. //当成绩更新完时,ER_Score表RecordStatus恢复可用状态,因为RecordStatus只用于标识本次不更新该成绩
  935. UnitOfWork.Update<ER_Score>(x => new ER_Score { RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.USABLE }, x => finalExaminationIDList.Contains(x.FinalExaminationID ?? Guid.Empty));
  936. //UnitOfWork.Commit();
  937. }
  938. catch (Exception)
  939. {
  940. throw;
  941. }
  942. }
  943. /// <summary>
  944. /// 审核不同意撤销成绩后执行方法
  945. /// </summary>
  946. /// <param name="finalExaminationIDList"></param>
  947. /// <param name="userID"></param>
  948. //public void FinalExaminationRebutDisAgree(Guid finalExaminationID, Guid userID)
  949. //{
  950. // try
  951. // {
  952. // var queryScore = scoreDAL.scoreRepository.GetList(x => x.FinalExaminationID == finalExaminationID, (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList();
  953. // //当不同意撤销成绩时,ER_Score表RecordStatus恢复可用状态,因为RecordStatus用于标识撤销成绩时不更新的成绩
  954. // queryScore.ForEach(x => x.RecordStatus = (int)EMIS.ViewModel.SYS_STATUS.USABLE);
  955. // UnitOfWork.Commit();
  956. // }
  957. // catch (Exception)
  958. // {
  959. // throw;
  960. // }
  961. //}
  962. // 申请撤销成绩时驳回后执行方法
  963. public void FinalExaminationRebutDisAgree(List<Guid> finalExaminationIDList, Guid userID)
  964. {
  965. try
  966. {
  967. this.FinalExaminationApproved(finalExaminationIDList, userID);
  968. }
  969. catch (Exception)
  970. {
  971. throw;
  972. }
  973. }
  974. ///// <summary>
  975. ///// 审核
  976. ///// </summary>
  977. ///// <param name="listFinalExaminationID"></param>
  978. ///// <param name="approvalStatus"></param>
  979. //public void GetFinalExaminationApprovalStatus(List<Guid> listFinalExaminationID, int? approvalStatus, string opinioncomment)
  980. //{
  981. // try
  982. // {
  983. // List<ER_SubmitedScore> listSubmitedScore = new List<ER_SubmitedScore>();
  984. // List<ER_SubmitedScoreDetail> listSubmitedScoreDetail = new List<ER_SubmitedScoreDetail>();
  985. // var query = scoreDAL.finalExaminationRepository.GetList(x => listFinalExaminationID.Contains(x.FinalExaminationID), (x => x.CF_Schoolyear)).ToList();
  986. // var schoolyearIDs = query.Select(x => x.SchoolyearID).ToList(); //获取学年学期
  987. // var coursematerialIDs = query.Select(x => x.CoursematerialID).ToList(); //获取课程
  988. // var queryScore = scoreDAL.scoreRepository.GetList(x => listFinalExaminationID.Contains((Guid)x.FinalExaminationID), (x => x.ER_ScoreDetail), (x => x.CF_Student.CF_Recruitstudents.CF_Schoolyear)).ToList();
  989. // var queryFinalExaminationStudentList = scoreDAL.finalExaminationRepository.GetList(x => listFinalExaminationID.Contains((Guid)x.FinalExaminationID), (x => x.ER_FinalExaminationStudent.Select(w => w.CF_Student.CF_Classmajor.CF_Grademajor)))
  990. // .ToList().SelectMany(x => x.ER_FinalExaminationStudent).ToList();
  991. // var userIDs = queryScore.Select(x => x.UserID).ToList();
  992. // foreach (var finalExamination in query)
  993. // {
  994. // var listScore = queryScore.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID).ToList();
  995. // var listFinalExaminationStudentList = queryFinalExaminationStudentList.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID).ToList();
  996. // if (approvalStatus == (int)EMIS.ViewModel.CF_ScoreState.Approved)
  997. // {
  998. // foreach (var score in listScore)
  999. // {
  1000. // var finalExaminationStudent = listFinalExaminationStudentList.Where(x => x.UserID == score.UserID).FirstOrDefault();
  1001. // if (finalExaminationStudent == null)
  1002. // {
  1003. // continue;
  1004. // }
  1005. // //已提交成绩
  1006. // ER_SubmitedScore submitedScore = new ER_SubmitedScore();
  1007. // submitedScore.SubmitedScoreID = Guid.NewGuid();
  1008. // submitedScore.SchoolyearID = finalExamination.SchoolyearID;
  1009. // submitedScore.SchoolyearNumID = finalExaminationStudent.SchoolyearNumID;
  1010. // submitedScore.DepartmentID = finalExamination.DepartmentID;
  1011. // submitedScore.ClassName = finalExamination.ClassName;
  1012. // submitedScore.CoursematerialID = finalExamination.CoursematerialID;
  1013. // submitedScore.CourseTypeID = finalExamination.CourseTypeID;
  1014. // submitedScore.ExamsCategoryID = finalExamination.ExamsCategoryID;
  1015. // submitedScore.ExaminationModeID = finalExamination.ExaminationModeID;
  1016. // submitedScore.Credit = finalExamination.Credit;
  1017. // submitedScore.ExamsDatetime = finalExamination.ExamsDatetime;
  1018. // submitedScore.ResultTypeID = finalExamination.ResultTypeID;
  1019. // submitedScore.CreatorUserID = finalExamination.CreatorUserID;
  1020. // submitedScore.EntryDeadlineTime = finalExamination.EntryDeadlineTime;
  1021. // submitedScore.IsEntry = finalExamination.IsEntry;
  1022. // submitedScore.ExaminationType = finalExamination.ExaminationType;
  1023. // submitedScore.StarttermID = finalExaminationStudent.StarttermID;
  1024. // submitedScore.UserID = score.UserID;
  1025. // submitedScore.ExamsStateID = score.ExamsStateID;
  1026. // submitedScore.TotalScore = score.TotalScore;
  1027. // submitedScore.ScoreCredit = score.Credit;
  1028. // submitedScore.GradePoint = score.GradePoint;
  1029. // submitedScore.Remark = score.Remark;
  1030. // SetNewStatus(submitedScore);
  1031. // listSubmitedScore.Add(submitedScore); //已提交成绩
  1032. // //详细表
  1033. // foreach (var scoreDetail in score.ER_ScoreDetail)
  1034. // {
  1035. // //已提交成绩录入分数表
  1036. // ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail();
  1037. // submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid();
  1038. // submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID;
  1039. // submitedScoreDetail.ScoreTypeID = scoreDetail.ScoreTypeID;
  1040. // submitedScoreDetail.Score = scoreDetail.Score;
  1041. // SetNewStatus(submitedScoreDetail);
  1042. // listSubmitedScoreDetail.Add(submitedScoreDetail);
  1043. // }
  1044. // }
  1045. // }
  1046. // }
  1047. // query.ForEach(x => x.ApprovalStatus = approvalStatus);
  1048. // query.ForEach(x => x.Remark = opinioncomment);
  1049. // UnitOfWork.BulkInsert(listSubmitedScore);
  1050. // UnitOfWork.BulkInsert(listSubmitedScoreDetail);
  1051. // foreach (var finalExamination in query)
  1052. // {
  1053. // var userList = queryScore.Where(x => x.FinalExaminationID == finalExamination.FinalExaminationID).Select(x => x.UserID).ToList();
  1054. // StudentScoreServices.Value.RefreshFinallyScore(finalExamination.CoursematerialID ?? Guid.Empty, userList, null);
  1055. // }
  1056. // UnitOfWork.Commit();
  1057. // }
  1058. // catch (Exception)
  1059. // {
  1060. // throw;
  1061. // }
  1062. //}
  1063. public void RefreshExaminationSuspensionState(IList<Guid> examinationSuspensionIDList)
  1064. {
  1065. var suspensionID = ExamsStateSettingDAL.GetExaminationSuspensionID();
  1066. var statusList = this.GetStatusViewList(); //获取工作流列表
  1067. //审核中的数据(节点的Description为[AP])和end的节点不能修改
  1068. var approvedFinalExaminationState = statusList.Where(x => (x.Description ?? "").Contains("[AP]") && (x.Description ?? "").Contains("[PASS]")).Select(x => x.ID).ToList();
  1069. //List<int?> approvedFinalExaminationState = new List<int?> { (int)CF_ScoreState.Approved, (int)CF_ScoreState.Submitted };
  1070. var submitedFinalExaminationList = this.scoreDAL.GetFinalExaminationByExaminationSuspension(
  1071. (x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)),
  1072. (x => approvedFinalExaminationState.Contains(x.ApprovalStatus))
  1073. ).ToList();
  1074. if (submitedFinalExaminationList.Count > 0)
  1075. {
  1076. throw new Exception("该课程的期末考试成绩已经提交,无法更新缓考状态。");
  1077. }
  1078. var scoreList = this.scoreDAL.GetScoreByExaminationSuspension((x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)))
  1079. .Include(x => x.ER_ScoreDetail).ToList();
  1080. foreach (var score in scoreList)
  1081. {
  1082. score.ExamsStateID = suspensionID;
  1083. score.TotalScore = null;
  1084. score.Credit = null;
  1085. score.GradePoint = null;
  1086. foreach (var detail in score.ER_ScoreDetail)
  1087. {
  1088. detail.Score = null;
  1089. }
  1090. }
  1091. this.UnitOfWork.Commit();
  1092. }
  1093. public void RefreshCancelExaminationSuspensionState(IList<Guid> examinationSuspensionIDList)
  1094. {
  1095. var normalStateID = ExamsStateSettingDAL.GetNormalID();
  1096. List<int?> approvedFinalExaminationState = new List<int?> { (int)CF_ScoreState.Approved, (int)CF_ScoreState.Submitted };
  1097. var submitedFinalExaminationList = this.scoreDAL.GetFinalExaminationByExaminationSuspension(
  1098. (x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)),
  1099. (x => approvedFinalExaminationState.Contains(x.ApprovalStatus))
  1100. ).ToList();
  1101. if (submitedFinalExaminationList.Count > 0)
  1102. {
  1103. throw new Exception("该课程的期末考试成绩已经提交,无法更新缓考状态。");
  1104. }
  1105. var scoreList = this.scoreDAL.GetScoreByExaminationSuspension((x => examinationSuspensionIDList.Contains(x.ExaminationSuspensionID)))
  1106. .Include(x => x.ER_ScoreDetail).ToList();
  1107. foreach (var score in scoreList)
  1108. {
  1109. score.ExamsStateID = normalStateID;
  1110. score.TotalScore = null;
  1111. score.Credit = null;
  1112. score.GradePoint = null;
  1113. foreach (var detail in score.ER_ScoreDetail)
  1114. {
  1115. detail.Score = null;
  1116. }
  1117. }
  1118. this.UnitOfWork.Commit();
  1119. }
  1120. public void RefreshExaminationExemptionState(IList<Guid> examinationExemptionIDList)
  1121. {
  1122. var exemptionID = ExamsStateSettingDAL.GetExaminationExemptionID();
  1123. var scoreList = this.scoreDAL.GetScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID))
  1124. .Include(x => x.ER_ScoreDetail)
  1125. .Include(x => x.ER_FinalExamination)
  1126. .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList();
  1127. var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID))
  1128. .Include(x => x.ER_SubmitedScoreDetail).ToList();
  1129. foreach (var score in scoreList)
  1130. {
  1131. score.ExamsStateID = exemptionID;
  1132. score.TotalScore = null;
  1133. score.Credit = null;
  1134. score.GradePoint = null;
  1135. foreach (var detail in score.ER_ScoreDetail)
  1136. {
  1137. detail.Score = null;
  1138. }
  1139. var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID);
  1140. if (finalExaminationStudent != null)
  1141. {
  1142. var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID
  1143. && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID);
  1144. if (submittedScore != null)
  1145. {
  1146. submittedScore.ExamsStateID = exemptionID;
  1147. submittedScore.TotalScore = null;
  1148. submittedScore.Credit = null;
  1149. submittedScore.GradePoint = null;
  1150. foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail)
  1151. {
  1152. submitedScoreDetail.Score = null;
  1153. }
  1154. }
  1155. }
  1156. }
  1157. this.UnitOfWork.Commit();
  1158. var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList();
  1159. this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList);
  1160. this.UnitOfWork.Commit();
  1161. }
  1162. public void RefreshCancelExaminationExemptionState(IList<Guid> examinationExemptionIDList)
  1163. {
  1164. var normalStateID = ExamsStateSettingDAL.GetNormalID();
  1165. var scoreList = this.scoreDAL.GetScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID))
  1166. .Include(x => x.ER_ScoreDetail)
  1167. .Include(x => x.ER_FinalExamination)
  1168. .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList();
  1169. var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID))
  1170. .Include(x => x.ER_SubmitedScoreDetail).ToList();
  1171. foreach (var score in scoreList)
  1172. {
  1173. score.ExamsStateID = normalStateID;
  1174. score.TotalScore = null;
  1175. score.Credit = null;
  1176. score.GradePoint = null;
  1177. foreach (var detail in score.ER_ScoreDetail)
  1178. {
  1179. detail.Score = null;
  1180. }
  1181. var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID);
  1182. if (finalExaminationStudent != null)
  1183. {
  1184. var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID
  1185. && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID);
  1186. if (submittedScore != null)
  1187. {
  1188. submittedScore.ExamsStateID = normalStateID;
  1189. submittedScore.TotalScore = null;
  1190. submittedScore.Credit = null;
  1191. submittedScore.GradePoint = null;
  1192. foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail)
  1193. {
  1194. submitedScoreDetail.Score = null;
  1195. }
  1196. }
  1197. }
  1198. }
  1199. this.UnitOfWork.Commit();
  1200. var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList();
  1201. this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList);
  1202. this.UnitOfWork.Commit();
  1203. }
  1204. #region 免修刷成绩注释
  1205. //public void RefreshExaminationExemptionState(IList<Guid> examinationExemptionIDList)
  1206. //{
  1207. // var exemptionID = ExamsStateSettingDAL.GetExaminationExemptionID();
  1208. // var exemptionScore = ExamsStateSettingDAL.GetExemptionScore();
  1209. // var scoreList = this.scoreDAL.GetScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID))
  1210. // .Include(x => x.ER_ScoreDetail)
  1211. // .Include(x => x.ER_FinalExamination)
  1212. // .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList();
  1213. // var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByExaminationExemption(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID))
  1214. // .Include(x => x.ER_SubmitedScoreDetail).ToList();
  1215. // if (scoreList.Count > 0)
  1216. // {
  1217. // foreach (var score in scoreList)
  1218. // {
  1219. // score.ExamsStateID = exemptionID;
  1220. // score.TotalScore = null;
  1221. // score.Credit = null;
  1222. // score.GradePoint = null;
  1223. // foreach (var detail in score.ER_ScoreDetail)
  1224. // {
  1225. // detail.Score = null;
  1226. // }
  1227. // var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID);
  1228. // if (finalExaminationStudent != null)
  1229. // {
  1230. // var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID
  1231. // && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID);
  1232. // if (submittedScore != null)
  1233. // {
  1234. // submittedScore.ExamsStateID = exemptionID;
  1235. // submittedScore.TotalScore = null;
  1236. // submittedScore.Credit = null;
  1237. // submittedScore.GradePoint = null;
  1238. // foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail)
  1239. // {
  1240. // submitedScoreDetail.Score = null;
  1241. // }
  1242. // }
  1243. // }
  1244. // }
  1245. // this.UnitOfWork.Commit();
  1246. // var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList();
  1247. // this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList);
  1248. // this.UnitOfWork.Commit();
  1249. // }
  1250. // else
  1251. // {
  1252. // List<ER_SubmitedScore> listSubmitedScore = new List<ER_SubmitedScore>();
  1253. // List<ER_SubmitedScoreDetail> listSubmitedScoreDetail = new List<ER_SubmitedScoreDetail>();
  1254. // //查询该课程来源是否为期末设定
  1255. // var examinationExemptionFromFinalExamination = scoreDAL.GetExaminationExemptionFromFinalExamination(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)).FirstOrDefault();
  1256. // var examinationExemptionFromEducationMission = scoreDAL.GetExaminationExemptionFromFinalExamination(x => examinationExemptionIDList.Contains(x.ExaminationExemptionID)).FirstOrDefault();
  1257. // if (examinationExemptionFromFinalExamination != null)
  1258. // {
  1259. // List<Guid> SubmitedScoreIDList = new List<Guid>();
  1260. // var GradePoint = this.StudentScoreServices.Value.GetGradePoint(examinationExemptionFromFinalExamination.CollegeID, examinationExemptionFromFinalExamination.GradeYearID, examinationExemptionFromFinalExamination.ExamsCategoryID, examinationExemptionFromFinalExamination.CourseTypeID, exemptionScore);
  1261. // ER_SubmitedScore submitedScore = new ER_SubmitedScore();
  1262. // submitedScore.SubmitedScoreID = Guid.NewGuid();
  1263. // submitedScore.SchoolyearID = examinationExemptionFromFinalExamination.SchoolyearID;
  1264. // submitedScore.SchoolyearNumID = examinationExemptionFromFinalExamination.SchooolYearNumID;
  1265. // submitedScore.FinalExaminationID = examinationExemptionFromFinalExamination.FinalExaminationID;
  1266. // submitedScore.DepartmentID = examinationExemptionFromFinalExamination.DepartmentID;
  1267. // submitedScore.ClassName = examinationExemptionFromFinalExamination.ClassName;
  1268. // submitedScore.CoursematerialID = examinationExemptionFromFinalExamination.CoursematerialID;
  1269. // submitedScore.CourseTypeID = examinationExemptionFromFinalExamination.CourseTypeID;
  1270. // submitedScore.ExamsCategoryID = examinationExemptionFromFinalExamination.ExamsCategoryID;
  1271. // submitedScore.ExaminationModeID = examinationExemptionFromFinalExamination.ExaminationModeID;
  1272. // submitedScore.Credit = examinationExemptionFromFinalExamination.Credit;
  1273. // submitedScore.ExamsDatetime = examinationExemptionFromFinalExamination.ExamsDatetime;
  1274. // submitedScore.ResultTypeID = examinationExemptionFromFinalExamination.ResultTypeID;
  1275. // submitedScore.CreatorUserID = examinationExemptionFromFinalExamination.CreatorUserID;
  1276. // submitedScore.EntryDeadlineTime = examinationExemptionFromFinalExamination.EntryDeadlineTime;
  1277. // submitedScore.IsEntry = examinationExemptionFromFinalExamination.IsEntry;
  1278. // submitedScore.ExaminationType = examinationExemptionFromFinalExamination.ExaminationType;
  1279. // submitedScore.StarttermID = examinationExemptionFromFinalExamination.StarttermID;
  1280. // submitedScore.UserID = examinationExemptionFromFinalExamination.UserID;
  1281. // submitedScore.ExamsStateID = exemptionID;
  1282. // submitedScore.TotalScore = exemptionScore;
  1283. // submitedScore.ScoreCredit = examinationExemptionFromFinalExamination.Credit;
  1284. // submitedScore.GradePoint = GradePoint;
  1285. // submitedScore.Remark = null;
  1286. // //在期末设定、已提交成绩、最终成绩增加总学时字段,已提交成绩总学时来源于期末设定
  1287. // submitedScore.TotalHours = examinationExemptionFromFinalExamination.TotalHours;
  1288. // SetNewStatus(submitedScore);
  1289. // listSubmitedScore.Add(submitedScore);
  1290. // var scoreDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  1291. // //详细表
  1292. // foreach (var scoreDetail in scoreDynamicTypes)
  1293. // {
  1294. // //已提交成绩录入分数表
  1295. // ER_SubmitedScoreDetail submitedScoreDetail = new ER_SubmitedScoreDetail();
  1296. // submitedScoreDetail.SubmitedScoreDetailID = Guid.NewGuid();
  1297. // submitedScoreDetail.SubmitedScoreID = submitedScore.SubmitedScoreID;
  1298. // submitedScoreDetail.ScoreTypeID = scoreDetail.Value;
  1299. // submitedScoreDetail.Score = null;
  1300. // SetNewStatus(submitedScoreDetail);
  1301. // listSubmitedScoreDetail.Add(submitedScoreDetail);
  1302. // }
  1303. // SubmitedScoreIDList.Add(submitedScore.SubmitedScoreID);
  1304. // UnitOfWork.BulkInsert(listSubmitedScore);
  1305. // UnitOfWork.BulkInsert(listSubmitedScoreDetail);
  1306. // this.UnitOfWork.Commit();
  1307. // this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(SubmitedScoreIDList);
  1308. // }
  1309. // //查询该课程来源是否为教学任务
  1310. // //查询该课程来源是否为执行计划
  1311. // }
  1312. //}
  1313. #endregion
  1314. public void RefreshMisconductState(IList<Guid> misconductIDList)
  1315. {
  1316. var scoreList = this.scoreDAL.GetScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID))
  1317. .Include(x => x.ER_ScoreDetail)
  1318. .Include(x => x.ER_FinalExamination)
  1319. .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList();
  1320. var misconductViewList = this.MisconductDAL.GetMisconductViewQueryable(x => misconductIDList.Contains(x.MisconductID)).ToList();
  1321. var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID))
  1322. .Include(x => x.ER_SubmitedScoreDetail).ToList();
  1323. foreach (var score in scoreList)
  1324. {
  1325. var finalExamination = score.ER_FinalExamination;
  1326. var misconductView = misconductViewList.FirstOrDefault(x => x.SchoolyearID == finalExamination.SchoolyearID
  1327. && x.CoursematerialID == finalExamination.CoursematerialID && x.ExamsCategoryID == finalExamination.ExamsCategoryID
  1328. && x.UserID == score.UserID);
  1329. score.ExamsStateID = misconductView.ExamsStateID;
  1330. score.TotalScore = null;
  1331. score.Credit = null;
  1332. score.GradePoint = null;
  1333. foreach (var detail in score.ER_ScoreDetail)
  1334. {
  1335. detail.Score = null;
  1336. }
  1337. var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID);
  1338. if (finalExaminationStudent != null)
  1339. {
  1340. var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == misconductView.CoursematerialID
  1341. && x.UserID == misconductView.UserID && x.StarttermID == finalExaminationStudent.StarttermID);
  1342. if (submittedScore != null)
  1343. {
  1344. submittedScore.ExamsStateID = misconductView.ExamsStateID;
  1345. submittedScore.TotalScore = null;
  1346. submittedScore.Credit = null;
  1347. submittedScore.GradePoint = null;
  1348. foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail)
  1349. {
  1350. submitedScoreDetail.Score = null;
  1351. }
  1352. }
  1353. }
  1354. }
  1355. this.UnitOfWork.Commit();
  1356. var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList();
  1357. this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList);
  1358. this.UnitOfWork.Commit();
  1359. }
  1360. public void RefreshCancelMisconductState(IList<Guid> misconductIDList)
  1361. {
  1362. var normalStateID = ExamsStateSettingDAL.GetNormalID();
  1363. var scoreList = this.scoreDAL.GetScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID))
  1364. .Include(x => x.ER_ScoreDetail)
  1365. .Include(x => x.ER_FinalExamination)
  1366. .Include(x => x.ER_FinalExamination.ER_FinalExaminationStudent).ToList();
  1367. var misconductViewList = this.MisconductDAL.GetMisconductViewQueryable(x => misconductIDList.Contains(x.MisconductID)).ToList();
  1368. var submitedScoreList = this.StudentScoreDAL.GetSubmitedScoreByMisconduct(x => misconductIDList.Contains(x.MisconductID))
  1369. .Include(x => x.ER_SubmitedScoreDetail).ToList();
  1370. foreach (var score in scoreList)
  1371. {
  1372. score.ExamsStateID = normalStateID;
  1373. score.TotalScore = null;
  1374. score.Credit = null;
  1375. score.GradePoint = null;
  1376. foreach (var detail in score.ER_ScoreDetail)
  1377. {
  1378. detail.Score = null;
  1379. }
  1380. var finalExaminationStudent = score.ER_FinalExamination.ER_FinalExaminationStudent.FirstOrDefault(x => x.UserID == score.UserID);
  1381. if (finalExaminationStudent != null)
  1382. {
  1383. var submittedScore = submitedScoreList.FirstOrDefault(x => x.CoursematerialID == score.ER_FinalExamination.CoursematerialID
  1384. && x.UserID == score.UserID && x.StarttermID == finalExaminationStudent.StarttermID);
  1385. if (submittedScore != null)
  1386. {
  1387. submittedScore.ExamsStateID = normalStateID;
  1388. submittedScore.TotalScore = null;
  1389. submittedScore.Credit = null;
  1390. submittedScore.GradePoint = null;
  1391. foreach (var submitedScoreDetail in submittedScore.ER_SubmitedScoreDetail)
  1392. {
  1393. submitedScoreDetail.Score = null;
  1394. }
  1395. }
  1396. }
  1397. }
  1398. this.UnitOfWork.Commit();
  1399. var submitedScoreIDList = submitedScoreList.Select(x => x.SubmitedScoreID).ToList();
  1400. this.StudentScoreServices.Value.RefreshFinallyScoreBySubmitedScoreID(submitedScoreIDList);
  1401. this.UnitOfWork.Commit();
  1402. }
  1403. private List<string> GetImportColumns()
  1404. {
  1405. List<string> cellheader = new List<string>
  1406. {
  1407. "学号", "姓名", "考试性质"
  1408. };
  1409. var scoreTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  1410. scoreTypeList.ForEach(x => {
  1411. cellheader.Add(x.Name);
  1412. });
  1413. return cellheader;
  1414. }
  1415. private void CheckColumns(List<string> cellheader, DataTable data)
  1416. {
  1417. List<string> missColumn = new List<string>();
  1418. cellheader.ForEach(x =>
  1419. {
  1420. if (data.Columns.IndexOf(x) < 0)
  1421. {
  1422. missColumn.Add(x);
  1423. }
  1424. });
  1425. if (missColumn.Count > 0)
  1426. {
  1427. throw new Exception("导入模板中缺少" + string.Join("、", missColumn) + "列的信息。");
  1428. }
  1429. }
  1430. private object[] GetErrorMessageData(int rowIndex, DataRow row, string message)
  1431. {
  1432. var result = row.ItemArray;
  1433. result = (new object[] { (object)(rowIndex + 1) })
  1434. .Concat(result)
  1435. .Concat(new object[] { (object)("第" + (rowIndex + 1).ToString() + "行数据错误:" + message) }).ToArray();
  1436. return result;
  1437. }
  1438. private IEnumerable<string> GetErrorCellHeader(IList<string> cellheader)
  1439. {
  1440. return new List<string> { "行号" }
  1441. .Concat(cellheader)
  1442. .Concat(new List<string> { "错误提示" });
  1443. }
  1444. private DataTable CheckValues(IList<string> cellheader, DataTable data,
  1445. IList<Sys_User> userList, IList<Guid?> examStudentList, IList<StudentScoreImportView> correctList)
  1446. {
  1447. var errorColumnList = GetErrorCellHeader(cellheader);
  1448. var scoreTypeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ScoreType);
  1449. var errorTable = new DataTable();
  1450. errorColumnList.ForEach(x => errorTable.Columns.Add(x));
  1451. List<object[]> errorStack = new List<object[]>();
  1452. var dupRows = data.AsEnumerable()
  1453. .GroupBy(key => key.Field<string>("学号"))
  1454. .Where(w => w.Count() > 1)
  1455. .SelectMany(s => s)
  1456. .ToArray();
  1457. for (int i = data.Rows.Count - 1; i >= 0; i--)
  1458. {
  1459. DataRow row = data.Rows[i];
  1460. var allNull = true;
  1461. var rowErrorMessage = "";
  1462. foreach (var columnName in cellheader)
  1463. {
  1464. if (!string.IsNullOrEmpty(row[columnName] as string))
  1465. {
  1466. allNull = false;
  1467. }
  1468. }
  1469. if (allNull)
  1470. {
  1471. continue;
  1472. }
  1473. var importRow = new StudentScoreImportView();
  1474. var loginID = row["学号"] as string;
  1475. var userName = row["姓名"] as string;
  1476. if (string.IsNullOrEmpty(loginID))
  1477. {
  1478. rowErrorMessage += "学号不能为空;";
  1479. }
  1480. else
  1481. {
  1482. if (dupRows.Any(x => x.Field<string>("学号") == loginID))
  1483. {
  1484. rowErrorMessage += "学号重复;";
  1485. }
  1486. var user = userList.FirstOrDefault(x => x.LoginID == loginID);
  1487. if (user == null)
  1488. {
  1489. rowErrorMessage += "系统中找不到对应的学生;";
  1490. }
  1491. else if (!examStudentList.Contains(user.UserID))
  1492. {
  1493. rowErrorMessage += "该学号不存在当前录入班级,请检查;";
  1494. }
  1495. else
  1496. {
  1497. importRow.LoginID = loginID;
  1498. importRow.UserName = userName;
  1499. importRow.UserID = user.UserID;
  1500. }
  1501. }
  1502. importRow.ScoreDetail = new Dictionary<int?, decimal?>();
  1503. scoreTypeList.ForEach(x =>
  1504. {
  1505. var score = row[x.Name];
  1506. if (score == null || score.ToString().Trim() == "")
  1507. {
  1508. importRow.ScoreDetail.Add(x.Value, null);
  1509. }
  1510. else if (!Regex.IsMatch(score.ToString(), @"^\d+(\.\d{1,2})?$"))
  1511. {
  1512. rowErrorMessage += x.Name + "必须为保留最多两位小数的数字;";
  1513. }
  1514. else
  1515. {
  1516. importRow.ScoreDetail.Add(x.Value, Convert.ToDecimal(score));
  1517. }
  1518. });
  1519. if (!string.IsNullOrEmpty(rowErrorMessage))
  1520. {
  1521. errorStack.Add(this.GetErrorMessageData(i, row, rowErrorMessage));
  1522. }
  1523. else
  1524. {
  1525. correctList.Add(importRow);
  1526. }
  1527. }
  1528. errorStack.OrderBy(x => x[0]).ForEach(x => errorTable.Rows.Add(x));
  1529. return errorTable;
  1530. }
  1531. private string WriteErrorFile(NpoiExcelHelper excel, IEnumerable<string> errorCellheader, DataTable errorTable)
  1532. {
  1533. var errorExcelBuff = excel.ExportMemoryStream(errorTable, "", errorCellheader.ToArray());
  1534. var logicalPath = Const.LOCAL_SETTING_UPLOAD_FILEPATH + "/" + Guid.NewGuid().ToString() + ".xls";
  1535. var physicalPath = HttpContext.Current.Server.MapPath(logicalPath);
  1536. var fs = File.Create(physicalPath);
  1537. fs.Write(errorExcelBuff, 0, errorExcelBuff.Length);
  1538. fs.Flush();
  1539. fs.Close();
  1540. return UrlHelper.GenerateContentUrl(logicalPath, HttpContext.Current.Request.RequestContext.HttpContext);
  1541. }
  1542. public ExcelImportResult ScoreImport(string filePath, Guid? finalExaminationID)
  1543. {
  1544. var result = new ExcelImportResult();
  1545. var excel = new NpoiExcelHelper();
  1546. List<string> cellheader = GetImportColumns();
  1547. var dt = excel.ImpotColumns(filePath);
  1548. System.IO.File.Delete(filePath);//删除本地缓存文件
  1549. this.CheckColumns(cellheader, dt);
  1550. #region 准备校验数据
  1551. var loginIDList = dt.AsEnumerable().Select(x => x.Field<string>("学号")).Distinct();
  1552. var userList = this.ImportScoreDAL.UserRepository.GetList(x => loginIDList.Contains(x.LoginID)).ToList();
  1553. var examStudentList = this.FinalExaminationStudentRepository.GetList(x => x.FinalExaminationID == finalExaminationID)
  1554. .Select(x => x.UserID).ToList();
  1555. #endregion
  1556. var correctList = new List<StudentScoreImportView>();
  1557. var errorTable = this.CheckValues(cellheader, dt, userList, examStudentList, correctList);
  1558. result.SuccessCount = correctList.Count;
  1559. result.ErrorCount = errorTable.Rows.Count;
  1560. if (errorTable.Rows.Count > 0)
  1561. {
  1562. result.IsAllSuccess = false;
  1563. var errorCellHeader = this.GetErrorCellHeader(cellheader).ToArray();
  1564. result.ErrorFilePath = this.WriteErrorFile(excel, this.GetErrorCellHeader(cellheader), errorTable);
  1565. result.Message = string.Format("导入失败,详情请点击错误数据下载查看。");
  1566. }
  1567. else
  1568. {
  1569. result.IsAllSuccess = true;
  1570. result.Data = correctList;
  1571. }
  1572. return result;
  1573. }
  1574. public int? GetNormalExamsID()
  1575. {
  1576. return this.ExamsStateSettingDAL.GetNormalID();
  1577. }
  1578. public int? GetExaminationSuspensionID()
  1579. {
  1580. return this.ExamsStateSettingDAL.GetExaminationSuspensionID();
  1581. }
  1582. public int? GetExaminationExemptionID()
  1583. {
  1584. return this.ExamsStateSettingDAL.GetExaminationExemptionID();
  1585. }
  1586. public List<int?> GetMisconductIDList()
  1587. {
  1588. return this.ExamsStateSettingDAL.GetMisconductIDList();
  1589. }
  1590. public List<ER_ResultTypeDetail> GetScoreType(Guid? finalExaminationIDs)
  1591. {
  1592. var finalExamination=scoreDAL.finalExaminationRepository.Entities.Where(x => x.FinalExaminationID == finalExaminationIDs).FirstOrDefault();
  1593. return scoreDAL.ResultTypeDetailRepository.GetList(x=>x.ResultTypeID==finalExamination.ResultTypeID).ToList();
  1594. }
  1595. public List<ER_ExamsStateSetting> GetExamsStateSettingList()
  1596. {
  1597. return this.ExamsStateSettingDAL.ExamsStateSettingRepository.Entities.ToList();
  1598. }
  1599. public List<ER_ScoreFormula> GetScoreFormulaList()
  1600. {
  1601. var query = ScoreFormulaRepository.Entities.ToList();
  1602. return query;
  1603. }
  1604. }
  1605. }