Пример #1
0
        public static int GetFileSize(IHttpClientFactory httpClientFactory, LoaderProperties loaderProperties, DBConnector cnn, int fieldId, string shortFieldUrl, string longFieldUrl)
        {
            if (loaderProperties.UseFileSizeService)
            {
                var url    = GetFileStorageUrl(cnn, fieldId, longFieldUrl);
                var client = httpClientFactory.CreateClient();
                try
                {
                    var response = client.GetAsync(url).Result.Content.ReadAsStringAsync().Result;
                    return(int.Parse(response));
                }
                catch (Exception ex)
                {
                    Logger.Warn()
                    .Exception(ex)
                    .Message("Cannot receive file size with url: {url}", url)
                    .Write();

                    return(0);
                }
            }

            var path = GetFileFromQpFieldPath(cnn, fieldId, shortFieldUrl);

            if (File.Exists(path))
            {
                return((int)new FileInfo(path).Length);
            }

            Logger.Warn()
            .Message("Cannot find file with path: {path}", path)
            .Write();

            return(0);
        }
Пример #2
0
 public XmlProductService(
     ILogger logger,
     ISettingsService settingsService,
     IConnectionProvider connectionProvider,
     IRegionTagReplaceService regionTagReplaceService,
     IOptions <LoaderProperties> loaderProperties,
     IHttpClientFactory factory
     )
 {
     _logger                  = logger;
     _settingsService         = settingsService;
     _regionTagReplaceService = regionTagReplaceService;
     _customer                = connectionProvider.GetCustomer();
     _loaderProperties        = loaderProperties.Value;
     _factory                 = factory;
 }
Пример #3
0
        public JsonProductService(
            IConnectionProvider connectionProvider,
            ILogger logger,
            ContentService contentService,
            FieldService fieldService,
            VirtualFieldContextService virtualFieldContextService,
            IRegionTagReplaceService regionTagReplaceService,
            IOptions<LoaderProperties> loaderProperties,
            IHttpClientFactory factory            
            )
        {
            _logger = logger;
            _contentService = contentService;
            _fieldService = fieldService;

            var customer = connectionProvider.GetCustomer();
            _dbConnector = new DBConnector(customer.ConnectionString, customer.DatabaseType);

            _virtualFieldContextService = virtualFieldContextService;
            _regionTagReplaceService = regionTagReplaceService;
            _loaderProperties = loaderProperties.Value;
            _factory = factory;
        }
Пример #4
0
 public WarmUpRepeater(IOptions <LoaderProperties> props, IWarmUpProvider provider)
 {
     _provider = provider;
     _props    = props.Value;
 }
Пример #5
0
 public ProductLoaderWarmUpProvider(ProductLoader productLoader, ILogger logger, IOptions <LoaderProperties> props)
 {
     _productLoader = productLoader;
     _props         = props.Value;
     _logger        = logger;
 }