public virtual async Task <OrderInfoResponse> GetOrderAsync(string incrementId, Mark childMark)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 300000;

                var res = new salesOrderInfoResponse();

                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);

                    using (var stateTimer = new Timer(tcb, privateClient, 1000, delayBeforeCheck))
                        res = await privateClient.salesOrderInfoAsync(sessionId.SessionId, incrementId).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new OrderInfoResponse(res));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetOrderAsync(incrementId:{0})", incrementId), exc);
            }
        }
Exemplo n.º 2
0
        public virtual async Task <OrderInfoResponse> GetOrderAsync(string incrementId)
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 300000;

                var res = new salesOrderInfoResponse();

                var privateClient = await this.CreateMagentoServiceClientAsync(this.BaseMagentoUrl).ConfigureAwait(false);

                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.salesOrderInfoAsync(sessionId.SessionId, incrementId).ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new OrderInfoResponse(res));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetOrderAsync(incrementId:{0})", incrementId), exc);
            }
        }