示例#1
0
        public Product getSingleProduct(string ASIN)
        {
            AMZNHelper amznHelper = new AMZNHelper();

            IDictionary<string, string> r1 = new Dictionary<string, String>();

            r1["Action"] = "GetMatchingProduct";
            r1["SellerId"] = "A3FWGQLMG1AAXG";
            r1["MarketplaceId"] = "ATVPDKIKX0DER";
            r1["ASINList.ASIN.1"] = ASIN;
            r1["Version"] = "2011-10-01";

            MWSWebRequest wr = new MWSWebRequest();
            string s = wr.getResponse("https://mws.amazonservices.com/Products/2011-10-01", r1, false, true);

            var xDoc = XDocument.Parse(s);

            XElement xe = Util.stripNS(xDoc.Elements().First());

            IEnumerable<XElement> Products = xe.Descendants("Product");
            foreach (XElement product in Products)
            {
                string title = Util.tryGetElementValueString(xe.Descendants("ItemAttributes").First(), "Title", true);

                Product p = new Product(ASIN, title);
                DataStore.Upsert_Product(p);
                return p;
            }

            return null;
        }
示例#2
0
        public void TestDataStore()
        {
            InventoryMember i = new InventoryMember("x", "y", "z");
            DataStore.Upsert_Inventory(i);

            InventoryMember i2 = DataStore.getInventoryByAsin(i.ASIN);

            Assert.IsNotNull(i2);
            Assert.AreEqual(i2.FNSKU, i.FNSKU);

            Product p = new Product("z", "a");
            Product p2 = DataStore.getProductByAsin(p.ASIN);
        }
示例#3
0
        public static void Upsert_Product(Product p)
        {
            loadFiles();
            lock (Products)
            {
                Products[p.ASIN] = p;

                if (Inventory.ContainsKey(p.ASIN))
                {
                    InventoryMember inv = Inventory[p.ASIN];
                    var label = new FNSkuLabel(inv.ASIN, inv.FNSKU, p.Title, "New", 1, 3);
                    if (Labels.Contains(label))
                    {
                        Labels.Remove(label);
                    }
                    Labels.Add(label);
                }
            }
            saveProduct();
        }