AgentMessageJob.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233
  1. using Quartz;
  2. using System.Linq;
  3. using System.Threading.Tasks;
  4. using wispro.sp.entity;
  5. namespace wispro.sp.api.Job
  6. {
  7. public class AgentMessageJob : IJob
  8. {
  9. public Task Execute(IJobExecutionContext context)
  10. {
  11. spDbContext spDb = new spDbContext();
  12. CalMonth calMonth = spDb.CalMonths.FirstOrDefault(s => s.Status == 0);
  13. var lstStaff = spDb.Staffs.Where<Staff>(s => s.ItemStaffs.Where<ItemStaff>(p => p.Item.CalMonthId == calMonth.Id).Count<ItemStaff>() > 0);
  14. foreach (var staff in lstStaff.ToList<Staff>())
  15. {
  16. string strSubject = $"{calMonth.Year}年{calMonth.Month}月绩效数据确认通知";
  17. string strBody = $"<div style=\"position:absolute;width:800;height:300;margin-top:50px;margin-left:200px;margin-right:200px;box-shadow:0px 0px 3px 3px #ccc \"><div style= \"margin-top: 20px; margin-left:20px;;font-size:14px; \">{staff.Name},您好!</div><div style= \"margin-top: 25px; margin-left:20px;font-size:14px; \"><div>{calMonth.Year}年{calMonth.Month}月绩效已开始计算,请<a href= \"http://1.116.113.26\">登录绩效系统</a>查看,如有任何问题,请使用绩效系统在<B>{utility.ConfigHelper.GetSectionValue("Lastest_feedback_date")}日</B>前反馈!</div><div style= \"margin-top: 100px;margin-right:15px; padding-bottom: 20px; font-size:14px;color:#888888;float:right; \">小美集团绩效管理系统</div></div>";
  18. string strTo = staff.Mail;
  19. if (!string.IsNullOrEmpty(strTo))
  20. {
  21. _ = QuartzUtil.AddMailJob(strSubject, strBody, staff.Name, strTo);
  22. }
  23. }
  24. return Task.CompletedTask;
  25. }
  26. }
  27. }