CheckingControlServices.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Reflection;
  7. using System.ComponentModel;
  8. using Bowin.Common.Linq;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.Entities;
  11. using EMIS.ViewModel;
  12. using EMIS.ViewModel.StudentManage.OnlineChecking;
  13. using EMIS.ViewModel.StudentManage.StudentProfile;
  14. using EMIS.DataLogic.StudentManage.OnlineChecking;
  15. namespace EMIS.CommonLogic.StudentManage.OnlineChecking
  16. {
  17. public class CheckingControlServices : BaseServices , ICheckingControlServices
  18. {
  19. public Lazy<CheckingControlDAL> CheckingControlDAL { get; set; }
  20. /// <summary>
  21. /// 查询对应的学生校对控制信息CheckingControlView
  22. /// </summary>
  23. /// <param name="configuretView"></param>
  24. /// <param name="checkingTypeID"></param>
  25. /// <param name="pageIndex"></param>
  26. /// <param name="pageSize"></param>
  27. /// <returns></returns>
  28. public IGridResultSet<CheckingControlView> GetStudentEditControlViewGrid(ConfiguretView configuretView, int? checkingTypeID, int pageIndex, int pageSize)
  29. {
  30. Expression<Func<CF_StudentEditControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  31. if (checkingTypeID.HasValue)
  32. {
  33. exp = exp.And(x => x.CheckingTypeID == checkingTypeID);
  34. }
  35. var query = CheckingControlDAL.Value.GetStudentEditControlQueryable(exp);
  36. //查询条件
  37. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  38. {
  39. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  40. }
  41. var result = query.OrderBy(x => x.OrderNo).ToGridResultSet<CheckingControlView>(pageIndex, pageSize);
  42. result.rows.ForEach(x =>
  43. {
  44. var property = typeof(StudentView).GetProperty(x.ColumnName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
  45. if (property == null)
  46. {
  47. return;
  48. }
  49. var displayNameAttribute = (DisplayNameAttribute)property.GetCustomAttributes(typeof(DisplayNameAttribute), false).FirstOrDefault();
  50. if (displayNameAttribute != null)
  51. {
  52. x.DisplayColumnName = displayNameAttribute.DisplayName;
  53. }
  54. });
  55. result.rows = result.rows.Where(x => x.DisplayColumnName != null).ToList();
  56. result.total = result.rows.Count;
  57. return result;
  58. }
  59. /// <summary>
  60. /// 查询对应的学生校对控制信息List
  61. /// </summary>
  62. /// <param name="configuretView"></param>
  63. /// <param name="checkingTypeID"></param>
  64. /// <returns></returns>
  65. public IList<CheckingControlView> GetStudentEditControlViewList(ConfiguretView configuretView, int? checkingTypeID)
  66. {
  67. Expression<Func<CF_StudentEditControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  68. if (checkingTypeID.HasValue)
  69. {
  70. exp = exp.And(x => x.CheckingTypeID == checkingTypeID);
  71. }
  72. var query = CheckingControlDAL.Value.GetStudentEditControlQueryable(exp);
  73. //查询条件
  74. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  75. {
  76. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  77. }
  78. var result = query.OrderBy(x => x.OrderNo).ToList();
  79. result.ForEach(x =>
  80. {
  81. var property = typeof(StudentView).GetProperty(x.ColumnName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase);
  82. if (property == null)
  83. {
  84. return;
  85. }
  86. var displayNameAttribute = (DisplayNameAttribute)property.GetCustomAttributes(typeof(DisplayNameAttribute), false).FirstOrDefault();
  87. if (displayNameAttribute != null)
  88. {
  89. x.DisplayColumnName = displayNameAttribute.DisplayName;
  90. }
  91. });
  92. result = result.Where(x => x.DisplayColumnName != null).ToList();
  93. return result;
  94. }
  95. /// <summary>
  96. /// 学生信息校对控制设置
  97. /// </summary>
  98. /// <param name="columnNames"></param>
  99. /// <param name="checkingTypeIDs"></param>
  100. public void StudentEditControlSet(IList<string> columnNames, IList<int?> checkingTypeIDs)
  101. {
  102. List<CF_StudentEditControl> studentEditControlUpList = new List<CF_StudentEditControl>();
  103. for (int i = 0; i < columnNames.Count(); i++)
  104. {
  105. var columnName = columnNames[i];
  106. Expression<Func<CF_StudentEditControl, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  107. exp = exp.And(x => x.ColumnName == columnName);
  108. var studentEditControl = CheckingControlDAL.Value.StudentEditControlRepository.GetList(exp).SingleOrDefault();
  109. if (studentEditControl != null)
  110. {
  111. studentEditControl.CheckingTypeID = checkingTypeIDs[i];
  112. this.SetModifyStatus(studentEditControl);
  113. studentEditControlUpList.Add(studentEditControl);
  114. }
  115. }
  116. if (studentEditControlUpList != null && studentEditControlUpList.Count() > 0)
  117. {
  118. UnitOfWork.BatchUpdate(studentEditControlUpList);
  119. }
  120. }
  121. }
  122. }