/// <summary> /// Alarm Menu Item Click Event. /// </summary> private void AlarmMenuItem2_Click(object sender, EventArgs e) { try { var data = new DataTable(); var colors = new Dictionary <Int32, Excel.Color>(); data.Columns.Add("序号", typeof(String)); data.Columns.Add("告警标识", typeof(String)); data.Columns.Add("所属地区", typeof(String)); data.Columns.Add("所属县市", typeof(String)); data.Columns.Add("所属局站", typeof(String)); data.Columns.Add("所属设备", typeof(String)); data.Columns.Add("测点编号", typeof(String)); data.Columns.Add("测点名称", typeof(String)); data.Columns.Add("告警描述", typeof(String)); data.Columns.Add("告警级别", typeof(String)); data.Columns.Add("告警时间", typeof(String)); data.Columns.Add("结束时间", typeof(String)); data.Columns.Add("告警历时", typeof(String)); data.Columns.Add("处理标识", typeof(String)); data.Columns.Add("处理时间", typeof(String)); data.Columns.Add("处理人员", typeof(String)); for (var i = 0; i < CurAlarms.Count; i++) { var dr = data.NewRow(); dr["序号"] = i + 1; dr["告警标识"] = CurAlarms[i].SerialNO.ToString(); dr["所属地区"] = CurAlarms[i].Area2Name; dr["所属县市"] = CurAlarms[i].Area3Name; dr["所属局站"] = CurAlarms[i].StaName; dr["所属设备"] = CurAlarms[i].DevName; dr["测点编号"] = CurAlarms[i].NodeID.ToString(); dr["测点名称"] = CurAlarms[i].NodeName; dr["告警描述"] = CurAlarms[i].AlarmDesc; dr["告警级别"] = ((Int32)CurAlarms[i].AlarmLevel).ToString(); dr["告警时间"] = Common.GetDateTimeString(CurAlarms[i].StartTime); dr["结束时间"] = Common.GetDateTimeString(CurAlarms[i].EndTime); dr["告警历时"] = Common.GetTimeInterval(CurAlarms[i].StartTime, CurAlarms[i].EndTime); dr["处理标识"] = Common.GetConfirmMarkingName(CurAlarms[i].ConfirmMarking); dr["处理时间"] = Common.GetDateTimeString(CurAlarms[i].ConfirmTime); dr["处理人员"] = CurAlarms[i].ConfirmName; data.Rows.Add(dr); if (AlarmMenuItem1.Checked) { colors[i] = Common.GetExcelAlarmColor(CurAlarms[i].AlarmLevel); } } Common.ExportDataToExcel(null, "历史告警信息", "智能门禁管理系统 历史告警信息报表", String.Format("操作员:{0}{1} 日期:{2}", Common.CurUser.UserName, String.IsNullOrWhiteSpace(Common.CurUser.RemarkName) ? String.Empty : String.Format("({0})", Common.CurUser.RemarkName), Common.GetDateTimeString(DateTime.Now)), data, colors); } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.HisAlarmForm.AlarmMenuItem2.Click", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }