Beispiel #1
0
        public virtual async Task <ProductAttributeMediaListResponse> GetProductAttributeMediaListAsync(GetProductAttributeMediaListRequest getProductAttributeMediaListRequest, bool throwException = true)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var privateClient = this.CreateMagentocatalogProductAttributeMediaGalleryRepositoryServiceClient(this.BaseMagentoUrl);

                var res = new catalogProductAttributeMediaGalleryManagementV1GetListResponse1();
                await ActionPolicies.GetAsync.Do(async() =>
                {
                    var statusChecker = new StatusChecker(maxCheckCount);
                    TimerCallback tcb = statusChecker.CheckStatus;

                    if (privateClient.State != CommunicationState.Opened &&
                        privateClient.State != CommunicationState.Created &&
                        privateClient.State != CommunicationState.Opening)
                    {
                        privateClient = this.CreateMagentocatalogProductAttributeMediaGalleryRepositoryServiceClient(this.BaseMagentoUrl);
                    }

                    var catalogProductAttributeMediaGalleryManagementV1GetListRequest = new CatalogProductAttributeMediaGalleryManagementV1GetListRequest()
                    {
                        sku = getProductAttributeMediaListRequest.Sku
                    };
                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        res = await privateClient.catalogProductAttributeMediaGalleryManagementV1GetListAsync(catalogProductAttributeMediaGalleryManagementV1GetListRequest).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new ProductAttributeMediaListResponse(res, getProductAttributeMediaListRequest.ProductId, getProductAttributeMediaListRequest.Sku));
            }
            catch (Exception exc)
            {
                if (throwException)
                {
                    throw new MagentoSoapException(string.Format("An error occured during GetProductAttributeMediaListAsync({0})", getProductAttributeMediaListRequest), exc);
                }
                else
                {
                    return(new ProductAttributeMediaListResponse(exc));
                }
            }
        }
Beispiel #2
0
 public ProductAttributeMediaListResponse(catalogProductAttributeMediaGalleryManagementV1GetListResponse1 res, string productId, string sku)
 {
     this.ProductId     = productId;
     this.Sku           = sku;
     this.MagentoImages = res.catalogProductAttributeMediaGalleryManagementV1GetListResponse.result.Select(x => new MagentoImage(x)).ToList();
 }