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取代