diff --git a/FrontendWebApi/ApiControllers/DashboardController.cs b/FrontendWebApi/ApiControllers/DashboardController.cs index 7cc76f5..5e6d4ff 100644 --- a/FrontendWebApi/ApiControllers/DashboardController.cs +++ b/FrontendWebApi/ApiControllers/DashboardController.cs @@ -1,11 +1,13 @@ using FrontendWebApi.Models; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.Logging; using NPOI.SS.Formula.Functions; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System; +using System.Collections.Generic; using System.Data.SqlTypes; using System.IO; using System.Threading.Tasks; @@ -42,5 +44,27 @@ namespace FrontendWebApi.ApiControllers } return Ok(apiResult); } + + [HttpPost] + [Route("api/AlarmCard")] + public async Task>>> AlarmCard() + { + ApiResult> apiResult = new ApiResult>(); + try + { + var sqlString = $@"select * from v_alarm where isOpen = 1"; + var result = await backendRepository.GetAllAsync(sqlString); + + apiResult.Data = result; + apiResult.Code = "0000"; + } + catch (Exception exception) + { + apiResult.Code = "9999"; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + return Ok(apiResult); + } + return Ok(apiResult); + } } } diff --git a/FrontendWebApi/Models/AlarmRecord.cs b/FrontendWebApi/Models/AlarmRecord.cs index 25e3f0d..9a71033 100644 --- a/FrontendWebApi/Models/AlarmRecord.cs +++ b/FrontendWebApi/Models/AlarmRecord.cs @@ -1,4 +1,5 @@ -using System; +using NPOI.Util; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -56,4 +57,14 @@ namespace FrontendWebApi.Models public byte IsSolve { get;set;} public byte IsAck { get;set;} } + + public class VAlarmRecord + { + public DateTime timestamp { get; set; } + public int id { get; set; } + public int priority { get; set; } + public string alarmClass_txt { get; set; } + public string device_name { get; set; } + public string errMsg { get; set; } + } }