Feature: Sync MWS Shipment with Database

Various restructuring and misc. features added.
Removed reliance on ABrain Amazon MWS NuGet package, added Amazon's own C# lib
This commit is contained in:
Bobbie Hodgetts
2019-06-24 16:01:50 +01:00
committed by GitHub
parent bc44546efd
commit 116aedb897
27 changed files with 2236 additions and 289 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
namespace bnhtrade.Core.Data.AmazonMWS
{
public class CurrentDateTime
{
public DateTime GetUtc()
{
var xmlDoc = new XmlDocument();
xmlDoc.Load("https://mws.amazonservices.com/");
DateTime returnTime = default(DateTime);
XmlNodeList elemList = xmlDoc.GetElementsByTagName("Timestamp");
for (int i = 0; i < elemList.Count; i++)
{
string attrVal = elemList[i].Attributes["timestamp"].Value;
if (!string.IsNullOrWhiteSpace(attrVal))
{
returnTime = DateTime.Parse(attrVal);
break;
}
}
if (returnTime == default(DateTime))
{
throw new Exception("Error requesting time from Amazon");
}
returnTime = returnTime.ToUniversalTime();
returnTime = returnTime.AddTicks(-(returnTime.Ticks % TimeSpan.TicksPerSecond));
return returnTime;
}
public DateTime GetLocal()
{
return GetUtc().ToLocalTime();
}
}
}