123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Students;
- using EMIS.DataLogic.SystemSetting;
- using EMIS.ViewModel;
- using EMIS.DataLogic.Common.CalendarManage;
- using EMIS.Entities;
- using System.Transactions;
- using EMIS.DataLogic.Common.Students.HighBaseTable;
- namespace EMIS.CommonLogic.Students.HighBaseTable
- {
- public class RecruitStatusServices : BaseServices, IRecruitStatusServices
- {
- public RecruitStatusDAL RecruitStatusDAL { get; set; }
- public DictionaryItemDAL DictionaryItemDAL { get; set; }
- public SchoolYearDAL SchoolYearDAL { get; set; }
- public void Update(int SchoolYear)
- {
- try
- {
- var schoolYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
- var territorial = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(CF_Province).Name).Select(x => x.Value).ToList();
- var educationType = DictionaryItemDAL.GetDictionaryItemViewQueryable(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_EducationType).Name).Select(x => x.Value).ToList();
- var queryInschoolCount = RecruitStatusDAL.GetRecruitStatusInschoolCount(SchoolYear).ToList();
- var queryRecruitCount = RecruitStatusDAL.GetRecruitStatusRecruitCount(SchoolYear).ToList();
- List<HB_RecruitStatus> recruitStatusList = new List<HB_RecruitStatus>();
- foreach (var i in territorial)
- {
- foreach (var t in educationType)
- {
- HB_RecruitStatus recruitStatus = new HB_RecruitStatus();
- recruitStatus.RecruitStatusID = Guid.NewGuid();
- recruitStatus.Year = SchoolYear;
- recruitStatus.Territorial = i;
- recruitStatus.EducationTypeID = t;
- recruitStatus.RecruitCount = queryRecruitCount.Where(x => x.Territorial == i && x.EducationTypeID == t).Select(x => x.RecruitCount).FirstOrDefault();
- recruitStatus.InschoolCount = queryInschoolCount.Where(x => x.Territorial == i && x.EducationTypeID == t).Select(x => x.InschoolCount).FirstOrDefault();
- SetNewStatus(recruitStatus);
- recruitStatusList.Add(recruitStatus);
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.Delete<HB_RecruitStatus>(x => x.Year == SchoolYear);
- UnitOfWork.BulkInsert(recruitStatusList);//统一写入
- ts.Complete();
- }
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- public List<string> SchoolYearDropDownList()
- {
- var item = RecruitStatusDAL.RecruitStatusRepository.Entities.Select(x => x.Year.ToString()).Distinct().ToList();
- return item;
- }
- }
- }
|