[後端] 修改transaction scope使用地方
This commit is contained in:
parent
0fe9c76acb
commit
bf1133311d
@ -22,8 +22,9 @@
|
||||
//"Database": "siTUcDaC/g2yGTMFWD72Kg==", //tpe_dome_hotel
|
||||
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
|
||||
//"Database": "Rq7Gn4x6LwBvVtl7GY8LbA==", //mcut
|
||||
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||
//"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||
//"Database": "2U+9jYGy0dCbMzLaguBXow==", //tpe_dome_mall
|
||||
"Database": "FbHCCU4CapG9UryANXC1W+iMe403Bd82RnA7bCNVbL0=", //ibms_dome_cinema,
|
||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||
},
|
||||
|
@ -35,8 +35,6 @@ namespace Repository.BackendRepository.Implement
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
try
|
||||
{
|
||||
@ -59,10 +57,16 @@ namespace Repository.BackendRepository.Implement
|
||||
`is_used` smallint(1) DEFAULT 0,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;";
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sql);
|
||||
}
|
||||
sql = "delete from import_niagara_tag where device_building_tag = '" + b + "' limit 10000";
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sql);
|
||||
}
|
||||
}
|
||||
|
||||
//N4資料groupBy後放入import_niagara_tag資料表
|
||||
var ds2 = ds.GroupBy(x => new
|
||||
@ -126,7 +130,10 @@ namespace Repository.BackendRepository.Implement
|
||||
if (count >= 100)
|
||||
{
|
||||
count = 0;
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
}
|
||||
}
|
||||
@ -135,7 +142,10 @@ namespace Repository.BackendRepository.Implement
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
var temp = sb.ToString();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(temp);
|
||||
}
|
||||
sb.Clear();
|
||||
|
||||
//巨蛋特殊處理
|
||||
@ -151,10 +161,13 @@ namespace Repository.BackendRepository.Implement
|
||||
set device_system_tag = b.s1_code -- tag 第二碼為小類(除了安全系統之外)
|
||||
where (device_system_tag <> 'S' and device_system_tag <> 'CWB' and device_system_tag <> 'B' and
|
||||
(device_system_tag <> 'FM' or device_system_tag <> 'APS' or device_system_tag <> 'VICL')); -- 安全系統 第二段大類 第四段小類");
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Console.WriteLine(sb.ToString());
|
||||
@ -166,7 +179,6 @@ namespace Repository.BackendRepository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 獲取照明開關 是否在 device_node 層
|
||||
@ -196,8 +208,6 @@ namespace Repository.BackendRepository.Implement
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
#region 刪除 import_niagara_item資料表中選取的棟別
|
||||
@ -215,10 +225,16 @@ namespace Repository.BackendRepository.Implement
|
||||
`full_name` varchar(50) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;";
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sql);
|
||||
}
|
||||
sql = "delete from import_niagara_item where device_building_tag = '" + b + "' limit 10000;";
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sql);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
ds = ds.GroupBy(x => new {
|
||||
device_area_tag = x.device_area_tag,
|
||||
@ -271,7 +287,10 @@ namespace Repository.BackendRepository.Implement
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
}
|
||||
#endregion
|
||||
@ -284,7 +303,7 @@ namespace Repository.BackendRepository.Implement
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@ -297,7 +316,6 @@ namespace Repository.BackendRepository.Implement
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope((TransactionScopeOption)TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<NiagaraTags> result;
|
||||
@ -489,6 +507,7 @@ namespace Repository.BackendRepository.Implement
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -502,8 +521,6 @@ namespace Repository.BackendRepository.Implement
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<NiagaraTagsForItem> result;
|
||||
@ -547,8 +564,11 @@ namespace Repository.BackendRepository.Implement
|
||||
"now(), now());");
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
}
|
||||
}
|
||||
@ -579,7 +599,10 @@ namespace Repository.BackendRepository.Implement
|
||||
|
||||
");
|
||||
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
|
||||
sb.Clear();
|
||||
sb.Append($@" SET SQL_SAFE_UPDATES = 0;
|
||||
@ -597,8 +620,11 @@ namespace Repository.BackendRepository.Implement
|
||||
SET d.is_show_history = CASE WHEN subquery.device_point_name IS NULL THEN 0 ELSE 1 END
|
||||
WHERE (d.is_show_history);");
|
||||
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
@ -609,7 +635,6 @@ namespace Repository.BackendRepository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增資料至 buildingMenu
|
||||
@ -620,8 +645,6 @@ namespace Repository.BackendRepository.Implement
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<NiagaraTags> result;
|
||||
@ -662,8 +685,11 @@ namespace Repository.BackendRepository.Implement
|
||||
#endregion
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
}
|
||||
}
|
||||
@ -677,8 +703,11 @@ namespace Repository.BackendRepository.Implement
|
||||
and a.device_system_tag COLLATE utf8mb4_0900_ai_ci = b.main_system_tag COLLATE utf8mb4_0900_ai_ci and a.device_name_tag COLLATE utf8mb4_0900_ai_ci = b.sub_system_tag COLLATE utf8mb4_0900_ai_ci
|
||||
SET b.is_link = 0
|
||||
WHERE a.device_building_tag IS NULL");
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
@ -689,7 +718,6 @@ namespace Repository.BackendRepository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增資料至 subSystemFloor
|
||||
@ -700,8 +728,6 @@ namespace Repository.BackendRepository.Implement
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
List<NiagaraTags> result;
|
||||
@ -738,8 +764,11 @@ namespace Repository.BackendRepository.Implement
|
||||
#endregion
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
}
|
||||
}
|
||||
@ -755,8 +784,12 @@ namespace Repository.BackendRepository.Implement
|
||||
and b.floor_tag COLLATE utf8mb4_0900_ai_ci = a.device_floor_tag COLLATE utf8mb4_0900_ai_ci
|
||||
SET b.is_link = 0
|
||||
WHERE b.building_tag IS NULL");
|
||||
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw exception;
|
||||
@ -767,7 +800,6 @@ namespace Repository.BackendRepository.Implement
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 檢查device內FullName為空的值,以device_Name取代
|
||||
/// </summary>
|
||||
@ -1123,8 +1155,6 @@ namespace Repository.BackendRepository.Implement
|
||||
using (IDbConnection conn = GetDbConnection())
|
||||
{
|
||||
conn.Open();
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
try
|
||||
{
|
||||
//改成每次都新增
|
||||
@ -1155,7 +1185,10 @@ CREATE TABLE `import_niagara_item_history` (
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 271 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;";
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sql);
|
||||
}
|
||||
|
||||
#region 刪除 import_niagara_item資料表中選取的棟別
|
||||
//foreach (var b in building)
|
||||
@ -1190,8 +1223,11 @@ device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, d
|
||||
sb.Append(ss);
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||
{
|
||||
await conn.ExecuteAsync(sb.ToString());
|
||||
}
|
||||
sb.Clear();
|
||||
}
|
||||
#endregion
|
||||
@ -1206,7 +1242,6 @@ device_floor_tag, device_master_tag, device_last_name_tag, device_serial_tag, d
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recover device_system_tag
|
||||
|
Loading…
Reference in New Issue
Block a user