1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.RetakeManage;
- using EMIS.Entities;
- using EMIS.ViewModel;
- using EMIS.ViewModel.RetakeManage;
- using EMIS.Utility;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.ViewModel.EducationManage;
- using EMIS.DataLogic.EducationManage;
- using EMIS.CommonLogic.EducationSchedule;
- namespace EMIS.CommonLogic.RetakeManage
- {
- public class RetakePlanServices : BaseServices, IRetakePlanServices
- {
- public RetakeConditionDAL RetakeConditionDAL { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- public void Generate()
- {
- var schoolyearID = ParameterServices.Value.GetParameterValue<Guid>(CF_ParameterType.RetakeSchoolyearID);
- var retakeStudentViewQueryable = this.RetakeConditionDAL.GetRetakeStudentView();
- var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList();
- foreach (var condition in retakeConditionList)
- {
- retakeStudentViewQueryable = (IQueryable<RetakeStudentListView>)ReflectorHelper.RunDALMethod(condition.MethodFullName, retakeStudentViewQueryable);
- }
- var retakeStudentViewList = retakeStudentViewQueryable.ToList();
- var retakePlanGroup = retakeStudentViewList
- .GroupBy(x => new { x.CoursematerialID, x.Abbreviation, x.CourseName, x.CourseTypeID, x.CourseTypeDesc, x.Credit });
-
- var planInsertList = new List<ER_RetakePlan>();
- var planStudentInsertList = new List<ER_RetakePlanStudent>();
- foreach (var retakePlan in retakePlanGroup)
- {
- var plan = new ER_RetakePlan
- {
- RetakePlanID = Guid.NewGuid(),
- CoursematerialID = retakePlan.Key.CoursematerialID,
- ClassName = (retakePlan.Key.Abbreviation ?? retakePlan.Key.CourseName) + "-重修(" + retakePlan.Key.CourseTypeDesc +
- string.Format("{0:#.00}", retakePlan.Key.Credit) + "学分)",
- SchoolyearID = schoolyearID,
- CourseTypeID = retakePlan.Key.CourseTypeID,
- Credit = retakePlan.Key.Credit
- };
- this.SetNewStatus(plan);
- foreach (var retakePlanStudent in retakePlan.Select(w => w).ToList())
- {
- var planStudent = new ER_RetakePlanStudent
- {
- RetakePlanStudentID = Guid.NewGuid(),
- RetakePlanID = plan.RetakePlanID,
- UserID = retakePlanStudent.UserID.Value,
- SchoolyearNumID = retakePlanStudent.SchoolyearNumID,
- StarttermID = retakePlanStudent.StarttermID
- };
- this.SetNewStatus(planStudent);
- planStudentInsertList.Add(planStudent);
- }
- planInsertList.Add(plan);
- }
- UnitOfWork.BulkInsert(planInsertList);
- UnitOfWork.BulkInsert(planStudentInsertList);
- }
- }
- }
|