ScheduleServices.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. using System.Linq;
  5. using System.Text;
  6. using EMIS.DataLogic.SystemDAL;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel;
  9. namespace EMIS.CommonLogic.SystemServices
  10. {
  11. public class ScheduleServices : BaseServices, IScheduleServices
  12. {
  13. public ScheduleDAL ScheduleDAL { get; set; }
  14. public void UpdateLastRun(Guid schedulerID)
  15. {
  16. this.UnitOfWork.Update<Sys_Scheduling>((x => new Sys_Scheduling { lastrun = DateTime.Now }), (x => x.scid == schedulerID));
  17. }
  18. public void UpdateLastRunAndLoopNum(Guid schedulerID)
  19. {
  20. var scheduling = ScheduleDAL.SchedulingRepository.GetSingle(x => x.scid == schedulerID);
  21. scheduling.lastrun = DateTime.Now;
  22. scheduling.totalloopnumb++;
  23. this.UnitOfWork.Commit();
  24. }
  25. public void InsertLog(Sys_ScheduleLog log)
  26. {
  27. log.scheduleLogID = Guid.NewGuid();
  28. log.RecordStatus = (int)SYS_STATUS.USABLE;
  29. log.CreateTime = DateTime.Now;
  30. this.UnitOfWork.Add(log);
  31. this.UnitOfWork.Commit();
  32. }
  33. public List<Sys_Scheduling> GetJobList()
  34. {
  35. return this.ScheduleDAL.SchedulingRepository.GetList(x => x.RecordStatus == (int)SYS_STATUS.USABLE
  36. && x.Sys_ScheduleJob.RecordStatus == (int)SYS_STATUS.USABLE
  37. && x.status == "1").Include(x => x.Sys_ScheduleJob).ToList();
  38. }
  39. }
  40. }