diff --git a/Backend/Controllers/NiagaraDataSynchronizeController.cs b/Backend/Controllers/NiagaraDataSynchronizeController.cs index ebe5cd4..27a5a3c 100644 --- a/Backend/Controllers/NiagaraDataSynchronizeController.cs +++ b/Backend/Controllers/NiagaraDataSynchronizeController.cs @@ -131,7 +131,7 @@ namespace Backend.Controllers { apiResult.Code = "9999"; apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message + Environment.NewLine + exception.StackTrace); } return apiResult; @@ -176,7 +176,7 @@ namespace Backend.Controllers { apiResult.Code = "9999"; apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message + Environment.NewLine + exception.StackTrace); } //return apiResult; @@ -239,7 +239,7 @@ namespace Backend.Controllers { apiResult.Code = "9999"; apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message; - Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); + Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message + Environment.NewLine + exception.StackTrace); } return apiResult; diff --git a/Backend/appsettings.json b/Backend/appsettings.json index 57a78d7..d276a82 100644 --- a/Backend/appsettings.json +++ b/Backend/appsettings.json @@ -18,8 +18,9 @@ "Port": "js2LutKe+rdjzdxMPQUrvQ==", //"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱 //"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp - "Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome + //"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome //"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office + "Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821 "Root": "SzdxEgaJJ7tcTCrUl2zKsA==", "Password": "FVAPxztxpY4gJJKQ/se4bQ==" }, diff --git a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs index e5ddbd8..9800fce 100644 --- a/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs +++ b/Repository/BackendRepository/Implement/NiagaraDataSynchronizeRepository.cs @@ -36,6 +36,7 @@ namespace Repository.BackendRepository.Implement conn.Open(); using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { + StringBuilder sb = new StringBuilder(); try { foreach(var b in building) @@ -53,6 +54,7 @@ namespace Repository.BackendRepository.Implement `device_last_name_tag` varchar(50) DEFAULT NULL, `device_serial_tag` varchar(50) DEFAULT NULL, `atDateTime` datetime(1) DEFAULT NULL, + `device_full_name` varchar(100) DEFAULT NULL, `is_used` smallint(1) DEFAULT 0, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;"; @@ -72,8 +74,9 @@ namespace Repository.BackendRepository.Implement displayName = x.Key.displayName2 }); - StringBuilder sb = new StringBuilder(); + // StringBuilder sb = new StringBuilder(); bool isDome = false; //是否為巨蛋案 + int count = 0; foreach (var row in ds2) { if (string.IsNullOrEmpty(row.tag_name)) continue; @@ -116,13 +119,22 @@ namespace Repository.BackendRepository.Implement arrTag[4] + "', '" + //device_serial_tag row.displayName + "', " + //device_full_name "now());"); //atDateTime + //await conn.ExecuteAsync(sb.ToString()); + //sb.Clear(); + count += 1; + if (count >= 100) + { + count = 0; + await conn.ExecuteAsync(sb.ToString()); + sb.Clear(); + } } } - } if (sb.Length > 0) { - await conn.ExecuteAsync(sb.ToString()); + var temp = sb.ToString(); + await conn.ExecuteAsync(temp); sb.Clear(); //巨蛋特殊處理 @@ -142,6 +154,7 @@ namespace Repository.BackendRepository.Implement } catch (Exception exception) { + Console.WriteLine(sb.ToString()); throw exception; } finally