|
@@ -229,7 +229,7 @@ namespace TCCInvoice
|
|
|
{
|
|
|
Path = SELLER_INVOICE_FAILURE_PATH,
|
|
|
Filter = "*.xml",
|
|
|
- NotifyFilter = NotifyFilters.LastWrite,
|
|
|
+ NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess,
|
|
|
IncludeSubdirectories = false,
|
|
|
EnableRaisingEvents = true,
|
|
|
};
|
|
@@ -285,6 +285,7 @@ namespace TCCInvoice
|
|
|
if (count == totalQuantity)
|
|
|
{
|
|
|
InvoiceCompleted?.Invoke(invoiceResponseItemList);
|
|
|
+ TurnOffFileSystemWatcher();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -317,6 +318,7 @@ namespace TCCInvoice
|
|
|
if (count == totalQuantity)
|
|
|
{
|
|
|
InvoiceCompleted?.Invoke(invoiceResponseItemList);
|
|
|
+ TurnOffFileSystemWatcher();
|
|
|
}
|
|
|
}
|
|
|
else // 上傳失敗
|
|
@@ -330,6 +332,7 @@ namespace TCCInvoice
|
|
|
if (count == totalQuantity)
|
|
|
{
|
|
|
InvoiceCompleted?.Invoke(invoiceResponseItemList);
|
|
|
+ TurnOffFileSystemWatcher();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -349,7 +352,7 @@ namespace TCCInvoice
|
|
|
await Task.Delay(500);
|
|
|
if (!File.Exists(responsePath)) // 可能是網優SQL連線失敗,需要嘗試重新上傳
|
|
|
{
|
|
|
- await Task.Delay(180000);
|
|
|
+ await Task.Delay(30000);
|
|
|
File.Copy(failurePath, sellerinvoicePath);
|
|
|
}
|
|
|
});
|
|
@@ -521,6 +524,28 @@ namespace TCCInvoice
|
|
|
Random rdm = new Random(Guid.NewGuid().GetHashCode());
|
|
|
return rdm.Next(min, max).ToString().PadLeft(4, '0');
|
|
|
}
|
|
|
+
|
|
|
+ private void TurnOffFileSystemWatcher()
|
|
|
+ {
|
|
|
+ if (preInvoiceResponseWatcher != null)
|
|
|
+ {
|
|
|
+ preInvoiceResponseWatcher.EnableRaisingEvents = false;
|
|
|
+ preInvoiceResponseWatcher.Dispose();
|
|
|
+ preInvoiceResponseWatcher = null;
|
|
|
+ }
|
|
|
+ if (sellerInvoiceResponseWatcher != null)
|
|
|
+ {
|
|
|
+ sellerInvoiceResponseWatcher.EnableRaisingEvents = false;
|
|
|
+ sellerInvoiceResponseWatcher.Dispose();
|
|
|
+ sellerInvoiceResponseWatcher = null;
|
|
|
+ }
|
|
|
+ if (sellerInvoiceFailureWatcher != null)
|
|
|
+ {
|
|
|
+ sellerInvoiceFailureWatcher.EnableRaisingEvents = false;
|
|
|
+ sellerInvoiceFailureWatcher.Dispose();
|
|
|
+ sellerInvoiceFailureWatcher = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
#endregion
|
|
|
|
|
|
#region Nested Classes
|