protected override void OnStart(string[] args) { MailerCenter.Start((msg) => { msg = "[{0}]-{1}".FormatWith(DateTime.Now.ToDateTimeFFF(), msg); Log.WriteLog(msg); }); }
public static void Resend(bool exit = false) { WriteLog("resend(rs) 重新发送邮件"); WriteLog("==============================================================================="); SendSettingHelper.Update(new SendSetting() { SettingID = 1, Status = 0 }); SendSettingHelper.ClearCacheSelectByID(1); new SQL() .Update(EmailList._) .Set(EmailList._LastSendStatus, 0) .Set(EmailList._LastSendError, "") .Set(EmailList._LastSendTime, null, true) .Set(EmailList._LastSendSmtp, "") .Set(EmailList._SendCount, 0) .ToExec(); new SQL().Update(SmtpList._) .Set(SmtpList._Sends, 0) .Set(SmtpList._SendFails, 0) .ToExec(); MailerCenter.Start((msg) => { msg = "[{0}]-{1}".FormatWith(DateTime.Now.ToDateTimeFFF(), msg); WriteLog(msg); }, () => { WriteLog("END"); if (exit) { System.Environment.Exit(0); } Console.Write("> "); }); Parse(Console.ReadLine()); }
private void mnuAdd_Click(object sender, EventArgs e) { listBox1.Items.Add(""); btnStart.Enabled = false; btnStop.Enabled = true; MailerCenter.Start((msg) => { if (!listBox1.IsHandleCreated) { return; } listBox1.BeginInvoke(new Pub.Class.Action(() => { msg = "[{0}]-{1}".FormatWith(DateTime.Now.ToDateTimeFFF(), msg); Log.WriteLog(msg); if (listBox1.Items.Count > 10000) { listBox1.Items.Clear(); } listBox1.Items.Add(msg); listBox1.SelectedIndex = listBox1.Items.Count - 1; })); }, () => { this.BeginInvoke(new Pub.Class.Action(() => { btnStart.Enabled = true; btnStop.Enabled = false; })); }); }
private void mnuDelete_Click(object sender, EventArgs e) { listBox1.Items.Add("正在停止发送....."); listBox1.SelectedIndex = listBox1.Items.Count - 1; MailerCenter.Stop(); btnStart.Enabled = true; btnStop.Enabled = false; }
public static void Send(bool exit = false) { WriteLog("send(s) 发送邮件"); WriteLog("==============================================================================="); MailerCenter.Start((msg) => { msg = "[{0}]-{1}".FormatWith(DateTime.Now.ToDateTimeFFF(), msg); WriteLog(msg); }, () => { WriteLog("END"); if (exit) { System.Environment.Exit(0); } Console.Write("> "); }); Parse(Console.ReadLine()); }
protected override void OnStop() { MailerCenter.Stop(); }
private void frmSendEmail_FormClosed(object sender, FormClosedEventArgs e) { MailerCenter.Abort(); }