コード例 #1
0
        /// <summary>
        /// Export Data To Text.
        /// </summary>
        private void ExportBtn_Click(object sender, EventArgs e)
        {
            try {
                if (GridLogs.Count > 0)
                {
                    var logText = new StringBuilder();
                    foreach (var log in GridLogs)
                    {
                        logText.AppendLine("=======================================================================================");
                        logText.AppendLine(String.Format("日志编号: {0}", log.EventId));
                        logText.AppendLine(String.Format("日志时间: {0}", Common.GetDateTimeString(log.EventTime)));
                        logText.AppendLine(String.Format("日志类型: {0}", ComUtility.GetLogTypeText(log.EventType)));
                        logText.AppendLine(String.Format("触发对象: {0}", log.Operator));
                        logText.AppendLine(String.Format("触发来源: {0}", log.Source));
                        logText.AppendLine(String.Format("日志描述: {0}", log.Message));
                        logText.AppendLine(String.Format("详细信息: {0}", log.StackTrace));
                        logText.AppendLine();
                    }

                    Common.ExportDataToText(null, "智能门禁管理系统 系统日志", logText.ToString());
                }
            } catch (Exception err) {
                Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.LogManagerForm.ExportBtn.Click", err.Message, err.StackTrace);
                MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }