AutoCreateSchoolYearJob.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Autofac;
  6. using Bowin.Common.Log;
  7. using EMIS.CommonLogic.CalendarManage;
  8. namespace EMIS.Services.ScheduleJob
  9. {
  10. public class AutoCreateSchoolYearJob : EAPServiceJob
  11. {
  12. #region 运行JOB
  13. /// <summary>
  14. /// 重写 MyJob 方法
  15. /// </summary>
  16. /// <returns></returns>
  17. protected override bool MyJob()
  18. {
  19. var result = true;
  20. try
  21. {
  22. if (DateTime.Today.Day != 1 && DateTime.Today.Month != 9)
  23. {
  24. return true;
  25. }
  26. LogHelper.WriteLog(LogType.ServiceLog, "----开始自动添加需要预留的学期学年-----");
  27. using (var scop = Program.AutofacContainer.BeginLifetimeScope())
  28. {
  29. ISchoolYearServices SchoolYearServices = scop.Resolve<ISchoolYearServices>();
  30. SchoolYearServices.AutoCreateSchoolyearAndYears();
  31. }
  32. LogHelper.WriteLog(LogType.ServiceLog, "----结束自动添加需要预留的学期学年-----");
  33. }
  34. catch (System.Exception err)
  35. {
  36. LogHelper.WriteLog(LogType.ServiceLog, "----自动添加需要预留的学期学年处理异常-----");
  37. LogHelper.WriteLog(LogType.ServiceLog, err.Message);
  38. result = false;
  39. }
  40. return result;
  41. }
  42. #endregion
  43. }
  44. }