public HomeController(ILogger <HomeController> logger, ILibraryService libraryService, IWebHostEnvironment webEnvironment, IBarcodeService barcodeService) { this.logger = logger; this.libraryService = libraryService; this.webEnvironment = webEnvironment; this.barcodeService = barcodeService; }
public CallWalmartProcessing(ILogService log, ITime time, ICacheService cacheService, IDbFactory dbFactory, IEmailService emailService, IItemHistoryService itemHistoryService, WalmartApi walmartApi, CompanyDTO company) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _walmartApi = walmartApi; _company = company; _emailService = emailService; _itemHistoryService = itemHistoryService; _actionService = new SystemActionService(_log, _time); _htmlScraper = new HtmlScraperService(log, time, dbFactory); _barcodeService = new BarcodeService(log, time, dbFactory); _openApi = new WalmartOpenApi(_log, "trn9fdghvb8p9gjj9j6bvjwx"); _autoCreateListingService = new AutoCreateWalmartListingService(log, time, dbFactory, _cacheService, _barcodeService, _emailService, _openApi, itemHistoryService, AppSettings.IsDebug); }
public CallEBayProcessing(ILogService log, ITime time, ICacheService cacheService, IDbFactory dbFactory, IStyleManager styleManager, eBayApi eBayApi, IEmailService emailService, CompanyDTO company) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _styleManager = styleManager; _descriptionTemplatePath = Path.Combine(AppSettings.TemplateDirectory, TemplateHelper.EBayDescriptionTemplateName); _descriptionMultiListingTemplatePath = Path.Combine(AppSettings.TemplateDirectory, TemplateHelper.EBayDescriptionMultiListingTemplateName); _eBayApi = eBayApi; _company = company; _emailService = emailService; _actionService = new SystemActionService(_log, _time); _htmlScraper = new HtmlScraperService(log, time, dbFactory); var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory); _barcodeService = new BarcodeService(log, time, dbFactory); _autoCreateListingService = new AutoCreateEBayListingService(_log, _time, dbFactory, cacheService, _barcodeService, _emailService, itemHistoryService, AppSettings.IsDebug); }
public CallSupplieroasisProcessing(ILogService log, ITime time, ICacheService cacheService, IEmailService emailService, IDbFactory dbFactory, CompanyDTO company) { _dbFactory = dbFactory; _cacheService = cacheService; _barcodeService = new BarcodeService(log, time, dbFactory); _trackingNumberService = new TrackingNumberService(log, time, dbFactory); _log = log; _time = time; _emailService = emailService; _company = company; _weightService = new WeightService(); _messageService = new SystemMessageService(_log, _time, dbFactory); _actionService = new SystemActionService(_log, _time); _htmlScraper = new HtmlScraperService(log, time, dbFactory); var itemHistoryService = new ItemHistoryService(log, time, dbFactory); _autoCreateListingService = new AutoCreateNonameListingService(_log, _time, dbFactory, cacheService, _barcodeService, _emailService, itemHistoryService, AppSettings.IsDebug); }
public BarcodeController( IBarcodeService barcodeService, IProductService productService ) { _barcodeService = barcodeService; _productService = productService; }
void Initialize() { if (azure == null || searchService == null) { azure = ServiceLocator.Instance.Resolve<IAzureClient>(); searchService = ServiceLocator.Instance.Resolve<ISearchService>(); barcodeService = ServiceLocator.Instance.Resolve<IBarcodeService>(); } }
void Initialize() { if (azure == null || searchService == null) { azure = ServiceLocator.Instance.Resolve <IAzureClient>(); searchService = ServiceLocator.Instance.Resolve <ISearchService>(); barcodeService = ServiceLocator.Instance.Resolve <IBarcodeService>(); } }
public ProductService(IProductRepository productRepository, ICategoryRepository categoryRepository, IBarcodeService barcodeService, IMapper mapper) { _productRepository = productRepository; _categoryRepository = categoryRepository; _barcodeService = barcodeService; _mapper = mapper; }
public static string GenerateBarcode(IBarcodeService barcodeService, string sku, DateTime when) { var barcodeInfo = barcodeService.AssociateBarcodes(sku, when, null); if (barcodeInfo != null) { return(barcodeInfo.Barcode); } return(String.Empty); }
public AutoCreateEBayListingService(ILogService log, ITime time, IDbFactory dbFactory, ICacheService cacheService, IBarcodeService barcodeService, IEmailService emailService, IItemHistoryService itemHistoryService, bool isDebug) : base(log, time, dbFactory, cacheService, barcodeService, emailService, itemHistoryService, isDebug) { _log = log; _time = time; _dbFactory = dbFactory; }
public AutoCreateAmazonAUListingService(ILogService log, ITime time, IDbFactory dbFactory, ICacheService cacheService, IBarcodeService barcodeService, IEmailService emailService, ISystemActionService actionService, IItemHistoryService itemHistoryService, bool isDebug) : base(log, time, dbFactory, cacheService, barcodeService, emailService, itemHistoryService, isDebug) { _log = log; _time = time; _dbFactory = dbFactory; _actionService = actionService; }
public CallMagentoProcessing(ILogService log, ITime time, IEmailService emailService, ICacheService cacheService, IDbFactory dbFactory) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _emailService = emailService; var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory); _barcodeService = new BarcodeService(log, time, dbFactory); _autoCreateListingService = new AutoCreateNonameListingService(_log, _time, dbFactory, cacheService, _barcodeService, _emailService, itemHistoryService, AppSettings.IsDebug); }
public AutoCreateWalmartCAListingService(ILogService log, ITime time, IDbFactory dbFactory, ICacheService cacheService, IBarcodeService barcodeService, IEmailService emailService, IItemHistoryService itemHistoryService, bool isDebug) : base(log, time, dbFactory, cacheService, barcodeService, emailService, itemHistoryService, isDebug) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _barcodeService = barcodeService; _emailService = emailService; _isDebug = isDebug; }
public ImportRelist(ILogService log, ITime time, IDbFactory dbFactory, ICacheService cacheService, IEmailService emailService, ISystemActionService actionService) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _emailService = emailService; _actionService = actionService; var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory); _barcodeService = new BarcodeService(_log, _time, _dbFactory); _autoCreateListingService = new AutoCreateNonameListingService(_log, _time, _dbFactory, _cacheService, _barcodeService, _emailService, itemHistoryService, AppSettings.IsDebug); }
public DSCustomItemsSync(ILogService log, ITime time, IDbFactory dbFactory, IBarcodeService barcodeService, long dropShipperId, MarketType destMarket, string destMarketplaceId, MarketType sourceMarket, string sourceMarketplaceId) { _log = log; _time = time; _dbFactory = dbFactory; _barcodeService = barcodeService; _dropShipperId = dropShipperId; _destMarket = destMarket; _destMarketplaceId = destMarketplaceId; _sourceMarket = sourceMarket; _sourceMarketplaceId = sourceMarketplaceId; }
public static IList <CustomBarcodeViewModel> AssociateBarcodes(IBarcodeService barcodeService, string skuText, DateTime when, long?by) { var skuList = skuText.Split(" \r\n\t".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var results = new List <CustomBarcodeViewModel>(); foreach (var sku in skuList) { var formattedSku = sku.Trim(); if (String.IsNullOrEmpty(formattedSku)) { continue; } var barcodeDto = barcodeService.AssociateBarcodes(sku, when, by); results.Add(new CustomBarcodeViewModel(barcodeDto)); } return(results); }
public CallDsApiProcessing(ILogService log, ITime time, ICacheService cacheService, IQuantityManager quantityManager, ISystemActionService actionService, IEmailService emailService, IDbFactory dbFactory) { _dbFactory = dbFactory; _cacheService = cacheService; _quantityManager = quantityManager; _actionService = actionService; _barcodeService = new BarcodeService(log, time, dbFactory); _log = log; _time = time; _emailService = emailService; var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory); var barcodeService = new BarcodeService(log, time, dbFactory); _autoCreateListingService = new AutoCreateNonameListingService(_log, _time, dbFactory, cacheService, barcodeService, emailService, itemHistoryService, AppSettings.IsDebug); }
public CallWalmartCAProcessing(ILogService log, ITime time, ICacheService cacheService, IDbFactory dbFactory, IEmailService emailService, WalmartCAApi walmartCAApi, CompanyDTO company) { _log = log; _time = time; _dbFactory = dbFactory; _cacheService = cacheService; _walmartCAApi = walmartCAApi; _company = company; _emailService = emailService; var itemHistoryService = new ItemHistoryService(_log, _time, _dbFactory); _actionService = new SystemActionService(_log, _time); _htmlScraper = new HtmlScraperService(log, time, dbFactory); _barcodeService = new BarcodeService(log, time, dbFactory); _autoCreateListingService = new AutoCreateWalmartCAListingService(log, time, dbFactory, _cacheService, _barcodeService, _emailService, itemHistoryService, AppSettings.IsDebug); }
public Entry2PageViewModel( INavigator navigator, IDialogService dialogService, ISettingService settingService, IBarcodeService barcodeService, ItemService itemService, EntryService entryService, Session session) { this.navigator = navigator; this.dialogService = dialogService; this.barcodeService = barcodeService; this.itemService = itemService; this.entryService = entryService; UserId.Value = session.UserId; TerminalNo.Value = settingService.GetTerminalNo(); BackCommand = MakeAsyncCommand(Back); NextCommand = MakeAsyncCommand(Next); ScanCommand = MakeAsyncCommand(Scan); EditCommand = MakeAsyncCommand <EntryEntity>(Edit); }
public ResultsController(IRepositoryFactory repositoryFactory, IPhredService phredService, IBarcodeService barcodeService) { _repositoryFactory = repositoryFactory; _phredService = phredService; _barcodeService = barcodeService; }
public UserJobController(IRepositoryFactory repositoryFactory, IBarcodeService barcodeService) { _repositoryFactory = repositoryFactory; _barcodeService = barcodeService; }
/// <summary> /// 初始化一个<see cref="ZXingBarcodeServiceTest"/>类型的实例 /// </summary> public ZXingBarcodeServiceTest(ITestOutputHelper output) : base(output) { _service = new ZXingBarcodeService(); }
public PrinterController(IBarcodeService barcodeService) { _barcodeService = barcodeService; }
public static void CopyToMarketplaces(IUnitOfWork db, ICacheService cache, IBarcodeService barcodeService, ISystemActionService actionService, IAutoCreateListingService autoCreateListingService, IItemHistoryService itemHistoryService, int id, DateTime when, long?by, IList <ItemMarketViewModel> toMarketplaces, out IList <MessageString> messages) { var parent = db.ParentItems.GetAsDTO(id); messages = new List <MessageString>(); foreach (var toMarketplace in toMarketplaces) { var model = ItemEditViewModel.CreateFromParentASIN(db, autoCreateListingService, parent.ASIN, parent.Market, parent.MarketplaceId, false, //NOTE: false - ex.: exclude to copy FBP to Walmart out messages); model.Id = null; model.Market = toMarketplace.Market; model.MarketplaceId = toMarketplace.MarketplaceId; //model.OnHold = true; var parentBaseASIN = SkuHelper.RemoveSKULastIndex(model.ASIN); var parentIndex = 0; while (db.ParentItems.GetAsDTO(parentBaseASIN + ((parentIndex == 0) ? "" : "-" + parentIndex), (MarketType)toMarketplace.Market, toMarketplace.MarketplaceId) != null) { parentIndex++; } var parentSKU = parentBaseASIN + ((parentIndex == 0) ? "" : "-" + parentIndex); var forceReplace = model.VariationList.Any(s => (s.Size ?? "").Contains("/")); model.ASIN = parentSKU; foreach (var item in model.VariationList) { item.Id = null; if (model.Market == (int)MarketType.Walmart || model.Market == (int)MarketType.WalmartCA) { item.Barcode = null; item.AutoGeneratedBarcode = true; } if (item.StyleItemId.HasValue) { var sourceUSDPrice = item.Price; var fromCurrency = PriceHelper.GetCurrencyAbbr((MarketType)parent.Market, parent.MarketplaceId); if (fromCurrency != PriceHelper.USDSymbol) { sourceUSDPrice = PriceHelper.ConvertToUSD(item.Price, fromCurrency); } var rateForMarketplace = RateHelper.GetRatesByStyleItemId(db, item.StyleItemId.Value); var newPrice = RateHelper.CalculateForMarket((MarketType)toMarketplace.Market, toMarketplace.MarketplaceId, sourceUSDPrice, rateForMarketplace[MarketplaceKeeper.AmazonComMarketplaceId], rateForMarketplace[MarketplaceKeeper.AmazonCaMarketplaceId], rateForMarketplace[MarketplaceKeeper.AmazonUkMarketplaceId], rateForMarketplace[MarketplaceKeeper.AmazonAuMarketplaceId], RateService.GetMarketShippingAmount(MarketType.Amazon, MarketplaceKeeper.AmazonComMarketplaceId), RateService.GetMarketShippingAmount((MarketType)toMarketplace.Market, toMarketplace.MarketplaceId), RateService.GetMarketExtraAmount((MarketType)toMarketplace.Market, toMarketplace.MarketplaceId)); if (newPrice.HasValue) { item.Price = newPrice.Value; } } if (db.Listings.CheckForExistenceSKU(item.SKU, (MarketType)toMarketplace.Market, toMarketplace.MarketplaceId)) { var baseSKU = item.StyleString + "-" + SizeHelper.PrepareSizeForSKU(item.StyleSize, forceReplace); var index = parentIndex; while (db.Listings.CheckForExistenceSKU(SkuHelper.SetSKUMiddleIndex(baseSKU, index), (MarketType)toMarketplace.Market, toMarketplace.MarketplaceId)) { index++; } item.SKU = SkuHelper.SetSKUMiddleIndex(baseSKU, index); } } model.Save(db, cache, barcodeService, actionService, itemHistoryService, when, by); } }
public string Export(IUnitOfWork db, ITime time, ILogService log, IBarcodeService barcodeService, IMarketCategoryService categoryService, IMarketplaceService marketplaceService, DateTime when, long?by) { log.Info("Export, parentId=" + Id + ", market=" + Market + ", marketplaceId=" + MarketplaceId); string filename = null; var parent = db.ParentItems.GetAsDTO((int)Id); var parentImage = db.ParentItemImages.GetAllAsDto().FirstOrDefault(pi => pi.ItemId == parent.Id); parent.LargeImage = parentImage; var parentChildren = db.Items.GetAllActualExAsDto().Where(i => i.ParentASIN == parent.ASIN && //NOTE: use original ASIN i.Market == (int)parent.Market && i.MarketplaceId == parent.MarketplaceId).ToList(); //if (exportMode != ExportToExcelMode.FBA) //TASK: Generate excel only for listing that haven't FBA parentChildren = parentChildren.Where(i => !i.IsFBA).ToList(); parentChildren = parentChildren .OrderBy(ch => ch.StyleString) .ThenBy(ch => SizeHelper.GetSizeIndex(ch.Size)) .ToList(); var children = VariationList .Where(v => v.IsSelected && !String.IsNullOrEmpty(v.StyleString)) .Select(v => new ItemExDTO() { StyleString = v.StyleString, StyleId = v.StyleId, StyleItemId = v.StyleItemId, Barcode = v.Barcode, SKU = v.SKU, Size = v.Size, Color = v.Color, CurrentPrice = v.Price, }).ToList(); parent.ASIN = ASIN; parent.AmazonName = Name; var styleStringList = children.Select(ch => ch.StyleString).Distinct().ToList(); var styles = db.Styles.GetAllActive().Where(s => styleStringList.Contains(s.StyleID)).ToList(); for (int i = 0; i < children.Count; i++) { var style = styles.FirstOrDefault(s => s.StyleID == children[i].StyleString); if (style != null) { children[i].StyleId = style.Id; } var existParentChild = parentChildren.FirstOrDefault(p => String.Compare(p.SKU, children[i].SKU, StringComparison.OrdinalIgnoreCase) == 0); if (existParentChild != null) { children[i].Id = existParentChild.Id; children[i].ASIN = existParentChild.ASIN; children[i].Name = existParentChild.Name; children[i].ImageUrl = existParentChild.ImageUrl; children[i].IsExistOnAmazon = existParentChild.IsExistOnAmazon; children[i].ListPrice = existParentChild.ListPrice; children[i].BrandName = existParentChild.BrandName; children[i].SpecialSize = existParentChild.SpecialSize; children[i].Features = existParentChild.Features; children[i].Department = existParentChild.Department; children[i].RealQuantity = existParentChild.RealQuantity; children[i].Weight = existParentChild.Weight; //NOTE: only for FBA children[i].IsPrime = existParentChild.IsPrime; } } var resultRecords = ExcelProductUSViewModel.GetItemsFor(db, categoryService, ExportToExcelMode.Normal, null, parent, children, PictureSourceType == PictureSourceTypes.FromStyle ? UseStyleImageModes.StyleImage : UseStyleImageModes.ListingImage, out filename); //NOTE: mark already exist listings as PartialUpdate foreach (var resultRecord in resultRecords) { if (resultRecord.Id > 0 && resultRecord.Parentage == ExcelHelper.ParentageChild && resultRecord.IsExistOnAmazon) { resultRecord.Update = "PartialUpdate"; resultRecord.Quantity = null; resultRecord.StandardPrice = null; //resultRecord.SuggestedPrice = null; //resultRecord.MainImageURL = null; //resultRecord.OtherImageUrl1 = null; //resultRecord.OtherImageUrl2 = null; //resultRecord.OtherImageUrl3 = null; } } var firstResult = resultRecords.FirstOrDefault(r => r.Parentage == ExcelHelper.ParentageChild); if (firstResult != null) { foreach (var resultRecord in resultRecords) { if (CopyBulletPoints && resultRecord.Id == 0 && resultRecord.Parentage == ExcelHelper.ParentageChild) { resultRecord.KeyProductFeatures1 = firstResult.KeyProductFeatures1; resultRecord.KeyProductFeatures2 = firstResult.KeyProductFeatures2; resultRecord.KeyProductFeatures3 = firstResult.KeyProductFeatures3; resultRecord.KeyProductFeatures4 = firstResult.KeyProductFeatures4; resultRecord.KeyProductFeatures5 = firstResult.KeyProductFeatures5; resultRecord.SearchTerms1 = firstResult.SearchTerms1; } } } var styleStringToGenerate = children.Where(ch => ch.Id == 0).Select(ch => ch.StyleString).Distinct().ToList(); foreach (var styleString in styleStringToGenerate) { var styleDto = db.Styles.GetActiveByStyleIdAsDto(styleString); var styleModel = new StyleViewModel(db, marketplaceService, styleDto); //Update Barcode and AutoGenerateBarcode flag, other info already exists in resultRecords foreach (var si in styleModel.StyleItems.Items) { var variationItem = VariationList.FirstOrDefault(v => v.StyleItemId == si.Id); if (variationItem != null) { if (!String.IsNullOrEmpty(variationItem.Barcode)) { si.Barcodes = new[] { new BarcodeDTO() { Barcode = variationItem.Barcode } } } ; si.AutoGeneratedBarcode = variationItem.AutoGeneratedBarcode; } } string tempFilename = null; var styleResultRecords = ExcelProductUSViewModel.GenerateToExcelUS(db, barcodeService, categoryService, styleModel, when, out tempFilename); foreach (var styleResultRecord in styleResultRecords) { if (!styleResultRecord.StyleItemId.HasValue) { continue; } var resultRecord = resultRecords.FirstOrDefault(s => s.StyleItemId == styleResultRecord.StyleItemId); if (resultRecord != null) { resultRecord.ASIN = styleResultRecord.ASIN; resultRecord.ProductId = styleResultRecord.ProductId; resultRecord.Title = styleResultRecord.Title; resultRecord.Description = styleResultRecord.Description; resultRecord.BrandName = styleResultRecord.BrandName; resultRecord.Type = styleResultRecord.Type; resultRecord.MainImageURL = styleResultRecord.MainImageURL; resultRecord.OtherImageUrl1 = styleResultRecord.OtherImageUrl1; resultRecord.OtherImageUrl2 = styleResultRecord.OtherImageUrl2; resultRecord.OtherImageUrl3 = styleResultRecord.OtherImageUrl3; resultRecord.Department = styleResultRecord.Department; resultRecord.SuggestedPrice = styleResultRecord.SuggestedPrice; resultRecord.Quantity = styleResultRecord.Quantity; if (!CopyBulletPoints) { resultRecord.KeyProductFeatures1 = styleResultRecord.KeyProductFeatures1; resultRecord.KeyProductFeatures2 = styleResultRecord.KeyProductFeatures2; resultRecord.KeyProductFeatures3 = styleResultRecord.KeyProductFeatures3; resultRecord.KeyProductFeatures4 = styleResultRecord.KeyProductFeatures4; resultRecord.KeyProductFeatures5 = styleResultRecord.KeyProductFeatures5; resultRecord.SearchTerms1 = styleResultRecord.SearchTerms1; } } } } var stream = ExcelHelper.ExportIntoFile(HttpContext.Current.Server.MapPath(ExcelProductUSViewModel.USTemplatePath), "Template", resultRecords); var filePath = UrlHelper.GetProductTemplateFilePath(filename); using (var file = File.Open(filePath, FileMode.Create)) { stream.WriteTo(file); } return(UrlHelper.GetProductTemplateUrl(filename)); } }
/// <summary> /// Initiated a instance of the <see cref="BarcodeController"/> class /// </summary> /// <param name="barcodeService">A implementation of the <see cref="IBarcodeService"/> interface</param> /// <param name="mapper">A implementation of the <see cref="IMapper"/> interface</param> public BarcodeController(IBarcodeService barcodeService, IMapper mapper) { this.barcodeService = barcodeService; this.mapper = mapper; }
public void SetUp() { _service = _kernel.Get <IBarcodeService>(); }
public CardService(IBarcodeService barcodeService) { _filePath = string.Empty; _barcodeService = barcodeService; }
public PrinterController(IBarcodeService barcodeService) { _barcodeService = barcodeService; }
public ResultsController(IRepositoryFactory repositoryFactory, IPhredService phredService, IBarcodeService barcodeService) { _repositoryFactory = repositoryFactory; _phredService = phredService; _barcodeService = barcodeService; }
/// <summary> /// Constructor. /// </summary> /// <param name="scanner">BarcodeScan service.</param> /// <param name="searcher"></param> /// <param name="logger">NLog logger.</param> public BarcodeController(IBarcodeService scanner, IBarcodeCatalogSearchService searcher, ILogger logger) : base(logger) { _scanner = scanner; _searcher = searcher; }
public static IList <ExcelWFSProductUSViewModel> GenerateToExcelUS(IUnitOfWork db, IBarcodeService barcodeService, IMarketCategoryService categoryService, StyleViewModel model, DateTime when, out string filename) { /* * 1. Item_sku: * a. First row = Style * b. Other rows – Style-%size%, i.e. K123123-2T, K123123-3T.. * 2. Item name: * a. First Raw - %Name% + “,”+%Size Group% (Infant, Toddler, Kids)+”Sizes”+%Size_Range%” (example: Planes Boys 'Turn Up the Heat' Coat Style Pajama Set, Toddler Sizes 2T-4T) * b. Other rows: %Name% + “,”+%Size Group% (Infant, Toddler, Kids)+%Size% (i.e. Planes Boys 'Turn Up the Heat' Coat Style Pajama Set, Toddler Size 2T) * 3. external_product_id – barcode (empty for first raw) * 4. external_product_id_type – harcoded “UPC” (empty for first raw) * 16. brand_name - Main License * 17. item_type – use same logic as you use when you generate xls from ASIN * 18. main_image_url – upload image to server, and insert public URL to this image here * 19. Color - %Color% * 20. Department_name - use same logic as you use when you generate xls from ASIN * 21. Size - %size% * 22. update_delete – “Update” * 23. standard_price - %price% * 24. list_price -- %MSRP% * 25. currency – “USD” * 26. quantity – “%Quantity% * 27. bullet_point1 – “Authentic ”+ %Main License% +” product with reliable quality and durability * 28. bullet_point2 – “Featuring “+%sublicense% * 29. bullet_point3 – if(Material != Cotton) “Flame resistant” else “100% Cotton” * 30. bullet_point4 – “Machine Wash, Easy Care” * 31. generic_keywords1 = if(Item style = pajama) “ sleepwear, pj, jummie, new, %sleeve%” * if(nightgown) “night, gown, night-gown, sleepwear, pj, jummie, new, %sleeve%, dress up” * 32. “Gift, present, 2015, cozy ” If(Material =fleece) “Fleece, microfleece, warm, winter spring” * 33. parent_child, parent_sku, relationship_type, variation_theme – same logic as you use when you generate xls from ASIN * 34. if More then one picture provided insert their URL into other_image_url1, other_image_url2, other_image_url3 */ var models = new List <ExcelWFSProductUSViewModel>(); var parent = new ExcelWFSProductUSViewModel(); var childs = new List <ExcelWFSProductUSViewModel>(); var sizes = model.StyleItems.Items; //Size Group, Size Range var hasKids2 = sizes.Any(s => ItemExportHelper.GetSizeGroupByName(s.SizeGroupName, true) == ExportSizeGroup.Kids2); ExportSizeGroup?sizeGroup = sizes.Any() ? (ExportSizeGroup?)ItemExportHelper.GetSizeGroupByName(sizes.Last().SizeGroupName, false) : null; var sizeGroupName = ItemExportHelper.GetSizeGroupName(sizeGroup); var sizeRange = ItemExportHelper.GetSizeRangeName(sizes.Select(s => s.Size).ToList(), hasKids2); var firstSize = sizes.Any() ? sizes[0].Size : String.Empty; //Features Values var features = model.Features.Select(f => new FeatureValueDTO() { FeatureId = f.FeatureId, Value = f.Value, }).ToList(); var allFeatureValues = db.FeatureValues.GetAllFeatureValueByItemType(1); var gender = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.GENDER); var itemStyle = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.ITEMSTYLE); var sleeve = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.SLEEVE); var material = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.MATERIAL); var color1 = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.COLOR1); var mainLicense = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.MAIN_LICENSE); var subLicense = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.SUB_LICENSE1); //var shippingSize = ItemExportHelper.GetFeatureValue(features, allFeatureValues, Feature.SHIPPING_SIZE); //var itemType = ItemExportHelper.GetItemType(itemStyle); var sizeType = ItemExportHelper.GetSizeType(firstSize); var categoryInfo = categoryService.GetCategory(MarketType.Amazon, MarketplaceKeeper.AmazonComMarketplaceId, itemStyle, gender, sizeType); var brandName = ItemExportHelper.GetBrandName(mainLicense, subLicense); var newItemType = categoryInfo.Key1;// ItemExportHelper.ItemTypeConverter(firstSize ?? "", itemType, itemStyle, gender); var newDepartment = StringHelper.GetFirstNotEmpty(categoryInfo.Key2, ItemExportHelper.DepartmentConverter(gender, newItemType, sizeType)); string clothingType = categoryInfo.Key3; var searchTerms = model.SearchTerms; // ItemExportHelper.BuildSearchTerms(itemStyle, material, sleeve); var keyFeatures = model.GetBulletPoints(); // ItemExportHelper.BuildKeyFeatures(mainLicense, subLicense, material); //-------------------------- //Parent item //-------------------------- parent.SKU = model.StyleId; parent.ASIN = ""; parent.Title = model.Name + "," + (!String.IsNullOrEmpty(sizeGroupName) ? " " + ItemExportHelper.FormatSizeGroupName(sizeGroupName) : String.Empty) + " " + sizeRange; //If it causes name length to exceed maximum allowed, please drop words “Kids” or Toddler” var inlcudeSizeGroup = true; if (parent.Title.Length > ItemExportHelper.MaxItemNameLength) { parent.Title = model.Name + ", " + sizeRange; inlcudeSizeGroup = false; } parent.ProductId = ""; parent.BrandName = brandName; parent.Type = newItemType; var images = new List <string>(); var swatchImage = ""; if (model.ImageSet != null) { images = model.ImageSet.Images .Where(im => im.Category != (int)StyleImageCategories.Swatch) .OrderByDescending(im => ImageHelper.GetSortIndex(im.Category)) .ThenByDescending(im => im.IsDefault) .ThenBy(im => im.Id) .Select(im => im.ImageUrl) .ToList(); swatchImage = model.ImageSet.Images .FirstOrDefault(im => im.Category == (int)StyleImageCategories.Swatch)?.ImageUrl; parent.MainImageURL = images.Count > 0 ? images[0] : ""; parent.OtherImageUrl1 = images.Count > 1 ? images[1] : ""; parent.OtherImageUrl2 = images.Count > 2 ? images[2] : ""; parent.OtherImageUrl3 = images.Count > 3 ? images[3] : ""; parent.SwatchImageUrl = swatchImage; } parent.Color = "";// color1; parent.Department = newDepartment; parent.Size = ""; parent.Description = model.Description; parent.Update = "Update"; parent.StandardPrice = ""; parent.SuggestedPrice = Math.Round(model.MSRP).ToString("G"); parent.Currency = "USD"; parent.Quantity = ""; parent.KeyProductFeatures1 = keyFeatures.Count > 0 ? keyFeatures[0] : ""; parent.KeyProductFeatures2 = keyFeatures.Count > 1 ? keyFeatures[1] : ""; parent.KeyProductFeatures3 = keyFeatures.Count > 2 ? keyFeatures[2] : ""; parent.KeyProductFeatures4 = keyFeatures.Count > 3 ? keyFeatures[3] : ""; parent.KeyProductFeatures5 = keyFeatures.Count > 4 ? keyFeatures[4] : ""; parent.SearchTerms1 = searchTerms; //parent.SearchTerms3 = ""; //parent.SearchTerms4 = ""; //parent.SearchTerms5 = ""; parent.Parentage = "Parent"; parent.ParentSKU = ""; parent.RelationshipType = ""; parent.VariationTheme = "Size"; parent.FeedProductType = clothingType; //-------------------------- //Child items //-------------------------- foreach (var size in sizes) { var child = new ExcelWFSProductUSViewModel(); child.SKU = model.StyleId + "-" + ItemExportHelper.ConvertSizeForStyleId(size.Size, hasKids2); child.StyleItemId = size.Id; child.StyleId = model.Id; if (size.AutoGeneratedBarcode) { var newBarcode = BarcodeHelper.GenerateBarcode(barcodeService, child.SKU, when); if (!String.IsNullOrEmpty(newBarcode)) { if (size.Barcodes == null) { size.Barcodes = new List <BarcodeDTO>(); } size.Barcodes.Insert(0, new BarcodeDTO() { Barcode = newBarcode }); } } child.ASIN = (size.Barcodes != null && size.Barcodes.Any()) ? size.Barcodes.FirstOrDefault().Barcode : String.Empty; child.Title = model.Name + "," + (inlcudeSizeGroup ? " " + ItemExportHelper.FormatSizeGroupName(size.SizeGroupName) : "") + " Size " + ItemExportHelper.ConvertSizeForItemName(size.Size, hasKids2); child.ProductId = "UPC"; child.BrandName = brandName; child.Type = newItemType; child.MainImageURL = images.Count > 0 ? images[0] : ""; child.OtherImageUrl1 = images.Count > 1 ? images[1] : ""; child.OtherImageUrl2 = images.Count > 2 ? images[2] : ""; child.OtherImageUrl3 = images.Count > 3 ? images[3] : ""; child.SwatchImageUrl = swatchImage; child.Color = ItemExportHelper.PrepareColor(String.IsNullOrEmpty(size.Color) ? color1 : size.Color); child.Department = newDepartment; child.Size = size.Size; child.Description = model.Description; child.Update = "Update"; child.StandardPrice = model.Price.ToString("G"); child.SuggestedPrice = Math.Round(model.MSRP).ToString("G"); child.Currency = "USD"; child.Quantity = size.Quantity.ToString(); child.KeyProductFeatures1 = parent.KeyProductFeatures1; child.KeyProductFeatures2 = parent.KeyProductFeatures2; child.KeyProductFeatures3 = parent.KeyProductFeatures3; child.KeyProductFeatures4 = parent.KeyProductFeatures4; child.KeyProductFeatures5 = parent.KeyProductFeatures5; child.SearchTerms1 = parent.SearchTerms1; //child.SearchTerms1 = parent.SearchTerms1; //child.SearchTerms2 = parent.SearchTerms2; //child.SearchTerms3 = parent.SearchTerms3; //child.SearchTerms4 = parent.SearchTerms4; //child.SearchTerms5 = parent.SearchTerms5; child.Parentage = "Child"; child.ParentSKU = parent.SKU; child.RelationshipType = "Variation"; child.VariationTheme = "Size"; child.FeedProductType = clothingType; childs.Add(child); } models.Add(parent); models.AddRange(childs); filename = model.StyleId + "_" + subLicense; filename = filename.Replace(" ", "") + "_US.xls"; return(models); }
public static IList <ExcelProductUKViewModel> GenerateToExcelUK(IUnitOfWork db, IBarcodeService barcodeService, IMarketCategoryService categoryService, StyleViewModel model, DateTime when, out string filename) { var gbpExchangeRate = PriceHelper.GBPtoUSD; var models = new List <ExcelProductUKViewModel>(); var parent = new ExcelProductUKViewModel(); var childs = new List <ExcelProductUKViewModel>(); var sizes = model.StyleItems.Items; //Size Group, Size Range var hasKids2 = sizes.Any(s => ItemExportHelper.GetSizeGroupByName(s.SizeGroupName, true) == ExportSizeGroup.Kids2); ExportSizeGroup?sizeGroup = sizes.Any() ? (ExportSizeGroup?)ItemExportHelper.GetSizeGroupByName(sizes.Last().SizeGroupName, false) : null; var sizeGroupName = ItemExportHelper.GetSizeGroupName(sizeGroup); var sizeRange = ItemExportHelper.GetSizeRangeName(sizes.Select(s => s.Size).ToList(), hasKids2); var firstSize = sizes.Any() ? sizes[0].Size : String.Empty; //Features Values var features = model.Features.Select(f => new FeatureValueDTO() { FeatureId = f.FeatureId, Value = f.Value, }).ToList(); var allFeatureValues = db.FeatureValues.GetAllFeatureValueByItemType(1); var gender = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.GENDER); var itemStyle = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.ITEMSTYLE); var sleeve = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.SLEEVE); var material = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.MATERIAL); var color1 = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.COLOR1); var mainLicense = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.MAIN_LICENSE); var subLicense = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.SUB_LICENSE1); //var shippingSize = ItemExportHelper.GetFeatureValue(features, allFeatureValues, StyleFeatureHelper.SHIPPING_SIZE); var materialComposition = ItemExportHelper.GetFeatureTextValue(features, StyleFeatureHelper.MATERIAL_COMPOSITION); var sizeType = ItemExportHelper.GetSizeType(firstSize); var categoryInfo = categoryService.GetCategory(MarketType.AmazonEU, MarketplaceKeeper.AmazonUkMarketplaceId, itemStyle, gender, sizeType); //var itemType = ItemExportHelper.GetItemType(itemStyle); var brandName = ItemExportHelper.GetBrandName(mainLicense, subLicense); var newItemType = categoryInfo.Key1;// ItemExportHelper.ItemTypeConverter(firstSize ?? "", itemType, itemStyle, gender); var newDepartment = StringHelper.GetFirstNotEmpty(categoryInfo.Key2, ItemExportHelper.DepartmentConverter(gender, newItemType, sizeType)); var searchTerms = model.SearchTerms; // ItemExportHelper.BuildSearchTerms(itemStyle, material, sleeve); var keyFeatures = model.GetBulletPoints(); // ItemExportHelper.BuildKeyFeatures(mainLicense, subLicense, material); var hasCotton = StringHelper.GetInOneOfStrings("Cotton", new List <string>() { searchTerms, model.Name, model.Description, material }); if (String.IsNullOrEmpty(materialComposition)) { if (hasCotton) { materialComposition = "Cotton"; } else { materialComposition = "Polyester"; } } //-------------------------- //Parent item //-------------------------- parent.SKU = model.StyleId; parent.ASIN = ""; parent.Title = model.Name + "," + (!String.IsNullOrEmpty(sizeGroupName) ? " " + ItemExportHelper.FormatSizeGroupName(sizeGroupName) : String.Empty) + " " + sizeRange; //If it causes name length to exceed maximum allowed, please drop words “Kids” or Toddler” var inlcudeSizeGroup = true; if (parent.Title.Length > ItemExportHelper.MaxItemNameLength) { parent.Title = model.Name + ", " + sizeRange; inlcudeSizeGroup = false; } parent.ProductId = ""; parent.BrandName = brandName; parent.ClothingType = "sleepwear"; // = newItemType; var images = new List <string>(); var swatchImage = ""; if (model.ImageSet != null) { images = model.ImageSet.Images .Where(im => im.Category != (int)StyleImageCategories.Swatch) .OrderByDescending(im => ImageHelper.GetSortIndex(im.Category)) .ThenByDescending(im => im.IsDefault) .ThenBy(im => im.Id) .Select(im => im.ImageUrl) .ToList(); swatchImage = model.ImageSet.Images .FirstOrDefault(im => im.Category == (int)StyleImageCategories.Swatch)?.ImageUrl; parent.MainImageURL = images.Count > 0 ? images[0] : ""; parent.OtherImageUrl1 = images.Count > 1 ? images[1] : ""; parent.OtherImageUrl2 = images.Count > 2 ? images[2] : ""; parent.OtherImageUrl3 = images.Count > 3 ? images[3] : ""; //parent.SwatchImageUrl = swatchImage; } parent.Color = ""; parent.Department = newDepartment; parent.Size = ""; parent.MaterialComposition = materialComposition; parent.Description = model.Description; parent.Update = "Update"; parent.StandardPrice = ""; //parent.SuggestedPrice = model.MSRP.ToString("G"); parent.Currency = "GBP"; parent.Quantity = ""; parent.RecommendedBrowseNodes1 = ExcelProductUKViewModel.GetRecommendedBrowseNodes1(newDepartment, firstSize, newItemType); parent.SearchTerms1 = searchTerms; parent.KeyProductFeatures1 = keyFeatures.Count > 0 ? keyFeatures[0] : ""; parent.KeyProductFeatures2 = keyFeatures.Count > 1 ? keyFeatures[1] : ""; parent.KeyProductFeatures3 = keyFeatures.Count > 2 ? keyFeatures[2] : ""; parent.KeyProductFeatures4 = keyFeatures.Count > 3 ? keyFeatures[3] : ""; parent.KeyProductFeatures5 = keyFeatures.Count > 4 ? keyFeatures[4] : ""; parent.Parentage = "Parent"; parent.ParentSKU = ""; parent.RelationshipType = ""; parent.VariationTheme = "Size"; //-------------------------- //Child items //-------------------------- foreach (var size in sizes) { var child = new ExcelProductUKViewModel(); child.SKU = model.StyleId + "-" + ItemExportHelper.ConvertSizeForStyleId(size.Size, hasKids2); if (size.AutoGeneratedBarcode) { var newBarcode = BarcodeHelper.GenerateBarcode(barcodeService, child.SKU, when); if (!String.IsNullOrEmpty(newBarcode)) { if (size.Barcodes == null) { size.Barcodes = new List <BarcodeDTO>(); } size.Barcodes.Insert(0, new BarcodeDTO() { Barcode = newBarcode }); } } child.UPC = (size.Barcodes != null && size.Barcodes.Any()) ? size.Barcodes.FirstOrDefault().Barcode : String.Empty; child.Title = model.Name + "," + (inlcudeSizeGroup ? " " + ItemExportHelper.FormatSizeGroupName(size.SizeGroupName) : "") + " Size " + ItemExportHelper.ConvertSizeForItemName(size.Size, hasKids2); child.ProductId = "UPC"; child.BrandName = brandName; child.ClothingType = "sleepwear";// newItemType; child.MainImageURL = images.Count > 0 ? images[0] : ""; child.OtherImageUrl1 = images.Count > 1 ? images[1] : ""; child.OtherImageUrl2 = images.Count > 2 ? images[2] : ""; child.OtherImageUrl3 = images.Count > 3 ? images[3] : ""; //child.SwatchImageUrl = swatchImage; child.Color = ItemExportHelper.PrepareColor(String.IsNullOrEmpty(size.Color) ? color1 : size.Color); child.Department = newDepartment; child.Size = ExcelProductUKViewModel.SizeConverter(size.Size, material); child.MaterialComposition = materialComposition; child.Description = model.Description; child.Update = "Update"; child.StandardPrice = PriceHelper.Convert(model.Price, gbpExchangeRate, true).ToString("G"); //child.SuggestedPrice = model.MSRP.ToString("G"); child.Currency = "GBP"; child.Quantity = size.Quantity.ToString(); child.RecommendedBrowseNodes1 = ExcelProductUKViewModel.GetRecommendedBrowseNodes1(newDepartment, child.Size, newItemType); child.KeyProductFeatures1 = parent.KeyProductFeatures1; child.KeyProductFeatures2 = parent.KeyProductFeatures2; child.KeyProductFeatures3 = parent.KeyProductFeatures3; child.KeyProductFeatures4 = parent.KeyProductFeatures4; child.KeyProductFeatures5 = parent.KeyProductFeatures5; child.SearchTerms1 = parent.SearchTerms1; //child.SearchTerms2 = parent.SearchTerms2; //child.SearchTerms3 = parent.SearchTerms3; //child.SearchTerms4 = parent.SearchTerms4; //child.SearchTerms5 = parent.SearchTerms5; child.Parentage = "Child"; child.ParentSKU = parent.SKU; child.RelationshipType = "Variation"; child.VariationTheme = "Size"; childs.Add(child); } models.Add(parent); models.AddRange(childs); filename = model.StyleId + "_" + subLicense; filename = filename.Replace(" ", "") + "_UK.xls"; return(models); //ExcelHelper.ExportIntoFile(HttpContext.Current.Server.MapPath(UKTemplatePath), models); }