From 2cb01620ecf2b04956a606e9605d7dbafbbae2e5 Mon Sep 17 00:00:00 2001 From: dev02 Date: Wed, 22 Nov 2023 14:19:15 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E8=AA=BF=E6=95=B4?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeRepository.cs | 58 +++++-------------- 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index a7d4594..198b170 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -526,54 +526,26 @@ namespace Repository.BackendRepository.Implement stopwatchSection.Start(); foreach (var data in result2) { - if (data.device_system_tag.Equals("S") && data.device_name_tag.Equals("C")) - { - var sqlString = new StringBuilder(); - sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "' and device_model_tag = '" + data.device_model_tag + "'"); - var dk = (await conn.QueryAsync(sqlString.ToString())).ToList(); + var sqlString = new StringBuilder(); + sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "'"); + var dk = (await conn.QueryAsync(sqlString.ToString())).ToList(); - if (dk.Count == 0) - { - sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag, - device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent, - created_by, created_at, device_model_tag, is_link) - VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + - "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), '" + data.device_model_tag + "', 1);"); - count += 1; - if (count >= 100) - { - using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled)) - { - await conn.ExecuteAsync(sb2.ToString()); - } - sb2.Clear(); - count = 0; - } - } - } - else + if (dk.Count == 0) { - var sqlString = new StringBuilder(); - sqlString.Append("select * from device_kind where device_building_tag = '" + data.device_building_tag + "' and device_system_tag = '" + data.device_system_tag + "' and device_name_tag = '" + data.device_name_tag + "'"); - var dk = (await conn.QueryAsync(sqlString.ToString())).ToList(); - - if (dk.Count == 0) + sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag, + device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent, + created_by, created_at, is_link) + VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + + "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 1);"); + count += 1; + if (count >= 100) { - sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag, - device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent, - created_by, created_at, is_link) - VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag + - "', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), 1);"); - count += 1; - if (count >= 100) + using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled)) { - using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled)) - { - await conn.ExecuteAsync(sb2.ToString()); - } - sb2.Clear(); - count = 0; + await conn.ExecuteAsync(sb2.ToString()); } + sb2.Clear(); + count = 0; } } }