コード例 #1
0
ファイル: AmazonLogService.cs プロジェクト: neozhu/Ecommerce
        public AmazonLog Add(AmazonLogType type, AmazonLogStatus status, Exception elmahError, MarketplaceWebService.Model.Error amazonError,
            AmazonApiSection? apiSection, string apiOperation, AmazonOrder amazonOrder, AmazonListing amazonListing, AmazonListingGroup amazonListingGroup,
            string message = "", string details = "")
        {
            var log = new AmazonLog
                          {
                              LogType = type,
                              LogStatus = status,
                              AmazonOrder = amazonOrder,
                              ApiSection = apiSection,
                              ApiOperation = !String.IsNullOrWhiteSpace(apiOperation) ? apiOperation : null,
                              AmazonListing = amazonListing,
                              AmazonListingGroup = amazonListingGroup,
                              Message = !String.IsNullOrWhiteSpace(message) ? message : null,
                              Detail = !String.IsNullOrWhiteSpace(details) ? details : null,
                              Site = CurrentRequestData.CurrentSite
                          };
            log.SetGuid(Guid.NewGuid());
            if (elmahError != null)
            {
                log.Message = elmahError.Message;
                log.Detail = elmahError.StackTrace;
            }
            if (amazonError != null)
            {
                log.ErrorCode = amazonError.Code;
                log.ErrorType = amazonError.Type;
                log.Message = amazonError.Message;
                log.Detail = amazonError.Detail.ToString();
            }

            return Save(log);
        }
コード例 #2
0
 public AmazonApiLog GetByTimeRange(AmazonApiSection? apiSection, string apiOperation, DateTime from, DateTime to)
 {
     return _session.QueryOver<AmazonApiLog>()
                .Where(x => from >= x.CreatedOn && x.CreatedOn <= to
                    && x.ApiSection == apiSection
                    && x.ApiOperation == apiOperation
                    && x.Site == CurrentRequestData.CurrentSite).Cacheable()
                .SingleOrDefault();
 }
コード例 #3
0
 public AmazonApiLog TrackNewApiCall(AmazonApiSection? apiSection, string apiOperation)
 {
     var amazonApiUsage = new AmazonApiLog()
         {
             ApiSection = apiSection,
             ApiOperation = apiOperation,
             Site = CurrentRequestData.CurrentSite
         };
        
     return _amazonApiUsageService.Save(amazonApiUsage);
 }
コード例 #4
0
        private AmazonServiceStatus GetServiceStatus(AmazonApiSection apiSection)
        {
            try
            {
                _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Stage, null, null, apiSection,
                                      "GetServiceStatus", null, null, null, "Getting Api Service Status");
                _amazonAnalyticsService.TrackNewApiCall(apiSection, "GetServiceStatus");
                switch (apiSection)
                {
                case AmazonApiSection.Orders:
                    var ordersApiRequest = new GetServiceStatusRequest {
                        SellerId = _amazonSellerSettings.SellerId
                    };
                    var ordersApiResult = GetOrdersApiService().GetServiceStatus(ordersApiRequest);
                    if (ordersApiResult != null && ordersApiResult.GetServiceStatusResult != null)
                    {
                        return(ordersApiResult.GetServiceStatusResult.Status.GetEnumByValue <AmazonServiceStatus>());
                    }
                    break;

                case AmazonApiSection.Products:
                    var productsApiRequest = new MarketplaceWebServiceProducts.Model.GetServiceStatusRequest
                    {
                        SellerId = _amazonSellerSettings.SellerId
                    };
                    var productsApiResult = GetProductsApiService().GetServiceStatus(productsApiRequest);
                    if (productsApiResult != null && productsApiResult.GetServiceStatusResult != null)
                    {
                        return(productsApiResult.GetServiceStatusResult.Status.GetEnumByValue <AmazonServiceStatus>());
                    }
                    break;
                }
            }
            catch (MarketplaceWebServiceProductsException ex)
            {
                _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Error, ex, null, apiSection, "GetServiceStatus",
                                      null, null, null);
            }
            catch (MarketplaceWebServiceOrdersException ex)
            {
                _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Error, ex, null, apiSection, "GetServiceStatus",
                                      null, null, null);
            }
            catch (Exception ex)
            {
                CurrentRequestData.ErrorSignal.Raise(ex);
            }
            return(AmazonServiceStatus.RED);
        }
コード例 #5
0
ファイル: AmazonApiService.cs プロジェクト: neozhu/Ecommerce
 private AmazonServiceStatus GetServiceStatus(AmazonApiSection apiSection)
 {
     try
     {
         _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Stage, null, null, apiSection,
                               "GetServiceStatus", null, null, null, "Getting Api Service Status");
         _amazonAnalyticsService.TrackNewApiCall(apiSection, "GetServiceStatus");
         switch (apiSection)
         {
             case AmazonApiSection.Orders:
                 var ordersApiRequest = new GetServiceStatusRequest { SellerId = _amazonSellerSettings.SellerId };
                 var ordersApiResult = GetOrdersApiService().GetServiceStatus(ordersApiRequest);
                 if (ordersApiResult != null && ordersApiResult.GetServiceStatusResult != null)
                     return ordersApiResult.GetServiceStatusResult.Status.GetEnumByValue<AmazonServiceStatus>();
                 break;
             case AmazonApiSection.Products:
                 var productsApiRequest = new MarketplaceWebServiceProducts.Model.GetServiceStatusRequest
                     {
                         SellerId = _amazonSellerSettings.SellerId
                     };
                 var productsApiResult = GetProductsApiService().GetServiceStatus(productsApiRequest);
                 if (productsApiResult != null && productsApiResult.GetServiceStatusResult != null)
                     return productsApiResult.GetServiceStatusResult.Status.GetEnumByValue<AmazonServiceStatus>();
                 break;
         }
     }
     catch (MarketplaceWebServiceProductsException ex)
     {
         _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Error, ex, null, apiSection, "GetServiceStatus",
                               null, null, null);
     }
     catch (MarketplaceWebServiceOrdersException ex)
     {
         _amazonLogService.Add(AmazonLogType.Api, AmazonLogStatus.Error, ex, null, apiSection, "GetServiceStatus",
                               null, null, null);
     }
     catch (Exception ex)
     {
         CurrentRequestData.ErrorSignal.Raise(ex);
     }
     return AmazonServiceStatus.RED;
 }
コード例 #6
0
ファイル: AmazonApiService.cs プロジェクト: neozhu/Ecommerce
 public bool IsLive(AmazonApiSection apiSection)
 {
     var serviceStatus = GetServiceStatus(apiSection);
     return serviceStatus == AmazonServiceStatus.GREEN || serviceStatus == AmazonServiceStatus.GREEN_I;
 }
コード例 #7
0
        public bool IsLive(AmazonApiSection apiSection)
        {
            var serviceStatus = GetServiceStatus(apiSection);

            return(serviceStatus == AmazonServiceStatus.GREEN || serviceStatus == AmazonServiceStatus.GREEN_I);
        }