SOCDAL_heyw.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.Cultureplan;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Common.Cultureplan;
  9. using EMIS.DataLogic.Repositories;
  10. using EMIS.ViewModel.DQPSystem;
  11. using EMIS.ViewModel;
  12. namespace EMIS.DataLogic.DQPSystem
  13. {
  14. public partial class SOCDAL
  15. {
  16. public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
  17. public StaffRepository StaffRepository { get; set; }
  18. public SOCDetailStudentRepository SOCDetailStudentRepository { get; set; }
  19. public SOCDetailGroupRepository SOCDetailGroupRepository { get; set; }
  20. public IQueryable<CoursematerialView> GetStaffRelateCoursematerialViewQueryable(Expression<Func<DQP_SOC, bool>> exp,
  21. Expression<Func<CF_Staff, bool>> staffExp)
  22. {
  23. var sql = (from course in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true)
  24. from soc in SOCRepository.Entities.Where(exp).Where(x => x.CoursematerialID == course.CoursematerialID)
  25. from teacher in soc.DQP_SOCStaff
  26. from staff in StaffRepository.Entities.Where(staffExp).Where(x => x.UserID == teacher.UserID)
  27. group course by course into g
  28. select g.Key);
  29. return sql;
  30. }
  31. public IQueryable<CoursematerialView> GetStudentRelateCoursematerialViewQueryable(Expression<Func<DQP_SOC, bool>> exp,
  32. Expression<Func<CF_Student, bool>> studentExp)
  33. {
  34. var sql = (from course in CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true)
  35. from soc in SOCRepository.Entities.Where(exp).Where(x => x.CoursematerialID == course.CoursematerialID)
  36. from student in soc.CF_Student.AsQueryable().Where(studentExp)
  37. group course by course into g
  38. select g.Key);
  39. return sql;
  40. }
  41. public IQueryable<SOCStudentView> GetSOCStudentViewQueryable(Expression<Func<DQP_SOC, bool>> exp, Expression<Func<CF_Student, bool>> studentExp)
  42. {
  43. var sql = (from soc in SOCRepository.GetList(exp)
  44. from schoolyear in schoolyearRepository.Entities.Where(x => x.SchoolyearID == soc.SchoolyearID)
  45. from course in coursematerialRepository.Entities.Where(x => x.CoursematerialID == soc.CoursematerialID)
  46. from student in soc.CF_Student.AsQueryable().Where(studentExp)
  47. from detail in SOCDetailRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && soc.SOCID == x.SOCID && x.IsGroup == true)
  48. from groupDetail in SOCDetailGroupRepository.Entities.Where(x => x.SOCDetailID == detail.SOCDetailID)
  49. from groupStudent in groupDetail.CF_Student.AsQueryable().Where(x => x.UserID == student.UserID)
  50. select new SOCStudentView
  51. {
  52. SOCDetailID = detail.SOCDetailID,
  53. SOCID = soc.SOCID,
  54. SOCDetailGroupID = groupDetail.SOCDetailGroupID,
  55. SchoolyearID = soc.SchoolyearID,
  56. SchoolyearCode = schoolyear.Code,
  57. CoursematerialID = soc.CoursematerialID,
  58. CourseCode = course.CourseCode,
  59. CourseName = course.CourseName,
  60. Name = detail.Name,
  61. Credit = detail.Credit,
  62. Weight = detail.Weight,
  63. StartTime = detail.StartTime,
  64. EndTime = detail.EndTime,
  65. Remark = groupDetail.Remark,
  66. RecordStatus = (groupDetail.RecordStatus ?? (int)DQP_SOCDetailSubmitStatus.NotSubmit)
  67. })
  68. .Concat(
  69. from soc in SOCRepository.GetList(exp)
  70. from schoolyear in schoolyearRepository.Entities.Where(x => x.SchoolyearID == soc.SchoolyearID)
  71. from course in coursematerialRepository.Entities.Where(x => x.CoursematerialID == soc.CoursematerialID)
  72. from student in soc.CF_Student.AsQueryable().Where(studentExp)
  73. from detail in SOCDetailRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && soc.SOCID == x.SOCID && x.IsGroup != true)
  74. from studentDetail in SOCDetailStudentRepository.Entities.Where(x => x.SOCDetailID == detail.SOCDetailID && x.UserID == student.UserID).DefaultIfEmpty()
  75. select new SOCStudentView
  76. {
  77. SOCDetailID = detail.SOCDetailID,
  78. SOCID = soc.SOCID,
  79. SOCDetailGroupID = null,
  80. SchoolyearID = soc.SchoolyearID,
  81. SchoolyearCode = schoolyear.Code,
  82. CoursematerialID = soc.CoursematerialID,
  83. CourseCode = course.CourseCode,
  84. CourseName = course.CourseName,
  85. Name = detail.Name,
  86. Credit = detail.Credit,
  87. Weight = detail.Weight,
  88. StartTime = detail.StartTime,
  89. EndTime = detail.EndTime,
  90. Remark = studentDetail.Remark,
  91. RecordStatus = (studentDetail.RecordStatus ?? (int)DQP_SOCDetailSubmitStatus.NotSubmit)
  92. });
  93. return sql;
  94. }
  95. }
  96. }