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); }
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(); }
public AmazonApiLog TrackNewApiCall(AmazonApiSection? apiSection, string apiOperation) { var amazonApiUsage = new AmazonApiLog() { ApiSection = apiSection, ApiOperation = apiOperation, Site = CurrentRequestData.CurrentSite }; return _amazonApiUsageService.Save(amazonApiUsage); }
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); }
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; }
public bool IsLive(AmazonApiSection apiSection) { var serviceStatus = GetServiceStatus(apiSection); return serviceStatus == AmazonServiceStatus.GREEN || serviceStatus == AmazonServiceStatus.GREEN_I; }
public bool IsLive(AmazonApiSection apiSection) { var serviceStatus = GetServiceStatus(apiSection); return(serviceStatus == AmazonServiceStatus.GREEN || serviceStatus == AmazonServiceStatus.GREEN_I); }