You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1685 lines
59 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//
using OpenPop.Pop3;
using OpenPop.Mime;
using System.IO;
using MailAnalyzeTools.Models;
using System.Configuration;
using System.Threading;
using MailAnalyzeTools.Common;
using MailAnalyzeTools.Logic;
using dongshengFtpTools;
using System.Data.SqlClient;
using MailAnalyzeTools.UControls;
using MailAnalyzeTools.Logic.HongAn;
using MailAnalyzeTools;
namespace MailAnalyzeTools
{
public partial class frmAnalyzeMail : Form
{
public frmAnalyzeMail()
{
InitializeComponent();
dataGridView2_tosend.AutoGenerateColumns = false;
dateTimePicker3_sendedMail_1.Text = DateTime.Today.ToString("yyyy-MM-01");
dateTimePicker3_sendedMail_2.Text = DateTime.Today.ToString("yyyy-MM-dd");
m_AppStartRunTime = DateTime.Now;
}
#region 事件
protected override void WndProc(ref System.Windows.Forms.Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_CLOSE = 0xF060;
const int SC_MINIMIZE = 0xF020;
if (m.Msg == WM_SYSCOMMAND && ((int)m.WParam == SC_CLOSE || (int)m.WParam == SC_MINIMIZE))
{
hidemainwindow();
return;
}
base.WndProc(ref m);
}
private void frmAnalyzeMail_Load(object sender, EventArgs e)
{
// TODO: 这行代码将数据加载到表“shippingWeb_LNHTDataSet.t_op_seae_edi_mail”中。您可以根据需要移动或删除它。
InitialLoad();
dateTimePicker1.MaxDate = DateTime.Today.Date;
dateTimePicker1.MinDate = DateTime.Today.AddDays(-10);
int mt = frmMailSet.MailconfigSet().IntervalMinutes;
if (mt <= 0)
{
mt = 1;
}
else if (mt >= 600)
{
mt = 600;
}
timer1.Interval = mt * 60 * 1000;
dataGridView3_sendedmail.AutoGenerateColumns = false;
timer1.Start();
if (frmMailSet.MailconfigSet().MailAutoDeal == 1)
{
//
tspLabel_autoSwitch.Text = "自动";
btnReadMail.Enabled = false;
tSStatusLabel2.Text = "分析邮件中...";
this.backgroundWorker1.RunWorkerAsync();
}
else
{
tspLabel_autoSwitch.Text = "手动";
}
//
initialDownloadinfo_BL();
//initialDownloadinfo_Bc();
//initialDownloadinfo_Invoice();
//
initialHaEdiImport();
timer2b_Warn.Enabled = true;
timer2b_Warn.Start();
}
/// <summary>
/// 手动读取分析邮件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnReadMail_Click(object sender, EventArgs e)
{
try
{
tSStatusLabel2.Text = "分析邮件中...";
btnReadMail.Enabled = false;
m_isManualProcessingDate = dateTimePicker1.Value;
m_isManualProcessing = true;
///m_dtMessages.Rows.Clear();
backgroundWorker1.RunWorkerAsync();
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
}
}
/// <summary>
/// 计时器
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
if (frmMailSet.MailconfigSet().MailAutoDeal != 1)
{
tspLabel_autoSwitch.Text = "手动";
return;
}
tspLabel_autoSwitch.Text = "自动";
//不忙,自动删除,邮件数量>5000 ....
if ( (!m_isBusying_ReceiveMail) &&chkAutoDelMail.Checked && m_mailcount > 5000)
{
//自动删除3天以上的邮件
DeleteOver3daysMail();
}
try
{
///m_dtMessages.Rows.Clear();
if (!m_isBusying_ReceiveMail)
{
btnReadMail.Enabled = false;
tSStatusLabel2.Text = "分析邮件中...";
this.backgroundWorker1.RunWorkerAsync();
}
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dataGridView2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0 && dataGridViewHistory.Columns.Contains("舱单申报编号"))
{
int icol = dataGridViewHistory.Columns["舱单申报编号"].Index;
string cdbh = dataGridViewHistory.Rows[e.RowIndex].Cells[icol].Value.ToString();
initialCDSBInfo(cdbh);
}
}
private void dataGridView_CDSB_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
// tabControl1.SelectedTab = tabPage2;
}
#endregion //事件
#region 私有方法
/// <summary>
///
/// </summary>
private void InitialLoad()
{
m_AppTitle = this.Text;
try
{
//
m_db_sendmail_Logic = new Logic.db_sendmail_Logic();
bindGridviewMailReceivedHistory();
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
throw;
}
}
/// <summary>
/// 绑定邮件接收历史
/// </summary>
private void bindGridviewMailReceivedHistory()
{
string sqlpre = @" select ROW_NUMBER() OVER(ORDER BY 邮件发送日期 desc) as 行号, [序号],[邮件ID],[邮件主题],[HBLNO],[Edistatus],
ISMATCHED,FTPSTATUS,[邮件内容],[邮件发送日期],[处理时间],[状态] ,[备注],[邮件来源] ,附件名称
from [t_op_seae_edi_mail] t ";
string strdate = dateTimePicker_search.Value.Date.ToString("yyyy-MM-dd HH:mm:ss");
string wheredate = "where datediff(day,t.[邮件发送日期],cast('{0}' as datetime ))=0 ";
string wheremainno = " where HBLNO LIKE '%{0}%' or 邮件主题 like '%{0}%' or ftpstatus like '%{0}%' ";
string strmainno = txtSeachMainNo.Text.Trim().Replace("'", "''");
string sql = sqlpre + (strmainno.Length > 0 ? string.Format(wheremainno, strmainno) : string.Format(wheredate, strdate));
DataTable dt = DbHelperSQL.QueryTable(sql);
dataGridViewHistory.DataSource = dt;
}
/// <summary>
/// 绑定邮件发送记录历史
/// </summary>
private void bindGridviewMailSendHistory()
{
string strdate1 = dateTimePicker3_sendedMail_1.Value.Date.ToString("yyyy-MM-dd HH:mm:ss");
string strdate2 = dateTimePicker3_sendedMail_2.Value.Date.ToString("yyyy-MM-dd 23:59:59");
string wheredate = "where realsenddate>=cast('{0}' as datetime ) and realsenddate<= cast('{1}' as datetime ) ";
string strwhere = string.Format(wheredate, strdate1, strdate2);
DataTable dt = m_db_sendmail_Logic.GetSendedmail(strwhere);
dataGridView3_sendedmail.DataSource = dt;
}
private void initialCDSBInfo(string cdbh)
{
if (string.IsNullOrEmpty(cdbh))
{
return;
}
}
#region 读取及分析邮件
public static bool GetOpenClient(Pop3Client pop3Client)
{
Mailconfig mcg = frmMailSet.MailconfigSet();
string txtMailServer = mcg.Pop3MailServer_Addr;//"popcom.263xmail.com";
string txtPort = mcg.Pop3MailServer_Port.ToString(); //"110";
string txtUserName = mcg.MailAddress;//"gshengsoft@dongshengsoft.com";
string txtPassword = mcg.MailPassWord;// "ds20040201";
bool chkSSL = mcg.Pop3MailServer_SSL == 1 ? true : false;
//
bool conOk;
conOk = ConnectMailServer(pop3Client, txtMailServer, int.Parse(txtPort), chkSSL, txtUserName, txtPassword, true);
if (!conOk)
{
System.Threading.Thread.Sleep(1000);
return conOk;
;
}
return conOk;
}
/// <summary>
/// 连接邮件服务器
/// </summary>
/// <param name="pop3Client"></param>
/// <param name="txtMailServer"></param>
/// <param name="iPort"></param>
/// <param name="chkSSL"></param>
/// <param name="txtUserName"></param>
/// <param name="txtPassword"></param>
/// <param name="showErrTip"></param>
/// <returns></returns>
public static bool ConnectMailServer(Pop3Client pop3Client, string txtMailServer, int iPort, bool chkSSL, string txtUserName, string txtPassword, bool showErrTip = false)
{
try
{
pop3Client.Connect(txtMailServer, iPort, chkSSL);
pop3Client.Authenticate(txtUserName, txtPassword);
//this.BackColor = Color.White;
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
//this.BackColor = Color.Red;
//MessageBox.Show(String.Format(info, ex.Message));
return false;
}
return true;
}
public static bool TestConnectMailServer(string txtMailServer, int iPort, bool chkSSL, string txtUserName, string txtPassword, bool showErrTip = true)
{
string info = "连接邮件服务器时发生异常:{0}!";
try
{
Pop3Client pop3Client = new Pop3Client();
pop3Client.Connect(txtMailServer, iPort, chkSSL);
pop3Client.Authenticate(txtUserName, txtPassword);
}
catch (Exception ex)
{
MessageBox.Show(String.Format(info, ex.Message));
return false;
}
return true;
}
/// <summarey>
/// 分析处理EDI文件
/// </summary>
/// <param name="attachment"></param>
/// <param name="mainOrderno"></param>
/// <param name="subOrderno"></param>
private bool analyzeAttach(MessagePart attachment, string mainOrderno, string subOrderno, DataRow dr_person_price_remark = null)
{
StringBuilder bldEdiContent;
bool isok;
bldEdiContent = new StringBuilder();
bldEdiContent.Append(System.Text.Encoding.Default.GetString(attachment.Body));
AnalyzeEdiFile anaEF = new AnalyzeEdiFile();
isok = anaEF.Analyze_seae_edi_data(bldEdiContent, mainOrderno, subOrderno, dr_person_price_remark);
//获得舱单申报编号
m_AppSheetCode = anaEF.GetOpsee_edi().F_01_BH;
//获得错误信息
m_errlist = anaEF.GetErrList();
return isok;
}
/// <summary>
/// // 保存附件
/// </summary>
/// <param name="attachment"></param>
private void saveAttach(MessagePart attachment, string messageid)
{
//string basepath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "EDI");
string basepath = GetMailInBoxTargetPath(messageid);
DirectoryInfo dri = new DirectoryInfo(basepath);
if (!dri.Exists)
{
try
{
dri.Create();
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
basepath = System.AppDomain.CurrentDomain.BaseDirectory;
}
}
//文件名去空格
string filename = Path.Combine(basepath, attachment.FileName.Trim().Replace('?', '_').Replace('*', '_').Replace(':', '_').Replace(' ', '_').Replace('/','_').Replace("'", "-"));
FileInfo file = new FileInfo(filename);
if (file.Exists)
{
file.Delete();
}
try
{
attachment.Save(file);
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
m_errlist.Add(ex.Message);
//MessageBox.Show(this, "附件保存失败,异常信息: " + e.Message);
}
}
/// <summary>
/// 从标题中分离出[主提单号]、[分提单号]
/// </summary>
/// <param name="subject"></param>
/// <returns></returns>
private string[] GetMmainSub_ordernoFromSubject(string subject)
{
string[] arrayOrderno = new string[2] { "", "" };
var arr = subject.Split(' ');
foreach (var item in arr)
{
if (item.StartsWith("主提单号"))
{
string[] bh = item.Replace("", ":").Split(':');
if (bh.Length > 1)
{
arrayOrderno[0] = bh[1];
}
}
else if (item.StartsWith("分提单号"))
{
string[] bh = item.Replace("", ":").Split(':');
if (bh.Length > 1)
{
arrayOrderno[1] = bh[1];
}
}
}
return arrayOrderno;
}
private string getErrorInfo()
{
if (m_errlist == null || m_errlist.Count < 1)
{
return "";
}
StringBuilder bldtmp = new StringBuilder();
foreach (var item in m_errlist)
{
bldtmp.AppendLine(item);
}
return bldtmp.ToString();
}
/// <summary>
/// 初始化已经处理邮件ID:Old
/// </summary>
/// <returns></returns>
private bool inItialMailID0()
{
// 优化获取条件待定
string sql;
if (m_dicMailIds == null)
{
m_dicMailIds = new Dictionary<string, string>();
sql = "SELECT [邮件ID],[状态] FROM [t_op_seae_edi_mail] ";
}
else
{
sql = "SELECT 4000 [邮件ID],[状态],t.序号 FROM [t_op_seae_edi_mail] t order by t.处理时间 desc ";
}
try
{
DataTable dt = DbHelperSQL.QueryTable(sql);
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
if (!m_dicMailIds.Keys.Contains(item[0].ToString()))
{
m_dicMailIds.Add(item[0].ToString(), item[1].ToString());
}
}
}
return true;
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
return false;
}
}
/// <summary>
/// 初始化已经处理邮件ID
/// </summary>
/// <returns>
/// 通过缓存ID优化查询速度
/// </returns>
private bool inItialMailID()
{
// 优化获取条件待定
string sql;
if (m_dicMailIds == null)
{
m_dicMailIds = new Dictionary<string, string>();
// [邮件ID],[状态]
sql = "SELECT [id],[no] FROM t_mailid order by no ";
}
else
{
//读取新邮件字典优化
sql = string.Format(" SELECT [id],[no] FROM [t_mailid] where no > {0} order by no ",
m_maxno_receive);
}
try
{
DataTable dt = DbHelperSQL.QueryTable(sql);
if (dt.Rows.Count < 1)
{
return inItialMailID0();
}
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow item in dt.Rows)
{
if (!m_dicMailIds.Keys.Contains(item[0].ToString()))
{
m_dicMailIds.Add(item[0].ToString(), item[1].ToString());
}
}
int tmpMaxno = int.Parse(dt.Rows[dt.Rows.Count - 1]["no"].ToString());
if (m_maxno_receive < tmpMaxno)
{
m_maxno_receive = tmpMaxno;
}
}
return true;
}
catch (Exception ex)
{
LogHelper.WriteLog(this.GetType(), ex);
return false;
}
}
#endregion 读取及分析邮件
#endregion //私有方法
#region 属性或私有变量
private string m_AppTitle;
private DateTime m_AppStartRunTime;
/// <summary>
/// 处理的邮件数量
/// </summary>
int m_counter;
/// <summary>
/// 异常列表
/// </summary>
private List<string> m_errlist;
/// <summary>
/// 舱单申报编号
/// </summary>
private string m_AppSheetCode;
///DataTable m_dtMessages;
/// <summary>
/// 已处理的邮件ID
/// </summary>
private Dictionary<string, string> m_dicMailIds;
private bool m_isBusying_ReceiveMail;//邮件接收处理中
private bool m_isBusying_SendMail;//邮件发送处理中
/// <summary>
/// 最近一次执行邮件分析时间
/// </summary>
private static DateTime m_lastDealMailDatetime;
bool m_isManualProcessing;
DateTime m_isManualProcessingDate;
bool m_isneedRefresh_ReceiveMail;
/// <summary>
/// 当前邮件数量
/// </summary>
int m_mailcount;
/// <summary>
/// 是否正在发送邮件
/// </summary>
DataTable m_dt_tosend;
#endregion //属性或私有变量
private void tsmenu_set_Click(object sender, EventArgs e)
{
//a=
if (dataGridViewHistory.Rows.Count > 0 && dataGridViewHistory.SelectedRows.Count > 0)
{
var fj = dataGridViewHistory.SelectedRows[0].Cells["clmGrdv1_attachName"].Value;
var yjid = dataGridViewHistory.SelectedRows[0].Cells["clmGrdv1_mailID"].Value;
if (fj != null)
{
string filename =
Path.Combine(GetMailInBoxTargetPath(yjid.ToString()), fj.ToString().Replace('/', '_'));
//string basepath = Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "EDI");
//string filename = basepath + "\\" + fj.ToString();
if (File.Exists(filename))
{
System.Diagnostics.Process.Start(filename);
}
}
}
}
private void menuSet_Click(object sender, EventArgs e)
{
}
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (m_isneedRefresh_ReceiveMail)
{
bindGridviewMailReceivedHistory();
}
m_isManualProcessing = false;
m_isBusying_ReceiveMail = false;
btnReadMail.Enabled = true;
tSStatusLabel2.Text = "就绪...";
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
if (m_isBusying_ReceiveMail)
return;
m_isBusying_ReceiveMail = true;
m_isneedRefresh_ReceiveMail = false;
AnalyzeUnreadMailLit();
}
private void frmAnalyzeMail_FormClosing(object sender, FormClosingEventArgs e)
{
if (m_isBusying_ReceiveMail)
{
if (MessageBox.Show(this, "系统正在处理邮件,您确实要退出吗?", "信息提示", MessageBoxButtons.YesNo)
== System.Windows.Forms.DialogResult.No)
{
e.Cancel = true;
}
}
}
private void dataGridViewHistory_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
}
private void dataGridViewHistory_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
if (e.RowIndex >= 0)
{
//若行已是选中状态就不再进行设置
if (dataGridViewHistory.Rows[e.RowIndex].Selected == false)
{
dataGridViewHistory.ClearSelection();
dataGridViewHistory.Rows[e.RowIndex].Selected = true;
}
//只选中一行时设置活动单元格
if (dataGridViewHistory.SelectedRows.Count == 1)
{
dataGridViewHistory.CurrentCell = dataGridViewHistory.Rows[e.RowIndex].Cells[e.ColumnIndex];
}
//弹出操作菜单
contextMenuStrip1.Show(MousePosition.X, MousePosition.Y);
}
}
}
private void btnSearMail_Click(object sender, EventArgs e)
{
bindGridviewMailReceivedHistory();
}
#region DateGridView导出到csv格式的Excel
/// <summary>
/// 常用方法,列之间加\t一行一行输出此文件其实是csv文件不过默认可以当成Excel打开。
/// </summary>
/// <remarks>
/// using System.IO;
/// </remarks>
/// <param name="dgv"></param>
private void DataGridViewToExcel(DataGridView dgv)
{
SaveFileDialog dlg = new SaveFileDialog();
dlg.Filter = "Execl files (*.xls)|*.xls";
dlg.FilterIndex = 0;
dlg.RestoreDirectory = true;
dlg.CreatePrompt = true;
dlg.Title = "保存为Excel文件";
if (dlg.ShowDialog() == DialogResult.OK)
{
Stream myStream;
myStream = dlg.OpenFile();
StreamWriter sw = new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0));
string columnTitle = "";
try
{
//写入列标题
for (int i = 0; i < dgv.ColumnCount; i++)
{
if (i > 0)
{
columnTitle += "\t";
}
columnTitle += dgv.Columns[i].HeaderText;
}
sw.WriteLine(columnTitle);
//写入列内容
for (int j = 0; j < dgv.Rows.Count; j++)
{
string columnValue = "";
for (int k = 0; k < dgv.Columns.Count; k++)
{
if (k > 0)
{
columnValue += "\t";
}
if (dgv.Rows[j].Cells[k].Value == null)
columnValue += "";
else
columnValue += dgv.Rows[j].Cells[k].Value.ToString().Trim();
}
sw.WriteLine(columnValue);
}
sw.Close();
myStream.Close();
}
catch (Exception e)
{
MessageBox.Show(e.ToString());
}
finally
{
sw.Close();
myStream.Close();
}
}
}
#endregion
private void rmnuexportCSVToolStripMenuItem_Click(object sender, EventArgs e)
{
DataGridViewToExcel(dataGridViewHistory);
}
private void btn2_debugEdi_Click(object sender, EventArgs e)
{
StringBuilder bldEdiContent;
OpenFileDialog dlg = new OpenFileDialog();
bool isok;
dlg.Filter = "edi 文件(*.txt)|*.txt";
if (dlg.ShowDialog() != DialogResult.OK)
return;
bldEdiContent = new StringBuilder();
using (StreamReader sr = new StreamReader(dlg.FileName))//读取文件txt
{
while (!sr.EndOfStream)
{
string sLine = sr.ReadLine();
bldEdiContent.AppendLine(sLine);
}
}
AnalyzeEdiFile anaEF = new AnalyzeEdiFile();
isok = anaEF.Analyze_seae_edi_data(bldEdiContent, "111", "112", null);
//获得舱单申报编号
m_AppSheetCode = anaEF.GetOpsee_edi().F_01_BH;
//获得错误信息.
m_errlist = anaEF.GetErrList();
}
private void button1DelRec_Click(object sender, EventArgs e)
{
if (dataGridViewHistory.SelectedRows.Count < 1)
return;
string xhs = "";
if (MessageBox.Show("您确实要删除当前选中的记录吗", "信息提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
int icount = dataGridViewHistory.SelectedRows.Count;
for (int i = 0; i < icount; i++)
{
if (i == 0)
xhs = dataGridViewHistory.SelectedRows[i].Cells[1].Value.ToString();
else
xhs += "," + dataGridViewHistory.SelectedRows[i].Cells[1].Value.ToString();
}
string sql = "delete from t_op_seae_edi_mail where 序号 in (" + xhs + ")";
try
{
DbHelperSQL.ExecuteSql(sql);
bindGridviewMailReceivedHistory();
MessageBox.Show("删除成功", "信息提示", MessageBoxButtons.OK);
}
catch (Exception ex)
{
MessageBox.Show("发生错误" + ex.Message, "信息提示", MessageBoxButtons.OK);
}
}
}
private void 退ToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void ToolStripMenuItem_reback_Click(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
private void ToolStripMenuItem_mailset_Click(object sender, EventArgs e)
{
new frmMailSet().ShowDialog();
int mt = frmMailSet.MailconfigSet().IntervalMinutes;
if (mt <= 0)
{
mt = 1;
}
else if (mt >= 600)
{
mt = 600;
}
timer1.Interval = mt * 60 * 1000;
mt = frmMailSet.FtpConfigSet().IntervalMinutes;
if (mt <= 0)
{
mt = 1;
}
else if (mt >= 600)
{
mt = 600;
}
timer3_download_BL.Interval = mt * 60 * 1000;
}
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
this.Visible = true;
this.WindowState = FormWindowState.Normal;
this.notifyIcon1.Visible = false;
}
private void hidemainwindow()
{
this.Hide();
this.notifyIcon1.Visible = true;
}
private void frmAnalyzeMail_Shown(object sender, EventArgs e)
{
Do_WarnAnalyze();
//
timer2_BcMailMatch2.Enabled=true;
timer2_BcMailMatch2.Start();
}
private void dataGridViewHistory_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0)
return;
//
if (e.ColumnIndex == 9)
{
//string nr = dataGridViewHistory.Rows[e.RowIndex].Cells[邮件内容DataGridViewTextBoxColumn.Index].Value.ToString();
//string subject = dataGridViewHistory.Rows[e.RowIndex].Cells[邮件主题DataGridViewTextBoxColumn.Index].Value.ToString();
string nr = dataGridViewHistory.Rows[e.RowIndex].Cells[clmGrdv1_mailSubject.Index].Value.ToString();
string subject = dataGridViewHistory.Rows[e.RowIndex].Cells[clmGrdv1_mailContent.Index].Value.ToString();
if (string.IsNullOrEmpty(nr))
return;
frmShowMailContent a = new frmShowMailContent();
if (nr.Length > 4 && nr.Trim().Substring(0, 4).IndexOf("ht") < 0)
{
nr = nr.Replace("\r", "<br>").Replace(" ", "&nbsp;");
}
a.htmlNR = nr;
a.subject = subject;
a.Show();
}
else
{
//string nr = dataGridViewHistory.Rows[e.RowIndex].Cells[邮件内容DataGridViewTextBoxColumn.Index].Value.ToString();
//string subject = dataGridViewHistory.Rows[e.RowIndex].Cells[邮件主题DataGridViewTextBoxColumn.Index].Value.ToString();
string subject = dataGridViewHistory.Rows[e.RowIndex].Cells[clmGrdv1_mailSubject.Index].Value.ToString();
string nr = dataGridViewHistory.Rows[e.RowIndex].Cells[clmGrdv1_mailContent.Index].Value.ToString();
//if (string.IsNullOrEmpty(nr))
// return;
frmForwardmail a = new frmForwardmail();
if (nr.Length > 4 && nr.Trim().Substring(0, 4).IndexOf("ht") < 0)
{
nr = nr.Replace("\r", "<br>").Replace(" ", "&nbsp;");
}
a.htmlNR = nr;
a.subject = subject;
a.Show();
}
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show(this, "您确实要删除3个月以上的邮件记录吗", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
!= System.Windows.Forms.DialogResult.Yes)
return;
try
{
string strsql = "delete from [t_op_seae_edi_mail] where 邮件发送日期 <= DATEADD(M,-3,CAST(GETDATE() AS DATE));";
DbHelperSQL.ExecuteSql(strsql);
}
catch (Exception ex)
{
LogHelper.WriteLog(this.GetType(), ex);
}
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
label_sendmail.Text = "邮件发送中...";
Application.DoEvents();
sendmailAction();
Thread.Sleep(3000);
label_sendmail.Text = "";
}
private void timer2_send_Tick(object sender, EventArgs e)
{
try
{
if (!m_isBusying_SendMail && m_db_sendmail_Logic.CheckHasToSendmail())
{
this.backgroundWorker2_send.RunWorkerAsync();
}
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(frmAnalyzeMail), ex);
}
}
private void backgroundWorker2_send_DoWork(object sender, DoWorkEventArgs e)
{
if (m_isBusying_SendMail == false)
{
//检查是否有邮件
tSStatusLabel4_sendmail.Text = "邮件发送中...";
m_isBusying_SendMail = true;
DoSendmail();
}
}
private void backgroundWorker2_send_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//
m_isBusying_SendMail = false;
tSStatusLabel4_sendmail.Text = "";
}
private void DoSendmail()
{
sendmailAction();
Thread.Sleep(3000);//3秒
}
private void btnSeachSendedMail_Click(object sender, EventArgs e)
{
bindGridviewMailSendHistory();
}
private void dataGridView3_sendedmail_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
//
// if (e.ColumnIndex == 8)
{
string nr = dataGridView3_sendedmail.Rows[e.RowIndex].Cells[7].Value.ToString();
string subject = dataGridView3_sendedmail.Rows[e.RowIndex].Cells[5].Value.ToString();
if (string.IsNullOrEmpty(nr))
return;
frmShowMailContent a = new frmShowMailContent();
if (nr.Length > 4 && nr.Trim().Substring(0, 4).IndexOf("ht") < 0)
{
nr = nr.Replace("\r", "<br>").Replace(" ", "&nbsp;").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;");
}
a.htmlNR = nr;
a.subject = subject;
a.Show();
}
}
private void dataGridView3_sendedmail_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
/// <summary>
/// 下载BL报文的ftp实例
/// </summary>
ftptool m_ftp0;
//
bool m_isbusy_downloadfile;
frmDownloadFileTool m_frmDownloadFileTool;
UcHaEdiImport m_ucHaEdiImport;
/// <summary>
/// 已缓存的邮件id顺序号
/// </summary>
private int m_maxno_receive;
private void initialDownloadinfo_BL()
{
m_ftp0 = new ftptool();
m_ftp0.propUpdateDownloadStatus = new ftptool.UpdateDownloadStatus(UpdateDownloadStatus);
m_ftp0.TSLabl_Info = toolStripStatusLabel2;
//timer3_download.Interval = 30 * 1000;
int mt = frmMailSet.FtpConfigSet().IntervalMinutes;
if (mt <= 0)
{
mt = 1;
}
else if (mt >= 600)
{
mt = 600;
}
timer3_download_BL.Interval = mt * 60 * 1000;
timer3_download_BL.Enabled = true;
timer3_download_BL.Start();
}
private void timer3_download_Tick(object sender, EventArgs e)
{
if (frmMailSet.FtpConfigSet().AutoDownload == 0)
{
return;
}
try
{
if (!m_isbusy_downloadfile)
{
backgroundWorker3_download.RunWorkerAsync();
}
}
catch (Exception ex)
{
LogHelper.WriteLog(typeof(ftptool), ex);
}
}
private void backgroundWorker3_download_DoWork(object sender, DoWorkEventArgs e)
{
if (m_isbusy_downloadfile == false)
{
m_isbusy_downloadfile = true;
try
{
m_ftp0.downloadfile();
}
catch (Exception ex)
{
LogHelper.WriteLog("处理下载时发生异常:", ex.Message);
}
}
}
/// <summary>
/// FTP 下载记录查询界面
/// </summary>
private void initialDownloadinfo_Bc()
{
if (m_frmDownloadFileTool == null)
{
m_frmDownloadFileTool = new frmDownloadFileTool();
m_frmDownloadFileTool.Parent = tabPage4_ftp;
m_frmDownloadFileTool.Dock = DockStyle.Fill;
m_frmDownloadFileTool.Show();
}
m_frmDownloadFileTool.initialDownloadinfo_BC(this.toolStripStatusLabel5_BcState);
}
//
private void initialDownloadinfo_Invoice()
{
if (m_frmDownloadFileTool == null)
{
m_frmDownloadFileTool = new frmDownloadFileTool();
m_frmDownloadFileTool.Parent = tabPage4_ftp;
m_frmDownloadFileTool.Dock = DockStyle.Fill;
m_frmDownloadFileTool.Show();
}
m_frmDownloadFileTool.initialDownloadinfo_Invoice(null);
}
//= new UcHaEdiImport()
private void initialHaEdiImport()
{
if (m_ucHaEdiImport == null)
{
m_ucHaEdiImport = new UcHaEdiImport();
m_ucHaEdiImport.Parent = tabPage5_EdiHA;
m_ucHaEdiImport.Dock = DockStyle.Fill;
m_ucHaEdiImport.Show();
}
// m_frmDownloadFileTool.initialDownloadinfo_BC(this.toolStripStatusLabel5_BcState);
}
private void backgroundWorker3_download_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
//
m_isbusy_downloadfile = false;
}
private void UpdateDownloadStatus(string info)
{
try
{
toolStripStatusLabel2.Text = info;
}
catch (Exception)
{
// ; throw;
}
}
private void tabControl1_TabIndexChanged(object sender, EventArgs e)
{
}
private void tabControl1_Selected(object sender, TabControlEventArgs e)
{
if (tabControl1.SelectedTab == tabPage4_ftp)
{
if (m_frmDownloadFileTool == null)
{
m_frmDownloadFileTool = new frmDownloadFileTool();
m_frmDownloadFileTool.Parent = tabPage4_ftp;
m_frmDownloadFileTool.Dock = DockStyle.Fill;
m_frmDownloadFileTool.Show();
}
}
}
/// <summary>
/// 收件箱邮件的当前邮件的目标路径
/// </summary>
/// <param name="mailid"></param>
/// <returns></returns>
private static string GetMailInBoxTargetPath(string mailid)
{
string basepath = System.AppDomain.CurrentDomain.BaseDirectory;
string targetpath = Path.Combine(Directory.GetParent(basepath).Parent.FullName, "data");
if (!Directory.Exists(targetpath))
{
Directory.CreateDirectory(targetpath);
}
//
targetpath = Path.Combine(targetpath, frmMailSet.MailconfigSet().MailAddress + "\\mailIn");
if (!Directory.Exists(targetpath))
{
Directory.CreateDirectory(targetpath);
}
targetpath = Path.Combine(targetpath, mailid);
if (!Directory.Exists(targetpath))
{
Directory.CreateDirectory(targetpath);
}
return targetpath;
}
/// <summary>
/// 返回邮件的附件存储的位置路径
/// </summary>
/// <param name="edimail"></param>
/// <returns></returns>
private string GetMailInBoxTargetPath(TOp_seae_edi_mail edimail)
{
string basepath = System.AppDomain.CurrentDomain.BaseDirectory;
string targetpath = Path.Combine(Directory.GetParent(basepath).Parent.FullName, "data");
if (!Directory.Exists(targetpath))
{
Directory.CreateDirectory(targetpath);
}
//
targetpath = Path.Combine(targetpath, edimail.F_18_mailAccount + "\\mailIn");
if (!Directory.Exists(targetpath))
{
Directory.CreateDirectory(targetpath);
}
targetpath = Path.Combine(targetpath, edimail.F_01_YJID);
if (!Directory.Exists(targetpath))
{
Directory.CreateDirectory(targetpath);
}
return targetpath;
}
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
clmGrdv1_mailContent.Visible = this.chkMailContentVisible.Checked;
}
private void button4_Click(object sender, EventArgs e)
{
}
private bool Do_WarnAnalyze()
{
bool isok = true;
try
{
string procedurename = "p_gen_sea_Origi_warntask";
IDataParameter[] iparas = new SqlParameter[1];
iparas[0] = new SqlParameter("@tskCount", SqlDbType.Int); //, 4, ParameterDirection.Output,false,null);
iparas[0].Direction = ParameterDirection.Output;
int i;
DbHelperSQL.RunProcedure(procedurename, iparas, out i);
try
{
toolStripStatusLabel5_warninfo.Text = string.Format("最新预警信息数:{0}", i);
}
catch (Exception ex)
{
;
}
}
catch (Exception ex)
{
isok = false;
LogHelper.WriteLog("获得预警信息发生错误:", ex.Message);
}
return isok;
}
private void timer2b_Warn_Tick(object sender, EventArgs e)
{
//30分钟执行一次预警分析任务
Do_WarnAnalyze();
}
/// <summary>
/// 删除超过3天的邮件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnDelServerMailOver3days_Click(object sender, EventArgs e)
{
//debug
if (m_isBusying_ReceiveMail)
{
MessageBox.Show("正在处理邮件,请稍后再试...");
return;
}
try
{
m_isBusying_ReceiveMail = true;
ReceiveMailTool.DeleteOver3daysMail(label5_delMailInfo);
}
finally
{
m_isBusying_ReceiveMail = false;
label5_delMailInfo.Visible = false;
}
}
private bool DeleteOver3daysMail()
{
//debug
if (m_isBusying_ReceiveMail)
{
return false ;
}
try
{
m_isBusying_ReceiveMail = true;
ReceiveMailTool.DeleteOver3daysMail(label5_delMailInfo,false);
}
finally
{
m_isBusying_ReceiveMail = false;
label5_delMailInfo.Visible = false;
}
return true;
}
private void btnSendQueRfresh_Click(object sender, EventArgs e)
{
bindTosendMailData();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
this.btn5ReSend.Visible = this.radioButton3_falur.Checked;
bindTosendMailData();
}
private void bindTosendMailData()
{
string sql = "select ROW_NUMBER() OVER(ORDER BY mail_no) as 行号 , * from t_op_seae_edi_tosend_mail ";
if (radioButton2.Checked)
{
sql += " where trytimes<3 ";
}
else if (radioButton3_falur.Checked)
{
sql += " where trytimes>=3; ";
}
DataTable DT = DbHelperSQL.QueryTable(sql);
dataGridView2_tosend.DataSource = DT;
}
/// <summary>
/// BC报文和邮件二次匹配处理的Timer事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer2_BcMailMatch2_Tick(object sender, EventArgs e)
{
BcMailMatch2();
}
/// <summary>
/// BC报文和邮件二次匹配
/// </summary>
private void BcMailMatch2()
{
//
DateTime dt = DateTime.Now;
DayOfWeek dw = dt.DayOfWeek;
bool isNeedLongCircle = true;
switch (dw)
{
case DayOfWeek.Friday:
case DayOfWeek.Monday:
case DayOfWeek.Tuesday:
case DayOfWeek.Wednesday:
//工作日白天 10分钟检查一次
int ihh = int.Parse(dt.ToString("HH"));
if (ihh <= 19 && ihh >= 8)
isNeedLongCircle = false;
break;
//
case DayOfWeek.Saturday:
case DayOfWeek.Sunday:
isNeedLongCircle = true;
break;
default:
isNeedLongCircle = true;
break;
}
int imm = int.Parse(dt.ToString("mm"));
if (isNeedLongCircle)
{
//判断区间,1小时内两个区间执行2此匹配,否则退出
//0~15,30~45
if ((imm >= 15 && imm < 30) || (imm >= 45 && imm < 60))
{
return;
}
}
//正常工作时间15分钟执行一次二次匹配,其他时间1小时两次匹配
string sql = @" update t_op_task set 文件编号=v.reportid,备注= case when t_op_task.备注 is null then 'bc报文2' else t_op_task.备注 end
from
(
select t.*,b.*,abs(DATEDIFF(MI,t.任务开始时间,b.lastmodi_date)) as dfminitue from t_op_task t,( select bc.ReportID, bc.lastmodi_date,bcf.F_RFF_BN from t_op_seae_ftpfile_bc bc, t_op_seae_edi_rp_iftmbc bcf where bc.fileType='IFTMBC'
and not exists(select * from t_op_task t where t.文件编号=bc.ReportID) and bc.ReportID=bcf.F_Base_ReportID
) b
where DATEDIFF(DAY,任务开始时间, GETDATE())<=3
and t.任务类型 in ('bc','BA','BCL') and isnull(文件编号,'')='' and 是否公共=0
and t.提单号=b.F_RFF_BN and abs(DATEDIFF(MI,t.任务开始时间,b.lastmodi_date))<3
) v where t_op_task.pl_id=v.pl_id and t_op_task.文件编号 is null and t_op_task.任务类型 in('BA','BC','BCL');";
try
{
//更新匹配前先获得要发送邮件和挂单的任务列表
DataTable dtBcPatch2SendMail = BcMatch2SendMailTable();
int i= DbHelperSQL.ExecuteSql(sql);
if (i > 0 && dtBcPatch2SendMail != null && dtBcPatch2SendMail.Rows.Count > 0)
{
//发邮件
//挂单
//结束任务
DealBcMatch2SendMailTable(dtBcPatch2SendMail);
}
}
catch (Exception ex)
{
LogHelper.WriteLog("BC报文--邮件二次匹配出错", ex.Message);
}
}
/// <summary>
/// 二次匹配后处理BC报文的自动发送
/// </summary>
/// <param name="dtOptsk"></param>
/// <returns></returns>
private bool DealBcMatch2SendMailTable(DataTable dtOptsk)
{
// pl_id 任务编号 任务类型 提单号 邮件编号 电子档案路径 是否公共 任务相关人员 SEA编号 操作人 是否完成 ReportID lastmodi_date F_RFF_BN dfminitue
//56617 6F53C05A-9B78-4395-B81C-5E1C6CE44E97 BA 586806156 147696 \\dev000\data\BA\201803\586806156\BA\586806156_20180330104458_DB_aabfccdajebi0x027C.pdf 0 田菲 915547 NULL 0 dcf6527a22e645d9a8c0d4c3826914ff 2018-03-15 22:47:00.000 586806156 19737
bool isok;
foreach (DataRow dr in dtOptsk.Rows)
{
string error = "";
TOP_Task optsk = new TOP_Task();
optsk.F_01RWBH = dr["任务编号"].ToString();
optsk.F_03RWLX = dr["任务类型"].ToString();
optsk.F_13TDH = dr["提单号"].ToString();
optsk.F_14WJBH = dr["文件编号"] == null ? "" : dr["文件编号"].ToString();
optsk.F_15YJBH = dr["邮件编号"].ToString();
optsk.F_16DZDALJ = dr["电子档案路径"] == null ? "" : dr["电子档案路径"].ToString();
optsk.F_17SFGG = dr["是否公共"].ToString() == "1" ? true : false;
optsk.F_18RWXGRY = dr["任务相关人员"] == null ? "" : dr["任务相关人员"].ToString();
optsk.F_19SEABH = dr["SEA编号"] == null ? "" : dr["SEA编号"].ToString();
optsk.F_21SFWC = dr["是否完成"].ToString() == "1" ? 1 : 0;
//判断BC业务是否匹配
// ----判断BC报文是否匹配记录大于0则成立
string sqlpre=@" select b.F_EXT_IsMatchBusiRemark from t_op_task t,t_op_seae_edi_rp_iftmbc b
where t.任务编号='{0}' and t.文件编号=b.F_Base_ReportID and b.F_EXT_IsMatchBusi=1";
string sql = string.Format(sqlpre, optsk.F_01RWBH);
try
{
DataTable dt = DbHelperSQL.QueryTable(sql);
if (dt == null || dt.Rows.Count < 1)
{
LogHelper.WriteLog("DealBcMatch2SendMailTable函数不能自动转发:BC报文不匹配", sql);
return false;
}
}
catch (Exception ex )
{
LogHelper.WriteLog("DealBcMatch2SendMailTable 函数错误1467",ex.Message);
LogHelper.WriteLog("DealBcMatch2SendMailTable 函数错误1467", sql);
return false;
}
//判断 不含msds关键字/合约号等于运费协议号/邮件方案不可为空
//委托单位
string wtdw = "";
sqlpre = @" select bn.F_HYH,s.运费协议号,s.客户邮件方案,s.委托单位 from t_op_task t, t_op_seae_edi_mail_bcinfo bn
, t_op_seae s where t.任务编号='{0}' and t.SEA编号=s.编号 and t.邮件编号=bn.F_Base_MailID
and bn.F_isMsds=0 and bn.F_HYH=s.运费协议号 and isnull(s.客户邮件方案,'')<>''";
sql = string.Format(sqlpre, optsk.F_01RWBH);
try
{
DataTable dt = DbHelperSQL.QueryTable(sql);
if (dt == null || dt.Rows.Count < 1)
{
LogHelper.WriteLog("DealBcMatch2SendMailTable函数不能自动转发:BC报文不满足不含msds关键字/合约号等于运费协议号/邮件方案不可为空)", sql);
return false;
}
wtdw = dt.Rows[0]["委托单位"]== DBNull.Value?"": dt.Rows[0]["委托单位"].ToString();
}
catch (Exception ex)
{
LogHelper.WriteLog("DealBcMatch2SendMailTable 函数错误1486", ex.Message);
LogHelper.WriteLog("DealBcMatch2SendMailTable 函数错误:不含msds关键字/合约号等于运费协议号/邮件方案不可为空", sql);
return false;
}
try
{
TOp_seae_edi_mail edimail = ftptool.GetEdiMail(optsk.F_15YJBH);
//读取邮件信息,然后转发
if (wtdw != "" && edimail != null)
{
//如果不自动转发BC邮件则是调试模式调试模式邮件全部发送到dev003且不挂单不结束任务
bool isdebugsend = false;
if (!frmAnalyzeMail.SendbyYJFang_an(wtdw, optsk, edimail,isdebugsend))
{
//
LogHelper.WriteLog(string.Format("二次匹配>文件编号:{0}/邮件编号:{1}BC类邮件自动转发失败", optsk.F_14WJBH, optsk.F_15YJBH), "自动转发邮件失败");
}
else
{
//调试,不自动发送bc邮件时不挂单 cjb 2018-04-02
// if (isdebugsend)
// {
// continue;
// }
//挂单路径
string tarpath;
//执行挂单
bool guadanok = true;
try
{
guadanok = GuadanTool.Guadan(optsk.F_13TDH, optsk.F_19SEABH, "入货通知", optsk.F_16DZDALJ, out tarpath, true);
}
catch (Exception ex)
{
LogHelper.WriteLog("2ci匹配后后挂单失败 :ftp 1534", ex.Message);
}
sql = string.Format("update t_op_task set 任务状态='已转发',是否完成=1,完成方式='自动', 操作人='DEMO-SA',完成时间=GETDATE() where 任务编号='{0}'", optsk.F_01RWBH);
try
{
DbHelperSQL.ExecuteSql(sql);
LogHelper.WriteLog("二次匹配后发邮件后,更新t_op_task状态OK: "+optsk.F_13TDH, sql);
}
catch (Exception ex)
{
LogHelper.WriteLog("二次匹配后发邮件后,更新t_op_task状态失败 frmAnalyzeMail", sql);
}
}//end if 发送成功
} // end --〉 (wtdw != ""&&edimail!=null)
}
catch (Exception ex )
{
LogHelper.WriteLog("二次匹配后发邮件后出错frmAnalyzeMail 1544--〉", ex.Message);
}
}
return true;
}
/// <summary>
/// 获取BC的二次匹配的待发邮件的datatable
/// </summary>
/// <returns></returns>
private DataTable BcMatch2SendMailTable()
{
DataTable dtToMail = null ;
try
{
//获得待发邮件的列表
// 增加检查已发送邮件中已经发送了该邮件(通过电子档案路径检查) cjb 2018-04-02
string sql = @"select t.pl_id, t.任务编号, t.任务类型, t.提单号 ,'' as 文件编号, t.邮件编号, t.电子档案路径, t.是否公共, t.任务相关人员, t.SEA编号, t.操作人, t.是否完成
,b.*,abs(DATEDIFF(MI,t.任务开始时间,b.lastmodi_date)) as dfminitue
from t_op_task t,
( select bc.ReportID, bc.lastmodi_date,bcf.F_RFF_BN from t_op_seae_ftpfile_bc bc, t_op_seae_edi_rp_iftmbc bcf where bc.fileType='IFTMBC'
and not exists(select 文件编号 from t_op_task t where t.文件编号=bc.ReportID) and bc.ReportID=bcf.F_Base_ReportID
) b
where DATEDIFF(DAY,任务开始时间, GETDATE())<=3
and t.任务类型='BC' and isnull(文件编号,'')='' and t.是否完成=0 and 是否公共=0
and t.提单号=b.F_RFF_BN and abs(DATEDIFF(MI,t.任务开始时间,b.lastmodi_date))<3
and not exists(select * from t_op_seae_edi_send_mailbox m where DATEDIFF(DAY,m.createdate, GETDATE())<1 and cast(t.电子档案路径 as varchar(200)) =cast(m.attachment as varchar(200)))";
dtToMail = DbHelperSQL.QueryTable(sql);
}
catch (Exception ex )
{
LogHelper.WriteLog("BcPatch2SendMailTable的sql语句执行失败", ex.Message);
}
return dtToMail;
}
/// <summary>
/// 程序已运行时间时钟事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer9_calcRuntime_Tick(object sender, EventArgs e)
{
RefreshRuntime();
}
private void RefreshRuntime()
{
TimeSpan ts = new TimeSpan();
ts = DateTime.Now - m_AppStartRunTime;
this.Text = m_AppTitle+ "(已运行:"+ ts.Days + "天" + ts.Hours + "小时" + ts.Minutes + "分" + ts.Seconds + "秒)";
}
private void btn5ReSend_Click(object sender, EventArgs e)
{
if (this.dataGridView2_tosend.SelectedRows.Count < 1)
return;
string xhs = "";
if (MessageBox.Show("您确实要重新发送当前选中的记录吗", "信息提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
int icount = dataGridView2_tosend.SelectedRows.Count;
for (int i = 0; i < icount; i++)
{
if (i == 0)
xhs = dataGridView2_tosend.SelectedRows[i].Cells[0].Value.ToString();
else
xhs += "," + dataGridView2_tosend.SelectedRows[i].Cells[0].Value.ToString();
}
string sql = "update t_op_seae_edi_tosend_mail set trytimes=0 where mail_no in (" + xhs + ")";
try
{
DbHelperSQL.ExecuteSql(sql);
bindTosendMailData();
}
catch (Exception ex)
{
MessageBox.Show("发生错误" + ex.Message, "信息提示", MessageBoxButtons.OK);
}
}
}
private void button5_Click_1(object sender, EventArgs e)
{
}
private void button4_Click_1(object sender, EventArgs e)
{
//AnalyzeMscBcMailBusinestext();
// System.Windows.Forms.MessageBox.Show("aaa");
// HAEdiXmlAnalyzeTool hntool = new HAEdiXmlAnalyzeTool();
// TOp_seae_edi_rp_iftmbc edi_rp_iftmbc = new TOp_seae_edi_rp_iftmbc();
// List<TOP_EDI_CTN_HACS> ctnlist = new List<TOP_EDI_CTN_HACS>();
// StringBuilder blderrorinfo = new StringBuilder();
//// bool isok = hntool.AnalyzeHAEdi("1.xml", edi_rp_iftmbc, ctnlist, blderrorinfo);
// bool hasMSDS = false;
// //含有的MSDS关键字(不超过)
// string msds_keyword = "";
// TOp_seae_edi_mail_bcinfo bcinfo = new TOp_seae_edi_mail_bcinfo();
// bool isok = AnalizeMailBcPDF("d:\\2.pdf", bcinfo, out hasMSDS, out msds_keyword);
}
}//class
class MessageKeyValue
{
public string messageid;
public OpenPop.Mime.Message message;
}
}//namespace