diff --git a/FrontendWebApi/ApiControllers/AlertController.cs b/FrontendWebApi/ApiControllers/AlertController.cs index 5f752fa..1264492 100644 --- a/FrontendWebApi/ApiControllers/AlertController.cs +++ b/FrontendWebApi/ApiControllers/AlertController.cs @@ -113,7 +113,7 @@ namespace FrontendWebApi.ApiControllers foreach (var a in alerts) { var sqlString = $@"select formId from operation_record where error_code = @error_code"; - var formId = backendRepository.GetOneAsync(sqlString, new { @error_code = a.error_code }); + var formId = backendRepository.GetOneAsync(sqlString, new { @error_code = a.uuid }); RowPosition += 1; row = sheet.CreateRow(RowPosition); for (var i = 0; i < 8; i++) @@ -121,11 +121,11 @@ namespace FrontendWebApi.ApiControllers cell = row.CreateCell(i); if (i == 0) { - cell.SetCellValue(a.building_tag + a.floor_tag); + cell.SetCellValue(a.buildingFloorName); } if (i == 1) { - cell.SetCellValue(a.error_code); + cell.SetCellValue(a.uuid); } if (i == 2) { @@ -133,19 +133,19 @@ namespace FrontendWebApi.ApiControllers } if (i == 3) { - cell.SetCellValue(a.error_type); + cell.SetCellValue(a.alarmClass); } if (i == 4) { - cell.SetCellValue(a.device_number); + cell.SetCellValue(a.sourceName_zh); } if (i == 5) { - cell.SetCellValue(a.error_reason); + cell.SetCellValue(a.msgText); } if (i == 6) { - cell.SetCellValue(a.ACKconfirm); + cell.SetCellValue(a.ackState_zh); } if (i == 7) { @@ -178,8 +178,8 @@ namespace FrontendWebApi.ApiControllers { foreach(var a in alerts) { - var sqlString = $@"select * from operation_record where error_code = @error_code"; - var formId = await backendRepository.GetOneAsync(sqlString, new { @error_code = a.error_code }); + var sqlString = $@"select formId from operation_record where error_code = @error_code"; + var formId = await backendRepository.GetOneAsync(sqlString, new { @error_code = a.uuid }); a.formId = formId; } } diff --git a/FrontendWebApi/Models/Alert.cs b/FrontendWebApi/Models/Alert.cs index b287da2..d09c89c 100644 --- a/FrontendWebApi/Models/Alert.cs +++ b/FrontendWebApi/Models/Alert.cs @@ -1,14 +1,32 @@ -namespace FrontendWebApi.Models +using System; +using System.Collections.Generic; + +namespace FrontendWebApi.Models { - public class Alert : Actor + public class Alert { - public string building_tag { get; set; } - public string floor_tag { get; set; } - public string error_code { get; set; } - public string error_type { get; set; } - public string device_number { get; set; } - public string error_reason { get; set; } - public string ACKconfirm { get; set; } + public string buildingFloorName { get; set; } //building_name and floor_name + public string uuid { get; set; } //error_code + public string alarmClass { get; set; } //error_type + public string msgText { get; set; } //error_reason + public string sourceName_zh { get; set; } //device_number + public string ackState { get; set; } //ACKconfirm: Acked/Unacked + public DateTime timestamp { get; set; }//發生時間 occur time public string formId { get; set; } + public string ackState_zh + { + get + { + Dictionary name = new Dictionary() + { + { "Acked" , "確認" }, + { "Unacked" , "未確認" } + }; + return name[ackState]; + } + } + + public string created_at { get { return timestamp.ToString(); } set { } } + public string Created_at { get { return Convert.ToDateTime(created_at).ToString("yyyy-MM-dd HH:mm:ss"); } set { created_at = value; } } //發生時間顯示 } }