SupEvaluationServices.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.SupervisionManage;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel.SupervisionManage;
  8. using EMIS.ViewModel;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using Bowin.Common.Linq;
  12. using EMIS.CommonLogic.SystemServices;
  13. namespace EMIS.CommonLogic.SupervisionManage
  14. {
  15. public class SupEvaluationServices : BaseServices, ISupEvaluationServices
  16. {
  17. public SupEvaluationDAL SupEvaluationDAL { get; set; }
  18. public IGridResultSet<SupEvaluationView> GetSupEvaluationViewGrid(ConfiguretView configuretView,Guid? schoolyearID, Guid? collegeID, DateTime? startTimes, DateTime? endTimes, int? SupervisionTypeID, int DataRange, int pageIndex, int pageSize)
  19. {
  20. Expression<Func<SUP_LessonRecord, bool>> lessonFilter = (x => true);
  21. Expression<Func<SUP_ProjectRecord, bool>> projectFilter = (x => true);
  22. Expression<Func<CF_Staff, bool>> supervisorExp = (x => true);
  23. if (schoolyearID.HasValue)
  24. {
  25. lessonFilter = lessonFilter.And(x => x.SchoolyearID == schoolyearID);
  26. projectFilter = projectFilter.And(x => x.SchoolyearID == schoolyearID);
  27. }
  28. if (collegeID.HasValue)
  29. {
  30. supervisorExp = supervisorExp.And(x => x.CollegeID == collegeID);
  31. }
  32. if(startTimes.HasValue)
  33. {
  34. lessonFilter = lessonFilter.And(x => x.LessonDate >= startTimes);
  35. projectFilter = projectFilter.And(x => x.ProjectDate >= startTimes);
  36. }
  37. if (endTimes.HasValue)
  38. {
  39. var endDate= endTimes.Value.AddDays(1);
  40. lessonFilter = lessonFilter.And(x => x.LessonDate < endDate);
  41. projectFilter = projectFilter.And(x => x.ProjectDate < endDate);
  42. }
  43. if(DataRange!=(int)SYS_DataRange.All)
  44. {
  45. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  46. var curUserID = curUser.UserID;
  47. lessonFilter = lessonFilter.And(x => x.UserID == curUserID);
  48. projectFilter = projectFilter.And(x => x.UserID == curUserID);
  49. }
  50. var query = SupEvaluationDAL.GetSupEvaluationViewQueryable(lessonFilter, projectFilter, supervisorExp);
  51. if (SupervisionTypeID.HasValue)
  52. {
  53. if (SupervisionTypeID == (int)SUP_EvaluationType.Lesson)
  54. {
  55. query = query.Where(x => x.SupervisionTypeID ==null);
  56. }
  57. else
  58. {
  59. query = query.Where(x => x.SupervisionTypeID == (int)SUP_SupervisionType.Evaluation);
  60. }
  61. }
  62. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  63. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  64. var result = query.OrderByDescending(x => x.SchoolyearCode).ThenBy(x=>x.SupervisionCollegeName).ThenBy(x=>x.UserName)
  65. .ThenBy(x => x.CourseName).ThenByDescending(x => x.LessonDate).ToGridResultSet<SupEvaluationView>(pageIndex, pageSize);
  66. return result;
  67. }
  68. public List<SupEvaluationView> GetSupEvaluationViewGridList(ConfiguretView configuretView,Guid? schoolyearID, Guid? collegeID, DateTime? startTimes, DateTime? endTimes, int? SupervisionTypeID, int DataRange, List<Guid> selectedLessonRecordID, List<Guid> selectedProjectRecordID)
  69. {
  70. Expression<Func<SUP_LessonRecord, bool>> lessonFilter = (x => true);
  71. Expression<Func<SUP_ProjectRecord, bool>> projectFilter = (x => true);
  72. Expression<Func<CF_Staff, bool>> supervisorExp = (x => true);
  73. if (schoolyearID.HasValue)
  74. {
  75. lessonFilter = lessonFilter.And(x => x.SchoolyearID == schoolyearID);
  76. projectFilter = projectFilter.And(x => x.SchoolyearID == schoolyearID);
  77. }
  78. if (collegeID.HasValue)
  79. {
  80. supervisorExp = supervisorExp.And(x => x.CollegeID == collegeID);
  81. }
  82. if (startTimes.HasValue)
  83. {
  84. lessonFilter = lessonFilter.And(x => x.LessonDate >= startTimes);
  85. projectFilter = projectFilter.And(x => x.ProjectDate >= startTimes);
  86. }
  87. if (endTimes.HasValue)
  88. {
  89. lessonFilter = lessonFilter.And(x => x.LessonDate < endTimes.Value.AddDays(1));
  90. projectFilter = projectFilter.And(x => x.ProjectDate < endTimes.Value.AddDays(1));
  91. }
  92. if (DataRange != (int)SYS_DataRange.All)
  93. {
  94. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  95. var curUserID = curUser.UserID;
  96. lessonFilter = lessonFilter.And(x => x.UserID == curUserID);
  97. projectFilter = projectFilter.And(x => x.UserID == curUserID);
  98. }
  99. var query = SupEvaluationDAL.GetSupEvaluationViewQueryable(lessonFilter, projectFilter, supervisorExp);
  100. if (selectedLessonRecordID.Count > 0)
  101. {
  102. List<Guid?> LessonRecordIDList = new List<Guid?>();
  103. foreach(var LessonRecordID in selectedLessonRecordID)
  104. {
  105. LessonRecordIDList.Add(LessonRecordID);
  106. }
  107. query = query.Where(x => LessonRecordIDList.Contains(x.LessonRecordID));
  108. }
  109. if (selectedProjectRecordID.Count > 0)
  110. {
  111. List<Guid?> ProjectRecordIDList = new List<Guid?>();
  112. foreach (var ProjectRecordID in selectedLessonRecordID)
  113. {
  114. ProjectRecordIDList.Add(ProjectRecordID);
  115. }
  116. query = query.Where(x => ProjectRecordIDList.Contains(x.ProjectRecordID));
  117. }
  118. if (SupervisionTypeID.HasValue)
  119. {
  120. query = query.Where(x => x.SupervisionTypeID == SupervisionTypeID);
  121. }
  122. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  123. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  124. return query.ToList();
  125. }
  126. }
  127. }