private void mnuDeleteAll_Click(object sender, EventArgs e) { switch (type) { case 1: if (MessageBox.Show("确认要删除全部记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { int rows = new SQL().Database("ConnString").Delete(EmailList._).ToExec(); EmailListHelper.ClearCacheAll(); BindData(); } break; case 2: if (MessageBox.Show("确认要删除全部记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { int rows = new SQL().Database("ConnString").Delete(SmtpList._).ToExec(); SmtpListHelper.ClearCacheAll(); BindData(); } break; case 3: if (MessageBox.Show("确认要删除全部记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { int rows = new SQL().Database("ConnString").Delete(IpHistory._).ToExec(); IpHistoryHelper.ClearCacheAll(); BindData(); } break; } }
private void inportSmtpList(object o) { int totals = 0; int success = 0; WriteLog(""); WriteLog("正在读取数据....."); IList <string> data = FileDirectory.FileRead(fileName, FileDirectory.FileEncoding(fileName)); totals = data.Count; WriteLog("读取到:" + totals + " 行记录!"); WriteLog("正在导入数据....."); int index = 1; int port = 25; foreach (string str in data) { string[] list = str.Split(','); if (list.Length != 3) { WriteLog("第" + index.ToString() + "行数据格式不正确:" + str); } else { string smtp = list[0].Trim(); string userName = list[1].Trim(); if (!IsSmtp(smtp)) { WriteLog("第" + index.ToString() + "行Smtp服务器地址格式不正确:" + str); } else { if (SmtpListHelper.IsExistByID(smtp, port, userName)) { WriteLog("第" + index.ToString() + "行数据已存在:" + str); } else { //bool isTrue = NetHelper.CheckSMTP(list[1], list[2], list[0]); //if (isTrue) { SmtpList info = new SmtpList(); info.SmtpServer = list[0]; info.UserName = list[1]; info.SPassword = list[2]; info.SmtpPort = 25; info.CreateTime = DateTime.Now.ToDateTime().ToDateTime(); SmtpListHelper.Insert(info); success++; //} else { // WriteLog("第" + index.ToString() + "行SMTP无法连接到服务器,请检查用户名和密码是否正确和账号是否被封:" + str); //} } } } index++; } SmtpListHelper.ClearCacheAll(); WriteLog("导入Smtp服务器列表完成:共 {0} 条记录,成功 {1} 条记录,失败 {2} 条记录!".FormatWith(totals, success, totals - success)); }
public static void Delete(string[] args, bool exit = false) { if (args.Length == 2) { args = (string.Join(" ", args) + " *").Split(" "); } if (args[1].Trim().ToLower() == "smtp") { WriteLog("delete(d) smtp * 删除SMTP数据"); } if (args[1].Trim().ToLower() == "email") { WriteLog("delete(d) email * 删除邮箱数据"); } WriteLog("==============================================================================="); if (args[1].Trim().ToLower() == "smtp") { args = string.Join(" ", args, 2, args.Length - 2).Split(' '); int len = 0; if (args.Length == 1 && args [0] == "*") { len = new SQL().Delete(SmtpList._).ToExec(); } else { foreach (string s in args) { string[] ss = s.Split(','); if (ss.Length != 3) { continue; } len += SmtpListHelper.DeleteByID(ss[0], ss[1].ToInt(25), ss[2]) ? 1 : 0; } } WriteLog("删除影响行数:{0}", len); SmtpListHelper.ClearCacheAll(); } else if (args[1].Trim().ToLower() == "email") { args = string.Join(" ", args, 2, args.Length - 2).Split(' '); int len = 0; if (args.Length == 1 && args [0] == "*") { len = new SQL().Delete(EmailList._).ToExec(); } else { foreach (string s in args) { len += EmailListHelper.DeleteByID(s) ? 1 : 0; } } WriteLog("删除影响行数:{0}", len); EmailListHelper.ClearCacheAll(); } WriteLog("END"); Input(exit); }
/// <summary> /// 清理缓存 /// </summary> private void clear() { SmtpListHelper.ClearCacheAll(); smtpList = null; EmailListHelper.ClearCacheAll(); emailList = null; SendSettingHelper.ClearCacheAll(); sendSetting = null; HtmlTemplateHelper.ClearCacheAll(); templateList = null; IpHistoryHelper.ClearCacheAll(); }
private void mnuDelete_Click(object sender, EventArgs e) { switch (type) { case 1: if (listView1.CheckedItems.Count == 0) { MessageBox.Show("请选择你要删除的记录!", " 系统提示"); return; } if (MessageBox.Show("确认要删除选中的记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { IList <string> data = new List <string>(); foreach (ListViewItem item in listView1.Items) { if (item.Checked) { data.Add(item.Tag.ToString()); } } int rows = new SQL().Database("ConnString").Delete(EmailList._) .Where(new Where() .And(EmailList._EmailAddress, "('" + data.Select(p => p.SafeSql()).Join("','") + "')", Operator.In) ).ToExec(); EmailListHelper.ClearCacheAll(); BindData(); } break; case 2: if (listView1.CheckedItems.Count == 0) { MessageBox.Show("请选择你要删除的记录!", " 系统提示"); return; } if (MessageBox.Show("确认要删除选中的记录吗?", " 系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { foreach (ListViewItem item in listView1.Items) { if (item.Checked) { string[] list = item.Tag.ToString().Split(','); string id = list[0].ToString(); int port = list[1].ToString().ToInt(25); string username = list[2].ToString(); string password = list[3].ToString(); SmtpListHelper.DeleteByID(id, port, username, password); } } SmtpListHelper.ClearCacheAll(); BindData(); } break; } }
private void button1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtSmtpServer.Text)) { MessageBox.Show("SMTP服务器不能为空", "系统提示"); return; } if (string.IsNullOrEmpty(this.txtSmtpPort.Text)) { MessageBox.Show("SMTP服务器端口不能为空", "系统提示"); return; } if (string.IsNullOrEmpty(this.txtUserName.Text)) { MessageBox.Show("登录用户名不能为空", "系统提示"); return; } SmtpList info = new SmtpList(); info.SmtpServer = this.txtSmtpServer.Text; info.SmtpPort = this.txtSmtpPort.Text.ToInt(25); info.UserName = this.txtUserName.Text; info.SPassword = this.txtSPassword.Text; info.SSL = this.checkBoxSSL.Checked; info.Status = this.checkBoxStatus.Checked == true ? 0 : 1; //bool isTrue = NetHelper.CheckSMTP(info.UserName, info.SPassword, info.SmtpServer); //if (!isTrue) { // MessageBox.Show("无法连接SMTP服务器,请检查用户名和密码是否正确和账号是否被封。", " 系统提示"); // return; //} DialogResult = System.Windows.Forms.DialogResult.OK; if (!smtp.IsNullEmpty() || SmtpListHelper.IsExistByID(info.SmtpServer, info.SmtpPort.Value, info.UserName)) { SmtpListHelper.Update(info); } else { info.CreateTime = DateTime.Now.ToDateTime().ToDateTime(); SmtpListHelper.Insert(info); } SmtpListHelper.ClearCacheAll(); MessageBox.Show("保存数据成功!", " 系统提示"); this.Close(); }
private void mnuSearch_Click(object sender, EventArgs e) { switch (type) { case 1: EmailListHelper.ClearCacheAll(); break; case 2: SmtpListHelper.ClearCacheAll(); break; case 3: IpHistoryHelper.ClearCacheAll(); break; } BindData(); }
private void mnuDisable_Click(object sender, EventArgs e) { switch (type) { case 1: EmailListHelper.ClearCacheAll(); break; case 2: SmtpListHelper.ClearCacheAll(); foreach (ListViewItem item in listView1.Items) { if (item.Checked) { string[] list = item.Tag.ToString().Split(','); SmtpList info = new SmtpList(); info.SmtpServer = list[0].ToString(); info.SmtpPort = list[1].ToString().ToInt(25); info.UserName = list[2].ToString(); info.SPassword = list[3].ToString(); info.Status = 1; SmtpListHelper.Update(info); //if (!info.SmtpServer.IsNullEmpty() || SmtpListHelper.IsExistByID(info.SmtpServer, info.SmtpPort.Value, info.UserName)) { // SmtpListHelper.Update(info); //} } } break; case 3: IpHistoryHelper.ClearCacheAll(); break; } BindData(); }