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; } } }