TeacherScheduleSettingServices.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.Entities;
  6. using System.Linq.Expressions;
  7. using Bowin.Common.Linq.Entity;
  8. using Bowin.Common.Linq;
  9. using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
  10. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  11. using EMIS.ViewModel.CalendarManage;
  12. using EMIS.CommonLogic.CalendarManage;
  13. namespace EMIS.CommonLogic.SchedulingManage.SchedulingSettings
  14. {
  15. public class TeacherScheduleSettingServices : BaseServices, ITeacherScheduleSettingServices
  16. {
  17. public TeacherScheduleSettingDAL teacherScheduleSettingDAL { get; set; }
  18. public IArrangementServices arrangementServices { get; set; }
  19. /// <summary>
  20. /// 查询
  21. /// </summary>
  22. /// <param name="userID"></param>
  23. /// <param name="teacherTypeID"></param>
  24. /// <param name="incumbencyStateID"></param>
  25. /// <param name="titleID"></param>
  26. /// <param name="collegeID"></param>
  27. /// <param name="pageIndex"></param>
  28. /// <param name="pageSize"></param>
  29. /// <returns></returns>
  30. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.SchedulingManage.SchedulingSettings.TeacherScheduleSettingView> GetTeacherScheduleSettingViewGrid(Guid? userID, int? teacherTypeID, int? incumbencyStateID, int? titleID, Guid? collegeID, int pageIndex, int pageSize)
  31. {
  32. Expression<Func<CF_Staff, bool>> exp = (x => true);
  33. if (userID.HasValue)
  34. exp = exp.And(x => x.UserID == userID);
  35. if (teacherTypeID.HasValue)
  36. exp = exp.And(x => x.TeacherTypeID == teacherTypeID);
  37. if (incumbencyStateID.HasValue)
  38. exp = exp.And(x => x.IncumbencyState == incumbencyStateID);
  39. if (titleID.HasValue)
  40. exp = exp.And(x => x.TitleID == titleID);
  41. if (collegeID.HasValue)
  42. exp = exp.And(x => x.CollegeID == collegeID);
  43. var query = teacherScheduleSettingDAL.GetTeacherScheduleSettingViewQueryable(exp);
  44. return query.OrderByDescending(x => x.CreateTime).ToGridResultSet<TeacherScheduleSettingView>(pageIndex, pageSize);
  45. }
  46. /// <summary>
  47. /// 查询
  48. /// </summary>
  49. /// <param name="userID"></param>
  50. /// <returns></returns>
  51. public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.CalendarManage.ArrangementView> GetArrangementViewGrid(Guid? userID)
  52. {
  53. var resultSet = teacherScheduleSettingDAL.GetArrangementViewQueryable(userID).OrderBy(x => x.StartTimes).ToGridResultSet<ArrangementView>();
  54. if (resultSet.total > 0)
  55. {
  56. return resultSet;
  57. }
  58. return arrangementServices.GetArrangementViewGrid();
  59. }
  60. /// <summary>
  61. /// 新增
  62. /// </summary>
  63. /// <param name="listArrangement"></param>
  64. public void TeacherScheduleSettingAdd(List<ArrangementView> listArrangement, Guid? userID)
  65. {
  66. try
  67. {
  68. UnitOfWork.Delete<ES_TeacherScheduleSetting>(x => x.UserID == userID);
  69. foreach (var arrangementView in listArrangement)
  70. {
  71. bool? IsOnWork = false;
  72. for (int i = 0; i < 7; i++)
  73. {
  74. if (i == (int)DayOfWeek.Monday)
  75. IsOnWork = arrangementView.MondayIsOnWork;
  76. if (i == (int)DayOfWeek.Tuesday)
  77. IsOnWork = arrangementView.TuesdayIsOnWork;
  78. if (i == (int)DayOfWeek.Wednesday)
  79. IsOnWork = arrangementView.WednesdayIsOnWork;
  80. if (i == (int)DayOfWeek.Thursday)
  81. IsOnWork = arrangementView.ThursdayIsOnWork;
  82. if (i == (int)DayOfWeek.Friday)
  83. IsOnWork = arrangementView.FridayIsOnWork;
  84. if (i == (int)DayOfWeek.Saturday)
  85. IsOnWork = arrangementView.SaturdayIsOnWork;
  86. if (i == (int)DayOfWeek.Sunday)
  87. IsOnWork = arrangementView.SundayIsOnWork;
  88. ES_TeacherScheduleSetting teacherScheduleSettin = new ES_TeacherScheduleSetting();
  89. teacherScheduleSettin.TeacherScheduleSettingID = Guid.NewGuid();
  90. teacherScheduleSettin.UserID = userID;
  91. teacherScheduleSettin.CoursesTimeID = arrangementView.CoursesTimeID;
  92. teacherScheduleSettin.Weekday = i;
  93. teacherScheduleSettin.IsOnWork = IsOnWork;
  94. SetNewStatus(teacherScheduleSettin);
  95. UnitOfWork.Add(teacherScheduleSettin);
  96. }
  97. }
  98. UnitOfWork.Commit();
  99. }
  100. catch (Exception)
  101. {
  102. throw;
  103. }
  104. }
  105. /// <summary>
  106. /// 删除
  107. /// </summary>
  108. /// <param name="userIDs"></param>
  109. public void TeacherScheduleSettingDelete(List<Guid?> userIDs)
  110. {
  111. try
  112. {
  113. UnitOfWork.Delete<ES_TeacherScheduleSetting>(x => userIDs.Contains(x.UserID));
  114. }
  115. catch (Exception)
  116. {
  117. throw;
  118. }
  119. }
  120. }
  121. }