SOCTemplateDAL.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel.DQPSystem;
  10. using EMIS.ViewModel.CultureplanManage;
  11. namespace EMIS.DataLogic.DQPSystem
  12. {
  13. public class SOCTemplateDAL
  14. {
  15. public SOCTemplateDetailRepository SOCTemplateDetailRepository { get; set; }
  16. public SOCTemplateRepository SOCTemplateRepository { get; set; }
  17. public FacultymajorRepository facultymajorRepository { get; set; }
  18. public CoursematerialRepository coursematerialRepository { get; set; }
  19. public SpecialtyCourseRepository specialtyCourseRepository { get; set; }
  20. public DepartmentRepository departmentRepository { get; set; }
  21. public SOCTemplateDetailAttachmentRepository SOCTemplateDetailAttachmentRepository { get; set; }
  22. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  23. //public FacultymajorRepository facultymajorRepository { get; set; }
  24. public IQueryable<FileUploadView> GetFileUploadViewQueryable(Expression<Func<DQP_SOCTemplateDetail, bool>> exp)
  25. {
  26. var sql = (from detail in SOCTemplateDetailRepository.GetList(exp)
  27. from attachment in detail.DQP_SOCTemplateDetailAttachment
  28. select new FileUploadView
  29. {
  30. FileID = attachment.SOCTemplateDetailAttachmentID,
  31. FormID = attachment.SOCTemplateItemID,
  32. FileUrl = attachment.Url,
  33. FileName = attachment.Name
  34. });
  35. return sql;
  36. }
  37. public IQueryable<SOCTemplateView> GetSOCTemplateViewQueryable(Expression<Func<DQP_SOCTemplate, bool>> exp, Expression<Func<CF_Facultymajor, bool>> facexp)
  38. {
  39. var query = from templ in SOCTemplateRepository.GetList(exp)
  40. join dep in departmentRepository.Entities
  41. on templ.DepartmentID equals dep.DepartmentID
  42. join fac in facultymajorRepository.GetList(facexp)
  43. on templ.FacultymajorID equals fac.FacultymajorID
  44. into dfac
  45. from facde in dfac.DefaultIfEmpty()
  46. join cou in coursematerialRepository.Entities
  47. on templ.CoursematerialID equals cou.CoursematerialID
  48. //join spc in specialtyCourseRepository.Entities
  49. //on new { templ.CoursematerialID, templ.DepartmentID } equals new { spc.CoursematerialID, spc.DepartmentID }
  50. select new SOCTemplateView
  51. {
  52. SOCTemplateID = templ.SOCTemplateID,
  53. StandardID = facde.StandardID,
  54. FacultymajorID = facde.FacultymajorID,
  55. FacultymajorName = facde.Name,
  56. EducationID = facde.EducationID,
  57. LearningformID = facde.LearningformID,
  58. LearnSystem = facde.LearnSystem,
  59. CoursematerialID = templ.CoursematerialID,
  60. CourseCode = cou.CourseCode,
  61. CourseName = cou.CourseName,
  62. Credit = templ.Credit,
  63. SchoolyearNumID = templ.SchoolyearNumID,
  64. SchoolcodeID = templ.SchoolcodeID,
  65. DepartmentID = templ.DepartmentID,
  66. DepartmentCode = dep.No,
  67. IsEnable = templ.RecordStatus == 1 ? true : false,
  68. DepartmentName = dep.Name,
  69. RecordStatus = templ.RecordStatus,
  70. SOCCount = templ.DQP_SOCTemplateDetail.Count,
  71. HandleModeID = templ.HandleModeID,
  72. OptionalCourseTypeID = templ.OptionalCourseTypeID
  73. };
  74. return query;
  75. }
  76. public IQueryable<SOCTemplateDetailView> GetSOCTemplateDetailViewByIDQueryable(Expression<Func<DQP_SOCTemplateDetail, bool>> exp)
  77. {
  78. var query = from detail in SOCTemplateDetailRepository.GetList(exp)
  79. //join att in SOCTemplateDetailAttachmentRepository.Entities
  80. //on detail.SOCTemplateItemID equals att.SOCTemplateItemID
  81. //into deatt
  82. //from gatt in deatt.DefaultIfEmpty()
  83. select new SOCTemplateDetailView
  84. {
  85. SOCTemplateItemID = detail.SOCTemplateItemID,
  86. SOCTemplateID = detail.SOCTemplateID,
  87. Name = detail.Name,
  88. Credit = detail.Credit,
  89. Weight = detail.Weight,
  90. Description = detail.Description,
  91. AttachmentList = detail.DQP_SOCTemplateDetailAttachment,
  92. IsGroup = detail.IsGroup,
  93. };
  94. return query;
  95. }
  96. public IQueryable<SpecialtyCourseView> GetSpecialtyCourseViewQueryable(Expression<Func<EM_SpecialtyCourse, bool>> exp, Expression<Func<CF_Facultymajor, bool>> facexp)
  97. {
  98. var query = from a in specialtyCourseRepository.GetList(exp)
  99. join fac in facultymajorRepository.GetList(facexp)
  100. on new { a.CF_Department.CollegeID, a.CF_Specialty.StandardID } equals new { fac.CollegeID, fac.StandardID }
  101. join d in dictionaryItemRepository.Entities.Where(x => x.DictionaryCode == typeof(CF_Standard).Name) on a.CF_Specialty.StandardID equals d.Value
  102. select new SpecialtyCourseView
  103. {
  104. SpecialtyCourseID = a.SpecialtyCourseID,
  105. FacultymajorID = fac.FacultymajorID,
  106. DepartmentID = a.DepartmentID,
  107. DepartmentCode = a.CF_Department.No,
  108. DepartmentName = a.CF_Department.Name,
  109. CourseStructureID = a.CourseStructureID,
  110. CourseCategoryID = a.CourseCategoryID,
  111. CourseTypeID = a.CourseTypeID,
  112. CourseQualityID = a.CourseQualityID,
  113. PracticeTypeID = a.PracticeTypeID,
  114. ExaminationModeID = a.ExaminationModeID,
  115. TeachinglanguageID = a.TeachinglanguageID,
  116. SchoolyearNumID = (a.StarttermID % 2) == 0 ? (a.StarttermID / 2) : (a.StarttermID / 2) + 1,
  117. SchoolcodeID = (a.StarttermID % 2) == 0 ? 1 : 2,
  118. StarttermID = a.StarttermID,
  119. CourseFineID = a.CourseFineID,
  120. IsSpecialtycore = a.IsSpecialtycore ?? true,
  121. IsCooperation = a.IsCooperation ?? true,
  122. IsRequired = a.IsRequired ?? true,
  123. IsElective = a.IsElective ?? true,
  124. IsNetworkCourse = a.IsNetworkCourse ?? true,
  125. IsMainCourse = a.IsMainCourse ?? true,
  126. IsEnable = a.IsEnable ?? true,
  127. Credit = a.EM_SpecialtyCourseTeachingSetting.Credit ?? 0,
  128. TheoryCourse = a.EM_SpecialtyCourseTeachingSetting.TheoryCourse,
  129. Practicehours = a.EM_SpecialtyCourseTeachingSetting.Practicehours,
  130. Trialhours = a.EM_SpecialtyCourseTeachingSetting.Trialhours,
  131. Totalhours = (a.EM_SpecialtyCourseTeachingSetting.TheoryCourse + a.EM_SpecialtyCourseTeachingSetting.Practicehours),
  132. WeeklyNum = a.EM_SpecialtyCourseTeachingSetting.WeeklyNum,
  133. TheoryWeeklyNum = a.EM_SpecialtyCourseTeachingSetting.TheoryWeeklyNum,
  134. PracticeWeeklyNum = a.EM_SpecialtyCourseTeachingSetting.PracticeWeeklyNum,
  135. TrialWeeklyNum = a.EM_SpecialtyCourseTeachingSetting.TrialWeeklyNum,
  136. SchoolweeksNum = (a.EM_SpecialtyCourseTeachingSetting.TheoryWeeklyNum + a.EM_SpecialtyCourseTeachingSetting.PracticeWeeklyNum),
  137. StartWeeklyNum = a.EM_SpecialtyCourseTeachingSetting.StartWeeklyNum,
  138. EndWeeklyNum = a.EM_SpecialtyCourseTeachingSetting.EndWeeklyNum,
  139. SpecialtyID = a.CF_Specialty.SpecialtyID,
  140. StandardID = a.CF_Specialty.StandardID,
  141. LearnSystem = a.CF_Specialty.LearnSystem,
  142. EducationID = a.CF_Specialty.EducationID,
  143. LearningformID = a.CF_Specialty.LearningformID,
  144. CoursematerialID = a.EM_Coursematerial.CoursematerialID,
  145. CourseCode = a.EM_Coursematerial.CourseCode,
  146. CourseName = a.EM_Coursematerial.CourseName,
  147. WeeklyHours = a.EM_SpecialtyCourseTeachingSetting.WeeklyHours,
  148. ResultTypeID = a.ResultTypeID,
  149. CreateTime = a.CreateTime,
  150. CreateUserID = a.CreateUserID
  151. };
  152. return query;
  153. }
  154. }
  155. }