Inheritance: MWSClientCsRuntime.AbstractMwsObject
Esempio n. 1
1
        /// <summary>
        /// Get Matching Product For ID
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnMatchingProductSearch_Click(object sender, RoutedEventArgs e)
        {
            string SellerId = CommonValue.strMerchantId;
            string MarketplaceId = CommonValue.strMarketplaceId;
            string AccessKeyId = CommonValue.strAccessKeyId;
            string SecretKeyId = CommonValue.strSecretKeyId;
            string ApplicationVersion = CommonValue.strApplicationVersion;
            string ApplicationName = CommonValue.strApplicationName;
            string MWSAuthToken = CommonValue.strMWSAuthToken;
            string strbuff = string.Empty;

            MarketplaceWebServiceProductsConfig config = new MarketplaceWebServiceProductsConfig();
            config.ServiceURL = CommonValue.strServiceURL;

            MarketplaceWebServiceProductsClient client = new MarketplaceWebServiceProductsClient(
                                                             ApplicationName,
                                                             ApplicationVersion,
                                                             AccessKeyId,
                                                             SecretKeyId,
                                                             config);
            GetMatchingProductForIdRequest request = new GetMatchingProductForIdRequest();
            request.SellerId = SellerId;
            request.MarketplaceId = MarketplaceId;
            request.IdType = "ASIN";
            IdListType idList = new IdListType();
            idList.Id.Add(txtMatchingProductSearchValue.Text.ToString().Trim());
            request.IdList = idList;

            GetMatchingProductForIdResponse response = client.GetMatchingProductForId(request);
            if (response.IsSetGetMatchingProductForIdResult())
            {
                List<GetMatchingProductForIdResult> getMatchingProductForIdResultList = response.GetMatchingProductForIdResult;
                if (getMatchingProductForIdResultList[0].IsSetProducts())
                {
                    ProductList productList = getMatchingProductForIdResultList[0].Products;
                    List<Product> products = productList.Product;

                    System.Xml.XmlElement elements = (System.Xml.XmlElement)products[0].AttributeSets.Any[0];

                    foreach (System.Xml.XmlElement element in elements)
                    {
                        switch (element.LocalName)
                        {
                            case "Title":
                                strbuff += "タイトル:" + element.InnerText + System.Environment.NewLine;
                                break;
                            case "Creator":
                                strbuff += "著者:" + element.InnerText + System.Environment.NewLine;
                                break;
                            case "ListPrice":
                                strbuff += "価格:" + element.InnerText + System.Environment.NewLine;
                                break;
                            case "Manufacturer":
                                strbuff += "販売会社:" + element.InnerText + System.Environment.NewLine;
                                break;
                            default:
                                break;
                        }
                    }
                    txtMatchingProductResult.Text = strbuff;
                }
            }
        }
 public GetMatchingProductForIdRequest(string sellerId, string marketplaceId, string idType, IdListType idList) : base()
 {
     this._sellerId      = sellerId;
     this._marketplaceId = marketplaceId;
     this._idType        = idType;
     this._idList        = idList;
 }
 public override void ReadFragmentFrom(IMwsReader reader)
 {
     _sellerId      = reader.Read <string>("SellerId");
     _mwsAuthToken  = reader.Read <string>("MWSAuthToken");
     _marketplaceId = reader.Read <string>("MarketplaceId");
     _idType        = reader.Read <string>("IdType");
     _idList        = reader.Read <IdListType>("IdList");
 }
 /// <summary>
 /// Sets the IdList property.
 /// </summary>
 /// <param name="idList">IdList property.</param>
 /// <returns>this instance.</returns>
 public GetMatchingProductForIdRequest WithIdList(IdListType idList)
 {
     this._idList = idList;
     return(this);
 }
        private void GetProductInfo()
        {
            if (Simulated)
            {
                ProcessingLog.LogAndPrintScreenMessage("Simulated Get Product Info", true);
                return;
            }

            int requestCount = 1;
            int asinCount = 0;
            IdListType asinList = new IdListType();

            foreach (AsinInputItemShort asinInputItem in _asinInputList)
            {
                if (!string.IsNullOrEmpty(asinInputItem.Asin))
                {
                    asinCount++;
                    asinList.Id.Add(asinInputItem.Asin);
                }

                if (asinCount == 5)
                {
                    asinCount = 0;
                    requestCount++;
                    ProcessAsinList(asinList, requestCount);
                    asinList.Id.Clear();

                    System.Threading.Thread.Sleep(1100);
                }

                //if (requestCount > 80) break;
            }

            if (asinCount > 0)
            {
                ProcessAsinList(asinList, requestCount);
            }
        }
        private void ProcessAsinList(IdListType asinList, int reqCount)
        {
            GetMatchingProductForIdResponse response = InvokeMatchingProductForId(asinList);
            ProcessingLog.LogAndPrintScreenMessage(string.Format("Got product info header meta data:\n {0}", response.ResponseHeaderMetadata), false);

            if (reqCount % 50 == 0)
            {
                Console.WriteLine();
                ProcessingLog.LogAndPrintScreenMessage(string.Format("Got product info request count: {0}", reqCount), true);
            }
            else
            {
                Console.Write("*");
            }

            foreach (GetMatchingProductForIdResult getMatchingProductForIdResult in response.GetMatchingProductForIdResult)
            {
                AsinInputItemShort asinInputItem = GetMatchingSkuForAsin(getMatchingProductForIdResult.Id);

                if (asinInputItem == null)
                {
                    ProcessingLog.LogAndPrintScreenMessage(string.Format("Could not find Asin Upload List: {0}", getMatchingProductForIdResult.Id), true);
                    continue;
                }

                if (!getMatchingProductForIdResult.status.Equals("Success", StringComparison.CurrentCultureIgnoreCase))
                {
                    string errorCode = "NoError";
                    string errorType = "NoError";
                    string errorMessage = "NoError";
                    if (getMatchingProductForIdResult.Error != null)
                    {
                        errorCode = getMatchingProductForIdResult.Error.Code;
                        errorType = getMatchingProductForIdResult.Error.Type;
                        errorMessage = getMatchingProductForIdResult.Error.Message;
                    }
                    Console.WriteLine();
                    ProcessingLog.LogAndPrintScreenMessage(string.Format(
                        "Error processing: {0}. Status: {1}. Error Code: {2}. Error Type {3}. Error Message {4}.",
                        getMatchingProductForIdResult.Id, getMatchingProductForIdResult.status, errorCode, errorType, errorMessage), true);
                    continue;
                }

                try
                {
                    foreach (Product product in getMatchingProductForIdResult.Products.Product)
                    {
                        ProcessProduct(product, asinInputItem);
                    }
                }
                catch (Exception ex)
                {
                    ProcessingLog.LogAndPrintScreenMessage(string.Format("Error processing: {0}.  Due to {1}.", getMatchingProductForIdResult.Id, ex.Message), true);
                }
            }
        }
        private GetMatchingProductForIdResponse InvokeMatchingProductForId(IdListType asinList)
        {
            GetMatchingProductForIdRequest request = new GetMatchingProductForIdRequest();
            request.SellerId = _sellerId;
            request.MarketplaceId = AccountSettingsConfigSection.Rst_marketplaceId.Value;
            request.IdType = "ASIN";
            request.IdList = asinList;

            return _client.GetMatchingProductForId(request);
        }
 public GetMatchingProductForIdResponse InvokeGetMatchingProductForId()
 {
     // Create a request.
     GetMatchingProductForIdRequest request = new GetMatchingProductForIdRequest();
     string sellerId = "example";
     request.SellerId = sellerId;
     string mwsAuthToken = "example";
     request.MWSAuthToken = mwsAuthToken;
     string marketplaceId = "example";
     request.MarketplaceId = marketplaceId;
     string idType = "example";
     request.IdType = idType;
     IdListType idList = new IdListType();
     request.IdList = idList;
     return this.client.GetMatchingProductForId(request);
 }
 /// <summary>
 /// Sets the IdList property.
 /// </summary>
 /// <param name="idList">IdList property.</param>
 /// <returns>this instance.</returns>
 public GetMatchingProductForIdRequest WithIdList(IdListType idList)
 {
     this._idList = idList;
     return this;
 }
 public override void ReadFragmentFrom(IMwsReader reader)
 {
     _sellerId = reader.Read<string>("SellerId");
     _mwsAuthToken = reader.Read<string>("MWSAuthToken");
     _marketplaceId = reader.Read<string>("MarketplaceId");
     _idType = reader.Read<string>("IdType");
     _idList = reader.Read<IdListType>("IdList");
 }