SendWeComMsgJob.cs
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Hh.Mes.POJO.Response;
using Hh.Mes.Service;
using Hh.Mes.Service.QuartzJobService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
namespace Quartz.Job.Jobs
{
[PersistJobDataAfterExecution]
[DisallowConcurrentExecution]
public class SendWeComMsgJob : JobBase
{
private readonly BulletinBoardService bulletinBoardService;
private readonly FaultReportService faultReportService;
public SendWeComMsgJob(BulletinBoardService bulletinBoardService, FaultReportService faultReportService)
{
this.bulletinBoardService = bulletinBoardService;
this.faultReportService = faultReportService;
}
public override void ExecuteJob(IJobExecutionContext context)
{
this.bulletinBoardService.sysUserApiAccount = "System";//HttpContext.Items["Account"] as string;
ResponseNew result = bulletinBoardService.GetFaultReportSevenDayAndMonth();
if (result.status)
{
var data = result.data;
var fileName = "项目故障报告" + DateTime.Now.ToString("yyyyMMddHHmmssfff");
Task.Run(async () =>
{
await faultReportService.Export(data, fileName);//导出excel到本地
await faultReportService.SendToWeChatWorkAsync();//发送附件短信至企微
}).Wait();
}
}
}
}