From 2a1e0d8575714b313a9755ced11b43f73dd7c3b8 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 10 Nov 2022 11:08:24 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AD=A6=E5=91=8Aexport?= =?UTF-8?q?=20excel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/AlertController.cs | 12 +++---- FrontendWebApi/Models/Alert.cs | 36 ++++++++++++++----- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/FrontendWebApi/ApiControllers/AlertController.cs b/FrontendWebApi/ApiControllers/AlertController.cs index 5f752fa..11be331 100644 --- a/FrontendWebApi/ApiControllers/AlertController.cs +++ b/FrontendWebApi/ApiControllers/AlertController.cs @@ -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) { 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; } } //發生時間顯示 } } From e7b1ca0fa58c95aabaa91842e3bc9018f29e67d2 Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 10 Nov 2022 11:15:06 +0800 Subject: [PATCH 2/4] fix parameter --- FrontendWebApi/ApiControllers/AlertController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/AlertController.cs b/FrontendWebApi/ApiControllers/AlertController.cs index 11be331..42917a8 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++) From fc89404cb03cfda87a6abeddd8dbbcb289e025eb Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 10 Nov 2022 11:29:00 +0800 Subject: [PATCH 3/4] fix parameter --- FrontendWebApi/ApiControllers/AlertController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/AlertController.cs b/FrontendWebApi/ApiControllers/AlertController.cs index 42917a8..b0f848b 100644 --- a/FrontendWebApi/ApiControllers/AlertController.cs +++ b/FrontendWebApi/ApiControllers/AlertController.cs @@ -179,7 +179,7 @@ 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 formId = await backendRepository.GetOneAsync(sqlString, new { @error_code = a.uuid }); a.formId = formId; } } From b3acc3212688b6ad5c6541681840c36259b1c8cd Mon Sep 17 00:00:00 2001 From: dev02 Date: Thu, 10 Nov 2022 11:30:06 +0800 Subject: [PATCH 4/4] fix column --- FrontendWebApi/ApiControllers/AlertController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrontendWebApi/ApiControllers/AlertController.cs b/FrontendWebApi/ApiControllers/AlertController.cs index b0f848b..1264492 100644 --- a/FrontendWebApi/ApiControllers/AlertController.cs +++ b/FrontendWebApi/ApiControllers/AlertController.cs @@ -178,7 +178,7 @@ namespace FrontendWebApi.ApiControllers { foreach(var a in alerts) { - var sqlString = $@"select * from operation_record where error_code = @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; }