Example #1
0
 private static CallRetry GetCallRetry()
 {
     CallRetry retry = new CallRetry();
     retry.DelayTime = 1000;
     retry.MaximumRetries = 2;
     retry.TriggerHttpStatusCodes = new Int32Collection();
     retry.TriggerHttpStatusCodes.Add(502);
     retry.TriggerHttpStatusCodes.Add(404);
     return retry;
 }
Example #2
0
		private static CallRetry GetCallRetry() 
		{
			if (retry != null)
				return retry;

			try {
				mRetry.WaitOne();
				if (retry != null)
					return retry;

				retry = new CallRetry();
				retry.DelayTime = 1000;		// 1 second
				retry.MaximumRetries = 2;
				// retry.TriggerErrorCodes
				// retry.TriggerExceptions
				return retry;
			}
			finally {
				mRetry.ReleaseMutex();
			}
		}
Example #3
0
        /// <summary>
        ///
        /// </summary>
        internal void SendRequest()
        {
            try
            {
                if (AbstractRequest == null)
                {
                    throw new ApiException("RequestType reference not set to an instance of an object.", new System.ArgumentNullException());
                }
                if (ApiContext == null)
                {
                    throw new ApiException("ApiContext reference not set to an instance of an object.", new System.ArgumentNullException());
                }
                if (ApiContext.ApiCredential == null)
                {
                    throw new ApiException("Credentials reference in ApiContext object not set to an instance of an object.", new System.ArgumentNullException());
                }

                string apiName = AbstractRequest.GetType().Name.Replace("RequestType", "");

                if (this.ApiContext.EnableMetrics)
                {
                    mCallMetrics = this.ApiContext.CallMetricsTable.GetNewEntry(apiName);
                    mCallMetrics.ApiCallStarted = System.DateTime.Now;
                }

                CustomSecurityHeaderType secHdr = this.GetSecurityHeader();

                // Get default constructor.

                /*
                 * ConstructorInfo svcCCTor = this.mServiceType.GetConstructor(
                 *  BindingFlags.Instance | BindingFlags.Public, null,
                 *  CallingConventions.HasThis, null, null);
                 */
                ConstructorInfo svcCCTor = this.mServiceType.GetConstructor(new Type[] { });

                object svcInst = svcCCTor.Invoke(null);

                PropertyInfo pi;

                pi = this.mServiceType.GetProperty("ApiLogManager");
                if (pi == null)
                {
                    throw new SdkException("ApiLogManager was not found in InterfaceServiceType");
                }
                pi.SetValue(svcInst, this.mApiContext.ApiLogManager, null);

                pi = this.mServiceType.GetProperty("EnableComression");
                if (pi == null)
                {
                    throw new SdkException("EnableComression was not found in InterfaceServiceType");
                }
                pi.SetValue(svcInst, this.mEnableCompression, null);

                //Add oAuth
                //if (pi == null)
                //    throw new SdkException("RequesterCredentials was not found in InterfaceServiceType");
                //pi.SetValue(svcInst, this., null);
                if (string.IsNullOrEmpty(this.ApiContext.ApiCredential.oAuthToken))
                {
                    pi = this.mServiceType.GetProperty("RequesterCredentials");
                    if (pi == null)
                    {
                        throw new SdkException("RequesterCredentials was not found in InterfaceServiceType");
                    }
                    pi.SetValue(svcInst, secHdr, null);
                }

                pi = this.mServiceType.GetProperty("WebProxy");
                if (pi == null)
                {
                    throw new SdkException("WebProxy was not found in InterfaceServiceType");
                }
                pi.SetValue(svcInst, this.mApiContext.WebProxy, null);
                if (this.mApiContext.WebProxy != null)
                {
                    LogMessage("Proxy Server is Set", MessageType.Information, MessageSeverity.Informational);
                }

                pi = this.mServiceType.GetProperty("CallMetricsEntry");
                if (pi == null)
                {
                    throw new SdkException("CallMetricsEntry was not found in InterfaceServiceType");
                }
                if (this.ApiContext.EnableMetrics)
                {
                    pi.SetValue(svcInst, this.mCallMetrics, null);
                }
                else
                {
                    pi.SetValue(svcInst, null, null);
                }

                pi = this.mServiceType.GetProperty("OAuthToken");
                if (!string.IsNullOrEmpty(this.ApiContext.ApiCredential.oAuthToken))
                {
                    this.mOAuth = this.ApiContext.ApiCredential.oAuthToken;
                    pi.SetValue(svcInst, this.OAuth, null);
                }

                string url = "";
                try
                {
                    if (ApiContext.SoapApiServerUrl != null && ApiContext.SoapApiServerUrl.Length > 0)
                    {
                        url = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}?callname={1}&siteid={2}&client=netsoap",
                                            ApiContext.SoapApiServerUrl, apiName, SiteUtility.GetSiteID(Site).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        url = (string)this.mServiceType.GetProperty("Url").GetValue(svcInst, null);
                        url = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}?callname={1}&siteid={2}&client=netsoap",
                                            url, apiName, SiteUtility.GetSiteID(Site).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    }

                    //svcCCTor.Url = url;
                    this.mServiceType.GetProperty("Url").SetValue(svcInst, url, null);
                }
                catch (Exception ex)
                {
                    throw new ApiException(ex.Message, ex);
                }

                LogMessage(url, MessageType.Information, MessageSeverity.Informational);

                //svcCCTor.Timeout = Timeout;
                this.mServiceType.GetProperty("Timeout").SetValue(svcInst, Timeout, null);

                AbstractRequest.Version = Version;

                if (!mDetailLevelOverride && AbstractRequest.DetailLevel == null)
                {
                    AbstractRequest.DetailLevel = new DetailLevelCodeTypeCollection();
                    AbstractRequest.DetailLevel.AddRange(mDetailLevelList);
                }

                //Added OutputSelector to base call JIRA-SDK-561
                AbstractRequest.OutputSelector = new StringCollection();
                AbstractRequest.OutputSelector.AddRange(mOutputSelector);

                if (ApiContext.ErrorLanguage != ErrorLanguageCodeType.CustomCode)
                {
                    AbstractRequest.ErrorLanguage = ApiContext.ErrorLanguage.ToString();
                }

                //Populate the message
                AbstractRequest.MessageID = System.Guid.NewGuid().ToString();

                Type     methodtype = svcInst.GetType();
                object[] reqparm    = new object[] { AbstractRequest };

                int       retries    = 0;
                int       maxRetries = 0;
                bool      doretry    = false;
                CallRetry retry      = null;
                if (mCallRetry != null)
                {
                    retry      = mCallRetry;
                    maxRetries = retry.MaximumRetries;
                }
                else if (ApiContext.CallRetry != null)
                {
                    retry      = ApiContext.CallRetry;
                    maxRetries = retry.MaximumRetries;
                }


                do
                {
                    Exception callException = null;
                    try
                    {
                        mResponse     = null;
                        mApiException = null;

                        if (retries > 0)
                        {
                            LogMessage("Invoking Call Retry", MessageType.Information, MessageSeverity.Informational);
                            System.Threading.Thread.Sleep(retry.DelayTime);
                        }

                        if (BeforeRequest != null)
                        {
                            BeforeRequest(this, new BeforeRequestEventArgs(AbstractRequest));
                        }


                        //Invoke the Service
                        DateTime start = DateTime.Now;
                        mResponse     = (AbstractResponseType)methodtype.GetMethod(apiName).Invoke(svcInst, reqparm);
                        mResponseTime = DateTime.Now - start;

                        if (AfterRequest != null)
                        {
                            AfterRequest(this, new AfterRequestEventArgs(mResponse));
                        }

                        // Catch Token Expiration warning
                        if (mResponse != null && secHdr.HardExpirationWarning != null)
                        {
                            ApiContext.ApiCredential.TokenHardExpirationWarning(
                                System.Convert.ToDateTime(secHdr.HardExpirationWarning, System.Globalization.CultureInfo.CurrentUICulture));
                        }


                        if (mResponse != null && mResponse.Errors != null && mResponse.Errors.Count > 0)
                        {
                            throw new ApiException(new ErrorTypeCollection(mResponse.Errors));
                        }
                    }

                    catch (Exception ex)
                    {
                        // this catches soap faults
                        if (ex.GetType() == typeof(TargetInvocationException))
                        {
                            // we never care about the outer exception
                            Exception iex = ex.InnerException;

                            // Parse Soap Faults
                            if (iex.GetType() == typeof(SoapException))
                            {
                                ex = ApiException.FromSoapException((SoapException)iex);
                            }
                            else if (iex.GetType() == typeof(InvalidOperationException))
                            {
                                // Go to innermost exception
                                while (iex.InnerException != null)
                                {
                                    iex = iex.InnerException;
                                }
                                ex = new ApiException(iex.Message, iex);
                            }
                            else if (iex.GetType() == typeof(HttpException))
                            {
                                HttpException httpEx = (HttpException)iex;
                                String        str    = "HTTP Error Code: " + httpEx.StatusCode;
                                ex = new ApiException(str, iex);
                            }
                            else
                            {
                                ex = new ApiException(iex.Message, iex);
                            }
                        }
                        callException = ex;

                        // log the message - override current switches - *if* (a) we wouldn't normally log it, and (b)
                        // the exception matches the exception filter.

                        if (retry != null)
                        {
                            doretry = retry.ShouldRetry(ex);
                        }

                        if (!doretry || retries == maxRetries)
                        {
                            throw ex;
                        }
                        else
                        {
                            string soapReq  = (string)this.mServiceType.GetProperty("SoapRequest").GetValue(svcInst, null);
                            string soapResp = (string)this.mServiceType.GetProperty("SoapResponse").GetValue(svcInst, null);

                            LogMessagePayload(soapReq + "\r\n\r\n" + soapResp, MessageSeverity.Informational, ex);
                            MessageSeverity svr = ((ApiException)ex).SeverityErrorCount > 0 ? MessageSeverity.Error : MessageSeverity.Warning;
                            LogMessage(ex.Message, MessageType.Exception, svr);
                        }
                    }

                    finally
                    {
                        string soapReq  = (string)this.mServiceType.GetProperty("SoapRequest").GetValue(svcInst, null);
                        string soapResp = (string)this.mServiceType.GetProperty("SoapResponse").GetValue(svcInst, null);

                        if (!doretry || retries == maxRetries)
                        {
                            LogMessagePayload(soapReq + "\r\n\r\n" + soapResp, MessageSeverity.Informational, callException);
                        }

                        if (mResponse != null && mResponse.TimestampSpecified)
                        {
                            ApiContext.CallUpdate(mResponse.Timestamp);
                        }
                        else
                        {
                            ApiContext.CallUpdate(new DateTime(0));
                        }

                        mSoapRequest  = soapReq;
                        mSoapResponse = soapResp;
                        retries++;
                    }
                } while (doretry && retries <= maxRetries);
            }

            catch (Exception ex)
            {
                ApiException aex = ex as ApiException;

                if (aex != null)
                {
                    mApiException = aex;
                }
                else
                {
                    mApiException = new ApiException(ex.Message, ex);
                }
                MessageSeverity svr = mApiException.SeverityErrorCount > 0 ? MessageSeverity.Error : MessageSeverity.Warning;
                LogMessage(mApiException.Message, MessageType.Exception, svr);

                if (mApiException.SeverityErrorCount > 0)
                {
                    throw mApiException;
                }
            }
            finally
            {
                if (this.ApiContext.EnableMetrics)
                {
                    mCallMetrics.ApiCallEnded = DateTime.Now;
                }
            }
        }
Example #4
0
        internal void SendRequest2()
        {
            try
            {
                if (AbstractRequest == null)
                {
                    throw new ApiException("RequestType reference not set to an instance of an object.", new System.ArgumentNullException());
                }
                if (ApiContext == null)
                {
                    throw new ApiException("ApiContext reference not set to an instance of an object.", new System.ArgumentNullException());
                }
                if (ApiContext.ApiCredential == null)
                {
                    throw new ApiException("Credentials reference in ApiContext object not set to an instance of an object.", new System.ArgumentNullException());
                }



                string apiName     = AbstractRequest.GetType().Name.Replace("RequestType", "");
                var    requestName = Type.GetType("eBay.Service.Core.Soap." + apiName + "Request");


                if (this.ApiContext.EnableMetrics)
                {
                    mCallMetrics = this.ApiContext.CallMetricsTable.GetNewEntry(apiName);
                    mCallMetrics.ApiCallStarted = System.DateTime.Now;
                }


                string url = "";
                try
                {
                    if (ApiContext.SoapApiServerUrl != null && ApiContext.SoapApiServerUrl.Length > 0)
                    {
                        url = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}?callname={1}&siteid={2}&client=netsoap",
                                            ApiContext.SoapApiServerUrl, apiName, SiteUtility.GetSiteID(Site).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        url = "https://api.ebay.com/wsapi";
                        url = String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}?callname={1}&siteid={2}&client=netsoap",
                                            url, apiName, SiteUtility.GetSiteID(Site).ToString(System.Globalization.CultureInfo.InvariantCulture));
                    }
                }
                catch (Exception ex)
                {
                    throw new ApiException(ex.Message, ex);
                }

                LogMessage(url, MessageType.Information, MessageSeverity.Informational);



                //mEnableCompression//数据压缩
                //moAuthToken//moAuthToken授权//
                //mWebProxy//代理
                //mCallMetrics速度监控



                var eBayAPIInterfaceClient = eBayAPIInstance.Instance.GeteBayAPIClient(url, timeout: this.Timeout);
                //var 报文 = new 报文();
                //eBayAPIInterfaceClient.Endpoint.EndpointBehaviors.Add(new ContextPropagationBehavior(报文));
                //PropertyInfo pi;

                //pi = this.mServiceType.GetProperty("ApiLogManager");
                //if (pi == null)
                //    throw new SdkException("ApiLogManager was not found in InterfaceServiceType");
                //pi.SetValue(svcInst, this.mApiContext.ApiLogManager, null);

                //pi = this.mServiceType.GetProperty("EnableComression");
                //if (pi == null)
                //    throw new SdkException("EnableComression was not found in InterfaceServiceType");
                //pi.SetValue(svcInst, this.mEnableCompression, null);

                //Add oAuth
                //if (pi == null)
                //    throw new SdkException("RequesterCredentials was not found in InterfaceServiceType");
                //pi.SetValue(svcInst, this., null);
                //if (string.IsNullOrEmpty(this.ApiContext.ApiCredential.oAuthToken))
                //{
                //    pi = this.mServiceType.GetProperty("RequesterCredentials");
                //    if (pi == null)
                //        throw new SdkException("RequesterCredentials was not found in InterfaceServiceType");
                //    pi.SetValue(svcInst, secHdr, null);
                //}

                //pi = this.mServiceType.GetProperty("WebProxy");
                //if (pi == null)
                //    throw new SdkException("WebProxy was not found in InterfaceServiceType");
                //pi.SetValue(svcInst, this.mApiContext.WebProxy, null);
                //if (this.mApiContext.WebProxy != null)
                //{
                //    LogMessage("Proxy Server is Set", MessageType.Information, MessageSeverity.Informational);
                //}

                //pi = this.mServiceType.GetProperty("CallMetricsEntry");
                //if (pi == null)
                //    throw new SdkException("CallMetricsEntry was not found in InterfaceServiceType");
                //if (this.ApiContext.EnableMetrics)
                //    pi.SetValue(svcInst, this.mCallMetrics, null);
                //else
                //    pi.SetValue(svcInst, null, null);

                //pi = this.mServiceType.GetProperty("OAuthToken");
                //if (!string.IsNullOrEmpty(this.ApiContext.ApiCredential.oAuthToken))
                //{
                //    this.mOAuth = this.ApiContext.ApiCredential.oAuthToken;
                //    pi.SetValue(svcInst, this.OAuth, null);
                //}



                ////svcCCTor.Timeout = Timeout;
                //this.mServiceType.GetProperty("Timeout").SetValue(svcInst, Timeout, null);

                AbstractRequest.Version = Version;

                if (!mDetailLevelOverride && AbstractRequest.DetailLevel == null)
                {
                    AbstractRequest.DetailLevel = mDetailLevelList;
                }

                //Added OutputSelector to base call JIRA-SDK-561
                AbstractRequest.OutputSelector = mOutputSelector;

                if (ApiContext.ErrorLanguage != ErrorLanguageCodeType.CustomCode)
                {
                    AbstractRequest.ErrorLanguage = ApiContext.ErrorLanguage.ToString();
                }

                //Populate the message
                AbstractRequest.MessageID = System.Guid.NewGuid().ToString();

                //Type methodtype = svcInst.GetType();
                //object[] reqparm = new object[] { AbstractRequest };

                CustomSecurityHeaderType secHdr = this.GetSecurityHeader();
                var request = System.Activator.CreateInstance(requestName);
                requestName.GetProperty("RequesterCredentials").SetValue(request, secHdr);
                requestName.GetProperty(apiName + "RequestType").SetValue(request, AbstractRequest);
                //, secHdr, this.AbstractRequest
                int       retries    = 0;
                int       maxRetries = 0;
                bool      doretry    = false;
                CallRetry retry      = null;
                if (mCallRetry != null)
                {
                    retry      = mCallRetry;
                    maxRetries = retry.MaximumRetries;
                }
                else if (ApiContext.CallRetry != null)
                {
                    retry      = ApiContext.CallRetry;
                    maxRetries = retry.MaximumRetries;
                }



                do
                {
                    Exception callException = null;
                    try
                    {
                        //        mResponse = null;
                        //        mApiException = null;

                        if (retries > 0)
                        {
                            LogMessage("Invoking Call Retry", MessageType.Information, MessageSeverity.Informational);
                            System.Threading.Thread.Sleep(retry.DelayTime);
                        }

                        if (BeforeRequest != null)
                        {
                            BeforeRequest(this, new BeforeRequestEventArgs(AbstractRequest));
                        }


                        //Invoke the Service
                        DateTime start = DateTime.Now;
                        //mResponse = (AbstractResponseType)methodtype.GetMethod(apiName).Invoke(svcInst, reqparm);

                        if (mCallMetrics != null)
                        {
                            mCallMetrics.NetworkSendStarted = DateTime.Now;
                            //request.Headers.Add("X-EBAY-API-METRICS", "true");
                        }
                        var response = eBayAPIInterfaceClient.GetType().GetMethod(apiName).Invoke(eBayAPIInterfaceClient, new[] { request });

                        mResponse = (AbstractResponseType)response.GetType().GetProperty(apiName + "ResponseType").GetValue(response);
                        if (mCallMetrics != null)
                        {
                            mCallMetrics.NetworkReceiveEnded = DateTime.Now;
                            //mCallMetrics.ServerProcessingTime = convertProcessingTime(response.Headers.Get("X-EBAY-API-PROCESS-TIME"));
                        }
                        //validate(response.StatusCode);
                        mResponseTime = DateTime.Now - start;

                        if (AfterRequest != null)
                        {
                            AfterRequest(this, new AfterRequestEventArgs(mResponse));
                        }

                        // Catch Token Expiration warning
                        if (mResponse != null && secHdr.HardExpirationWarning != null)
                        {
                            ApiContext.ApiCredential.TokenHardExpirationWarning(
                                System.Convert.ToDateTime(secHdr.HardExpirationWarning, System.Globalization.CultureInfo.CurrentUICulture));
                        }


                        if (mResponse != null && mResponse.Errors != null && mResponse.Errors.Count > 0)
                        {
                            throw new ApiException(new List <ErrorType>(mResponse.Errors));
                        }
                    }

                    catch (Exception ex)
                    {
                        // this catches soap faults
                        if (ex.GetType() == typeof(TargetInvocationException))
                        {
                            // we never care about the outer exception
                            Exception iex = ex.InnerException;

                            //// Parse Soap Faults
                            //if (iex.GetType() == typeof(SoapException))
                            //{
                            //    ex = ApiException.FromSoapException((SoapException)iex);
                            //}
                            //else
                            if (iex.GetType() == typeof(InvalidOperationException))
                            {
                                // Go to innermost exception
                                while (iex.InnerException != null)
                                {
                                    iex = iex.InnerException;
                                }
                                ex = new ApiException(iex.Message, iex);
                            }
                            else if (iex.GetType() == typeof(HttpException))
                            {
                                HttpException httpEx = (HttpException)iex;
                                String        str    = "HTTP Error Code: " + httpEx.StatusCode;
                                ex = new ApiException(str, iex);
                            }
                            else
                            {
                                ex = new ApiException(iex.Message, iex);
                            }
                        }
                        callException = ex;

                        // log the message - override current switches - *if* (a) we wouldn't normally log it, and (b)
                        // the exception matches the exception filter.

                        if (retry != null)
                        {
                            doretry = retry.ShouldRetry(ex);
                        }

                        if (!doretry || retries == maxRetries)
                        {
                            throw ex;
                        }
                        else
                        {
                            //string soapReq = 报文.发送.LastOrDefault();//  (string)this.mServiceType.GetProperty("SoapRequest").GetValue(svcInst, null);
                            //string soapResp = 报文.接收.LastOrDefault(); // (string)this.mServiceType.GetProperty("SoapResponse").GetValue(svcInst, null);

                            //LogMessagePayload(soapReq + "\r\n\r\n" + soapResp, MessageSeverity.Informational, ex);
                            MessageSeverity svr = ((ApiException)ex).SeverityErrorCount > 0 ? MessageSeverity.Error : MessageSeverity.Warning;
                            LogMessage(ex.Message, MessageType.Exception, svr);
                        }
                    }

                    finally
                    {
                        //string soapReq = 报文.发送.LastOrDefault();// (string)this.mServiceType.GetProperty("SoapRequest").GetValue(svcInst, null);
                        //string soapResp = 报文.接收.LastOrDefault(); //(string)this.mServiceType.GetProperty("SoapResponse").GetValue(svcInst, null);

                        //if (!doretry || retries == maxRetries)
                        //    LogMessagePayload(soapReq + "\r\n\r\n" + soapResp, MessageSeverity.Informational, callException);

                        if (mResponse != null && mResponse.Timestamp.HasValue)
                        {
                            ApiContext.CallUpdate(mResponse.Timestamp.Value);
                        }
                        else
                        {
                            ApiContext.CallUpdate(new DateTime(0));
                        }

                        //mSoapRequest = soapReq;
                        //mSoapResponse = soapResp;
                        retries++;



                        //var ssss = System.Xml.Linq.XElement.Parse(soapResp);
                        //var sdfsdfdsf = ssss.Elements().LastOrDefault().FirstNode.ToString();

                        //var ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(eBay.Service.Core.Soap.GetApiAccessRulesResponseType), "GetApiAccessRulesResponse");
                        //using (var ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(sdfsdfdsf)))
                        //{
                        //    var jsonObject = ser.ReadObject(ms);
                        //}
                    }
                } while (doretry && retries <= maxRetries);
            }

            catch (Exception ex)
            {
                ApiException aex = ex as ApiException;

                if (aex != null)
                {
                    mApiException = aex;
                }
                else
                {
                    mApiException = new ApiException(ex.Message, ex);
                }
                MessageSeverity svr = mApiException.SeverityErrorCount > 0 ? MessageSeverity.Error : MessageSeverity.Warning;
                LogMessage(mApiException.Message, MessageType.Exception, svr);

                if (mApiException.SeverityErrorCount > 0)
                {
                    throw mApiException;
                }
            }
            finally
            {
                if (this.ApiContext.EnableMetrics)
                {
                    mCallMetrics.ApiCallEnded = DateTime.Now;
                }
            }
        }
        static void SetServiceContext()
        {
            eBayApiServiceUrl = Utility.GetApplicationSetting<string>(Constants.CONST_SETTINGS_EBAY_API_SERVER_URL, "");

            eBayApiToken = Utility.GetApplicationSetting<string>(Constants.CONST_SETTINGS_EBAY_API_TOKEN, "");

            _apiContext = new ApiContext();

            _apiContext.SoapApiServerUrl = eBayApiServiceUrl;

            ApiCredential apiCredential = new ApiCredential();

            apiCredential.eBayToken = eBayApiToken;

            _apiContext.ApiCredential = apiCredential;

            _apiContext.Site = SiteCodeType.UK;

            _apiContext.ApiLogManager = new ApiLogManager();

            CallRetry retry = new CallRetry();

            retry.DelayTime = 3000;

            retry.MaximumRetries = 5;

            retry.TriggerHttpStatusCodes.Add(500);
            retry.TriggerHttpStatusCodes.Add(502);

            _apiContext.CallRetry = retry;

            FileLogger loger = new FileLogger();

            string path = Utility.GetApplicationSetting<string>("LogFilePath", @"D:\");

            //string assemblyDir = Path.GetDirectoryName(path);

            string logFileDirectory = Path.Combine(path, @"LogFilePath");

            if (!Directory.Exists(logFileDirectory))
            {
                Directory.CreateDirectory(logFileDirectory);
            }

            string logFileName = string.Format(@"{0}\eBayLog_{1}.txt", logFileDirectory, DateTime.Now.Date.ToString("yyyyMMdd"));

            loger.FileName = logFileName;

            //loger.LogApiMessages = true;
            loger.LogExceptions = true;
            loger.LogInformations = false;

            _apiContext.ApiLogManager.ApiLoggerList.Add(loger);

            _apiContext.ApiLogManager.EnableLogging = true;
        }