From 9ad73b749bbd829161eb7412e4c92de995b72bc7 Mon Sep 17 00:00:00 2001 From: dev02 Date: Tue, 14 Nov 2023 12:20:04 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9sql=20?= =?UTF-8?q?execute=20over=20time=20problem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeRepository.cs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index a0acdbc..1531883 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -271,11 +271,28 @@ namespace Repository.BackendRepository.Implement row.full_name + "'," + "0" + ");"); + + if (sb.Length >= 100) + { + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } + + sb.Clear(); + } } var isDome = await GetOneAsync("select system_value from variable where deleted = 0 and system_type = 'project_name';"); if (sb.Length > 0) { + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } + + sb.Clear(); + if (isDome.Contains("ibms_dome")) { sb.Append($@" update import_niagara_item a @@ -283,8 +300,15 @@ namespace Repository.BackendRepository.Implement join variable v1 on b.system_parent_id = v1.id set device_system_tag = v1.system_value where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');"); + + using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) + { + await conn.ExecuteAsync(sb.ToString()); + } } + sb.Clear(); + sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;"); using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) {