private async Task <BulkOperationStatus <TStatus> > GetStatusWithRetries()
        {
            var retriesLeft = MaxGetStatusRetries;

            do
            {
                try
                {
                    return(await _statusProvider.GetCurrentStatus(_bulkServiceClient).ConfigureAwait(false));
                }
                catch (FaultException <AdApiFaultDetail> fault)
                {
                    if (retriesLeft-- <= 0)
                    {
                        throw;
                    }
                    HandlerRateLimitFailure(fault, retriesLeft);
                }
                catch (CommunicationException)
                {
                    if (retriesLeft-- <= 0)
                    {
                        throw;
                    }
                }
                catch (TimeoutException)
                {
                    if (retriesLeft-- <= 0)
                    {
                        throw;
                    }
                }
            } while (true);
        }
Пример #2
0
        /// <summary>
        /// Gets the status of the bulk operation.
        /// </summary>
        /// <returns><see cref="BulkOperationStatus{TStatus}"/></returns>
        /// <exception cref="FaultException{TDetail}">Thrown if a fault is returned from the Bing Ads service.</exception>
        /// <exception cref="OAuthTokenRequestException">Thrown if tokens can't be refreshed due to an error received from the Microsoft Account authorization server.</exception>
        public async Task <BulkOperationStatus <TStatus> > GetStatusAsync()
        {
            if (FinalStatus != null)
            {
                return(FinalStatus);
            }

            var currentStatus = await _statusProvider.GetCurrentStatus(_bulkServiceClient).ConfigureAwait(false);

            if (_statusProvider.IsFinalStatus(currentStatus))
            {
                FinalStatus = currentStatus;
            }

            return(currentStatus);
        }