RecruitStatusDAL.cs 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.Students.HighBaseTable;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.DataLogic.Common.CalendarManage;
  8. namespace EMIS.DataLogic.Common.Students.HighBaseTable
  9. {
  10. public class RecruitStatusDAL
  11. {
  12. public RecruitStatusRepository RecruitStatusRepository { get; set; }
  13. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  14. public StudentRepository StudentRepository { get; set; }
  15. public StudentProfileRepository StudentProfileRepository { get; set; }
  16. public ClassmajorRepository ClassmajorRepository { get; set; }
  17. public GrademajorRepository GrademajorRepository { get; set; }
  18. public FacultymajorRepository FacultymajorRepository { get; set; }
  19. public SchoolyearRepository SchoolyearRepository { get; set; }
  20. public RecruitstudentsRepository RecruitstudentsRepository { get; set; }
  21. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  22. public EducationTypeSettingRepository EducationTypeSettingRepository { get; set; }
  23. public SchoolYearDAL SchoolYearDAL { get; set; }
  24. public StudentReportRepository StudentReportRepository { get; set; }
  25. public IQueryable<RecruitStatusView> GetRecruitStatusViewQueryable(int? schoolYear)
  26. {
  27. //var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  28. var query = from student in StudentRepository.Entities
  29. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  30. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  31. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  32. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  33. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  34. join edutype in EducationTypeSettingRepository.Entities on famajor.EducationID equals edutype.EducationID
  35. join entyear in SchoolyearRepository.Entities on recruit.EnteringSchoolYearID equals entyear.SchoolyearID
  36. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true) on student.InSchoolStatusID equals inschool.InSchoolStatusID into dinschool
  37. from inschool in dinschool.DefaultIfEmpty()
  38. //join report in
  39. // (
  40. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE
  41. // && x.ReportStatusID == (int)EMIS.ViewModel.CF_ReportStatus.Havetoreportforduty)
  42. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  43. // where schoolyear.Years == schoolYear
  44. // select report.UserID
  45. // ).Distinct() on student.UserID equals report into tmp
  46. //from report in tmp.DefaultIfEmpty()
  47. //join schyear in SchoolyearRepository.GetList(x => x.IsCurrent == true) on schyear.
  48. //join diction in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_STUDENTTYPE).Name) on student.StudentType equals diction.Value
  49. //into tmp from diction in tmp.DefaultIfEmpty()
  50. //join diction1 in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_StudentStatus).Name) on student.StudentStatus equals diction1.Value
  51. //into tmp1 from diction1 in tmp1.DefaultIfEmpty()
  52. //join diction2 in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_EducationType).Name) on edutype.EducationTypeID equals diction2.Value
  53. //into tmp2 from diction2 in tmp2.DefaultIfEmpty()
  54. //join diction3 in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Province).Name) on recruit.Territorial equals diction3.Value
  55. //into tmp3 from diction3 in tmp3.DefaultIfEmpty()
  56. select new RecruitStatusView
  57. {
  58. //Year = Year,
  59. StudentType = student.StudentType.Value,
  60. Territorial = recruit.TerritorialID.Value,
  61. EducationTypeID = edutype.EducationTypeID.Value,
  62. IsRecruitStudent = (entyear.Years == schoolYear && inschool.InSchoolSettingID != null) ? true : false,
  63. IsInSchoolStudent = (inschool.InSchoolSettingID != null),
  64. //RecruitCount=
  65. //InschoolCount
  66. }
  67. ;
  68. return query;
  69. }
  70. public IQueryable<RecruitStatusView> GetRecruitStatusInschoolCount(int? schYear)
  71. {
  72. var query = from student in StudentRepository.GetList(x => x.InSchoolStatusID == (int)EMIS.ViewModel.CF_InschoolStatus.InSchool)
  73. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  74. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  75. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  76. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  77. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  78. join edutype in EducationTypeSettingRepository.Entities on famajor.EducationID equals edutype.EducationID
  79. join entyear in SchoolyearRepository.Entities on recruit.EnteringSchoolYearID equals entyear.SchoolyearID
  80. //join report in
  81. // (
  82. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE
  83. // && x.ReportStatusID == (int)EMIS.ViewModel.CF_ReportStatus.Havetoreportforduty)
  84. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  85. // where schoolyear.Years == schYear
  86. // select report.UserID
  87. // ).Distinct() on student.UserID equals report
  88. group student by new { recruit.TerritorialID, edutype.EducationTypeID } into g
  89. select new RecruitStatusView
  90. {
  91. //StudentType = g.Key.StudentType,
  92. Territorial = g.Key.TerritorialID,
  93. EducationTypeID = g.Key.EducationTypeID,
  94. InschoolCount = g.Count()
  95. };
  96. return query;
  97. }
  98. public IQueryable<RecruitStatusView> GetRecruitStatusRecruitCount(int? schoolYear)
  99. {
  100. //var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  101. var query = from student in StudentRepository.GetList(x => x.InSchoolStatusID == (int)EMIS.ViewModel.CF_InschoolStatus.InSchool)
  102. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  103. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  104. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  105. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  106. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  107. join edutype in EducationTypeSettingRepository.Entities on famajor.EducationID equals edutype.EducationID
  108. join entyear in SchoolyearRepository.GetList(x => x.Years == schoolYear) on recruit.EnteringSchoolYearID equals entyear.SchoolyearID
  109. //join report in
  110. // (
  111. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE
  112. // && x.ReportStatusID == (int)EMIS.ViewModel.CF_ReportStatus.Havetoreportforduty)
  113. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  114. // where schoolyear.Years == schoolYear
  115. // select report.UserID
  116. // ).Distinct() on student.UserID equals report
  117. group student by new { recruit.TerritorialID, edutype.EducationTypeID } into g
  118. select new RecruitStatusView
  119. {
  120. //StudentType = g.Key.StudentType,
  121. Territorial = g.Key.TerritorialID,
  122. EducationTypeID = g.Key.EducationTypeID,
  123. RecruitCount = g.Count()
  124. };
  125. return query;
  126. }
  127. }
  128. }