using CommonUtil; using CommonUtil.Web; using Operater.DAL; using Quartz; using System; using System.Collections.Generic; using System.Data; using System.Text; using System.Threading.Tasks; namespace ScheduledTasks.Handle { public class SmsWarningHandle : IJob { public async Task Execute(IJobExecutionContext context) { await Synchronize(context); } public static async Task Synchronize(IJobExecutionContext context) { try { //查询超过3分钟未审核的 string searchSql = $"select count(1) as count from sms_send where sendstatus=0 and isshowsend=0 and TIMESTAMPDIFF(MINUTE, now(),createtime)>3"; DataTable shDt = new YzOrderinfoDAL().SearchBySqlDataTable("Sms", searchSql); int shCount = int.Parse(shDt.Rows[0]["count"].ToString()); if (shCount > 0) {//发预警 string warStr = "您有待审核的任务\n>类型:待审核\n>数量:" + shCount + "\n>查看:[点击处理](https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx7a9a40880081340d&redirect_uri=https%3A%2F%2Fsms.ushopvip.com%2Fpages%2Fad_page%2Ftrans&response_type=code&scope=snsapi_base&state=gzh#wechat_redirect)"; SendQwGroup.SendMessage(warStr); } //查询长时间未发送成功 searchSql = $"select count(1) as count from sms_send where isshowsend=0 and wantsendtime>now() and sendstatus=0 and TIMESTAMPDIFF(MINUTE, now(),wantsendtime)>5"; DataTable wfDt = new YzOrderinfoDAL().SearchBySqlDataTable("Sms", searchSql); int wfCount = int.Parse(wfDt.Rows[0]["count"].ToString()); if (wfCount > 0) {//发预警 string warStr = "长时间未发送完成任务\n>类型:任务异常\n>数量:" + wfCount; SendQwGroup.SendMessage(warStr); } } catch (Exception e) { LogUtil.Info(e.ToString(), "短信预警error"); Console.WriteLine($"短信预警error", e.ToString()); } } } }