static void CrashReport(string strText) { // MainForm main_form = Form.ActiveForm as MainForm; MessageBar _messageBar = null; _messageBar = new MessageBar(); _messageBar.TopMost = false; //_messageBar.BackColor = SystemColors.Info; //_messageBar.ForeColor = SystemColors.InfoText; _messageBar.Text = "dp2Circulation 出现异常"; _messageBar.MessageText = "正在向 dp2003.com 发送异常报告 ..."; _messageBar.StartPosition = FormStartPosition.CenterScreen; _messageBar.Show(_mainForm); _messageBar.Update(); int nRet = 0; string strError = ""; try { string strSender = ""; if (_mainForm != null) { strSender = _mainForm.GetCurrentUserName() + "@" + _mainForm.ServerUID; } // 崩溃报告 nRet = LibraryChannel.CrashReport( strSender, "dp2circulation", strText, out strError); } catch (Exception ex) { strError = "CrashReport() 过程出现异常: " + ExceptionUtil.GetDebugText(ex); nRet = -1; } finally { _messageBar.Close(); _messageBar = null; } if (nRet == -1) { strError = "向 dp2003.com 发送异常报告时出错,未能发送成功。详细情况: " + strError; MessageBox.Show(_mainForm, strError); // 写入错误日志 if (_mainForm != null) { _mainForm.WriteErrorLog(strError); } else { WriteWindowsLog(strError, EventLogEntryType.Error); } } }
// 2015/9/15 public static void EnvironmentReport(MainForm mainForm) { #if NO MessageBar _messageBar = null; _messageBar = new MessageBar(); _messageBar.TopMost = false; //_messageBar.BackColor = SystemColors.Info; //_messageBar.ForeColor = SystemColors.InfoText; _messageBar.Text = "dp2Circulation 出现异常"; _messageBar.MessageText = "正在向 dp2003.com 发送异常报告 ..."; _messageBar.StartPosition = FormStartPosition.CenterScreen; _messageBar.Show(_mainForm); _messageBar.Update(); #endif int nRet = 0; string strError = ""; try { string strSender = ""; if (mainForm != null) { strSender = mainForm.GetCurrentUserName() + "@" + mainForm.ServerUID; } // 崩溃报告 nRet = LibraryChannel.CrashReport( strSender, "dp2circulation 环境报告", GetEnvironmentDescription().Replace("\t", " "), out strError); } catch (Exception ex) { strError = "CrashReport() 过程出现异常: " + ExceptionUtil.GetDebugText(ex); nRet = -1; } finally { #if NO _messageBar.Close(); _messageBar = null; #endif } #if NO if (nRet == -1) { strError = "向 dp2003.com 发送异常报告时出错,未能发送成功。详细情况: " + strError; MessageBox.Show(_mainForm, strError); // 写入错误日志 if (_mainForm != null) { _mainForm.WriteErrorLog(strError); } else { WriteWindowsLog(strError, EventLogEntryType.Error); } } #endif }
// 2015/9/15 public static void EnvironmentReport(MainForm mainForm) { #if NO MessageBar _messageBar = null; _messageBar = new MessageBar(); _messageBar.TopMost = false; //_messageBar.BackColor = SystemColors.Info; //_messageBar.ForeColor = SystemColors.InfoText; _messageBar.Text = "dp2Circulation 出现异常"; _messageBar.MessageText = "正在向 dp2003.com 发送异常报告 ..."; _messageBar.StartPosition = FormStartPosition.CenterScreen; _messageBar.Show(_mainForm); _messageBar.Update(); #endif int nRet = 0; string strError = ""; try { string strSender = ""; if (mainForm != null) strSender = mainForm.GetCurrentUserName() + "@" + mainForm.ServerUID; // 崩溃报告 nRet = LibraryChannel.CrashReport( strSender, "dp2circulation 环境报告", GetEnvironmentDescription().Replace("\t", " "), out strError); } catch (Exception ex) { strError = "CrashReport() 过程出现异常: " + ExceptionUtil.GetDebugText(ex); nRet = -1; } finally { #if NO _messageBar.Close(); _messageBar = null; #endif } #if NO if (nRet == -1) { strError = "向 dp2003.com 发送异常报告时出错,未能发送成功。详细情况: " + strError; MessageBox.Show(_mainForm, strError); // 写入错误日志 if (_mainForm != null) _mainForm.WriteErrorLog(strError); else WriteWindowsLog(strError, EventLogEntryType.Error); } #endif }