[後端] 新增 log 會輸出 exception 的 error track
import_niagara_tag 的 insert 指令修改為每 100 筆執行一次
This commit is contained in:
parent
3dcc506236
commit
5261de75e2
@ -131,7 +131,7 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
apiResult.Code = "9999";
|
apiResult.Code = "9999";
|
||||||
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
|
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message + Environment.NewLine + exception.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiResult;
|
return apiResult;
|
||||||
@ -176,7 +176,7 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
apiResult.Code = "9999";
|
apiResult.Code = "9999";
|
||||||
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
|
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message + Environment.NewLine + exception.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
//return apiResult;
|
//return apiResult;
|
||||||
@ -239,7 +239,7 @@ namespace Backend.Controllers
|
|||||||
{
|
{
|
||||||
apiResult.Code = "9999";
|
apiResult.Code = "9999";
|
||||||
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
|
apiResult.Msg = "【" + controllerName + "/" + actionName + "】" + exception.Message;
|
||||||
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
|
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message + Environment.NewLine + exception.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return apiResult;
|
return apiResult;
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
"Port": "js2LutKe+rdjzdxMPQUrvQ==",
|
||||||
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱
|
//"Database": "VJB2XC+lAtzuHObDGMVOAA==", //三菱
|
||||||
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
//"Database": "IgYBsgG2VLKKxFb64j7LOA==", //wsp
|
||||||
"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
|
//"Database": "7gWfmZ28HGIJZbxEbK+0yg==", //tpe_dome_dome
|
||||||
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
|
//"Database": "iuaY0h0+TWkir44/eZLDqw==", //tpe_dome_office
|
||||||
|
"Database": "+5RAiFLJVU+LRyDxF1K/pcLZaoZa4k/thZqF6xKoCag=", //dome_online_0821
|
||||||
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
"Root": "SzdxEgaJJ7tcTCrUl2zKsA==",
|
||||||
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
"Password": "FVAPxztxpY4gJJKQ/se4bQ=="
|
||||||
},
|
},
|
||||||
|
@ -36,6 +36,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
conn.Open();
|
conn.Open();
|
||||||
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
|
||||||
{
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach(var b in building)
|
foreach(var b in building)
|
||||||
@ -53,6 +54,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
`device_last_name_tag` varchar(50) DEFAULT NULL,
|
`device_last_name_tag` varchar(50) DEFAULT NULL,
|
||||||
`device_serial_tag` varchar(50) DEFAULT NULL,
|
`device_serial_tag` varchar(50) DEFAULT NULL,
|
||||||
`atDateTime` datetime(1) DEFAULT NULL,
|
`atDateTime` datetime(1) DEFAULT NULL,
|
||||||
|
`device_full_name` varchar(100) DEFAULT NULL,
|
||||||
`is_used` smallint(1) DEFAULT 0,
|
`is_used` smallint(1) DEFAULT 0,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;";
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;";
|
||||||
@ -72,8 +74,9 @@ namespace Repository.BackendRepository.Implement
|
|||||||
displayName = x.Key.displayName2
|
displayName = x.Key.displayName2
|
||||||
});
|
});
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
// StringBuilder sb = new StringBuilder();
|
||||||
bool isDome = false; //是否為巨蛋案
|
bool isDome = false; //是否為巨蛋案
|
||||||
|
int count = 0;
|
||||||
foreach (var row in ds2)
|
foreach (var row in ds2)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(row.tag_name)) continue;
|
if (string.IsNullOrEmpty(row.tag_name)) continue;
|
||||||
@ -116,13 +119,22 @@ namespace Repository.BackendRepository.Implement
|
|||||||
arrTag[4] + "', '" + //device_serial_tag
|
arrTag[4] + "', '" + //device_serial_tag
|
||||||
row.displayName + "', " + //device_full_name
|
row.displayName + "', " + //device_full_name
|
||||||
"now());"); //atDateTime
|
"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)
|
if (sb.Length > 0)
|
||||||
{
|
{
|
||||||
await conn.ExecuteAsync(sb.ToString());
|
var temp = sb.ToString();
|
||||||
|
await conn.ExecuteAsync(temp);
|
||||||
sb.Clear();
|
sb.Clear();
|
||||||
|
|
||||||
//巨蛋特殊處理
|
//巨蛋特殊處理
|
||||||
@ -142,6 +154,7 @@ namespace Repository.BackendRepository.Implement
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(sb.ToString());
|
||||||
throw exception;
|
throw exception;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
Loading…
Reference in New Issue
Block a user