예제 #1
0
        public virtual async Task <GetCategoryTreeResponse> GetCategoriesTreeAsync(string rootCategory = "1")
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

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

                var res = new catalogCategoryTreeResponse();
                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.catalogCategoryTreeAsync(sessionId.SessionId, rootCategory, "0").ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new GetCategoryTreeResponse(res));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException(string.Format("An error occured during GetCategoriesTree({0})", rootCategory), exc);
            }
        }
예제 #2
0
        public virtual async Task <GetCategoryTreeResponse> GetCategoriesTreeAsync(string rootCategory = "1")
        {
            try
            {
                const int maxCheckCount    = 2;
                const int delayBeforeCheck = 1800000;

                var privateClient = this._clientFactory.GetClient();

                var res = new catalogCategoryTreeResponse();
                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.catalogCategoryTreeAsync(sessionId.SessionId, rootCategory, "0").ConfigureAwait(false);
                }).ConfigureAwait(false);

                return(new GetCategoryTreeResponse(res));
            }
            catch (Exception exc)
            {
                throw new MagentoSoapException($"An error occured during GetCategoriesTree({rootCategory})", exc);
            }
        }
예제 #3
0
        public GetCategoryTreeResponse(catalogCategoryTreeResponse catalogCategoryTreeResponse)
        {
            if (catalogCategoryTreeResponse == null || catalogCategoryTreeResponse.result == null)
            {
                return;
            }
            var rootCategory = new CategoryNode(catalogCategoryTreeResponse.result);

            RootCategory = rootCategory;
        }