事件處理常式
當封裝執行失敗時,啟動事件處理常式。
全封裝任一動作執行失敗
當全封裝任一動作執行失敗時,將錯誤訊息寫入資料庫,並啟動 LINE Notify 通知。
Get ErrorSource, ErrorCode, ErrorDesc, Datetime Insert Into ErrorLog
目的:將錯誤來源、錯誤代號、錯誤詳細資以及發生時間訊寫入 ErrorLog Table 中。
ConnectType 屬性:OLE DB
Connection 屬性:Stock_API
SQLSourceType:直接輸入
運算式
屬性:SqlStatementSource
運算式
"INSERT INTO ErrorLog VALUES ('" + @[System::SourceName] +"', '" + (DT_WSTR, 50) @[System::ErrorCode] + "', '" + @[System::ErrorDescription] + "', GETDATE())"Send Error Msg to LINE Notify
目的:啟動 LINE Notify 通知
ReadOnlyVariables 屬性:
System::ErrorCode,System::ErrorDescription,System::SourceNameScript
// ......
public void Main()
{
// TODO: Add your code here
using (var wc = new WebClient())
{
var bearer = $"[Your LINE Notify Token]";
wc.Encoding = Encoding.UTF8;
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
wc.Headers.Add("Authorization", $"Bearer {bearer}");
var nv = new NameValueCollection();
nv["message"] = "【Error Msg】"
+ "\nError Source:" + Dts.Variables["System::SourceName"].Value
+ "\nError Code:" + Dts.Variables["System::ErrorCode"].Value
+ "\nError Desc:" + Dts.Variables["System::ErrorDescription"].Value
+ "\nDatetime:" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
var bResult = wc.UploadValues($"https://notify-api.line.me/api/notify", nv);
var res = Encoding.UTF8.GetString(bResult);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
// ......Deserialize JSON & Insert Into Table 失敗
Foreach 迴圈容器
Foreach 迴圈列舉值:Foreach 檔案列舉值
資料夾:C:\Stock LINE Notify\Chart(完整檔案路徑與檔名)
變數對應:
User::ErrorChart/User::ErrorQuote
檔案系統工作
IsDestinationPathVariable 屬性:False
DestinationConnect 屬性:Chart_Backup/Quote_Backup
OverwriteDestination 屬性:True
Operation 屬性:移動檔案
IsSourcePathVariable 屬性:True
SourceVariable 屬性:
User::ErrorChart
Last updated