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.CreateMagentoServiceClient(this.BaseMagentoUrl);

                var res = new catalogProductAttributeMediaListResponse();
                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.CreateMagentoServiceClient(this.BaseMagentoUrl);
                    }

                    var sessionId = await this.GetSessionId().ConfigureAwait(false);

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        res = await privateClient.catalogProductAttributeMediaListAsync(sessionId.SessionId, getProductAttributeMediaListRequest.ProductId, "0", "1").ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new ProductAttributeMediaListResponse(res, getProductAttributeMediaListRequest.ProductId, getProductAttributeMediaListRequest.Sku));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetProductAttributeMediaListAsync({0})", getProductAttributeMediaListRequest), exc);
            }
        }
Beispiel #2
0
        public virtual async Task <ProductAttributeMediaListResponse> GetProductAttributeMediaListAsync(GetProductAttributeMediaListRequest getProductAttributeMediaListRequest, bool throwException = true)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var privateClient = this._clientFactory.GetClient();

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

                    privateClient = this._clientFactory.RefreshClient(privateClient);
                    var sessionId = await this.GetSessionId().ConfigureAwait(false);

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        res = await privateClient.catalogProductAttributeMediaListAsync(sessionId.SessionId, getProductAttributeMediaListRequest.ProductId, "0", "1").ConfigureAwait(false);
                }).ConfigureAwait(false);

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