diff --git a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs index 7397b26..b7b2885 100644 --- a/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs +++ b/FrontendWebApi/ApiControllers/EmergencyDeviceController.cs @@ -1,13 +1,17 @@ using FrontendWebApi.Models; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Repository.BackendRepository.Interface; using Repository.FrontendRepository.Interface; using System; using System.Collections.Generic; +using System.Data.SqlTypes; using System.Diagnostics; using System.Linq; +using System.Net.Sockets; +using System.Text; using System.Threading.Tasks; namespace FrontendWebApi.ApiControllers @@ -27,6 +31,51 @@ namespace FrontendWebApi.ApiControllers this.frontendRepository = frontendRepository; } + + [HttpPost("api/Send")] + public async Task>> SendMessageAsync(string message) + { + ApiResult> apiResult = new ApiResult>(); + var sqlString = "SELECT * from variable WHERE system_type = 'TcpClient'"; + var variables = await frontendRepository.GetAllAsync(sqlString); + var serverAddress = variables.Where(x => x.System_key == "Address").First().system_value; + var serverPort = int.Parse(variables.Where(x => x.System_key == "Port").First().system_value); + try + { + using (var client = new TcpClient()) + { + await client.ConnectAsync(serverAddress, serverPort); + using (var stream = client.GetStream()) + { + var data = Encoding.UTF8.GetBytes(message); + await stream.WriteAsync(data, 0, data.Length); + + //data = new byte[256]; + //var bytes = await stream.ReadAsync(data, 0, data.Length); + apiResult.Code = "0000"; + apiResult.Msg = "傳送指令, " + message; + return apiResult; + } + } + } + catch (SocketException ex) + { + apiResult.Code = "9999"; + apiResult.Msg = ex.Message; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + ex.Message); + + return apiResult; + } + catch (Exception ex) + { + apiResult.Code = "9999"; + apiResult.Msg = ex.Message; + Logger.LogError("【" + controllerName + "/" + actionName + "】" + ex.Message); + + return apiResult; + } + } + [HttpPost] [Route("api/DisasterList")] public async Task>>> DisasterList() @@ -155,7 +204,7 @@ namespace FrontendWebApi.ApiControllers WHERE d.deleted = 0 {deviceQue} ) d - left join floor on floor.full_name = d.device_floor_tag and floor.building_tag = d.device_building_tag + left join floor on floor.full_name = d.device_floor_tag and floor.building_tag = d.device_building_tag and floor.deleted = 0 left join ( SELECT v.*, diff --git a/FrontendWebApi/ApiControllers/WarningValueController.cs b/FrontendWebApi/ApiControllers/WarningValueController.cs index 46faf27..54111b9 100644 --- a/FrontendWebApi/ApiControllers/WarningValueController.cs +++ b/FrontendWebApi/ApiControllers/WarningValueController.cs @@ -93,7 +93,7 @@ namespace FrontendWebApi.ApiControllers XDocument xmlDoc = XDocument.Parse(resString); - if (xmlDoc?.Root?.Name?.LocalName == "str") + if (xmlDoc?.Root?.Name?.LocalName == "str" || xmlDoc?.Root?.Name?.LocalName == "bool") { result.targetValue = xmlDoc.Root.Attribute("val").Value; @@ -118,7 +118,7 @@ namespace FrontendWebApi.ApiControllers } /// - /// 取得警戒值 + /// 設定警戒值 /// /// /// diff --git a/FrontendWebApi/Models/WarningValue.cs b/FrontendWebApi/Models/WarningValue.cs index 6a17d6a..944bcb2 100644 --- a/FrontendWebApi/Models/WarningValue.cs +++ b/FrontendWebApi/Models/WarningValue.cs @@ -8,7 +8,8 @@ namespace FrontendWebApi.Models { public enum WarningValueType { Rain, //降雨 - Earthquake //地震 + Earthquake , //地震 + Infrared //紅外線 } public class WarningValueInput { diff --git a/FrontendWebApi/Views/EmergencyHardwareMenu/Index.cshtml b/FrontendWebApi/Views/EmergencyHardwareMenu/Index.cshtml index 2b5bda3..7a8c0d1 100644 --- a/FrontendWebApi/Views/EmergencyHardwareMenu/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyHardwareMenu/Index.cshtml @@ -616,6 +616,14 @@ } } ], + 'columnDefs': [ + // 隐藏第 7 列("alarm_timestamp" 列)和第 8 列(SOP 按钮列) + { + 'targets': [7, 8], + 'visible': false, + 'searchable': false + } + ], 'drawCallback': function () { $('#alarm-device-table tbody tr td').css('padding', '5px 8px 5px 8px'); }, diff --git a/FrontendWebApi/Views/EmergencyRecord/Index.cshtml b/FrontendWebApi/Views/EmergencyRecord/Index.cshtml index d2ff4f5..4b42cb0 100644 --- a/FrontendWebApi/Views/EmergencyRecord/Index.cshtml +++ b/FrontendWebApi/Views/EmergencyRecord/Index.cshtml @@ -1,12 +1,12 @@ @{ ViewData["MainNum"] = "4"; ViewData["SubNum"] = "4"; - ViewData["Title"] = "紀錄查詢"; + ViewData["Title"] = "事件查詢"; } @@ -17,7 +17,7 @@

- 紀錄查詢 + 事件查詢

@@ -273,11 +273,11 @@ } else if (val.finished == 1) { - val.type = "完成"; + val.finished = "完成"; } else { - val.type = "不執行"; + val.finished = "不執行"; } }) return data; @@ -406,7 +406,10 @@ $(this).parents().find('tr').css('background-color', '#fff'); $(this).css('background-color', '#67B4AC'); SelectEvent = $(this).attr('guid'); - $('#emergencyitem').find('.card-title').html("事件明細" + "-" + $(this).attr('type') + "-" + $(this).attr('device')); + var title = "事件明細" + "-" + $(this).attr('type') + if ($(this).attr('device') != undefined) { title += "-" + $(this).attr('device') } + $('#emergencyitem').find('.card-title').html(title); + // $('#emergencyitem').find('.card-title').html("事件明細" + "-" + $(this).attr('type') + "-" + $(this).attr('device')); EmergencyItemTable.ajax.reload(); $('#emergencyitem').show(); }) diff --git a/FrontendWebApi/Views/Shared/_Layout.cshtml b/FrontendWebApi/Views/Shared/_Layout.cshtml index b0e024e..cfe7dec 100644 --- a/FrontendWebApi/Views/Shared/_Layout.cshtml +++ b/FrontendWebApi/Views/Shared/_Layout.cshtml @@ -74,7 +74,6 @@ --> - @if (ViewBag.role.Contains("EmergencyDeviceMenuIndex") || ViewBag.role.Contains("EmergencyContactIndex") || ViewBag.role.Contains("EmergencyRecordIndex") @@ -94,7 +93,7 @@ 事件清單 - } + } @if (ViewBag.role.Contains("EmergencyHardwareIndex")) {
  • @@ -114,43 +113,43 @@ @if (ViewBag.role.Contains("EmergencyRecordIndex")) {
  • - - 紀錄查詢 + + 事件查詢
  • } - @if (ViewBag.role.Contains("RescueDeviceFireExtinguisher")) - { -
  • - - 滅火器設定 - -
  • - } - @if (ViewBag.role.Contains("RescueDeviceAED")) - { -
  • - - AED裝置設定 - -
  • - } + @*@if (ViewBag.role.Contains("RescueDeviceFireExtinguisher")) + { +
  • + + 滅火器設定 + +
  • + } + @if (ViewBag.role.Contains("RescueDeviceAED")) + { +
  • + + AED裝置設定 + +
  • + }*@ - + } - @if (ViewBag.role.Contains("WarningValueIndex")) + @if (ViewBag.role.Contains("WarningValueIndex")) { -
  • +
  • 警戒值設定 -
  • + } - +
    @@ -609,33 +608,33 @@
    @* - - Dr. Codex Lantern - - *@ + + Dr. Codex Lantern + + *@ @**@ + + + 個人資料 + 密碼修改 + + Fullscreen F11 Print Ctrl + P + + 登出 @fic +
    *@
    @@ -648,16 +647,16 @@ @@ -842,10 +841,10 @@ - +