[後端] 調整同步流程
This commit is contained in:
parent
cd83cf2133
commit
2cb01620ec
@ -526,54 +526,26 @@ namespace Repository.BackendRepository.Implement
|
|||||||
stopwatchSection.Start();
|
stopwatchSection.Start();
|
||||||
foreach (var data in result2)
|
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 + "'");
|
||||||
var sqlString = new StringBuilder();
|
var dk = (await conn.QueryAsync<device_kind>(sqlString.ToString())).ToList<device_kind>();
|
||||||
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<device_kind>(sqlString.ToString())).ToList<device_kind>();
|
|
||||||
|
|
||||||
if (dk.Count == 0)
|
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
|
|
||||||
{
|
{
|
||||||
var sqlString = new StringBuilder();
|
sb2.Append($@"INSERT device_kind (device_kind_guid, device_building_tag, device_system_tag, device_name_tag,
|
||||||
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 + "'");
|
device_normal_flashing, device_close_flashing, device_error_flashing, device_error_independent,
|
||||||
var dk = (await conn.QueryAsync<device_kind>(sqlString.ToString())).ToList<device_kind>();
|
created_by, created_at, is_link)
|
||||||
|
VALUES (uuid(), '" + data.device_building_tag + "', '" + data.device_system_tag + "', '" + data.device_name_tag +
|
||||||
if (dk.Count == 0)
|
"', 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,
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
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))
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
{
|
|
||||||
await conn.ExecuteAsync(sb2.ToString());
|
|
||||||
}
|
|
||||||
sb2.Clear();
|
|
||||||
count = 0;
|
|
||||||
}
|
}
|
||||||
|
sb2.Clear();
|
||||||
|
count = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user