ChargeControlServices.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.CommonLogic.SystemServices;
  6. using EMIS.ViewModel.ChargeManage.ArrearsSituation;
  7. using EMIS.ViewModel;
  8. using EMIS.DataLogic.ChargeManage.ArrearsSituation;
  9. namespace EMIS.CommonLogic.ChargeManage.ArrearsSituation
  10. {
  11. public class ChargeControlServices:BaseServices,IChargeControlServices
  12. {
  13. public ChargeControlDAL ChargeControlDAL { get; set; }
  14. public Lazy<IControlItemServices> ControlItemServices { get; set; }
  15. /// <summary>
  16. /// 查询费用控制类型相应的信息View(费用控制-1,注册控制-2,评价控制-3)
  17. /// </summary>
  18. /// <returns></returns>
  19. public ChargeControlView GetChargeControlView()
  20. {
  21. var chargeControlView = new ChargeControlView();
  22. //数据字典配置控制类型(费用控制-1,注册控制-2,评价控制-3)
  23. var studentChargeType = SYS_ControlItemType.StudentCharge;
  24. //查询对应的控制类型信息
  25. var controlItemList = ControlItemServices.Value.GetControlItemList(studentChargeType);
  26. if (controlItemList == null || controlItemList.Count <= 0)
  27. {
  28. chargeControlView.IsStudentChargeLoginLock = false;
  29. chargeControlView.StudentChargeLoginLockMessage = "未设置。";
  30. chargeControlView.IsStudentChargeLoginDisplay = "none";
  31. chargeControlView.IsStudentChargeSelectCourseLock = false;
  32. chargeControlView.StudentChargeSelectCourseMessage = "未设置。";
  33. chargeControlView.IsStudentChargeSelectCourseDisplay = "none";
  34. chargeControlView.IsStudentChargeExaminationApplyLock = false;
  35. chargeControlView.StudentChargeExaminationApplyMessage = "未设置。";
  36. chargeControlView.IsStudentChargeExaminationApplyDisplay = "none";
  37. chargeControlView.IsStudentChargeScoreLock = false;
  38. chargeControlView.StudentChargeScoreLockMessage = "未设置。";
  39. chargeControlView.IsStudentChargeScoreDisplay = "none";
  40. chargeControlView.IsStudentChargeLevelScoreLock = false;
  41. chargeControlView.StudentChargeLevelScoreMessage = "未设置。";
  42. chargeControlView.IsStudentChargeLevelScoreDisplay = "none";
  43. }
  44. else
  45. {
  46. var chargeLoginLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeLogin" && x.IsLoginControl == true).SingleOrDefault();
  47. if (chargeLoginLock != null)
  48. {
  49. chargeControlView.IsStudentChargeLoginLock = chargeLoginLock.IsEnable ?? false;
  50. chargeControlView.StudentChargeLoginLockMessage = chargeLoginLock.Message;
  51. chargeControlView.IsStudentChargeLoginDisplay = "table-row";
  52. }
  53. else
  54. {
  55. chargeControlView.IsStudentChargeLoginLock = false;
  56. chargeControlView.StudentChargeLoginLockMessage = "未设置。";
  57. chargeControlView.IsStudentChargeLoginDisplay = "none";
  58. }
  59. var chargeSelectCourseLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeSelectCourse").SingleOrDefault();
  60. if (chargeSelectCourseLock != null)
  61. {
  62. chargeControlView.IsStudentChargeSelectCourseLock = chargeSelectCourseLock.IsEnable ?? false;
  63. chargeControlView.StudentChargeSelectCourseMessage = chargeSelectCourseLock.Message;
  64. chargeControlView.IsStudentChargeSelectCourseDisplay = "table-row";
  65. }
  66. else
  67. {
  68. chargeControlView.IsStudentChargeSelectCourseLock = false;
  69. chargeControlView.StudentChargeSelectCourseMessage = "未设置。";
  70. chargeControlView.IsStudentChargeSelectCourseDisplay = "none";
  71. }
  72. var chargeExaminationApplyLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeExaminationApply").SingleOrDefault();
  73. if (chargeExaminationApplyLock != null)
  74. {
  75. chargeControlView.IsStudentChargeExaminationApplyLock = chargeExaminationApplyLock.IsEnable ?? false;
  76. chargeControlView.StudentChargeExaminationApplyMessage = chargeExaminationApplyLock.Message;
  77. chargeControlView.IsStudentChargeExaminationApplyDisplay = "table-row";
  78. }
  79. else
  80. {
  81. chargeControlView.IsStudentChargeExaminationApplyLock = false;
  82. chargeControlView.StudentChargeExaminationApplyMessage = "未设置。";
  83. chargeControlView.IsStudentChargeExaminationApplyDisplay = "none";
  84. }
  85. var chargeScoreControlLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeScore").SingleOrDefault();
  86. if (chargeScoreControlLock != null)
  87. {
  88. chargeControlView.IsStudentChargeScoreLock = chargeScoreControlLock.IsEnable ?? false;
  89. chargeControlView.StudentChargeScoreLockMessage = chargeScoreControlLock.Message;
  90. chargeControlView.IsStudentChargeScoreDisplay = "table-row";
  91. }
  92. else
  93. {
  94. chargeControlView.IsStudentChargeScoreLock = false;
  95. chargeControlView.StudentChargeScoreLockMessage = "未设置。";
  96. chargeControlView.IsStudentChargeScoreDisplay = "none";
  97. }
  98. var chargeLevelScoreLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeLevelScore").SingleOrDefault();
  99. if (chargeLevelScoreLock != null)
  100. {
  101. chargeControlView.IsStudentChargeLevelScoreLock = chargeLevelScoreLock.IsEnable ?? false;
  102. chargeControlView.StudentChargeLevelScoreMessage = chargeLevelScoreLock.Message;
  103. chargeControlView.IsStudentChargeLevelScoreDisplay = "table-row";
  104. }
  105. else
  106. {
  107. chargeControlView.IsStudentChargeLevelScoreLock = false;
  108. chargeControlView.StudentChargeLevelScoreMessage = "未设置。";
  109. chargeControlView.IsStudentChargeLevelScoreDisplay = "none";
  110. }
  111. }
  112. return chargeControlView;
  113. }
  114. /// <summary>
  115. /// 费用控制保存
  116. /// </summary>
  117. /// <param name="chargeControlView"></param>
  118. public void ChargeControlSave(ChargeControlView chargeControlView)
  119. {
  120. try
  121. {
  122. var controlItemList = ControlItemServices.Value.GetControlItemList(SYS_ControlItemType.StudentCharge);
  123. if (controlItemList == null || controlItemList.Count <= 0)
  124. {
  125. throw new Exception("费用控制类型未配置,请配置。");
  126. }
  127. else
  128. {
  129. var chargeLoginLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeLogin" && x.IsLoginControl == true).SingleOrDefault();
  130. if (chargeLoginLock != null)
  131. {
  132. chargeLoginLock.IsEnable = chargeControlView.IsStudentChargeLoginLock;
  133. chargeLoginLock.Message = chargeControlView.StudentChargeLoginLockMessage;
  134. }
  135. var chargeSelectCourseLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeSelectCourse").SingleOrDefault();
  136. if (chargeSelectCourseLock != null)
  137. {
  138. chargeSelectCourseLock.IsEnable = chargeControlView.IsStudentChargeSelectCourseLock;
  139. chargeSelectCourseLock.Message = chargeControlView.StudentChargeSelectCourseMessage;
  140. }
  141. var chargeExaminationApplyLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeExaminationApply").SingleOrDefault();
  142. if (chargeExaminationApplyLock != null)
  143. {
  144. chargeExaminationApplyLock.IsEnable = chargeControlView.IsStudentChargeExaminationApplyLock;
  145. chargeExaminationApplyLock.Message = chargeControlView.StudentChargeExaminationApplyMessage;
  146. }
  147. var chargeScoreLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeScore").SingleOrDefault();
  148. if (chargeScoreLock != null)
  149. {
  150. chargeScoreLock.IsEnable = chargeControlView.IsStudentChargeScoreLock;
  151. chargeScoreLock.Message = chargeControlView.StudentChargeScoreLockMessage;
  152. }
  153. var chargeLevelScoreLock = controlItemList.Where(x => x.ControlItemCode == "StudentChargeLevelScore").SingleOrDefault();
  154. if (chargeLevelScoreLock != null)
  155. {
  156. chargeLevelScoreLock.IsEnable = chargeControlView.IsStudentChargeLevelScoreLock;
  157. chargeLevelScoreLock.Message = chargeControlView.StudentChargeLevelScoreMessage;
  158. }
  159. this.UnitOfWork.Commit();
  160. ControlItemServices.Value.RefreshCache();
  161. }
  162. }
  163. catch (Exception ex)
  164. {
  165. throw new Exception(ex.Message);
  166. }
  167. }
  168. /// <summary>
  169. /// 根据userID查询能否登录系统(同时包括个性化控制登录的判断--控制放行信息)
  170. /// </summary>
  171. /// <param name="userID"></param>
  172. /// <returns></returns>
  173. public bool CanLogin(Guid userID)
  174. {
  175. //查询对应的欠费信息
  176. var arrearsListView = ChargeControlDAL.GetArrearListViewAble(x => x.UserID == userID).SingleOrDefault();
  177. if (arrearsListView != null)
  178. {
  179. //查询对应的控制放行信息
  180. var passStudentView = ChargeControlDAL.GetPassStudentViewAble(x => x.UserID == userID).SingleOrDefault();
  181. if (passStudentView != null)
  182. {
  183. return true;
  184. }
  185. return false;
  186. }
  187. return true;
  188. }
  189. /// <summary>
  190. /// 根据userID查询能否网上选课(根据费用控制的设置,只要欠费将无法网上选课)
  191. /// </summary>
  192. /// <param name="userID"></param>
  193. /// <returns></returns>
  194. public bool CanSelectCourse(Guid userID)
  195. {
  196. //查询对应的欠费信息
  197. var arrearsListView = ChargeControlDAL.GetArrearListViewAble(x => x.UserID == userID).SingleOrDefault();
  198. if (arrearsListView != null)
  199. {
  200. //注:能登录系统不一定可网上选课(注释以下代码)
  201. ////查询对应的控制放行信息
  202. //var passStudentView = ChargeControlDAL.GetPassStudentViewAble(x => x.UserID == userID).SingleOrDefault();
  203. //if (passStudentView != null)
  204. //{
  205. // return true;
  206. //}
  207. return false;
  208. }
  209. return true;
  210. }
  211. /// <summary>
  212. /// 根据userID查询能否查询成绩(根据费用控制的设置,只要欠费将无法查询成绩)
  213. /// </summary>
  214. /// <param name="userID"></param>
  215. /// <returns></returns>
  216. public bool CanViewScore(Guid userID)
  217. {
  218. //查询对应的欠费信息
  219. var arrearsListView = ChargeControlDAL.GetArrearListViewAble(x => x.UserID == userID).SingleOrDefault();
  220. if (arrearsListView != null)
  221. {
  222. //注:能登录系统不一定可查询成绩(注释以下代码)
  223. ////查询对应的控制放行信息
  224. //var passStudentView = ChargeControlDAL.GetPassStudentViewAble(x => x.UserID == userID).SingleOrDefault();
  225. //if (passStudentView != null)
  226. //{
  227. // return true;
  228. //}
  229. return false;
  230. }
  231. return true;
  232. }
  233. }
  234. }