SOCDetailGroupDAL.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.DQPSystem;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel.Students;
  10. namespace EMIS.DataLogic.DQPSystem
  11. {
  12. public class SOCDetailGroupDAL
  13. {
  14. public SOCRepository SOCRepository { get; set; }
  15. public SOCDetailRepository SOCDetailRepository { get; set; }
  16. public SOCDetailAttachmentRepository SOCDetailAttachmentRepository { get; set; }
  17. public SOCDetailGroupRepository SOCDetailGroupRepository { get; set; }
  18. public StudentRepository studentRepository { get; set; }
  19. public EducationMissionRepository educationMissionRepository { get; set; }
  20. public IQueryable<SOCDetailGroupView> GetSOCDetailGroupViewQueryable(Expression<Func<DQP_SOCDetailGroup, bool>> exp)
  21. {
  22. var query = from fgro in SOCDetailGroupRepository.GetList(exp)
  23. join edu in educationMissionRepository.Entities
  24. on fgro.DQP_SOCDetail.DQP_SOC.EducationMissionID equals edu.EducationMissionID
  25. into gedu
  26. from edu in gedu.DefaultIfEmpty()
  27. //join att in SOCDetailAttachmentRepository.Entities
  28. //on detail.SOCDetailID equals att.SOCDetailID
  29. //into gatt
  30. //from fatt in gatt.DefaultIfEmpty()
  31. select new SOCDetailGroupView
  32. {
  33. SOCDetailGroupID = fgro.SOCDetailGroupID,
  34. EducationMissionID = fgro.DQP_SOCDetail.DQP_SOC.EducationMissionID,
  35. EducationMissionName = edu.ClassName,
  36. SOCDetailID = fgro.DQP_SOCDetail.SOCDetailID,
  37. Name = fgro.DQP_SOCDetail.Name,
  38. CoursematerialID = fgro.DQP_SOCDetail.DQP_SOC.CoursematerialID,
  39. CourseCode = fgro.DQP_SOCDetail.DQP_SOC.EM_Coursematerial.CourseCode,
  40. CourseName = fgro.DQP_SOCDetail.DQP_SOC.EM_Coursematerial.CourseName,
  41. No = fgro.No,
  42. Score = fgro.Score,
  43. StudentCount = fgro.CF_Student.Select(x => x.Sys_User).Distinct().Count(),
  44. StudentList = fgro.CF_Student.Select(x => x.Sys_User).Distinct()
  45. };
  46. return query;
  47. }
  48. /// <summary>
  49. /// 获取学生信息
  50. /// </summary>
  51. /// <param name="finalExaminationID"></param>
  52. /// <returns></returns>
  53. public IQueryable<BaseStudentView> GetStudentListForGroup(Guid? SOCDetailID)
  54. {
  55. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  56. var query = from a in SOCRepository.GetList(x => x.DQP_SOCDetail.Any(y => y.SOCDetailID == SOCDetailID))
  57. from c in a.DQP_SOCStaff.FirstOrDefault(x => x.UserID == curUser.UserID).CF_Student
  58. select new BaseStudentView
  59. {
  60. UserID = c.UserID,
  61. LoginID = c.Sys_User.LoginID,
  62. UserName = c.Sys_User.Name,
  63. SexID = c.SexID,
  64. IDNumber = c.IDNumber,
  65. InSchoolStatusID = c.InSchoolStatusID,
  66. StudentStatus = c.StudentStatus,
  67. ClassmajorCode = c.CF_Classmajor.No,
  68. ClassmajorName = c.CF_Classmajor.Name,
  69. };
  70. return query;
  71. }
  72. public IQueryable<GroupSOCDetailView> GetGroupSOCDetailViewQueryable(Expression<Func<DQP_SOCDetail, bool>> exp)
  73. {
  74. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  75. var query = from detail in SOCDetailRepository.GetList(exp)
  76. select new GroupSOCDetailView
  77. {
  78. SOCDetailID = detail.SOCDetailID,
  79. StudentTotalNum = detail.DQP_SOC.DQP_SOCStaff.FirstOrDefault(x => x.UserID == curUser.UserID).CF_Student.Distinct().Count(),
  80. };
  81. return query;
  82. }
  83. //public List<DQP_SOC> GetStudentsForGroup(Expression<Func<DQP_SOC, bool>> exp)
  84. //{
  85. // var query = SOCRepository.GetList(exp, x => x.CF_Student).ToList();
  86. // return query;
  87. //}
  88. /// <summary>
  89. /// 获取学生信息
  90. /// </summary>
  91. /// <param name="finalExaminationID"></param>
  92. /// <returns></returns>
  93. public IQueryable<BaseStudentView> GetSOCDetailGroupViewStudentList(Guid? SOCDetailGroupID)
  94. {
  95. var query = from a in SOCDetailGroupRepository.GetList(x => x.SOCDetailGroupID == SOCDetailGroupID)
  96. from c in a.CF_Student
  97. select new BaseStudentView
  98. {
  99. UserID = c.UserID,
  100. LoginID = c.Sys_User.LoginID,
  101. UserName = c.Sys_User.Name,
  102. SexID = c.SexID,
  103. IDNumber = c.IDNumber,
  104. InSchoolStatusID = c.InSchoolStatusID,
  105. StudentStatus = c.StudentStatus,
  106. ClassmajorCode = c.CF_Classmajor.No,
  107. ClassmajorName = c.CF_Classmajor.Name,
  108. };
  109. return query;
  110. }
  111. /// <summary>
  112. /// 获取学生信息(未分组)
  113. /// </summary>
  114. /// <param name="finalExaminationID"></param>
  115. /// <returns></returns>
  116. public IQueryable<BaseStudentView> GetNotGroupStudentList(Guid? SOCDetailGroupID)
  117. {
  118. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  119. var groupStu = from a in SOCDetailRepository.GetList(x => x.DQP_SOCDetailGroup.Any(y => y.SOCDetailGroupID == SOCDetailGroupID))
  120. from gro in a.DQP_SOCDetailGroup
  121. from stu in gro.CF_Student
  122. select new
  123. {
  124. UserID = stu.UserID,
  125. };
  126. var gStuID = groupStu.Select(x => x.UserID).Distinct().ToList();
  127. var query = from a in SOCDetailGroupRepository.GetList(x => x.SOCDetailGroupID == SOCDetailGroupID)
  128. from stu in a.DQP_SOCDetail.DQP_SOC.DQP_SOCStaff.FirstOrDefault(y => y.UserID == curUser.UserID).CF_Student
  129. join gstu in studentRepository.Entities
  130. on stu.UserID equals gstu.UserID
  131. where !gStuID.Contains(stu.UserID)
  132. select new BaseStudentView
  133. {
  134. UserID = stu.UserID,
  135. LoginID = gstu.Sys_User.LoginID,
  136. UserName = gstu.Sys_User.Name,
  137. SexID = stu.SexID,
  138. IDNumber = stu.IDNumber,
  139. InSchoolStatusID = stu.InSchoolStatusID,
  140. StudentStatus = stu.StudentStatus,
  141. ClassmajorCode = gstu.CF_Classmajor.No,
  142. ClassmajorName = gstu.CF_Classmajor.Name,
  143. };
  144. return query;
  145. }
  146. }
  147. }