Example #1
0
        public virtual async Task <CatalogProductInfoResponse> GetProductInfoAsync(CatalogProductInfoRequest request, bool throwException = true)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var res           = new catalogProductInfoResponse();
                var privateClient = this._clientFactory.GetClient();


                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);
                    var attributes = new catalogProductRequestAttributes {
                        additional_attributes = request.custAttributes ?? new string[0]
                    };

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

                return(new CatalogProductInfoResponse(res));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException($"An error occured during GetProductInfoAsync({request.ToJson()})", exc);
            }
        }
        public virtual async Task <CatalogProductInfoResponse> GetProductInfoAsync(CatalogProductInfoRequest request, bool throwException = true)
        {
            var attributes = new catalogProductRequestAttributes {
                additional_attributes = request.custAttributes ?? new string[0]
            };

            return(await this.GetWithAsync(
                       x => new CatalogProductInfoResponse(x),
                       async ( client, session ) => await client.catalogProductInfoAsync( session, request.ProductId, "0", attributes, "1" ).ConfigureAwait(false), 25000).ConfigureAwait(false));
        }
Example #3
0
        public virtual async Task <CatalogProductInfoResponse> GetProductInfoAsync(CatalogProductInfoRequest catalogProductInfoRequest, bool throwException = true)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var res           = new catalogProductRepositoryV1GetResponse1();
                var privateClient = this.CreateMagentoCatalogProductRepositoryServiceClient(this.BaseMagentoUrl);

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

                    // we don't need them, since Magento 2.0 returns all attributes
                    //var attributes = new catalogProductRequestAttributes { additional_attributes = custAttributes ?? new string[ 0 ] };

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                    {
                        var catalogProductRepositoryV1GetRequest = new CatalogProductRepositoryV1GetRequest()
                        {
                            sku = catalogProductInfoRequest.Sku
                        };
                        res = await privateClient.catalogProductRepositoryV1GetAsync(catalogProductRepositoryV1GetRequest).ConfigureAwait(false);
                    }
                }).ConfigureAwait(false);

                return(new CatalogProductInfoResponse(res));
            }
            catch (Exception exc)
            {
                if (throwException)
                {
                    throw new MagentoSoapException(string.Format("An error occured during GetProductInfoAsync({0})", catalogProductInfoRequest.ToJson()), exc);
                }
                else
                {
                    return(new CatalogProductInfoResponse(exc));
                }
            }
        }
Example #4
0
        public virtual async Task <CatalogProductInfoResponse> GetProductInfoAsync(CatalogProductInfoRequest request, bool throwException = true)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var res           = new catalogProductInfoResponse();
                var privateClient = this.CreateMagentoServiceClient(this.BaseMagentoUrl);

                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);
                    var attributes = new catalogProductRequestAttributes {
                        additional_attributes = request.custAttributes ?? new string[0]
                    };

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

                return(new CatalogProductInfoResponse(res));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetProductInfoAsync({0})", request.ToJson()), exc);
            }
        }
Example #5
0
 public Task <CatalogProductInfoResponse> GetProductInfoAsync(CatalogProductInfoRequest catalogProductInfoRequest, bool throwException = true)
 {
     return(null);
 }