From 3f718bb228e697ce2b95310eb5c58040ef5d18b7 Mon Sep 17 00:00:00 2001 From: "LAPTOP-6U09CO6D\\User" Date: Thu, 9 Feb 2023 12:07:17 +0800 Subject: [PATCH] =?UTF-8?q?feature:=E6=A0=B9=E6=93=9Aniagara=E6=9B=B4?= =?UTF-8?q?=E6=96=B0device=5Fitem=20is=5Fshow=5Fhistory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeController.cs | 1 + .../NiagaraDataSynchronizeRepository.cs | 36 +++++++++++++++++-- .../INiagaraDataSynchronizeRepository.cs | 2 ++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index b1f5206..60e02b0 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -149,6 +149,7 @@ namespace Backend.Controllers await niagaraDataSynchronizeRepository.DeviceItemComparison(); await niagaraDataSynchronizeRepository.CheckItemDiffFullNameAndCover(); await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName(); + await niagaraDataSynchronizeRepository.CheckItemIsShowHistory(); result = true; apiResult.Code = "0000"; diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index dddc9da..b1c5a91 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -512,8 +512,6 @@ namespace Repository.BackendRepository.Implement /// public async Task CheckFullNameEmptyReplaceByDeviceName() { - - using (IDbConnection conn = GetDbConnection()) { conn.Open(); @@ -534,7 +532,6 @@ namespace Repository.BackendRepository.Implement conn.Close(); } } - } } @@ -637,7 +634,40 @@ namespace Repository.BackendRepository.Implement conn.Close(); } } + } + } + /// + /// 先將device_ite的is_show_history全部關掉 + /// 根據niagara輸入資料來決定要開哪些點 + /// + /// + public async Task CheckItemIsShowHistory() + { + //先將所有is_show_history關閉,niagara有的才開啟 + using (IDbConnection conn = GetDbConnection()) + { + conn.Open(); + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + try + { + StringBuilder sb = new StringBuilder(); + //先全部關閉 + sb.Append("update device_item set is_show_history=0;"); + sb.Append("update device_item set is_show_history= 1" + + "(select distinct device_system_tag, device_name_tag, device_point_name From import_niagara_item);"); + await conn.ExecuteAsync(sb.ToString()); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + } } } } diff --git a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs index 5629b9c..e9bdf44 100644 --- a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs @@ -31,6 +31,8 @@ namespace Repository.BackendRepository.Interface /// Task CheckDiffFullNameAndCover(); + Task CheckItemIsShowHistory(); + /// /// 比對 device的FullName,若為空則以DeviceName取代