private static void exeNotify(string netType, string mongodbConnStr, string mongodbDatabase, string dailyTime, ref bool isDailySend, ref string blockNotInHour, Aliyun_SMS aliSMS, string phoneNumbers) { blockMonitor bm = new blockMonitor(mongodbConnStr, mongodbDatabase); var isNewBlockInByDB = bm.isNewBlockInByDB(); string lastBlockIndex = (string)isNewBlockInByDB["lastBlockIndex"]; string lastBlockTime = (string)isNewBlockInByDB["lastBlockTime"]; if ((bool)isNewBlockInByDB["isNewBlockIn"]) { if (DateTime.Now.ToString("HHmm") == dailyTime) { if (!isDailySend) { var sendSMSResulet = aliSMS.SendSMS_blockNotIn(phoneNumbers, netType, "0分钟", lastBlockIndex, lastBlockTime); Console.WriteLine("发送定时正常信息状态:" + sendSMSResulet + "|" + DateTime.Now.ToString("yyyy.MM.dd HH:mm")); isDailySend = true; } } else { isDailySend = false; } } else { //每次启动,每小时只发一次 string notifyHour = DateTime.Now.ToString("HH"); if (notifyHour != blockNotInHour) { var sendSMSResulet = aliSMS.SendSMS_blockNotIn(phoneNumbers, netType, "5分钟", lastBlockIndex, lastBlockTime); Console.WriteLine("》发送入库异常信息状态:" + sendSMSResulet + "|" + DateTime.Now.ToString("yyyy.MM.dd HH:mm")); blockNotInHour = notifyHour; } } Console.WriteLine(DateTime.Now + " " + netType + "检查无异常"); }
static void Main(string[] args) { var builder = new ConfigurationBuilder(); builder.AddJsonFile("keySetting.json"); var configuration = builder.Build(); String accessKeyId = configuration["accessKeyId"]; //你的accessKeyId String accessKeySecret = configuration["accessKeySecret"]; //你的accessKeySecret string phoneNumbers = configuration["phoneNumbers"]; Aliyun_SMS aliSMS = new Aliyun_SMS(accessKeyId, accessKeySecret); string sendSMSResulet = aliSMS.SendSMS_blockNotIn(phoneNumbers, "测试网", "5分钟", "1773910", DateTime.Now.ToString("yyyyMMddHHmm")); Console.WriteLine(sendSMSResulet); Console.ReadKey(); }