From 0db40ce635980ca03b3ce58d92bdc01c11ad885c Mon Sep 17 00:00:00 2001 From: "LAPTOP-6U09CO6D\\User" Date: Tue, 7 Feb 2023 17:55:29 +0800 Subject: [PATCH] =?UTF-8?q?refactor:device=5Fitem=E6=AA=A2=E6=9F=A5full=5F?= =?UTF-8?q?name=E7=82=BA=E7=A9=BA,=E4=BB=A5points=E6=9B=BF=E4=BB=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeController.cs | 1 + .../NiagaraDataSynchronizeRepository.cs | 34 +++++++++++++++++-- .../INiagaraDataSynchronizeRepository.cs | 2 ++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index c175fd5..77e2cdb 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -146,6 +146,7 @@ namespace Backend.Controllers var building = ds.FirstOrDefault().device_building_tag; await niagaraDataSynchronizeRepository.InsertItemFromNiagara(ds, building); await niagaraDataSynchronizeRepository.DeviceItemComparison(); + await niagaraDataSynchronizeRepository.ItemCheckFullNameEmptyReplaceByDeviceName(); result = true; apiResult.Code = "0000"; diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index ebb1530..116ec37 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -500,7 +500,7 @@ namespace Repository.BackendRepository.Implement throw exception; } finally - { + { conn.Close(); } } @@ -520,7 +520,37 @@ namespace Repository.BackendRepository.Implement try { StringBuilder sb = new StringBuilder(); - sb.Append("update bims_mitsubishi.device set full_name=device_number where full_Name='';"); + sb.Append("update device set full_name=device_number where full_Name='';"); + await conn.ExecuteAsync(sb.ToString()); + } + catch (Exception exception) + { + throw exception; + } + finally + { + conn.Close(); + } + } + + } + } + + /// + /// 檢查device_item內FullName為空的值,以points取代 + /// + /// + public async Task ItemCheckFullNameEmptyReplaceByDeviceName() + { + using (IDbConnection conn = GetDbConnection()) + { + conn.Open(); + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + try + { + StringBuilder sb = new StringBuilder(); + sb.Append("update device_item set full_name = points where full_Name = '''''';"); await conn.ExecuteAsync(sb.ToString()); } catch (Exception exception) diff --git a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs index 90b440c..f079975 100644 --- a/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Interface/INiagaraDataSynchronizeRepository.cs @@ -36,6 +36,8 @@ namespace Repository.BackendRepository.Interface /// /// Task DeviceItemComparison(); + + Task ItemCheckFullNameEmptyReplaceByDeviceName(); /// /// 新增資料至 buildingMenu ///