tijian_tieying/web/dccdc/jobs/TestNoticsJob.cs

64 lines
3.0 KiB
C#
Raw Normal View History

2025-02-20 12:14:39 +08:00
using dccdc.BLL;
using dccdc.Models;
using Quartz;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using System.Web;
namespace dccdc.jobs
{
public class TestNoticsJob : IJob
{
public Task Execute(IJobExecutionContext context)
{
try
{
//log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("体检提醒作业开始执行:" + DateTime.Now);
var bll = new BLL.InfectionTestBll();
List<Models.InfectionTestModel> list = bll.GetNoticsList();
//log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("体检提醒准备循环:" + DateTime.Now);
foreach (Models.InfectionTestModel test in list)
{
//log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info("体检提醒实体:" + test.id);
InfectionOpenUserInfoModel openuserinfo = new InfectionOpenUserInfoBll().findById(test.info_id);
InfectionOpenUserModel openuser = new InfectionOpenUserBll().GetDataByID(openuserinfo.user_id.ToString());
var data = new
{
touser = openuser.openid,
template_id = "JPHeSF11coRuhQNIaFb6WvMWHF5xkChup9aYYDLcchE",
url = "http://oa.dcqcdc.com/dccdc/Infection/Package",
data = new
{
first = new { value = "明日有您的体检预约", color = "#173177" },
keyword1 = new { value = openuserinfo.name, color = "#173177" },
keyword2 = new { value = "健康大礼包", color = "#173177" },
keyword3 = new { value = test.create_time, color = "#173177" },
keyword4 = new { value = test.order_date, color = "#173177" },
remark = new { value = "请您于" + test.order_date + "上午到德城区疾控中心体检请务必空腹体检。如您有疑问或需要修改预约日程请在本公众号留言或拨打电话2267105、2267111联系我们。", color = "#173177" },
}
};
WebClient wc = new WebClient();
wc.UploadData("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + Common.Global.getAccessTokenInfection.access_token, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(data)));
}
}
catch (Exception ex)
{
log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType).Info(ex.Message + ex.StackTrace);
}
return new Task(() =>
{
});
}
}
}