Migration from Amazon MWS to Selling Partner API

This commit is contained in:
Bobbie Hodgetts
2024-04-11 12:26:13 +01:00
committed by GitHub
parent e054278cdd
commit a7bc00e73a
1318 changed files with 2778105 additions and 5936 deletions

View 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.");
}
}
}