123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Linq.Expressions;
- using System.Data.Entity;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.SelectCourse;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.DataLogic.SelectCourse;
- using EMIS.DataLogic.Repositories;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.Utility.FormValidate;
- using EMIS.ViewModel.EnrollManage.SpecialtyManage;
- namespace EMIS.CommonLogic.SelectCourse
- {
- public class FreeSelectionCourseServices : BaseWorkflowServices<EM_FreeSelectionCouseApply>, IFreeSelectionCourseServices
- {
- public FreeSelectionCoursePlanDAL FreeSelectionCoursePlanDAL { get; set; }
- public FreeSelectionCourseDAL FreeSelectionCourseDAL { get; set; }
- public FreeSelectionCouseTeachingModeRepository FreeSelectionCouseTeachingModeRepository { get; set; }
- public IGridResultSet<FreeSelectionCourseView> GetFreeSelectionCourseViewGrid(ConfiguretView configuretView,
- Guid? coursematerialID,Guid? departmentID, int? schoolcodeID, int? starttermID, int? isEnable, int pageIndex, int pageSize)
- {
- List<FreeSelectionCourseView> list = new List<FreeSelectionCourseView>();
- var query = FreeSelectionCourseDAL.GetFreeSelectionCourseViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var queryTeachingModeType = FreeSelectionCourseDAL.GetTeachingModeTypeViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- queryTeachingModeType = queryTeachingModeType.Where(x => x.CoursematerialID == coursematerialID);
- }
- if (departmentID.HasValue)
- {
- query = query.Where(x => x.DepartmentID == departmentID);
- queryTeachingModeType = queryTeachingModeType.Where(x => x.DepartmentID == departmentID);
- }
- //if (schoolcodeID.HasValue)
- //{
- // query = query.Where(x => x.SchoolcodeID == schoolcodeID);
- // queryTeachingModeType = queryTeachingModeType.Where(x => x.SchoolcodeID == schoolcodeID);
- //}
- //if (starttermID.HasValue)
- //{
- // query = query.Where(x => x.StarttermID == starttermID);
- // queryTeachingModeType = queryTeachingModeType.Where(x => x.StarttermID == starttermID);
- //}
- if (isEnable.HasValue)
- {
- query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
- queryTeachingModeType = queryTeachingModeType.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- var result=this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.CreateTime).ToGridResultSet<FreeSelectionCourseView>(pageIndex, pageSize);
- result.rows.ForEach(x => x.TeachingModeName = string.Join(",", queryTeachingModeType.Where(w => w.FreeSelectionCouseID == x.FreeSelectionCouseID).Select(w => w.TeachingModeName)));
- return result;
- }
- public List<FreeSelectionCourseView> GetFreeSelectionCourseViewList(ConfiguretView configuretView,
- Guid? coursematerialID,Guid? departmentID, int? schoolcodeID, int? starttermID, int? isEnable)
- {
- List<FreeSelectionCourseView> list = new List<FreeSelectionCourseView>();
- var query = FreeSelectionCourseDAL.GetFreeSelectionCourseViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- var queryTeachingModeType = FreeSelectionCourseDAL.GetTeachingModeTypeViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (coursematerialID.HasValue)
- {
- query = query.Where(x => x.CoursematerialID == coursematerialID);
- queryTeachingModeType = queryTeachingModeType.Where(x => x.CoursematerialID == coursematerialID);
- }
- if (departmentID.HasValue)
- {
- query = query.Where(x => x.DepartmentID == departmentID);
- queryTeachingModeType = queryTeachingModeType.Where(x => x.DepartmentID == departmentID);
- }
- if (schoolcodeID.HasValue)
- {
- query = query.Where(x => x.SchoolcodeID == schoolcodeID);
- queryTeachingModeType = queryTeachingModeType.Where(x => x.SchoolcodeID == schoolcodeID);
- }
- if (starttermID.HasValue)
- {
- query = query.Where(x => x.StarttermID == starttermID);
- queryTeachingModeType = queryTeachingModeType.Where(x => x.StarttermID == starttermID);
- }
- if (isEnable.HasValue)
- {
- query = query.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
- queryTeachingModeType = queryTeachingModeType.Where(x => x.IsEnable == (isEnable == 1 ? true : false));
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- list = this.GetQueryByDataRangeByCollege(query).DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).ToList();
- else
- list = this.GetQueryByDataRangeByCollege(query).ToList();
- list.ForEach(x => x.TeachingModeName = string.Join(",", queryTeachingModeType.Where(w => w.FreeSelectionCouseID == x.FreeSelectionCouseID).Select(w => w.TeachingModeName)));
- return list.OrderBy(x => x.CreateTime).ToList();
- }
- public EM_FreeSelectionCouse GetFreeSelectionCourse(Guid? freeSelectionCourseID)
- {
- System.Linq.Expressions.Expression<Func<EM_FreeSelectionCouse, bool>> expression =
- (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.FreeSelectionCouseID == freeSelectionCourseID);
- return FreeSelectionCourseDAL.FreeSelectionCouseRepository.GetSingle(expression, (x => x.CF_Department), (x => x.EM_Coursematerial));
- }
- public FreeSelectionCourseView GetFreeSelectionCourseView(Guid? freeSelectionCourseID)
- {
- var query = FreeSelectionCourseDAL.GetFreeSelectionCourseViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- return query.Where(x => x.FreeSelectionCouseID == freeSelectionCourseID).FirstOrDefault();
- }
- public EM_FreeSelectionCouseTeachingSetting GetFreeSelectionCourseTeachingSetting(Guid? freeSelectionCourseID)
- {
- //查询条件
- System.Linq.Expressions.Expression<Func<EM_FreeSelectionCouseTeachingSetting, bool>> expression = (x => true);
- expression = (x => x.FreeSelectionCouseID == freeSelectionCourseID);
- return FreeSelectionCourseDAL.FreeSelectionCouseTeachingSettingRepository.GetSingle(expression);
- }
- private string GetFreeSelectionCourseNo(EM_FreeSelectionCouse freeSelectionCourse)
- {
- var course = this.FreeSelectionCourseDAL.CoursematerialDAL.Value.CoursematerialRepository.GetSingle(x => x.CoursematerialID == freeSelectionCourse.CoursematerialID);
- if (course == null)
- {
- throw new Exception("找不到所选的课程资料。");
- }
- string code = course.CourseCode + "-" + (freeSelectionCourse.SchoolyearNumID ?? 0).ToString() + "-" + (freeSelectionCourse.SchoolcodeID ?? 0).ToString();
- return code;
- }
- public bool FreeSelectionCourseAdd(FreeSelectionCourseView freeSelectionCourseView)
- {
- EM_FreeSelectionCouse freeSelectionCourse;
- EM_FreeSelectionCouseTeachingSetting freeSelectionCourseTeachingSetting;
- try
- {
- if (this.FreeSelectionCourseDAL.FreeSelectionCouseRepository .GetList(
- x => x.CoursematerialID == freeSelectionCourseView.CoursematerialID
- && x.DepartmentID == freeSelectionCourseView.DepartmentID
- && x.CourseTypeID == freeSelectionCourseView.CourseTypeID).Count() > 0)
- {
- throw new Exception("该教研室对应的课程已经存在,请重新输入。");
- }
- freeSelectionCourse = new EM_FreeSelectionCouse();
- freeSelectionCourse.FreeSelectionCouseID = Guid.NewGuid();
- freeSelectionCourse.DepartmentID = freeSelectionCourseView.DepartmentID;
- freeSelectionCourse.CoursematerialID = freeSelectionCourseView.CoursematerialID;
- freeSelectionCourse.CourseStructureID = freeSelectionCourseView.CourseStructureID;
- freeSelectionCourse.CourseCategoryID = freeSelectionCourseView.CourseCategoryID;
- freeSelectionCourse.CourseTypeID = freeSelectionCourseView.CourseTypeID;
- freeSelectionCourse.CourseQualityID = freeSelectionCourseView.CourseQualityID;
- freeSelectionCourse.PracticeTypeID = freeSelectionCourseView.PracticeTypeID;
- freeSelectionCourse.ExaminationModeID = freeSelectionCourseView.ExaminationModeID;
- freeSelectionCourse.TeachinglanguageID = freeSelectionCourseView.TeachinglanguageID;
- freeSelectionCourse.SchoolyearNumID = freeSelectionCourseView.SchoolyearNumID;
- freeSelectionCourse.SchoolcodeID = freeSelectionCourseView.SchoolcodeID;
- //freeSelectionCourse.StarttermID = freeSelectionCourseView.StarttermID;
- freeSelectionCourse.IsEnable = freeSelectionCourseView.IsEnable;
- freeSelectionCourse.ResultTypeID = freeSelectionCourseView.ResultTypeID;
- freeSelectionCourse.Remark = freeSelectionCourseView.Remark;
- //最后计算选课编号
- //freeSelectionCourse.No = this.GetFreeSelectionCourseNo(freeSelectionCourse);
- this.SetNewStatus(freeSelectionCourse);
- freeSelectionCourseTeachingSetting = new EM_FreeSelectionCouseTeachingSetting();
- freeSelectionCourseTeachingSetting.FreeSelectionCouseID = freeSelectionCourse.FreeSelectionCouseID;
- freeSelectionCourseTeachingSetting.Credit = freeSelectionCourseView.Credit;
- freeSelectionCourseTeachingSetting.TheoryCourse = freeSelectionCourseView.TheoryCourse;
- freeSelectionCourseTeachingSetting.Practicehours = freeSelectionCourseView.Practicehours;
- freeSelectionCourseTeachingSetting.Trialhours = freeSelectionCourseView.Trialhours;
- freeSelectionCourseTeachingSetting.WeeklyNum = freeSelectionCourseView.WeeklyNum;
- freeSelectionCourseTeachingSetting.TheoryWeeklyNum = freeSelectionCourseView.TheoryWeeklyNum;
- freeSelectionCourseTeachingSetting.PracticeWeeklyNum = freeSelectionCourseView.PracticeWeeklyNum;
- freeSelectionCourseTeachingSetting.TrialWeeklyNum = freeSelectionCourseView.TrialWeeklyNum;
- freeSelectionCourseTeachingSetting.StartWeeklyNum = freeSelectionCourseView.StartWeeklyNum;
- freeSelectionCourseTeachingSetting.EndWeeklyNum = freeSelectionCourseView.EndWeeklyNum;
- freeSelectionCourseTeachingSetting.WeeklyHours = freeSelectionCourseView.WeeklyHours;
- if (freeSelectionCourseView.TeachingModeID != null)
- {
- TeachingModeTypeAdd(freeSelectionCourseView.TeachingModeID, freeSelectionCourse.FreeSelectionCouseID);
- }
- UnitOfWork.Add(freeSelectionCourse);
- UnitOfWork.Add(freeSelectionCourseTeachingSetting);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public bool FreeSelectionCourseUpdate(FreeSelectionCourseView freeSelectionCourseView)
- {
- EM_FreeSelectionCouse freeSelectionCourse;
- EM_FreeSelectionCouseTeachingSetting freeSelectionCourseTeachingSetting;
- try
- {
- if (this.FreeSelectionCourseDAL.FreeSelectionCouseRepository.GetList(
- x => x.CoursematerialID == freeSelectionCourseView.CoursematerialID
- && x.DepartmentID == freeSelectionCourseView.DepartmentID
- && x.CourseTypeID == freeSelectionCourseView.CourseTypeID
- && x.FreeSelectionCouseID != freeSelectionCourseView.FreeSelectionCouseID).Count() > 0)
- {
- throw new Exception("该课程已经存在,请重新输入。");
- }
- freeSelectionCourse = GetFreeSelectionCourse(freeSelectionCourseView.FreeSelectionCouseID);
- freeSelectionCourseTeachingSetting = GetFreeSelectionCourseTeachingSetting(freeSelectionCourseView.FreeSelectionCouseID);
- freeSelectionCourse.FreeSelectionCouseID = freeSelectionCourseView.FreeSelectionCouseID;
- freeSelectionCourse.DepartmentID = freeSelectionCourseView.DepartmentID;
- freeSelectionCourse.CoursematerialID = freeSelectionCourseView.CoursematerialID;
- freeSelectionCourse.CourseStructureID = freeSelectionCourseView.CourseStructureID;
- freeSelectionCourse.CourseCategoryID = freeSelectionCourseView.CourseCategoryID;
- freeSelectionCourse.CourseTypeID = freeSelectionCourseView.CourseTypeID;
- freeSelectionCourse.CourseQualityID = freeSelectionCourseView.CourseQualityID;
- freeSelectionCourse.PracticeTypeID = freeSelectionCourseView.PracticeTypeID;
- freeSelectionCourse.ExaminationModeID = freeSelectionCourseView.ExaminationModeID;
- freeSelectionCourse.TeachinglanguageID = freeSelectionCourseView.TeachinglanguageID;
- freeSelectionCourse.SchoolyearNumID = freeSelectionCourseView.SchoolyearNumID;
- freeSelectionCourse.SchoolcodeID = freeSelectionCourseView.SchoolcodeID;
- //freeSelectionCourse.StarttermID = freeSelectionCourseView.StarttermID;
- freeSelectionCourse.IsEnable = freeSelectionCourseView.IsEnable;
- freeSelectionCourse.ResultTypeID = freeSelectionCourseView.ResultTypeID;
- freeSelectionCourse.Remark = freeSelectionCourseView.Remark;
- this.SetModifyStatus(freeSelectionCourse);
- freeSelectionCourseTeachingSetting.Credit = freeSelectionCourseView.Credit;
- freeSelectionCourseTeachingSetting.TheoryCourse = freeSelectionCourseView.TheoryCourse;
- freeSelectionCourseTeachingSetting.Practicehours = freeSelectionCourseView.Practicehours;
- freeSelectionCourseTeachingSetting.Trialhours = freeSelectionCourseView.Trialhours;
- freeSelectionCourseTeachingSetting.WeeklyNum = freeSelectionCourseView.WeeklyNum;
- freeSelectionCourseTeachingSetting.TheoryWeeklyNum = freeSelectionCourseView.TheoryWeeklyNum;
- freeSelectionCourseTeachingSetting.PracticeWeeklyNum = freeSelectionCourseView.PracticeWeeklyNum;
- freeSelectionCourseTeachingSetting.TrialWeeklyNum = freeSelectionCourseView.TrialWeeklyNum;
- freeSelectionCourseTeachingSetting.StartWeeklyNum = freeSelectionCourseView.StartWeeklyNum;
- freeSelectionCourseTeachingSetting.EndWeeklyNum = freeSelectionCourseView.EndWeeklyNum;
- freeSelectionCourseTeachingSetting.WeeklyHours = freeSelectionCourseView.WeeklyHours;
- if (freeSelectionCourseView.TeachingModeID != null)
- {
- TeachingModeTypeAdd(freeSelectionCourseView.TeachingModeID, freeSelectionCourse.FreeSelectionCouseID);
- }
- UnitOfWork.Update(freeSelectionCourse);
- UnitOfWork.Update(freeSelectionCourseTeachingSetting);
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- private bool TeachingModeTypeAdd(List<int> list, Guid? freeSelectionCourseID)
- {
- try
- {
- if (list.Count > 0)
- {
- UnitOfWork.Delete<EM_FreeSelectionCouseTeachingMode>(x => x.FreeSelectionCouseID == freeSelectionCourseID);
- foreach (var i in list)
- {
- EM_FreeSelectionCouseTeachingMode teachingModeType = new EM_FreeSelectionCouseTeachingMode();
- teachingModeType.FreeSelectionCouseTeachingModeID = Guid.NewGuid();
- teachingModeType.FreeSelectionCouseID = freeSelectionCourseID;
- teachingModeType.TeachingModeID = i;
- this.SetNewStatus(teachingModeType);
- UnitOfWork.Add(teachingModeType);
- }
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- public bool FreeSelectionCourseDelete(List<Guid?> freeSelectionCourseIDs)
- {
- try
- {
- if (freeSelectionCourseIDs.Count > 0)
- {
- UnitOfWork.Delete<EM_FreeSelectionCouseTeachingSetting>(x => freeSelectionCourseIDs.Contains(x.FreeSelectionCouseID));
- UnitOfWork.Delete<EM_FreeSelectionCouseTeachingMode>(x => freeSelectionCourseIDs.Contains(x.FreeSelectionCouseID));
- UnitOfWork.Delete<EM_FreeSelectionCouse>(x => freeSelectionCourseIDs.Contains(x.FreeSelectionCouseID));
- UnitOfWork.Commit();
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// 根据任选课程获取授课方式
- /// </summary>
- /// <param name="freeSelectionCourseID"></param>
- /// <returns></returns>
- public List<int> GetTeachingModeType(Guid? freeSelectionCourseID)
- {
- List<int> list = new List<int>();
- return FreeSelectionCourseDAL.GetTeachingModeType(x => x.FreeSelectionCouseID == freeSelectionCourseID)
- .Select(x => x.Value ?? 0).ToList();
- }
- public EM_FreeSelectionCouse GetFreeSelectionCourseCourse(Guid? coursematerialID)
- {
- //查询条件
- System.Linq.Expressions.Expression<Func<EM_FreeSelectionCouse, bool>> expression = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expression = (x => x.CoursematerialID == coursematerialID);
- return FreeSelectionCourseDAL.FreeSelectionCouseRepository.GetSingle(expression, (x => x.CF_Department), (x => x.EM_Coursematerial));
- }
- public void SaveFreeSelectionCourseTeachers(Guid freeSelectionCourseApplyID, IList<FreeSelectionCourseApplyTeacherListView> teacherList)
- {
- var freeSelectionCourseApply = this.FreeSelectionCoursePlanDAL.FreeSelectionCouseApplyRepository
- .GetSingle(x => x.FreeSelectionCouseApplyID == freeSelectionCourseApplyID, (x => x.EM_FreeSelectionCouseApplyTeacher));
- freeSelectionCourseApply.EM_FreeSelectionCouseApplyTeacher.ToList().ForEach(x => this.UnitOfWork.Remove(x));
- //teacherList.ToList().ForEach(x =>
- //{
- // var freeSelectionCourseApplyStaffEntity = new EM_FreeSelectionCouseApplyStaff
- // {
- // FreeSelectionCouseApplyStaffID = Guid.NewGuid(),
- // FreeSelectionCouseApplyID = freeSelectionCourseApplyID,
- // UserID = x.UserID,
- // TeachingMethod = x.TeachingMethod
- // };
- // this.SetNewStatus(freeSelectionCourseApplyStaffEntity);
- // this.UnitOfWork.Add(freeSelectionCourseApplyStaffEntity);
- //});
- this.UnitOfWork.Commit();
- }
- }
- }
|