/// <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); } }
/// <summary> /// Alarm GridView CellValue Needed Event. /// </summary> private void AlarmGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) { try { if (e.RowIndex > CurAlarms.Count - 1) { return; } switch (AlarmGridView.Columns[e.ColumnIndex].Name) { case "AIDColumn": e.Value = e.RowIndex + 1; AlarmGridView.Rows[e.RowIndex].DefaultCellStyle.BackColor = AlarmMenuItem1.Checked ? Common.GetLevelColor(CurAlarms[e.RowIndex].AlarmLevel) : Color.White; break; case "SerialNOColumn": e.Value = CurAlarms[e.RowIndex].SerialNO; break; case "Area2Column": e.Value = CurAlarms[e.RowIndex].Area2Name; break; case "Area3Column": e.Value = CurAlarms[e.RowIndex].Area3Name; break; case "StaNameColumn": e.Value = CurAlarms[e.RowIndex].StaName; break; case "DevNameColumn": e.Value = CurAlarms[e.RowIndex].DevName; break; case "NodeIDColumn": e.Value = CurAlarms[e.RowIndex].NodeID; break; case "NodeNameColumn": e.Value = CurAlarms[e.RowIndex].NodeName; break; case "AlarmDescColumn": e.Value = CurAlarms[e.RowIndex].AlarmDesc; break; case "AlarmLevelColumn": e.Value = (Int32)CurAlarms[e.RowIndex].AlarmLevel; break; case "AlarmTimeColumn": e.Value = Common.GetDateTimeString(CurAlarms[e.RowIndex].StartTime); break; case "EndTimeColumn": e.Value = Common.GetDateTimeString(CurAlarms[e.RowIndex].EndTime); break; case "AlarmIntervalColumn": e.Value = Common.GetTimeInterval(CurAlarms[e.RowIndex].StartTime, CurAlarms[e.RowIndex].EndTime); break; case "ConfirmMarkingColumn": e.Value = Common.GetConfirmMarkingName(CurAlarms[e.RowIndex].ConfirmMarking); break; case "ConfirmTimeColumn": e.Value = Common.GetDateTimeString(CurAlarms[e.RowIndex].ConfirmTime); break; case "ConfirmNameColumn": e.Value = CurAlarms[e.RowIndex].ConfirmName; break; default: break; } } catch (Exception err) { Common.WriteLog(DateTime.Now, EnmMsgType.Error, "System", "Delta.MPS.AccessSystem.HisAlarmForm.AlarmGridView.CellValueNeeded", err.Message, err.StackTrace); MessageBox.Show(err.Message, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }