EvaluationStudentSettingServices.cs 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Data;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.Entities;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.EvaluationManage.StudentEvaluation;
  13. using EMIS.ViewModel.EducationManage.EducationArrange;
  14. using EMIS.DataLogic.EvaluationManage.StudentEvaluation;
  15. using EMIS.DataLogic.EvaluationManage.EvaluationTable;
  16. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  17. namespace EMIS.CommonLogic.EvaluationManage.StudentEvaluation
  18. {
  19. public class EvaluationStudentSettingServices : BaseServices, IEvaluationStudentSettingServices
  20. {
  21. public EvaluationStudentSettingDAL EvaluationStudentSettingDAL { get; set; }
  22. public EvaluationTableDAL EvaluationTableDAL { get; set; }
  23. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  24. /// <summary>
  25. /// 查询对应的学评设定信息View
  26. /// </summary>
  27. /// <param name="configuretView"></param>
  28. /// <param name="schoolyearID"></param>
  29. /// <param name="campusID"></param>
  30. /// <param name="collegeID"></param>
  31. /// <param name="departmentID"></param>
  32. /// <param name="coursematerialID"></param>
  33. /// <param name="courseTypeID"></param>
  34. /// <param name="teachingModeID"></param>
  35. /// <param name="staffID"></param>
  36. /// <param name="teachingMethodID"></param>
  37. /// <param name="evaluationTableID"></param>
  38. /// <param name="openState"></param>
  39. /// <param name="pageIndex"></param>
  40. /// <param name="pageSize"></param>
  41. /// <returns></returns>
  42. public IGridResultSet<EvaluationStudentSettingView> GetEvaluationStudentSettingViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID,
  43. Guid? departmentID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? openState, int pageIndex, int pageSize)
  44. {
  45. Expression<Func<EM_EvaluationStudentSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  46. if (staffID.HasValue)
  47. {
  48. exp = exp.And(x => x.UserID == staffID);
  49. }
  50. if (teachingMethodID.HasValue)
  51. {
  52. exp = exp.And(x => x.TeachingMethodID == teachingMethodID);
  53. }
  54. if (evaluationTableID.HasValue)
  55. {
  56. exp = exp.And(x => x.EvaluationTableID == evaluationTableID);
  57. }
  58. if (openState.HasValue)
  59. {
  60. if (openState.Value == (int)CF_GeneralPurpose.IsYes)
  61. {
  62. exp = exp.And(x => x.OpenState == true);
  63. }
  64. if (openState.Value == (int)CF_GeneralPurpose.IsNo)
  65. {
  66. exp = exp.And(x => x.OpenState != true);
  67. }
  68. }
  69. var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(exp);
  70. if (schoolyearID.HasValue)
  71. {
  72. query = query.Where(x => x.SchoolyearID == schoolyearID);
  73. }
  74. if (campusID.HasValue)
  75. {
  76. query = query.Where(x => x.CampusID == campusID);
  77. }
  78. if (collegeID.HasValue)
  79. {
  80. query = query.Where(x => x.CollegeID == collegeID);
  81. }
  82. if (departmentID.HasValue)
  83. {
  84. query = query.Where(x => x.DepartmentID == departmentID);
  85. }
  86. if (coursematerialID.HasValue)
  87. {
  88. query = query.Where(x => x.CoursematerialID == coursematerialID);
  89. }
  90. if (courseTypeID.HasValue)
  91. {
  92. query = query.Where(x => x.CourseTypeID == courseTypeID);
  93. }
  94. if (handleModeID.HasValue)
  95. {
  96. query = query.Where(x => x.HandleModeID == handleModeID);
  97. }
  98. if (teachingModeID.HasValue)
  99. {
  100. query = query.Where(x => x.TeachingModeID == teachingModeID);
  101. }
  102. //查询条件
  103. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  104. {
  105. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  106. }
  107. return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
  108. .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToGridResultSet<EvaluationStudentSettingView>(pageIndex, pageSize);
  109. }
  110. /// <summary>
  111. /// 查询对应的学评设定信息List
  112. /// </summary>
  113. /// <param name="configuretView"></param>
  114. /// <param name="schoolyearID"></param>
  115. /// <param name="campusID"></param>
  116. /// <param name="collegeID"></param>
  117. /// <param name="departmentID"></param>
  118. /// <param name="coursematerialID"></param>
  119. /// <param name="courseTypeID"></param>
  120. /// <param name="teachingModeID"></param>
  121. /// <param name="staffID"></param>
  122. /// <param name="teachingMethodID"></param>
  123. /// <param name="evaluationTableID"></param>
  124. /// <param name="openState"></param>
  125. /// <returns></returns>
  126. public IList<EvaluationStudentSettingView> GetEvaluationStudentSettingViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID,
  127. Guid? departmentID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? evaluationTableID, int? openState)
  128. {
  129. Expression<Func<EM_EvaluationStudentSetting, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  130. if (staffID.HasValue)
  131. {
  132. exp = exp.And(x => x.UserID == staffID);
  133. }
  134. if (teachingMethodID.HasValue)
  135. {
  136. exp = exp.And(x => x.TeachingMethodID == teachingMethodID);
  137. }
  138. if (evaluationTableID.HasValue)
  139. {
  140. exp = exp.And(x => x.EvaluationTableID == evaluationTableID);
  141. }
  142. if (openState.HasValue)
  143. {
  144. if (openState.Value == (int)CF_GeneralPurpose.IsYes)
  145. {
  146. exp = exp.And(x => x.OpenState == true);
  147. }
  148. if (openState.Value == (int)CF_GeneralPurpose.IsNo)
  149. {
  150. exp = exp.And(x => x.OpenState != true);
  151. }
  152. }
  153. var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(exp);
  154. if (schoolyearID.HasValue)
  155. {
  156. query = query.Where(x => x.SchoolyearID == schoolyearID);
  157. }
  158. if (campusID.HasValue)
  159. {
  160. query = query.Where(x => x.CampusID == campusID);
  161. }
  162. if (collegeID.HasValue)
  163. {
  164. query = query.Where(x => x.CollegeID == collegeID);
  165. }
  166. if (departmentID.HasValue)
  167. {
  168. query = query.Where(x => x.DepartmentID == departmentID);
  169. }
  170. if (coursematerialID.HasValue)
  171. {
  172. query = query.Where(x => x.CoursematerialID == coursematerialID);
  173. }
  174. if (courseTypeID.HasValue)
  175. {
  176. query = query.Where(x => x.CourseTypeID == courseTypeID);
  177. }
  178. if (handleModeID.HasValue)
  179. {
  180. query = query.Where(x => x.HandleModeID == handleModeID);
  181. }
  182. if (teachingModeID.HasValue)
  183. {
  184. query = query.Where(x => x.TeachingModeID == teachingModeID);
  185. }
  186. //查询条件
  187. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  188. {
  189. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  190. }
  191. return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
  192. .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToList();
  193. }
  194. /// <summary>
  195. /// 查询对应的学评设定信息EvaluationStudentSettingView
  196. /// </summary>
  197. /// <param name="evaluationStudentSettingID"></param>
  198. /// <returns></returns>
  199. public EvaluationStudentSettingView GetEvaluationStudentSettingView(Guid? evaluationStudentSettingID)
  200. {
  201. try
  202. {
  203. Expression<Func<EM_EvaluationStudentSetting, bool>> exp = (x => x.EvaluationStudentSettingID == evaluationStudentSettingID);
  204. var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingViewQueryable(exp).SingleOrDefault();
  205. return query;
  206. }
  207. catch (Exception ex)
  208. {
  209. throw new Exception(ex.Message);
  210. }
  211. }
  212. /// <summary>
  213. /// 评价生成
  214. /// </summary>
  215. /// <param name="campusID"></param>
  216. /// <param name="collegeID"></param>
  217. /// <param name="departmentID"></param>
  218. /// <param name="gradeID"></param>
  219. /// <param name="standardID"></param>
  220. /// <param name="coursematerialID"></param>
  221. /// <param name="courseTypeID"></param>
  222. /// <param name="handleModeID"></param>
  223. /// <param name="teachingModeID"></param>
  224. /// <param name="staffID"></param>
  225. /// <param name="teachingMethodID"></param>
  226. /// <param name="schoolyearID"></param>
  227. /// <returns></returns>
  228. public string EvaluationStudentSettingCreate(Guid? campusID, Guid? collegeID, Guid? departmentID, int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID,
  229. int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID)
  230. {
  231. try
  232. {
  233. var schoolyear = EvaluationStudentSettingDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == schoolyearID).SingleOrDefault();
  234. if (schoolyear == null)
  235. {
  236. throw new Exception("选择的学年学期有误,请核查。");
  237. }
  238. var evaluationParticipateType = EvaluationStudentSettingDAL.EvaluationParticipateTypeRepository.GetList(x => x.ParticipateTypeID == (int)EM_ParticipateType.Student).SingleOrDefault();
  239. if (evaluationParticipateType == null)
  240. {
  241. throw new Exception("对应的参评类型不存在,请核查。");
  242. }
  243. Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  244. expEvaluationTable = expEvaluationTable.And(x => x.IsEnabled == true);
  245. expEvaluationTable = expEvaluationTable.And(x => x.EvaluationParticipateTypeID == evaluationParticipateType.EvaluationParticipateTypeID);
  246. var evaluationTableViewList = EvaluationTableDAL.GetEvaluationTableViewQueryable(expEvaluationTable).ToList();
  247. Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  248. expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled);
  249. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  250. bool classmajorHasValue = false;
  251. if (gradeID.HasValue)
  252. {
  253. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID);
  254. classmajorHasValue = true;
  255. }
  256. if (standardID.HasValue)
  257. {
  258. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  259. classmajorHasValue = true;
  260. }
  261. if (classmajorHasValue)
  262. {
  263. expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor));
  264. }
  265. if (coursematerialID.HasValue)
  266. {
  267. expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID);
  268. }
  269. if (courseTypeID.HasValue)
  270. {
  271. expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID);
  272. }
  273. if (handleModeID.HasValue)
  274. {
  275. expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID);
  276. }
  277. if (teachingModeID.HasValue)
  278. {
  279. expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID);
  280. }
  281. var query = EvaluationStudentSettingDAL.GetEducationMissionClassViewQueryable(expEducationMissionClass);
  282. if (campusID.HasValue)
  283. {
  284. query = query.Where(x => x.CampusID == campusID);
  285. }
  286. if (collegeID.HasValue)
  287. {
  288. query = query.Where(x => x.CollegeID == collegeID);
  289. }
  290. if (departmentID.HasValue)
  291. {
  292. query = query.Where(x => x.DepartmentID == departmentID);
  293. }
  294. if (staffID.HasValue)
  295. {
  296. query = query.Where(x => x.UserID == staffID);
  297. }
  298. if (teachingMethodID.HasValue)
  299. {
  300. query = query.Where(x => x.TeachingMethodID == teachingMethodID);
  301. }
  302. if (schoolyearID.HasValue)
  303. {
  304. query = query.Where(x => x.SchoolyearID == schoolyearID);
  305. }
  306. var educationMissionClassViewList = this.GetQueryByDataRangeByDepartment(query).ToList();
  307. if (educationMissionClassViewList == null || educationMissionClassViewList.Count() <= 0)
  308. {
  309. throw new Exception("对应的教学任务班评价信息为空,请核查(如:任务状态为未提交)。");
  310. }
  311. var educationMissionClassIDList = educationMissionClassViewList.Select(x => x.EducationMissionClassID).Distinct().ToList();
  312. var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => educationMissionClassIDList.Contains(x.EducationMissionClassID.Value)).ToList();
  313. int inSuccess = 0;
  314. int upSuccess = 0;
  315. int fail = 0;
  316. string tipMessage = null;
  317. var evaluationStudentSettingInList = new List<EM_EvaluationStudentSetting>();
  318. var evaluationStudentSettingUpList = new List<EM_EvaluationStudentSetting>();
  319. foreach (var educationMissionClassView in educationMissionClassViewList)
  320. {
  321. var evaluationTableList = evaluationTableViewList.Where(x => x.TeachingModeIDList.Contains(educationMissionClassView.TeachingModeID)).ToList();
  322. if (evaluationTableList == null || evaluationTableList.Count() <= 0)
  323. {
  324. fail++;
  325. }
  326. else if (evaluationTableList != null && evaluationTableList.Count() > 1)
  327. {
  328. fail++;
  329. }
  330. else
  331. {
  332. var evaluationTable = evaluationTableList.Where(x => true).SingleOrDefault();
  333. var educlStudentList = EvaluationStudentSettingDAL.GetEducationMissionClassStudentQueryable(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID).ToList();
  334. var evaluationStudentSettingVerify = evaluationStudentSettingList.Where(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID && x.UserID == educationMissionClassView.UserID).SingleOrDefault();
  335. if (evaluationStudentSettingVerify == null)
  336. {
  337. var newEvaluationStudentSetting = new EM_EvaluationStudentSetting();
  338. newEvaluationStudentSetting.EvaluationStudentSettingID = Guid.NewGuid();
  339. newEvaluationStudentSetting.EducationMissionClassID = educationMissionClassView.EducationMissionClassID;
  340. newEvaluationStudentSetting.EvaluationTableID = evaluationTable.EvaluationTableID;
  341. newEvaluationStudentSetting.UserID = educationMissionClassView.UserID;
  342. newEvaluationStudentSetting.TeachingMethodID = educationMissionClassView.TeachingMethodID;
  343. newEvaluationStudentSetting.OpenState = false;
  344. newEvaluationStudentSetting.Remark = educationMissionClassView.Remark;
  345. SetNewStatus(newEvaluationStudentSetting);
  346. evaluationStudentSettingInList.Add(newEvaluationStudentSetting);
  347. educlStudentList.ForEach(x => newEvaluationStudentSetting.CF_Student.Add(x));
  348. inSuccess++;
  349. }
  350. else
  351. {
  352. if (evaluationStudentSettingVerify.OpenState != true)
  353. {
  354. evaluationStudentSettingVerify.EvaluationTableID = evaluationTable.EvaluationTableID;
  355. }
  356. evaluationStudentSettingVerify.TeachingMethodID = educationMissionClassView.TeachingMethodID;
  357. SetModifyStatus(evaluationStudentSettingVerify);
  358. evaluationStudentSettingUpList.Add(evaluationStudentSettingVerify);
  359. var evaluationStudentList = EvaluationStudentSettingDAL.GetEvaluationStudentSettingStudentQueryable(x => x.EvaluationStudentSettingID == evaluationStudentSettingVerify.EvaluationStudentSettingID).ToList();
  360. foreach (var educlStudent in educlStudentList)
  361. {
  362. var student = evaluationStudentList.Where(x => x.UserID == educlStudent.UserID).SingleOrDefault();
  363. if (student == null)
  364. {
  365. evaluationStudentSettingVerify.CF_Student.Add(educlStudent);
  366. }
  367. }
  368. upSuccess++;
  369. }
  370. }
  371. }
  372. using (TransactionScope ts = new TransactionScope())
  373. {
  374. UnitOfWork.BulkInsert(evaluationStudentSettingInList);
  375. UnitOfWork.BulkInsert(evaluationStudentSettingInList, (x => x.CF_Student));
  376. if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0)
  377. {
  378. UnitOfWork.BatchUpdate(evaluationStudentSettingUpList);
  379. }
  380. UnitOfWork.BulkInsert(evaluationStudentSettingUpList, (x => x.CF_Student));
  381. ts.Complete();
  382. }
  383. if (upSuccess <= 0 && fail <= 0)
  384. {
  385. tipMessage = inSuccess + "条";
  386. }
  387. else
  388. {
  389. if (upSuccess > 0 && fail <= 0)
  390. {
  391. tipMessage = inSuccess + "条,更新成功" + upSuccess + "条";
  392. }
  393. else
  394. {
  395. tipMessage = inSuccess + "条,更新成功" + upSuccess + "条,失败" + fail + "条,原因:对应的评价表无法匹配,请检查";
  396. }
  397. }
  398. return tipMessage;
  399. }
  400. catch (Exception ex)
  401. {
  402. throw new Exception(ex.Message);
  403. }
  404. }
  405. /// <summary>
  406. /// 编辑
  407. /// </summary>
  408. /// <param name="evaluationStudentSettingView"></param>
  409. public void EvaluationStudentSettingEdit(EvaluationStudentSettingView evaluationStudentSettingView)
  410. {
  411. try
  412. {
  413. if (!evaluationStudentSettingView.EducationMissionClassID.HasValue || evaluationStudentSettingView.EducationMissionClassID == Guid.Empty)
  414. {
  415. throw new Exception("对应的教学任务数据有误,请核查。");
  416. }
  417. var evaluationStudentSettingVerify = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID != evaluationStudentSettingView.EvaluationStudentSettingID
  418. && x.EducationMissionClassID == evaluationStudentSettingView.EducationMissionClassID && x.UserID == evaluationStudentSettingView.UserID).SingleOrDefault();
  419. if (evaluationStudentSettingVerify == null)
  420. {
  421. var evaluationStudentSettingInList = new List<EM_EvaluationStudentSetting>();
  422. var evaluationStudentSettingUpList = new List<EM_EvaluationStudentSetting>();
  423. var educlStudentList = EvaluationStudentSettingDAL.GetEducationMissionClassStudentQueryable(x => x.EducationMissionClassID == evaluationStudentSettingView.EducationMissionClassID).ToList();
  424. if (evaluationStudentSettingView.EvaluationStudentSettingID != Guid.Empty)
  425. {
  426. var evaluationStudentSetting = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID == evaluationStudentSettingView.EvaluationStudentSettingID).SingleOrDefault();
  427. if (evaluationStudentSetting == null)
  428. {
  429. throw new Exception("数据有误,请核查。");
  430. }
  431. else
  432. {
  433. //表示修改
  434. evaluationStudentSetting.EvaluationTableID = evaluationStudentSettingView.EvaluationTableID;
  435. evaluationStudentSetting.UserID = evaluationStudentSettingView.UserID;
  436. evaluationStudentSetting.TeachingMethodID = evaluationStudentSettingView.TeachingMethodID;
  437. evaluationStudentSetting.Remark = evaluationStudentSettingView.Remark;
  438. SetModifyStatus(evaluationStudentSetting);
  439. evaluationStudentSettingUpList.Add(evaluationStudentSetting);
  440. var evaluationStudentList = EvaluationStudentSettingDAL.GetEvaluationStudentSettingStudentQueryable(x => x.EvaluationStudentSettingID == evaluationStudentSetting.EvaluationStudentSettingID).ToList();
  441. foreach (var educlStudent in educlStudentList)
  442. {
  443. var student = evaluationStudentList.Where(x => x.UserID == educlStudent.UserID).SingleOrDefault();
  444. if (student == null)
  445. {
  446. evaluationStudentSetting.CF_Student.Add(educlStudent);
  447. }
  448. }
  449. }
  450. }
  451. else
  452. {
  453. //表示新增
  454. var newEvaluationStudentSetting = new EM_EvaluationStudentSetting();
  455. newEvaluationStudentSetting.EvaluationStudentSettingID = Guid.NewGuid();
  456. newEvaluationStudentSetting.EducationMissionClassID = evaluationStudentSettingView.EducationMissionClassID;
  457. newEvaluationStudentSetting.EvaluationTableID = evaluationStudentSettingView.EvaluationTableID;
  458. newEvaluationStudentSetting.UserID = evaluationStudentSettingView.UserID;
  459. newEvaluationStudentSetting.TeachingMethodID = evaluationStudentSettingView.TeachingMethodID;
  460. newEvaluationStudentSetting.OpenState = false;
  461. newEvaluationStudentSetting.Remark = evaluationStudentSettingView.Remark;
  462. SetNewStatus(newEvaluationStudentSetting);
  463. evaluationStudentSettingInList.Add(newEvaluationStudentSetting);
  464. educlStudentList.ForEach(x => newEvaluationStudentSetting.CF_Student.Add(x));
  465. }
  466. using (TransactionScope ts = new TransactionScope())
  467. {
  468. UnitOfWork.BulkInsert(evaluationStudentSettingInList);
  469. UnitOfWork.BulkInsert(evaluationStudentSettingInList, (x => x.CF_Student));
  470. if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0)
  471. {
  472. UnitOfWork.BatchUpdate(evaluationStudentSettingUpList);
  473. }
  474. UnitOfWork.BulkInsert(evaluationStudentSettingUpList, (x => x.CF_Student));
  475. ts.Complete();
  476. }
  477. }
  478. else
  479. {
  480. throw new Exception("已存在相同的学生评价信息(教学任务班、任课教师唯一),请核查。");
  481. }
  482. }
  483. catch (Exception ex)
  484. {
  485. throw new Exception(ex.Message);
  486. }
  487. }
  488. /// <summary>
  489. /// 批量新增
  490. /// </summary>
  491. /// <param name="educationMissionClassViewList"></param>
  492. /// <param name="evaluationStudentSettingView"></param>
  493. /// <returns></returns>
  494. public string EvaluationStudentSettingBatchAdd(List<EducationMissionClassView> educationMissionClassViewList, EvaluationStudentSettingView evaluationStudentSettingView)
  495. {
  496. try
  497. {
  498. var schoolyear = EvaluationStudentSettingDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == evaluationStudentSettingView.SchoolyearID).SingleOrDefault();
  499. if (schoolyear == null)
  500. {
  501. throw new Exception("选择的学年学期有误,请核查。");
  502. }
  503. var evaluationParticipateType = EvaluationStudentSettingDAL.EvaluationParticipateTypeRepository.GetList(x => x.ParticipateTypeID == (int)EM_ParticipateType.Student).SingleOrDefault();
  504. if (evaluationParticipateType == null)
  505. {
  506. throw new Exception("对应的参评类型不存在,请核查。");
  507. }
  508. Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  509. expEvaluationTable = expEvaluationTable.And(x => x.IsEnabled == true);
  510. expEvaluationTable = expEvaluationTable.And(x => x.EvaluationParticipateTypeID == evaluationParticipateType.EvaluationParticipateTypeID);
  511. var evaluationTableViewList = EvaluationTableDAL.GetEvaluationTableViewQueryable(expEvaluationTable).ToList();
  512. var educationMissionClassIDList = educationMissionClassViewList.Select(x => x.EducationMissionClassID).Distinct().ToList();
  513. var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => educationMissionClassIDList.Contains(x.EducationMissionClassID.Value)).ToList();
  514. int success = 0;
  515. int fail = 0;
  516. string tipMessage = null;
  517. var evaluationStudentSettingInList = new List<EM_EvaluationStudentSetting>();
  518. foreach (var educationMissionClassView in educationMissionClassViewList)
  519. {
  520. var evaluationTableList = evaluationTableViewList.Where(x => x.TeachingModeIDList.Contains(educationMissionClassView.TeachingModeID)).ToList();
  521. if (evaluationTableList == null || evaluationTableList.Count() <= 0)
  522. {
  523. fail++;
  524. }
  525. else if (evaluationTableList != null && evaluationTableList.Count() > 1)
  526. {
  527. fail++;
  528. }
  529. else
  530. {
  531. var evaluationTable = evaluationTableList.Where(x => true).SingleOrDefault();
  532. var educlStudentList = EvaluationStudentSettingDAL.GetEducationMissionClassStudentQueryable(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID).ToList();
  533. var evaluationStudentSettingVerify = evaluationStudentSettingList.Where(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID && x.UserID == educationMissionClassView.UserID).SingleOrDefault();
  534. if (evaluationStudentSettingVerify == null)
  535. {
  536. var newEvaluationStudentSetting = new EM_EvaluationStudentSetting();
  537. newEvaluationStudentSetting.EvaluationStudentSettingID = Guid.NewGuid();
  538. newEvaluationStudentSetting.EducationMissionClassID = educationMissionClassView.EducationMissionClassID;
  539. newEvaluationStudentSetting.EvaluationTableID = evaluationTable.EvaluationTableID;
  540. newEvaluationStudentSetting.UserID = educationMissionClassView.UserID;
  541. newEvaluationStudentSetting.TeachingMethodID = educationMissionClassView.TeachingMethodID;
  542. newEvaluationStudentSetting.OpenState = false;
  543. newEvaluationStudentSetting.Remark = educationMissionClassView.Remark;
  544. SetNewStatus(newEvaluationStudentSetting);
  545. evaluationStudentSettingInList.Add(newEvaluationStudentSetting);
  546. educlStudentList.ForEach(x => newEvaluationStudentSetting.CF_Student.Add(x));
  547. success++;
  548. }
  549. else
  550. {
  551. fail++;
  552. }
  553. }
  554. }
  555. using (TransactionScope ts = new TransactionScope())
  556. {
  557. UnitOfWork.BulkInsert(evaluationStudentSettingInList);
  558. UnitOfWork.BulkInsert(evaluationStudentSettingInList, (x => x.CF_Student));
  559. ts.Complete();
  560. }
  561. if (success > 0 && fail <= 0)
  562. {
  563. tipMessage = success + "条";
  564. }
  565. else
  566. {
  567. tipMessage = success + "条,失败" + fail + "条,原因:对应的评价表无法匹配或已存在相同的学生评价信息(教学任务班、任课教师唯一),请核查";
  568. }
  569. return tipMessage;
  570. }
  571. catch (Exception ex)
  572. {
  573. throw new Exception(ex.Message);
  574. }
  575. }
  576. /// <summary>
  577. /// 查询教学任务班中未新增学生评价信息View
  578. /// </summary>
  579. /// <param name="configuretView"></param>
  580. /// <param name="campusID"></param>
  581. /// <param name="collegeID"></param>
  582. /// <param name="departmentID"></param>
  583. /// <param name="gradeID"></param>
  584. /// <param name="standardID"></param>
  585. /// <param name="coursematerialID"></param>
  586. /// <param name="courseTypeID"></param>
  587. /// <param name="handleModeID"></param>
  588. /// <param name="teachingModeID"></param>
  589. /// <param name="staffID"></param>
  590. /// <param name="teachingMethodID"></param>
  591. /// <param name="schoolyearID"></param>
  592. /// <param name="pageIndex"></param>
  593. /// <param name="pageSize"></param>
  594. /// <returns></returns>
  595. public IGridResultSet<EducationMissionClassView> GetEducationMissionClassViewNoAddGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID,
  596. int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID, int pageIndex, int pageSize)
  597. {
  598. Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  599. expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID);
  600. if (collegeID.HasValue)
  601. {
  602. expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID);
  603. }
  604. if (departmentID.HasValue)
  605. {
  606. expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID);
  607. }
  608. Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  609. expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled);
  610. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  611. bool classmajorHasValue = false;
  612. if (gradeID.HasValue)
  613. {
  614. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID);
  615. classmajorHasValue = true;
  616. }
  617. if (standardID.HasValue)
  618. {
  619. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  620. classmajorHasValue = true;
  621. }
  622. if (classmajorHasValue)
  623. {
  624. expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor));
  625. }
  626. if (coursematerialID.HasValue)
  627. {
  628. expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID);
  629. }
  630. if (courseTypeID.HasValue)
  631. {
  632. expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID);
  633. }
  634. if (handleModeID.HasValue)
  635. {
  636. expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID);
  637. }
  638. if (teachingModeID.HasValue)
  639. {
  640. expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID);
  641. }
  642. var query = EvaluationStudentSettingDAL.GetEducationMissionClassViewNoAddQueryable(expEducationMission, expEducationMissionClass);
  643. if (campusID.HasValue)
  644. {
  645. query = query.Where(x => x.CampusID == campusID);
  646. }
  647. if (staffID.HasValue)
  648. {
  649. query = query.Where(x => x.UserID == staffID);
  650. }
  651. if (teachingMethodID.HasValue)
  652. {
  653. query = query.Where(x => x.TeachingMethodID == teachingMethodID);
  654. }
  655. //查询条件
  656. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  657. {
  658. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  659. }
  660. return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
  661. .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  662. }
  663. /// <summary>
  664. /// 查询教学任务班中未新增学生评价信息List
  665. /// </summary>
  666. /// <param name="configuretView"></param>
  667. /// <param name="campusID"></param>
  668. /// <param name="collegeID"></param>
  669. /// <param name="departmentID"></param>
  670. /// <param name="gradeID"></param>
  671. /// <param name="standardID"></param>
  672. /// <param name="coursematerialID"></param>
  673. /// <param name="courseTypeID"></param>
  674. /// <param name="handleModeID"></param>
  675. /// <param name="teachingModeID"></param>
  676. /// <param name="staffID"></param>
  677. /// <param name="teachingMethodID"></param>
  678. /// <param name="schoolyearID"></param>
  679. /// <returns></returns>
  680. public IList<EducationMissionClassView> GetEducationMissionClassViewNoAddList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID,
  681. int? gradeID, int? standardID, Guid? coursematerialID, int? courseTypeID, int? handleModeID, int? teachingModeID, Guid? staffID, int? teachingMethodID, Guid? schoolyearID)
  682. {
  683. Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  684. expEducationMission = expEducationMission.And(x => x.SchoolyearID == schoolyearID);
  685. if (collegeID.HasValue)
  686. {
  687. expEducationMission = expEducationMission.And(x => x.CollegeID == collegeID);
  688. }
  689. if (departmentID.HasValue)
  690. {
  691. expEducationMission = expEducationMission.And(x => x.DepartmentID == departmentID);
  692. }
  693. Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  694. expEducationMissionClass = expEducationMissionClass.And(x => x.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted || x.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled);
  695. Expression<Func<CF_Classmajor, bool>> expClassmajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  696. bool classmajorHasValue = false;
  697. if (gradeID.HasValue)
  698. {
  699. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.GradeID == gradeID);
  700. classmajorHasValue = true;
  701. }
  702. if (standardID.HasValue)
  703. {
  704. expClassmajor = expClassmajor.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  705. classmajorHasValue = true;
  706. }
  707. if (classmajorHasValue)
  708. {
  709. expEducationMissionClass = expEducationMissionClass.And(x => x.CF_Classmajor.AsQueryable().Any(expClassmajor));
  710. }
  711. if (coursematerialID.HasValue)
  712. {
  713. expEducationMissionClass = expEducationMissionClass.And(x => x.CoursematerialID == coursematerialID);
  714. }
  715. if (courseTypeID.HasValue)
  716. {
  717. expEducationMissionClass = expEducationMissionClass.And(x => x.CourseTypeID == courseTypeID);
  718. }
  719. if (handleModeID.HasValue)
  720. {
  721. expEducationMissionClass = expEducationMissionClass.And(x => x.HandleModeID == handleModeID);
  722. }
  723. if (teachingModeID.HasValue)
  724. {
  725. expEducationMissionClass = expEducationMissionClass.And(x => x.TeachingModeID == teachingModeID);
  726. }
  727. var query = EvaluationStudentSettingDAL.GetEducationMissionClassViewNoAddQueryable(expEducationMission, expEducationMissionClass);
  728. if (campusID.HasValue)
  729. {
  730. query = query.Where(x => x.CampusID == campusID);
  731. }
  732. if (staffID.HasValue)
  733. {
  734. query = query.Where(x => x.UserID == staffID);
  735. }
  736. if (teachingMethodID.HasValue)
  737. {
  738. query = query.Where(x => x.TeachingMethodID == teachingMethodID);
  739. }
  740. //查询条件
  741. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  742. {
  743. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  744. }
  745. return this.GetQueryByDataRangeByDepartment(query, x => x.DepartmentID).OrderBy(x => x.SchoolyearValue).ThenBy(x => x.DepartmentNo.Length)
  746. .ThenBy(x => x.DepartmentNo).ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ThenBy(x => x.CourseTypeID).ThenBy(x => x.TeachingModeID).ToList();
  747. }
  748. /// <summary>
  749. /// 删除
  750. /// </summary>
  751. /// <param name="evaluationStudentSettingIDs"></param>
  752. /// <returns></returns>
  753. public bool EvaluationStudentSettingDelete(List<Guid?> evaluationStudentSettingIDs)
  754. {
  755. try
  756. {
  757. var evaluationStudentList = EvaluationStudentSettingDAL.EvaluationStudentRepository.GetList(x => evaluationStudentSettingIDs.Contains(x.EvaluationStudentSettingID)).ToList();
  758. if (evaluationStudentList == null || evaluationStudentList.Count() <= 0)
  759. {
  760. var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => evaluationStudentSettingIDs.Contains(x.EvaluationStudentSettingID), (x => x.CF_Student)).ToList();
  761. using (TransactionScope ts = new TransactionScope())
  762. {
  763. foreach (var evaluationStudentSetting in evaluationStudentSettingList)
  764. {
  765. //evaluationStudentSetting.CF_Student = new HashSet<CF_Student>();
  766. UnitOfWork.Delete(evaluationStudentSetting, (x => x.CF_Student));
  767. UnitOfWork.Delete<EM_EvaluationStudentSetting>(x => x.EvaluationStudentSettingID == evaluationStudentSetting.EvaluationStudentSettingID);
  768. //evaluationStudentSetting.CF_Student.RemoveWhere(x => true);
  769. //UnitOfWork.RemoveRange(evaluationStudentSetting.CF_Student);
  770. //UnitOfWork.Remove(evaluationStudentSetting);
  771. }
  772. //this.UnitOfWork.Commit();
  773. ts.Complete();
  774. return true;
  775. }
  776. }
  777. else
  778. {
  779. throw new Exception("选择删除的信息中,存在已评价信息无法删除。");
  780. }
  781. }
  782. catch (Exception)
  783. {
  784. throw;
  785. }
  786. }
  787. /// <summary>
  788. /// 查询学生评价中对应的学生名单信息View
  789. /// </summary>
  790. /// <param name="configuretView"></param>
  791. /// <param name="evaluationStudentSettingID"></param>
  792. /// <param name="isEvaluation"></param>
  793. /// <param name="inSchoolStatus"></param>
  794. /// <param name="pageIndex"></param>
  795. /// <param name="pageSize"></param>
  796. /// <returns></returns>
  797. public IGridResultSet<EvaluationStudentSettingDetailView> GetEvaluationStudentSettingDetailViewGrid(ConfiguretView configuretView, Guid? evaluationStudentSettingID, int? isEvaluation, int? inSchoolStatus, int pageIndex, int pageSize)
  798. {
  799. Expression<Func<EM_EvaluationStudentSetting, bool>> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  800. expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationStudentSettingID == evaluationStudentSettingID);
  801. Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  802. Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  803. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  804. if (inSchoolStatus != null && inSchoolStatus > -1)
  805. {
  806. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  807. if (inSchoolStatus == 1)
  808. {
  809. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  810. }
  811. if (inSchoolStatus == 0)
  812. {
  813. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  814. }
  815. }
  816. var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingDetailViewQueryable(expEvaluationStudentSetting, expEducationMissionClass, expEducationMission, expStudent);
  817. if (isEvaluation.HasValue)
  818. {
  819. if (isEvaluation.Value == (int)CF_GeneralPurpose.IsYes)
  820. {
  821. query = query.Where(x => x.IsEvaluation == true);
  822. }
  823. if (isEvaluation.Value == (int)CF_GeneralPurpose.IsNo)
  824. {
  825. query = query.Where(x => x.IsEvaluation != true);
  826. }
  827. }
  828. //查询条件
  829. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  830. {
  831. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  832. }
  833. return query.OrderBy(x => x.StudentNo).ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ToGridResultSet<EvaluationStudentSettingDetailView>(pageIndex, pageSize);
  834. }
  835. /// <summary>
  836. /// 查询学生评价中对应的学生名单信息List
  837. /// </summary>
  838. /// <param name="configuretView"></param>
  839. /// <param name="evaluationStudentSettingID"></param>
  840. /// <param name="isEvaluation"></param>
  841. /// <param name="inSchoolStatus"></param>
  842. /// <returns></returns>
  843. public IList<EvaluationStudentSettingDetailView> GetEvaluationStudentSettingDetailViewList(ConfiguretView configuretView, Guid? evaluationStudentSettingID, int? isEvaluation, int? inSchoolStatus)
  844. {
  845. Expression<Func<EM_EvaluationStudentSetting, bool>> expEvaluationStudentSetting = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  846. expEvaluationStudentSetting = expEvaluationStudentSetting.And(x => x.EvaluationStudentSettingID == evaluationStudentSettingID);
  847. Expression<Func<EM_EducationMissionClass, bool>> expEducationMissionClass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  848. Expression<Func<EM_EducationMission, bool>> expEducationMission = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  849. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  850. if (inSchoolStatus != null && inSchoolStatus > -1)
  851. {
  852. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  853. if (inSchoolStatus == 1)
  854. {
  855. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  856. }
  857. if (inSchoolStatus == 0)
  858. {
  859. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  860. }
  861. }
  862. var query = EvaluationStudentSettingDAL.GetEvaluationStudentSettingDetailViewQueryable(expEvaluationStudentSetting, expEducationMissionClass, expEducationMission, expStudent);
  863. if (isEvaluation.HasValue)
  864. {
  865. if (isEvaluation.Value == (int)CF_GeneralPurpose.IsYes)
  866. {
  867. query = query.Where(x => x.IsEvaluation == true);
  868. }
  869. if (isEvaluation.Value == (int)CF_GeneralPurpose.IsNo)
  870. {
  871. query = query.Where(x => x.IsEvaluation != true);
  872. }
  873. }
  874. //查询条件
  875. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  876. {
  877. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  878. }
  879. return query.OrderBy(x => x.StudentNo).ThenBy(x => x.ClassmajorNo.Length).ThenBy(x => x.ClassmajorNo).ToList();
  880. }
  881. /// <summary>
  882. /// 编辑学生
  883. /// </summary>
  884. /// <param name="evaluationStudentSettingID"></param>
  885. /// <param name="userID"></param>
  886. public void EvaluationStudentEdit(Guid? evaluationStudentSettingID, Guid? userID)
  887. {
  888. try
  889. {
  890. var evaluationStudentSetting = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID == evaluationStudentSettingID, (x => x.CF_Student)).SingleOrDefault();
  891. if (evaluationStudentSetting == null)
  892. {
  893. throw new Exception("数据有误,请核查。");
  894. }
  895. else
  896. {
  897. var evaluationStudentVerify = evaluationStudentSetting.CF_Student.Where(x => x.UserID == userID).SingleOrDefault();
  898. var student = EvaluationStudentSettingDAL.StudentRepository.GetList(x => x.UserID == userID).SingleOrDefault();
  899. if (evaluationStudentVerify == null)
  900. {
  901. evaluationStudentSetting.CF_Student.Add(student);
  902. }
  903. else
  904. {
  905. throw new Exception("已存在相同的学生名单信息,请核查。");
  906. }
  907. }
  908. UnitOfWork.Commit();
  909. }
  910. catch (Exception ex)
  911. {
  912. throw new Exception(ex.Message);
  913. }
  914. }
  915. /// <summary>
  916. /// 删除学生
  917. /// </summary>
  918. /// <param name="evaluationStudentSettingID"></param>
  919. /// <param name="userIDs"></param>
  920. /// <returns></returns>
  921. public bool EvaluationStudentDelete(Guid? evaluationStudentSettingID, List<Guid?> userIDs)
  922. {
  923. try
  924. {
  925. var evaluationStudentSetting = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => x.EvaluationStudentSettingID == evaluationStudentSettingID, (x => x.CF_Student), (x => x.EM_EvaluationStudent)).SingleOrDefault();
  926. using (TransactionScope ts = new TransactionScope())
  927. {
  928. var evaluationStudentList = evaluationStudentSetting.EM_EvaluationStudent.Where(x => userIDs.Contains(x.UserID)).ToList();
  929. if (evaluationStudentList == null || evaluationStudentList.Count() <= 0)
  930. {
  931. evaluationStudentSetting.CF_Student.RemoveWhere(x => userIDs.Contains(x.UserID));
  932. }
  933. else
  934. {
  935. throw new Exception("选择删除的学生中,存在已评价信息无法删除。");
  936. }
  937. UnitOfWork.Commit();
  938. ts.Complete();
  939. return true;
  940. }
  941. }
  942. catch (Exception)
  943. {
  944. throw;
  945. }
  946. }
  947. /// <summary>
  948. /// 取消
  949. /// </summary>
  950. /// <param name="evaluationStudentSettingIDList"></param>
  951. /// <returns></returns>
  952. public bool EvaluationStudentSettingCancel(List<Guid?> evaluationStudentSettingIDList)
  953. {
  954. try
  955. {
  956. var evaluationStudentSettingUpList = new List<EM_EvaluationStudentSetting>();
  957. var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList();
  958. foreach (var evaluationStudentSetting in evaluationStudentSettingList)
  959. {
  960. evaluationStudentSetting.OpenState = false;
  961. this.SetModifyStatus(evaluationStudentSetting);
  962. evaluationStudentSettingUpList.Add(evaluationStudentSetting);
  963. }
  964. if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0)
  965. {
  966. UnitOfWork.BatchUpdate(evaluationStudentSettingUpList);
  967. }
  968. return true;
  969. }
  970. catch (Exception)
  971. {
  972. throw;
  973. }
  974. }
  975. /// <summary>
  976. /// 开放
  977. /// </summary>
  978. /// <param name="evaluationStudentSettingIDList"></param>
  979. /// <returns></returns>
  980. public bool EvaluationStudentSettingOpen(List<Guid?> evaluationStudentSettingIDList)
  981. {
  982. try
  983. {
  984. var evaluationStudentSettingUpList = new List<EM_EvaluationStudentSetting>();
  985. var evaluationStudentSettingList = EvaluationStudentSettingDAL.EvaluationStudentSettingRepository.GetList(x => evaluationStudentSettingIDList.Contains(x.EvaluationStudentSettingID)).ToList();
  986. foreach (var evaluationStudentSetting in evaluationStudentSettingList)
  987. {
  988. evaluationStudentSetting.OpenState = true;
  989. this.SetModifyStatus(evaluationStudentSetting);
  990. evaluationStudentSettingUpList.Add(evaluationStudentSetting);
  991. }
  992. if (evaluationStudentSettingUpList != null && evaluationStudentSettingUpList.Count() > 0)
  993. {
  994. UnitOfWork.BatchUpdate(evaluationStudentSettingUpList);
  995. }
  996. return true;
  997. }
  998. catch (Exception)
  999. {
  1000. throw;
  1001. }
  1002. }
  1003. }
  1004. }