From 5261de75e2d394826c27c916f8f7a1426626a696 Mon Sep 17 00:00:00 2001 From: keke Date: Tue, 22 Aug 2023 09:58:02 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E6=96=B0=E5=A2=9E=20log?= =?UTF-8?q?=20=E6=9C=83=E8=BC=B8=E5=87=BA=20exception=20=E7=9A=84=20error?= =?UTF-8?q?=20track=20import=5Fniagara=5Ftag=20=E7=9A=84=20insert=20?= =?UTF-8?q?=E6=8C=87=E4=BB=A4=E4=BF=AE=E6=94=B9=E7=82=BA=E6=AF=8F=20100=20?= =?UTF-8?q?=E7=AD=86=E5=9F=B7=E8=A1=8C=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NiagaraDataSynchronizeController.cs | 6 +++--- Backend/appsettings.json | 3 ++- .../NiagaraDataSynchronizeRepository.cs | 19 ++++++++++++++++--- 3 files changed, 21 insertions(+), 7 deletions(-) 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