EvaluationControlServices.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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.EvaluationSetting;
  13. using EMIS.DataLogic.EvaluationManage.EvaluationSetting;
  14. using EMIS.CommonLogic.SystemServices;
  15. namespace EMIS.CommonLogic.EvaluationManage.EvaluationSetting
  16. {
  17. public class EvaluationControlServices : BaseServices, IEvaluationControlServices
  18. {
  19. public EvaluationControlDAL EvaluationControlDAL { get; set; }
  20. public Lazy<IControlItemServices> ControlItemServices { get; set; }
  21. /// <summary>
  22. /// 查询评价控制类型相应的信息View(费用控制-1,注册控制-2,评价控制-3)
  23. /// </summary>
  24. /// <returns></returns>
  25. public EvaluationControlView GetEvaluationControlView()
  26. {
  27. var evaluationControlView = EvaluationControlDAL.GetEvaluationControlViewQueryable(x => true).SingleOrDefault();
  28. if (evaluationControlView == null)
  29. {
  30. evaluationControlView = new EvaluationControlView();
  31. evaluationControlView.IsLoginLock = false;
  32. evaluationControlView.LoginLockMessage = "未设置";
  33. evaluationControlView.IsLoginLockDisplay = "none";
  34. evaluationControlView.IsSelectCourseLock = false;
  35. evaluationControlView.SelectCourseLockMessage = "未设置";
  36. evaluationControlView.IsSelectCourseLockDisplay = "none";
  37. evaluationControlView.IsExaminationApplyLock = false;
  38. evaluationControlView.ExaminationApplyLockMessage = "未设置";
  39. evaluationControlView.IsExaminationApplyLockDisplay = "none";
  40. evaluationControlView.IsCourseScoreLock = false;
  41. evaluationControlView.CourseScoreLockMessage = "未设置";
  42. evaluationControlView.IsCourseScoreLockDisplay = "none";
  43. evaluationControlView.IsLevelScoreLock = false;
  44. evaluationControlView.LevelScoreLockMessage = "未设置";
  45. evaluationControlView.IsLevelScoreLockDisplay = "none";
  46. evaluationControlView.NoNumber = 0;
  47. return evaluationControlView;
  48. }
  49. else
  50. {
  51. var controlItemList = EvaluationControlDAL.ControlItemRepository.GetList(x => x.ControlItemTypeID == (int)SYS_ControlItemType.Evaluation).ToList();
  52. if (controlItemList == null || controlItemList.Count <= 0)
  53. {
  54. evaluationControlView.IsLoginLock = false;
  55. evaluationControlView.LoginLockMessage = "未设置";
  56. evaluationControlView.IsLoginLockDisplay = "none";
  57. evaluationControlView.IsSelectCourseLock = false;
  58. evaluationControlView.SelectCourseLockMessage = "未设置";
  59. evaluationControlView.IsSelectCourseLockDisplay = "none";
  60. evaluationControlView.IsExaminationApplyLock = false;
  61. evaluationControlView.ExaminationApplyLockMessage = "未设置";
  62. evaluationControlView.IsExaminationApplyLockDisplay = "none";
  63. evaluationControlView.IsCourseScoreLock = false;
  64. evaluationControlView.CourseScoreLockMessage = "未设置";
  65. evaluationControlView.IsCourseScoreLockDisplay = "none";
  66. evaluationControlView.IsLevelScoreLock = false;
  67. evaluationControlView.LevelScoreLockMessage = "未设置";
  68. evaluationControlView.IsLevelScoreLockDisplay = "none";
  69. evaluationControlView.NoNumber = 0;
  70. }
  71. else
  72. {
  73. var loginLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLogin").SingleOrDefault();
  74. if (loginLock != null)
  75. {
  76. evaluationControlView.IsLoginLock = loginLock.IsEnable ?? false;
  77. evaluationControlView.LoginLockMessage = loginLock.Message;
  78. evaluationControlView.IsLoginLockDisplay = "table-row";
  79. }
  80. else
  81. {
  82. evaluationControlView.IsLoginLock = false;
  83. evaluationControlView.LoginLockMessage = "未设置。";
  84. evaluationControlView.IsLoginLockDisplay = "none";
  85. }
  86. var selectCourseLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationSelectCourse").SingleOrDefault();
  87. if (selectCourseLock != null)
  88. {
  89. evaluationControlView.IsSelectCourseLock = selectCourseLock.IsEnable ?? false;
  90. evaluationControlView.SelectCourseLockMessage = selectCourseLock.Message;
  91. evaluationControlView.IsSelectCourseLockDisplay = "table-row";
  92. }
  93. else
  94. {
  95. evaluationControlView.IsSelectCourseLock = false;
  96. evaluationControlView.SelectCourseLockMessage = "未设置。";
  97. evaluationControlView.IsSelectCourseLockDisplay = "none";
  98. }
  99. var examinationApplyLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationExaminationApply").SingleOrDefault();
  100. if (examinationApplyLock != null)
  101. {
  102. evaluationControlView.IsExaminationApplyLock = examinationApplyLock.IsEnable ?? false;
  103. evaluationControlView.ExaminationApplyLockMessage = examinationApplyLock.Message;
  104. evaluationControlView.IsExaminationApplyLockDisplay = "table-row";
  105. }
  106. else
  107. {
  108. evaluationControlView.IsExaminationApplyLock = false;
  109. evaluationControlView.ExaminationApplyLockMessage = "未设置。";
  110. evaluationControlView.IsExaminationApplyLockDisplay = "none";
  111. }
  112. var courseScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationCourseScore").SingleOrDefault();
  113. if (courseScoreLock != null)
  114. {
  115. evaluationControlView.IsCourseScoreLock = courseScoreLock.IsEnable ?? false;
  116. evaluationControlView.CourseScoreLockMessage = courseScoreLock.Message;
  117. evaluationControlView.IsCourseScoreLockDisplay = "table-row";
  118. }
  119. else
  120. {
  121. evaluationControlView.IsCourseScoreLock = false;
  122. evaluationControlView.CourseScoreLockMessage = "未设置。";
  123. evaluationControlView.IsCourseScoreLockDisplay = "none";
  124. }
  125. var levelScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLevelScore").SingleOrDefault();
  126. if (levelScoreLock != null)
  127. {
  128. evaluationControlView.IsLevelScoreLock = levelScoreLock.IsEnable ?? false;
  129. evaluationControlView.LevelScoreLockMessage = levelScoreLock.Message;
  130. evaluationControlView.IsLevelScoreLockDisplay = "table-row";
  131. }
  132. else
  133. {
  134. evaluationControlView.IsLevelScoreLock = false;
  135. evaluationControlView.LevelScoreLockMessage = "未设置。";
  136. evaluationControlView.IsLevelScoreLockDisplay = "none";
  137. }
  138. }
  139. return evaluationControlView;
  140. }
  141. }
  142. /// <summary>
  143. /// 评价控制保存
  144. /// </summary>
  145. /// <param name="evaluationControlView"></param>
  146. public void EvaluationControlSave(EvaluationControlView evaluationControlView)
  147. {
  148. try
  149. {
  150. var newEvaluationControlInList = new List<EM_EvaluationControl>();
  151. var controlItemList = EvaluationControlDAL.ControlItemRepository.GetList(x => x.ControlItemTypeID == (int)SYS_ControlItemType.Evaluation).ToList();
  152. if (controlItemList == null || controlItemList.Count <= 0)
  153. {
  154. throw new Exception("评价控制类型未配置,请配置。");
  155. }
  156. else
  157. {
  158. var loginLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLogin").SingleOrDefault();
  159. if (loginLock != null)
  160. {
  161. loginLock.IsLoginControl = true;
  162. loginLock.IsEnable = evaluationControlView.IsLoginLock;
  163. loginLock.Message = evaluationControlView.LoginLockMessage;
  164. }
  165. var selectCourseLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationSelectCourse").SingleOrDefault();
  166. if (selectCourseLock != null)
  167. {
  168. selectCourseLock.IsLoginControl = false;
  169. selectCourseLock.IsEnable = evaluationControlView.IsSelectCourseLock;
  170. selectCourseLock.Message = evaluationControlView.SelectCourseLockMessage;
  171. }
  172. var examinationApplyLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationExaminationApply").SingleOrDefault();
  173. if (examinationApplyLock != null)
  174. {
  175. examinationApplyLock.IsLoginControl = false;
  176. examinationApplyLock.IsEnable = evaluationControlView.IsExaminationApplyLock;
  177. examinationApplyLock.Message = evaluationControlView.ExaminationApplyLockMessage;
  178. }
  179. var courseScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationCourseScore").SingleOrDefault();
  180. if (courseScoreLock != null)
  181. {
  182. courseScoreLock.IsLoginControl = false;
  183. courseScoreLock.IsEnable = evaluationControlView.IsCourseScoreLock;
  184. courseScoreLock.Message = evaluationControlView.CourseScoreLockMessage;
  185. }
  186. var levelScoreLock = controlItemList.Where(x => x.ControlItemCode == "EvaluationLevelScore").SingleOrDefault();
  187. if (levelScoreLock != null)
  188. {
  189. levelScoreLock.IsLoginControl = false;
  190. levelScoreLock.IsEnable = evaluationControlView.IsLevelScoreLock;
  191. levelScoreLock.Message = evaluationControlView.LevelScoreLockMessage;
  192. }
  193. var evaluationControl = new EM_EvaluationControl();
  194. evaluationControl.EvaluationControlID = Guid.NewGuid();
  195. evaluationControl.SchoolyearID = evaluationControlView.SchoolyearID;
  196. evaluationControl.IsSelectCourseLock = evaluationControlView.IsSelectCourseLock;
  197. evaluationControl.IsExaminationApplyLock = evaluationControlView.IsExaminationApplyLock;
  198. evaluationControl.IsCourseScoreLock = evaluationControlView.IsCourseScoreLock;
  199. evaluationControl.IsLevelScoreLock = evaluationControlView.IsLevelScoreLock;
  200. evaluationControl.NoNumber = evaluationControlView.NoNumber;
  201. this.SetNewStatus(evaluationControl);
  202. newEvaluationControlInList.Add(evaluationControl);
  203. }
  204. using (TransactionScope ts = new TransactionScope())
  205. {
  206. UnitOfWork.Delete<EM_EvaluationControl>(x => true);
  207. UnitOfWork.BulkInsert(newEvaluationControlInList);
  208. this.UnitOfWork.Commit();
  209. ts.Complete();
  210. }
  211. ControlItemServices.Value.RefreshCache();
  212. }
  213. catch (Exception ex)
  214. {
  215. throw new Exception(ex.Message);
  216. }
  217. }
  218. }
  219. }