mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 06:27:15 +00:00
Migration from Amazon MWS to Selling Partner API
This commit is contained in:
59
src/bnhtrade.Core/Logic/Utilities/NightlyRoutine.cs
Normal file
59
src/bnhtrade.Core/Logic/Utilities/NightlyRoutine.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Logic.Utilities
|
||||
{
|
||||
public class NightlyRoutine
|
||||
{
|
||||
private Model.Credentials.AmazonSPAPI amznCredentials;
|
||||
private Model.Credentials.bnhtradeDB dbCredentials;
|
||||
|
||||
public NightlyRoutine(Model.Credentials.AmazonSPAPI amznCredentials, Model.Credentials.bnhtradeDB dbCredentials)
|
||||
{
|
||||
this.amznCredentials = amznCredentials;
|
||||
this.dbCredentials = dbCredentials;
|
||||
}
|
||||
|
||||
public void DownloadAll()
|
||||
{
|
||||
MiscFunction.EventLogInsert("Nightly scheduled tasks started.");
|
||||
|
||||
var stock = new bnhtrade.Core.Stock.StockReconciliation();
|
||||
var export = new bnhtrade.Core.Logic.Export.AmazonSettlement(dbCredentials.ConnectionString);
|
||||
|
||||
bool accountUpdate = false;
|
||||
bool stockUpdate = false;
|
||||
|
||||
bool accountProcess = false;
|
||||
bool stockProcess = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (accountUpdate == false) { accountUpdate = true; new Logic.Import.AmazonSettlement(amznCredentials).SyncDatabase(dbCredentials.ConnectionString); }
|
||||
if (accountProcess == false) { accountProcess = true; export.ToInvoice(); }
|
||||
if (stockUpdate == false) { stockUpdate = true; stock.UpdateFbaStockImportData(dbCredentials.ConnectionString); }
|
||||
|
||||
// if (stockProcess == false) { stockProcess = true; stock.ProcessFbaStockImportData(); }
|
||||
// ^^^^^^ best to process manually, case, fba inventory recepts, if a correction is made days later (ie -1) the already incorrect value
|
||||
// will have been entered in the stocktransaction table and maked as processed in the inventoryreceipt table
|
||||
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MiscFunction.EventLogInsert(
|
||||
"Exception caught running all report get method, see for further details",
|
||||
1,
|
||||
ex.ToString()
|
||||
);
|
||||
}
|
||||
}
|
||||
MiscFunction.EventLogInsert("Nightly scheduled tasks finished.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user