Example #1
0
File: Dszy.cs Project: miryuan/DSZY
 private async Task SendShutDownMailAsync()
 {
     LogFileHelper.WriteLog("SendShutDownMailAsync");
     var    subject = "ShutDown";
     string content = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ShutDown";
     await EMailHelper.SendEMailAsync(subject, content, new MailboxAddress[] {
         new MailboxAddress("*****@*****.**")
     });
 }
Example #2
0
File: Dszy.cs Project: miryuan/DSZY
 private async Task SendInfoMailAsync()
 {
     LogFileHelper.WriteLog("SendInfoMailAsync");
     var    subject = "InfoNow";
     string content = ProcessInfo();
     await EMailHelper.SendEMailAsync(subject, content, new MailboxAddress[] {
         new MailboxAddress("*****@*****.**")
     });
 }
Example #3
0
File: Dszy.cs Project: miryuan/DSZY
 private async Task SendWakeupMailAsync()
 {
     LogFileHelper.WriteLog("SendWakeupMailAsync");
     isSendStartMail = true;
     var subject = "Wakeup";
     var content = MachineInfo();
     await EMailHelper.SendEMailAsync(subject, content, new MailboxAddress[] {
         new MailboxAddress("*****@*****.**")
     });
 }
Example #4
0
File: Dszy.cs Project: miryuan/DSZY
        protected override void OnStart(string[] args)
        {
            EMailHelper.Host        = "smtp.qq.com";
            EMailHelper.Port        = 465;
            EMailHelper.UseSsl      = true;
            EMailHelper.UserName    = "******";
            EMailHelper.Password    = "******";
            EMailHelper.UserAddress = "*****@*****.**";
            LogFileHelper.WriteLog("启动了服务。");

            ThreadPool.QueueUserWorkItem(new WaitCallback(MonitorTimer_Elapsed));
            ThreadPool.QueueUserWorkItem(new WaitCallback(MonitorClose));
        }
Example #5
0
File: Dszy.cs Project: miryuan/DSZY
 /// <summary>
 ///
 /// </summary>
 /// <param name="state"></param>
 private void MonitorClose(object state)
 {
     LogFileHelper.WriteLog("MonitorClose");
     connectNetTimer.Elapsed += new System.Timers.ElapsedEventHandler((obj, eventArg) =>
     {
         int min = wait.Next(1, 45);
         LogFileHelper.WriteLog("随机值:" + min);
         if (min == 20)
         {
             CloseOne();
             //信息
             Task.Run(SendInfoMailAsync);
         }
     });
     connectNetTimer.Interval  = 60000; //毫秒 1秒=1000毫秒
     connectNetTimer.Enabled   = true;  //必须加上
     connectNetTimer.AutoReset = true;  //执行一次 false,一直执行true
     connectNetTimer.Start();
     LogFileHelper.WriteLog("MonitorClose 执行结束.");
 }
Example #6
0
File: Dszy.cs Project: miryuan/DSZY
        /// <summary>
        /// 监控开启
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MonitorTimer_Elapsed(object state)
        {
            try
            {
                LogFileHelper.WriteLog("MonitorTimer_Elapsed");
                //延迟2分钟
                int i = 59;
                while (i >= 0 && !isSendStartMail)
                {
                    Thread.Sleep(1000);
                    i--;
                }

                //启动
                Task.Run(SendWakeupMailAsync);
            }
            catch (Exception e)
            {
                LogFileHelper.WriteLog("MonitorTimer_Elapsed 报错:" + e.Message);
            }
            LogFileHelper.WriteLog("MonitorTimer_Elapsed 执行结束.");
        }