RetakePlanServices.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using Bowin.Common.Linq.Entity;
  7. using Bowin.Common.Linq;
  8. using EMIS.DataLogic.RetakeManage;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.RetakeManage;
  12. using EMIS.Utility;
  13. using EMIS.CommonLogic.SystemServices;
  14. using EMIS.ViewModel.EducationManage;
  15. using EMIS.DataLogic.EducationManage;
  16. using EMIS.CommonLogic.EducationSchedule;
  17. namespace EMIS.CommonLogic.RetakeManage
  18. {
  19. public class RetakePlanServices : BaseServices, IRetakePlanServices
  20. {
  21. public RetakeConditionDAL RetakeConditionDAL { get; set; }
  22. public Lazy<IParameterServices> ParameterServices { get; set; }
  23. public void Generate()
  24. {
  25. var schoolyearID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
  26. var retakeStudentViewQueryable = this.RetakeConditionDAL.GetRetakeStudentView();
  27. var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
  28. foreach (var condition in retakeConditionList)
  29. {
  30. retakeStudentViewQueryable = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, retakeStudentViewQueryable);
  31. }
  32. var retakeStudentViewList = retakeStudentViewQueryable.ToList();
  33. var retakePlanGroup = retakeStudentViewList
  34. .GroupBy(x => new { x.CoursematerialID, x.Abbreviation, x.CourseName, x.CourseTypeID, x.CourseTypeDesc, x.Credit });
  35. var planInsertList = new List<ER_RetakePlan>();
  36. var planStudentInsertList = new List<ER_RetakePlanStudent>();
  37. foreach (var retakePlan in retakePlanGroup)
  38. {
  39. var plan = new ER_RetakePlan
  40. {
  41. RetakePlanID = Guid.NewGuid(),
  42. CoursematerialID = retakePlan.Key.CoursematerialID,
  43. ClassName = (retakePlan.Key.Abbreviation ?? retakePlan.Key.CourseName) + "-重修(" + retakePlan.Key.CourseTypeDesc +
  44. string.Format("{0:#.00}", retakePlan.Key.Credit) + "学分)",
  45. SchoolyearID = schoolyearID,
  46. CourseTypeID = retakePlan.Key.CourseTypeID,
  47. Credit = retakePlan.Key.Credit
  48. };
  49. this.SetNewStatus(plan);
  50. foreach (var retakePlanStudent in retakePlan.Select(w => w).ToList())
  51. {
  52. var planStudent = new ER_RetakePlanStudent
  53. {
  54. RetakePlanStudentID = Guid.NewGuid(),
  55. RetakePlanID = plan.RetakePlanID,
  56. UserID = retakePlanStudent.UserID.Value,
  57. SchoolyearNumID = retakePlanStudent.SchoolyearNumID,
  58. StarttermID = retakePlanStudent.StarttermID
  59. };
  60. this.SetNewStatus(planStudent);
  61. planStudentInsertList.Add(planStudent);
  62. }
  63. planInsertList.Add(plan);
  64. }
  65. UnitOfWork.BulkInsert(planInsertList);
  66. UnitOfWork.BulkInsert(planStudentInsertList);
  67. }
  68. }
  69. }