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 ///