private void EnsureInitialized() { if (initialized) { return; } string connectionString = _fileSystemSettings.AzureUsingEmulator ? string.Format("UseDevelopmentStorage=true;") : string.Format( "DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", _fileSystemSettings.AzureAccountName, _fileSystemSettings.AzureAccountKey); if (CloudStorageAccount.TryParse(connectionString, out _storageAccount)) { CloudBlobClient cloudBlobClient = _storageAccount.CreateCloudBlobClient(); _container = cloudBlobClient.GetContainerReference( SeoHelper.TidyUrl( _fileSystemSettings.AzureContainerName.RemoveInvalidUrlCharacters())); if (_container.CreateIfNotExists()) { _container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); } initialized = true; } }
public override string GetUrl(string pageName, Webpage parent, bool useHierarchy) { var prefix = !string.IsNullOrWhiteSpace(_settings.CategoryUrl) ? _settings.CategoryUrl : "{0}"; var stringBuilder = new StringBuilder(); stringBuilder.Append(string.Format(prefix, SeoHelper.TidyUrl(pageName))); return(stringBuilder.ToString()); }
public List <BulkStockUpdateDataTransferObject> ValidateAndBulkStockUpdateProductVariants(Stream rawFile, ref Dictionary <string, List <string> > parseErrors) { var items = new List <BulkStockUpdateDataTransferObject>(); if (rawFile != null) { using (var file = new CsvReader(new StreamReader(rawFile))) { while (file.Read()) { string sku = file.GetField <string>(1), name = file.GetField <string>(0); string handle = sku.HasValue() ? sku : SeoHelper.TidyUrl(name); if (parseErrors.All(x => x.Key != handle)) { parseErrors.Add(handle, new List <string>()); } var pv = new BulkStockUpdateDataTransferObject { Name = file.GetField <string>(0), SKU = file.GetField <string>(1) }; if (file.GetField <string>(1).HasValue()) { pv.SKU = file.GetField <string>(1); } else { parseErrors[handle].Add("SKU is required."); } if (!GeneralHelper.IsValidInput <int>(file.GetField <string>(2))) { parseErrors[handle].Add("Stock value is not a valid number."); } else { pv.StockRemaining = file.GetField <string>(2).HasValue() ? Int32.Parse(file.GetField <string>(2)) : 0; } items.Add(pv); } } } parseErrors = parseErrors.Where(x => x.Value.Any()).ToDictionary(pair => pair.Key, pair => pair.Value); return(items); }
public override string GetUrl(string pageName, Webpage parent, bool useHierarchy) { var prefix = !string.IsNullOrWhiteSpace(_settings.BrandUrl) ? _settings.BrandUrl : "{0}"; var stringBuilder = new StringBuilder(); if (useHierarchy && parent != null) { stringBuilder.Insert(0, SeoHelper.TidyUrl(parent.UrlSegment) + "/"); } stringBuilder.Append(string.Format(prefix, SeoHelper.TidyUrl(pageName))); return(stringBuilder.ToString()); }
public string GetUrl(string pageName, Webpage parent, bool useHierarchy) { var stringBuilder = new StringBuilder(); if (useHierarchy) { //get breadcrumb from parent if (parent != null) { stringBuilder.Insert(0, SeoHelper.TidyUrl(parent.UrlSegment) + "/"); } } //add page name stringBuilder.Append(SeoHelper.TidyUrl(pageName)); return(stringBuilder.ToString()); }
public override string GetUrl(string pageName, Webpage parent, bool useHierarchy) { var stringBuilder = new StringBuilder(); if (useHierarchy) { //get breadcrumb from parent if (parent != null) { stringBuilder.Insert(0, SeoHelper.TidyUrl(parent.UrlSegment) + "/"); } } //add page name stringBuilder.AppendFormat("{0:yyyy/MM/}", CurrentRequestData.Now); stringBuilder.Append(SeoHelper.TidyUrl(pageName)); return(stringBuilder.ToString()); }
public override string GetUrl(string pageName, Webpage parent, bool useHierarchy) { var prefix = !string.IsNullOrWhiteSpace(_settings.CategoryUrl) ? _settings.CategoryUrl : "{0}"; var stringBuilder = new StringBuilder(); if (parent != null) { var tidyUrl = GetFormattedUrl(parent); if (!string.IsNullOrWhiteSpace(tidyUrl)) { stringBuilder.Append(tidyUrl + "/"); } } stringBuilder.Append(SeoHelper.TidyUrl(pageName)); var url = stringBuilder.ToString(); return(string.Format(prefix, url)); }
/// <summary> /// Validate And Import Products With Variants /// </summary> /// <param name="spreadsheet"></param> /// <param name="parseErrors"></param> /// <returns></returns> public HashSet <ProductImportDataTransferObject> ValidateAndImportProductsWithVariants(ExcelPackage spreadsheet, ref Dictionary <string, List <string> > parseErrors) { var productsToImport = new HashSet <ProductImportDataTransferObject>(); if (!parseErrors.Any()) { if (spreadsheet != null) { if (spreadsheet.Workbook != null) { var worksheet = spreadsheet.Workbook.Worksheets.SingleOrDefault(x => x.Name == "Items"); if (worksheet != null) { var totalRows = worksheet.Dimension.End.Row; for (var rowId = 2; rowId <= totalRows; rowId++) { if (!worksheet.GetValue <string>(rowId, 1).HasValue() && !worksheet.GetValue <string>(rowId, 2).HasValue() && !worksheet.GetValue <string>(rowId, 3).HasValue()) { continue; } var product = new ProductImportDataTransferObject(); //Prepare handle name for storing and grouping errors string url = worksheet.GetValue <string>(rowId, 1), name = worksheet.GetValue <string>(rowId, 2); var handle = url.HasValue() ? url : SeoHelper.TidyUrl(name); if (!productsToImport.Any(x => x.Name == name || x.UrlSegment == url)) { if (parseErrors.All(x => x.Key != handle)) { parseErrors.Add(handle, new List <string>()); } product.UrlSegment = worksheet.GetValue <string>(rowId, 1).HasValue() ? worksheet.GetValue <string>(rowId, 1) : _urlService.Suggest(null, new SuggestParams { PageName = name, DocumentType = typeof(Product).FullName }); //skip duplicate url if (productsToImport.Any(x => x.UrlSegment == product.UrlSegment)) { continue; } GetBasicData(parseErrors, worksheet, rowId, product, handle); GetCategories(parseErrors, worksheet, rowId, product, handle); GetSpecifications(parseErrors, worksheet, rowId, handle, product); GetImages(worksheet, rowId, product); GetUrlHistory(parseErrors, worksheet, rowId, product, handle); productsToImport.Add(product); } else { product = !string.IsNullOrWhiteSpace(url) ? productsToImport.SingleOrDefault(x => x.Name == name && x.UrlSegment == url) : productsToImport.SingleOrDefault(x => x.Name == name); } //Variants if (product != null) { var productVariant = GetProductVariant(parseErrors, worksheet, rowId, handle); if (productVariant != null) { //Options GetProductVariantOptions(worksheet, rowId, productVariant); //Price Breaks GetPriceBreaks(parseErrors, worksheet, rowId, handle, productVariant); product.ProductVariants.Add(productVariant); } } } } } } //Remove handles with no errors parseErrors = parseErrors.Where(x => x.Value.Any()).ToDictionary(pair => pair.Key, pair => pair.Value); } var i = productsToImport.Where(x => x.ProductVariants.Count == 0).ToList(); return(productsToImport); }