[後端] 修改同步修改device item 獲取資料
This commit is contained in:
parent
5931e057b0
commit
7ab418c7b1
@ -235,24 +235,23 @@ namespace Backend.Services.Implement
|
|||||||
|
|
||||||
result.Add(row);
|
result.Add(row);
|
||||||
}
|
}
|
||||||
else if (tagName.Split('_').Length == 6)
|
else if (tagName.Split('_').Length == 7)
|
||||||
{ //巨蛋 tag 5 段版本
|
{ //巨蛋 tag 5 段版本
|
||||||
ImpNiaItem row = new ImpNiaItem();
|
ImpNiaItem row = new ImpNiaItem();
|
||||||
if (tagName.Split('_')[1] == "S") //for security system
|
if (tagName.Split('_')[2] == "S" || tagName.Split('_')[2] == "B" || tagName.Split('_')[2] == "CWB") //for security system and parking system
|
||||||
{
|
{
|
||||||
row.device_building_tag = tagName.Split('_')[0];
|
row.device_building_tag = tagName.Split('_')[1];
|
||||||
row.device_system_tag = tagName.Split('_')[1];
|
row.device_system_tag = tagName.Split('_')[2];
|
||||||
row.device_floor_tag = tagName.Split('_')[2];
|
row.device_floor_tag = tagName.Split('_')[3];
|
||||||
row.device_name_tag = tagName.Split('_')[3];
|
row.device_name_tag = tagName.Split('_')[4];
|
||||||
row.device_point_name = tagName.Split('_')[5];
|
row.device_point_name = tagName.Split('_')[6];
|
||||||
}
|
}
|
||||||
else //for normal
|
else //for normal
|
||||||
{
|
{
|
||||||
row.device_building_tag = tagName.Split('_')[0];
|
row.device_building_tag = tagName.Split('_')[1];
|
||||||
//row.device_system_tag = tagName.Split('_')[1];
|
row.device_floor_tag = tagName.Split('_')[3];
|
||||||
row.device_floor_tag = tagName.Split('_')[2];
|
row.device_name_tag = tagName.Split('_')[2];
|
||||||
row.device_name_tag = tagName.Split('_')[1];
|
row.device_point_name = tagName.Split('_')[6];
|
||||||
row.device_point_name = tagName.Split('_')[5];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
row.parent_path = stationName;
|
row.parent_path = stationName;
|
||||||
@ -288,7 +287,7 @@ namespace Backend.Services.Implement
|
|||||||
}
|
}
|
||||||
else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
|
else if (n.name.Split('/').Length == 7) // Arena/D2/CWB/L110/CAP/D2_CWB_L110_CAP_MET1/Summery
|
||||||
{
|
{
|
||||||
if (n.name.Split('/')[3] == "S" || n.name.Split('/')[3] == "CWB") //for security system and CWB system
|
if (n.name.Split('/')[2] == "S" || n.name.Split('/')[2] == "B" || n.name.Split('/')[2] == "CWB") //for security system and CWB system
|
||||||
{
|
{
|
||||||
result.Add(new ImpNiaItem {
|
result.Add(new ImpNiaItem {
|
||||||
device_building_tag = n.name.Split('/')[1],
|
device_building_tag = n.name.Split('/')[1],
|
||||||
|
@ -283,7 +283,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
sb.Append($@" update import_niagara_item a join dic_system b
|
sb.Append($@" update import_niagara_item a join dic_system b
|
||||||
on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.s2_code COLLATE utf8mb4_0900_ai_ci
|
on a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.s2_code COLLATE utf8mb4_0900_ai_ci
|
||||||
set device_system_tag = b.s1_code
|
set device_system_tag = b.s1_code
|
||||||
where (device_system_tag <> 'S' and device_system_tag <> 'CWB');");
|
where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B');");
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;");
|
sb.Append($@" update import_niagara_item set full_name = device_point_name where full_name = '' or full_name is null;");
|
||||||
@ -315,7 +315,6 @@ namespace Repository.BackendRepository.Implement
|
|||||||
using (IDbConnection conn = GetDbConnection())
|
using (IDbConnection conn = GetDbConnection())
|
||||||
{
|
{
|
||||||
conn.Open();
|
conn.Open();
|
||||||
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<NiagaraTags> result;
|
List<NiagaraTags> result;
|
||||||
@ -374,8 +373,11 @@ namespace Repository.BackendRepository.Implement
|
|||||||
data.device_system_tag + "', 1, now(), now() );");
|
data.device_system_tag + "', 1, now(), now() );");
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count >= 100)
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@ -398,8 +400,11 @@ namespace Repository.BackendRepository.Implement
|
|||||||
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
|
"', 0, 0, 1, 0, 'B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now());");
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count >= 100)
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb2.ToString());
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
|
}
|
||||||
sb2.Clear();
|
sb2.Clear();
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@ -407,9 +412,12 @@ namespace Repository.BackendRepository.Implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sb.Length > 0)
|
if (sb.Length > 0)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
await conn.ExecuteAsync(sb2.ToString());
|
await conn.ExecuteAsync(sb2.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
sb2.Clear();
|
sb2.Clear();
|
||||||
@ -456,8 +464,11 @@ namespace Repository.BackendRepository.Implement
|
|||||||
"','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());");
|
"','B43E3CA7-96DD-4FC7-B6E6-974ACC3B0878', now(), now());");
|
||||||
count += 1;
|
count += 1;
|
||||||
if (count >= 100)
|
if (count >= 100)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
@ -465,8 +476,11 @@ namespace Repository.BackendRepository.Implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sb.Length > 0)
|
if (sb.Length > 0)
|
||||||
|
{
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,7 +496,10 @@ namespace Repository.BackendRepository.Implement
|
|||||||
) i ON d.device_number = i.niagara_tags
|
) i ON d.device_number = i.niagara_tags
|
||||||
SET d.is_link = 0
|
SET d.is_link = 0
|
||||||
WHERE d.is_link = 1 and i.niagara_tags is null;");
|
WHERE d.is_link = 1 and i.niagara_tags is null;");
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
|
|
||||||
@ -496,8 +513,12 @@ namespace Repository.BackendRepository.Implement
|
|||||||
) i ON dn.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
|
) i ON dn.device_number COLLATE utf8mb4_0900_ai_ci = i.niagara_tags COLLATE utf8mb4_0900_ai_ci
|
||||||
SET dn.is_link = 0
|
SET dn.is_link = 0
|
||||||
WHERE dn.is_link = 1 and i.niagara_tags is null;");
|
WHERE dn.is_link = 1 and i.niagara_tags is null;");
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||||
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
await conn.ExecuteAsync(sb.ToString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
//throw exception;
|
//throw exception;
|
||||||
@ -507,8 +528,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
{
|
{
|
||||||
conn.Close();
|
conn.Close();
|
||||||
}
|
}
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user