mirror of
https://github.com/stokebob/bnhtrade.git
synced 2026-03-19 06:27:15 +00:00
Last MWS report import date time saved
This commit is contained in:
@@ -24,7 +24,7 @@ namespace bnhtrade.Core.Data.AmazonMWS
|
||||
string attrVal = elemList[i].Attributes["timestamp"].Value;
|
||||
if (!string.IsNullOrWhiteSpace(attrVal))
|
||||
{
|
||||
returnTime = DateTime.Parse(attrVal);
|
||||
returnTime = DateTime.SpecifyKind(DateTime.Parse(attrVal), DateTimeKind.Utc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ namespace bnhtrade.Core.Data.AmazonMWS
|
||||
throw new Exception("Error requesting time from Amazon");
|
||||
}
|
||||
|
||||
returnTime = returnTime.ToUniversalTime();
|
||||
returnTime = returnTime.AddTicks(-(returnTime.Ticks % TimeSpan.TicksPerSecond));
|
||||
|
||||
return returnTime;
|
||||
|
||||
@@ -8,6 +8,21 @@ namespace bnhtrade.Core.Data.Database
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets the date bnhtrade started trading.
|
||||
/// </summary>
|
||||
/// <returns>Date and time</returns>
|
||||
public static DateTime GetBusinessStartUtc()
|
||||
{
|
||||
DateTime businessStart = new DateTime(2014, 09, 01);
|
||||
return DateTime.SpecifyKind(businessStart, DateTimeKind.Utc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int GetProductConditionIdNew()
|
||||
{
|
||||
return 10;
|
||||
|
||||
@@ -12,14 +12,7 @@ namespace bnhtrade.Core.Data.Database.Log
|
||||
public DateTimeLog(string sqlConnectionString) : base(sqlConnectionString)
|
||||
{
|
||||
}
|
||||
public DateTime GetBusinessStartUtc
|
||||
{
|
||||
get
|
||||
{
|
||||
DateTime businessStart = new DateTime(2014, 09, 01);
|
||||
return DateTime.SpecifyKind(businessStart, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Date and Time by a unique string.
|
||||
/// </summary>
|
||||
@@ -56,6 +49,7 @@ namespace bnhtrade.Core.Data.Database.Log
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDateTimeUtc(string logDateTimeID, DateTime utcDateTime)
|
||||
{
|
||||
utcDateTime = DateTime.SpecifyKind(utcDateTime, DateTimeKind.Utc);
|
||||
@@ -86,6 +80,7 @@ namespace bnhtrade.Core.Data.Database.Log
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void NewDateTimeUtc(string LogDateTimeId, DateTime utcDateTime, string comments = null)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(LogDateTimeId))
|
||||
@@ -131,6 +126,5 @@ namespace bnhtrade.Core.Data.Database.Log
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4887,19 +4887,19 @@ namespace bnhtrade.Core
|
||||
// endTime =<
|
||||
|
||||
List<string> reportIdList = new List<string>();
|
||||
DateTime now = DateTime.UtcNow;
|
||||
DateTime amazonNow = new Data.AmazonMWS.CurrentDateTime().GetUtc();
|
||||
// time checks
|
||||
if (startTime.ToUniversalTime() > now.ToUniversalTime())
|
||||
if (startTime.ToUniversalTime() > amazonNow.ToUniversalTime())
|
||||
{
|
||||
MiscFunction.EventLogInsert(
|
||||
"The most current date supplied from the database is a head of the current time. stoping...",
|
||||
"The most current date supplied from the database is ahead of the current time. stoping...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
reportIdList.Clear();
|
||||
return reportIdList;
|
||||
}
|
||||
else if (endTime.ToUniversalTime() > now.ToUniversalTime())
|
||||
else if (endTime.ToUniversalTime() > amazonNow.ToUniversalTime())
|
||||
{
|
||||
MiscFunction.EventLogInsert(
|
||||
"Get report end time is ahead of current time, re-setting to current time",
|
||||
@@ -4913,10 +4913,10 @@ namespace bnhtrade.Core
|
||||
do
|
||||
{
|
||||
reportCount = reportCount + 1;
|
||||
now = DateTime.UtcNow.AddMinutes(0);
|
||||
if (endTime.ToUniversalTime() > now.ToUniversalTime())
|
||||
amazonNow = DateTime.UtcNow.AddMinutes(0);
|
||||
if (endTime.ToUniversalTime() > amazonNow.ToUniversalTime())
|
||||
{
|
||||
endTime = now;
|
||||
endTime = amazonNow;
|
||||
stopFlag = true;
|
||||
}
|
||||
// build the request
|
||||
@@ -4958,7 +4958,7 @@ namespace bnhtrade.Core
|
||||
// add 30 days onto start date and loop
|
||||
startTime = endTime.AddSeconds(1);
|
||||
endTime = endTime.AddDays(reportMaxPeriod);
|
||||
if (startTime.ToUniversalTime() > now.ToUniversalTime())
|
||||
if (startTime.ToUniversalTime() > amazonNow.ToUniversalTime())
|
||||
{
|
||||
stopFlag = true;
|
||||
}
|
||||
@@ -4971,6 +4971,88 @@ namespace bnhtrade.Core
|
||||
return reportIdList;
|
||||
}
|
||||
|
||||
public void ImportByDateRange(string sqlConnectionString, string mwsReportEnum, DateTime lastRecordDate,
|
||||
int lastRecordOffsetDay = 0, int lastRecordOffsetSecond = 0)
|
||||
{
|
||||
// set start date
|
||||
DateTime startTime = new DateTime();
|
||||
DateTime endTime = new Data.AmazonMWS.CurrentDateTime().GetUtc();
|
||||
|
||||
var dbLogDate = new DateTimeLog(sqlConnectionString);
|
||||
DateTime logDate = dbLogDate.GetDateTimeUtc(mwsReportEnum);
|
||||
logDate = logDate.AddDays(-14);
|
||||
|
||||
if (lastRecordDate > logDate)
|
||||
{
|
||||
startTime = lastRecordDate;
|
||||
startTime = startTime.AddSeconds(lastRecordOffsetSecond);
|
||||
startTime = startTime.AddDays(lastRecordOffsetDay);
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = logDate;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded for " + mwsReportEnum);
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = false;
|
||||
|
||||
if (mwsReportEnum == "_GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA_")
|
||||
{
|
||||
ackImport = ImportReportFbaInventoryReceipt(sqlConnectionString, reportPath, startTime);
|
||||
}
|
||||
else if (mwsReportEnum == "_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_")
|
||||
{
|
||||
ackImport = ImportReportFbaSaleShipment(sqlConnectionString, reportPath);
|
||||
}
|
||||
else if (mwsReportEnum == "_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_")
|
||||
{
|
||||
ackImport = ImportReportFbaReturns(sqlConnectionString, reportPath);
|
||||
}
|
||||
else if (mwsReportEnum == "_GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA_")
|
||||
{
|
||||
ackImport = ImportReportFbaAdjustment(sqlConnectionString, reportPath);
|
||||
}
|
||||
else if (mwsReportEnum == "_GET_FBA_REIMBURSEMENTS_DATA_")
|
||||
{
|
||||
ackImport = ImportReportFbaReimbursement(sqlConnectionString, reportPath);
|
||||
}
|
||||
else if (mwsReportEnum == "_GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA_")
|
||||
{
|
||||
ackImport = ImportReportFbaRemovalOrder(sqlConnectionString, reportPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
MiscFunction.EventLogInsert("If statement not setup for report '" + mwsReportEnum + "'. stopping further report imports, do some coding",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// update log date
|
||||
dbLogDate.SetDateTimeUtc(mwsReportEnum, endTime);
|
||||
}
|
||||
|
||||
public bool SetMwsReportAcknowledgement(string reportId, bool acknowledged = true)
|
||||
{
|
||||
var service = new Service().MarketPlaceWeb;
|
||||
@@ -7096,6 +7178,7 @@ namespace bnhtrade.Core
|
||||
//return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFbaInventoryReceiptData(string sqlConnectionString)
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA_";
|
||||
@@ -7109,31 +7192,27 @@ namespace bnhtrade.Core
|
||||
*/
|
||||
|
||||
// get the most recent date from db table
|
||||
DateTime startTime;
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
DateTime currentTime = DateTime.UtcNow.AddMinutes(-5);
|
||||
|
||||
SqlConnection sqlConn;
|
||||
DateTime lastRecordDate;
|
||||
SqlConnection conn;
|
||||
try
|
||||
{
|
||||
using (sqlConn = new SqlConnection(sqlConnectionString))
|
||||
using (conn = new SqlConnection(sqlConnectionString))
|
||||
{
|
||||
sqlConn.Open();
|
||||
conn.Open();
|
||||
using (SqlCommand cmd = new SqlCommand(
|
||||
"SELECT Max([received-date]) AS MaxDate FROM tblImportFbaInventoryReceiptReport;"
|
||||
, sqlConn))
|
||||
, conn))
|
||||
{
|
||||
if (cmd.ExecuteScalar() == DBNull.Value)
|
||||
{
|
||||
// use first month started selling on Amazon
|
||||
startTime = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
lastRecordDate = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
// no need to specific timezone, etc, as "Z" already specifis UTC
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = ((DateTime)cmd.ExecuteScalar());
|
||||
startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
|
||||
startTime = startTime.AddSeconds(1);
|
||||
lastRecordDate = ((DateTime)cmd.ExecuteScalar());
|
||||
lastRecordDate = DateTime.SpecifyKind(lastRecordDate, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7147,29 +7226,9 @@ namespace bnhtrade.Core
|
||||
return;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded, stopping UpdateFbaInventoryReceiptData method...");
|
||||
return;
|
||||
ImportByDateRange(sqlConnectionString, mwsReportEnum, lastRecordDate, 0, 1);
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = ImportReportFbaInventoryReceipt(sqlConnectionString, reportPath, startTime);
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateFbaSaleShipmentData(string sqlConnectionString)
|
||||
{
|
||||
string mwsReportEnum = "_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_";
|
||||
@@ -7186,10 +7245,7 @@ namespace bnhtrade.Core
|
||||
*/
|
||||
|
||||
// get the most recent date from db table
|
||||
DateTime startTime;
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
DateTime latestTime = DateTime.UtcNow.AddMinutes(-5);
|
||||
|
||||
DateTime lastRecordDate;
|
||||
SqlConnection sqlConn;
|
||||
try
|
||||
{
|
||||
@@ -7203,18 +7259,15 @@ namespace bnhtrade.Core
|
||||
if (cmd.ExecuteScalar() == DBNull.Value)
|
||||
{
|
||||
// use first month started selling on Amazon
|
||||
startTime = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
lastRecordDate = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
// no need to specific timezone, etc, as "Z" already specifis UTC
|
||||
startTime = DateTime.Parse("2016-02-01T00:00:00Z");
|
||||
lastRecordDate = DateTime.Parse("2016-02-01T00:00:00Z");
|
||||
// fba sale shipments for previous 18 months only
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = ((DateTime)cmd.ExecuteScalar());
|
||||
startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
|
||||
// Amazon states in MWS guidance that shipments are added in near real time, however, in most cases,
|
||||
// there will be a delay of approximately one to three hours. In some rare cases there could be a delay of up to 24 hours.
|
||||
startTime = startTime.AddDays(-3);
|
||||
lastRecordDate = ((DateTime)cmd.ExecuteScalar());
|
||||
lastRecordDate = DateTime.SpecifyKind(lastRecordDate, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7228,29 +7281,9 @@ namespace bnhtrade.Core
|
||||
return;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded, stopping GetFbaReturnsReport method...");
|
||||
return;
|
||||
ImportByDateRange(sqlConnectionString, mwsReportEnum, lastRecordDate, -3, 0);
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = ImportReportFbaSaleShipment(sqlConnectionString, reportPath);
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateFbaReturnData(string sqlConnectionString)
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_";
|
||||
@@ -7268,8 +7301,7 @@ namespace bnhtrade.Core
|
||||
*/
|
||||
|
||||
// get the most recent date from db table
|
||||
DateTime startTime;
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
DateTime lastRecordDate;
|
||||
SqlConnection sqlConn;
|
||||
try
|
||||
{
|
||||
@@ -7283,15 +7315,13 @@ namespace bnhtrade.Core
|
||||
if (cmd.ExecuteScalar() == DBNull.Value)
|
||||
{
|
||||
// use first month started selling on Amazon
|
||||
startTime = DateTime.Parse("2015-08-25T00:00:00Z"); //this before first return
|
||||
lastRecordDate = DateTime.Parse("2015-08-25T00:00:00Z"); //this before first return
|
||||
// no need to specific timezone, etc, as "Z" already specifis UTC
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = ((DateTime)cmd.ExecuteScalar());
|
||||
startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
|
||||
// Amazon states in MWS guidance that content updated daily.
|
||||
startTime = startTime.AddDays(-14);
|
||||
lastRecordDate = ((DateTime)cmd.ExecuteScalar());
|
||||
lastRecordDate = DateTime.SpecifyKind(lastRecordDate, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7305,29 +7335,9 @@ namespace bnhtrade.Core
|
||||
return;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded, stopping GetFbaReturnsReport method...");
|
||||
return;
|
||||
ImportByDateRange(sqlConnectionString, mwsReportEnum, lastRecordDate, -14, 0);
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = ImportReportFbaReturns(sqlConnectionString, reportPath);
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateFbaAdustmentData(string sqlConnectionString)
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA_";
|
||||
@@ -7337,8 +7347,7 @@ namespace bnhtrade.Core
|
||||
//return;
|
||||
|
||||
// get the most recent date from db table
|
||||
DateTime startTime;
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
DateTime lastRecordDate;
|
||||
SqlConnection sqlConn;
|
||||
try
|
||||
{
|
||||
@@ -7352,15 +7361,13 @@ namespace bnhtrade.Core
|
||||
if (cmd.ExecuteScalar() == DBNull.Value)
|
||||
{
|
||||
// use first month started selling on Amazon
|
||||
startTime = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
lastRecordDate = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
// no need to specific timezone, etc, as "Z" already specifis UTC
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = ((DateTime)cmd.ExecuteScalar());
|
||||
startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
|
||||
// Amazon states in MWS guidance that content updated daily.
|
||||
startTime = startTime.AddDays(-3);
|
||||
lastRecordDate = ((DateTime)cmd.ExecuteScalar());
|
||||
lastRecordDate = DateTime.SpecifyKind(lastRecordDate, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7374,29 +7381,9 @@ namespace bnhtrade.Core
|
||||
return;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded, stopping GetFbaAdustmentData method...");
|
||||
return;
|
||||
ImportByDateRange(sqlConnectionString, mwsReportEnum, lastRecordDate, -3, 0);
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = ImportReportFbaAdjustment(sqlConnectionString, reportPath);
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateFbaReimbursementData(string sqlConnectionString)
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_REIMBURSEMENTS_DATA_";
|
||||
@@ -7406,8 +7393,7 @@ namespace bnhtrade.Core
|
||||
//return;
|
||||
|
||||
// get the most recent date from db table
|
||||
DateTime startTime;
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
DateTime lastRecordDate;
|
||||
SqlConnection sqlConn;
|
||||
try
|
||||
{
|
||||
@@ -7421,16 +7407,13 @@ namespace bnhtrade.Core
|
||||
if (cmd.ExecuteScalar() == DBNull.Value)
|
||||
{
|
||||
// use first month started selling on Amazon
|
||||
startTime = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
lastRecordDate = DateTime.Parse("2014-09-01T00:00:00Z");
|
||||
// no need to specific timezone, etc, as "Z" already specifis UTC
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = ((DateTime)cmd.ExecuteScalar());
|
||||
startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
|
||||
// Amazon states in MWS guidance that content updated daily.
|
||||
startTime = startTime.AddDays(-3);
|
||||
//startTime = DateTime.Parse("2015-05-01T00:00:00Z");
|
||||
lastRecordDate = ((DateTime)cmd.ExecuteScalar());
|
||||
lastRecordDate = DateTime.SpecifyKind(lastRecordDate, DateTimeKind.Utc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7444,29 +7427,9 @@ namespace bnhtrade.Core
|
||||
return;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded, stopping GetFbaReimbursementData method...");
|
||||
return;
|
||||
ImportByDateRange(sqlConnectionString, mwsReportEnum, lastRecordDate, -3, 0);
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = ImportReportFbaReimbursement(sqlConnectionString, reportPath);
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateFbaRemovalOrderReport(string sqlConnectionString)
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA_";
|
||||
@@ -7476,8 +7439,7 @@ namespace bnhtrade.Core
|
||||
//return;
|
||||
|
||||
// get the most recent date from db table
|
||||
DateTime startTime;
|
||||
DateTime endTime = DateTime.UtcNow;
|
||||
DateTime lastRecordDate;
|
||||
SqlConnection sqlConn;
|
||||
try
|
||||
{
|
||||
@@ -7491,14 +7453,14 @@ namespace bnhtrade.Core
|
||||
if (cmd.ExecuteScalar() == DBNull.Value)
|
||||
{
|
||||
// use first month started selling on Amazon
|
||||
startTime = DateTime.Parse("2015-09-15T00:00:00Z");
|
||||
lastRecordDate = DateTime.Parse("2015-09-15T00:00:00Z");
|
||||
// no need to specific timezone, etc, as "Z" already specifis UTC
|
||||
}
|
||||
else
|
||||
{
|
||||
startTime = ((DateTime)cmd.ExecuteScalar());
|
||||
startTime = DateTime.SpecifyKind(startTime, DateTimeKind.Utc);
|
||||
startTime = startTime.AddDays(-30); // yes, that's right -30 days
|
||||
lastRecordDate = ((DateTime)cmd.ExecuteScalar());
|
||||
lastRecordDate = DateTime.SpecifyKind(lastRecordDate, DateTimeKind.Utc);
|
||||
lastRecordDate = lastRecordDate.AddDays(-30); // yes, that's right -30 days
|
||||
//startTime = DateTime.Parse("2015-05-01T00:00:00Z");
|
||||
}
|
||||
}
|
||||
@@ -7513,31 +7475,10 @@ namespace bnhtrade.Core
|
||||
return;
|
||||
}
|
||||
|
||||
// get list of reports
|
||||
List<string> reportPathList = GetMwsReportByPeriod(mwsReportEnum, startTime, endTime, 24);
|
||||
if (reportPathList.Count == 0)
|
||||
{
|
||||
// no report downloadeded
|
||||
MiscFunction.EventLogInsert("No reports downloaded, stopping GetFbaReimbursementData method...");
|
||||
return;
|
||||
}
|
||||
|
||||
// loop throught list of filepaths
|
||||
foreach (string reportPath in reportPathList)
|
||||
{
|
||||
bool ackImport = ImportReportFbaRemovalOrder(sqlConnectionString, reportPath);
|
||||
if (ackImport == false)
|
||||
{
|
||||
MiscFunction.EventLogInsert("Problem importing report '" + mwsReportEnum + "'. stopping further report imports...",
|
||||
1,
|
||||
MiscFunction.TraceMessage()
|
||||
);
|
||||
return;
|
||||
}
|
||||
ImportByDateRange(sqlConnectionString, mwsReportEnum, lastRecordDate, -30, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public class MiscFunction
|
||||
{
|
||||
public static void EventLogInsert
|
||||
|
||||
28
src/bnhtrade.Core/Test/AmazonMWS/Report.cs
Normal file
28
src/bnhtrade.Core/Test/AmazonMWS/Report.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace bnhtrade.Core.Test.AmazonMWS
|
||||
{
|
||||
public class Report
|
||||
{
|
||||
private string sqlConnectionString;
|
||||
public Report(string sqlConnectionString)
|
||||
{
|
||||
this.sqlConnectionString = sqlConnectionString;
|
||||
|
||||
// method you want to start here
|
||||
GetRport();
|
||||
|
||||
}
|
||||
public void GetRport()
|
||||
{
|
||||
string mwsReportEnum = "_GET_FBA_FULFILLMENT_INVENTORY_RECEIPTS_DATA_";
|
||||
DateTime start = new DateTime(2020, 10, 01);
|
||||
DateTime finish = new DateTime(2020, 11, 03);
|
||||
var result = new bnhtrade.Core.AmazonReport().GetMwsReportByPeriod(mwsReportEnum, start, finish, 12, 30);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,6 +170,7 @@
|
||||
<Compile Include="Model\Stock\StatusBalance.cs" />
|
||||
<Compile Include="Model\Stock\StatusTransaction.cs" />
|
||||
<Compile Include="Test\Account\Account.cs" />
|
||||
<Compile Include="Test\AmazonMWS\Report.cs" />
|
||||
<Compile Include="Test\AutoExec.cs" />
|
||||
<Compile Include="Test\Export\Export.cs" />
|
||||
<Compile Include="Test\Import\AmazonSettlement.cs" />
|
||||
|
||||
@@ -290,8 +290,8 @@ namespace bnhtradeScheduledTasks
|
||||
Console.WriteLine("<5> Test Logic");
|
||||
Console.WriteLine("<6> Test SKU");
|
||||
Console.WriteLine("<7> Test Stock");
|
||||
Console.WriteLine("<8> Test xxxxxxx");
|
||||
Console.WriteLine("<9> Detele Sku Transaction 'n'");
|
||||
Console.WriteLine("<8> Test AmazonMWS Report");
|
||||
Console.WriteLine("<9> Test Log");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("<0> Back");
|
||||
Console.WriteLine("");
|
||||
@@ -376,7 +376,7 @@ namespace bnhtradeScheduledTasks
|
||||
{
|
||||
Console.Clear();
|
||||
|
||||
Console.WriteLine("Nothing......");
|
||||
new bnhtrade.Core.Test.AmazonMWS.Report(sqlConnectionString);
|
||||
|
||||
Console.WriteLine("Done");
|
||||
Console.WriteLine("Complete, press any key to continue...");
|
||||
@@ -386,7 +386,13 @@ namespace bnhtradeScheduledTasks
|
||||
{
|
||||
Console.Clear();
|
||||
|
||||
new bnhtrade.Core.Logic.Stock.SkuTransactionPersistance(sqlConnectionString).DeleteJournalEntry(32731);
|
||||
var timeeee = new DateTime(2014, 9, 1);
|
||||
var logdate = new bnhtrade.Core.Data.Database.Log.DateTimeLog(sqlConnectionString);
|
||||
logdate.NewDateTimeUtc("_GET_AMAZON_FULFILLED_SHIPMENTS_DATA_", timeeee);
|
||||
logdate.NewDateTimeUtc("_GET_FBA_FULFILLMENT_CUSTOMER_RETURNS_DATA_", timeeee);
|
||||
logdate.NewDateTimeUtc("_GET_FBA_FULFILLMENT_INVENTORY_ADJUSTMENTS_DATA_", timeeee);
|
||||
logdate.NewDateTimeUtc("_GET_FBA_REIMBURSEMENTS_DATA_", timeeee);
|
||||
logdate.NewDateTimeUtc("_GET_FBA_FULFILLMENT_REMOVAL_ORDER_DETAIL_DATA_", timeeee);
|
||||
|
||||
Console.WriteLine("Done");
|
||||
Console.WriteLine("Complete, press any key to continue...");
|
||||
|
||||
Reference in New Issue
Block a user