// REVIEW: This makes no sense. We should always receive a real object from the Builder. private OUImportationLine GetOUImportationLine(object data) { IFormatProvider formatProvider = new CultureInfo("en-US"); OUImportationLine line = new OUImportationLine(); line.ProgramName = GetValue("ProgramName", data).ToString(); line.Name = GetValue("Name", data).ToString(); line.Description = GetValue("Description", data).ToString(); line.Keywords = GetValue("Keywords", data).ToString(); line.Sku = GetValue("Sku", data).ToString(); if (!string.IsNullOrEmpty(GetValue("Price", data).ToString())) { line.Price = Convert.ToDecimal(GetValue("Price", data).ToString(), formatProvider); } line.BuyUrl = GetValue("BuyUrl", data).ToString(); line.ImageUrl = GetValue("ImageUrl", data).ToString(); return(CheckLine(line)); }
//REVIEW: Why are we using a generic object????? private void ProcessOUImportationLine(object data) { try { OUImportationLine line = GetOUImportationLine(data); if (line != null) { lines.Add(line); } else { linesWithErrors.Add(actualLine.ToString()); } } catch (Exception) { linesWithErrors.Add(actualLine.ToString()); } }
private OUImportationLine CheckLine(OUImportationLine line) { //Chekeo de datos obligatorios if (string.IsNullOrEmpty(line.Sku) || string.IsNullOrEmpty(line.ProgramName) || string.IsNullOrEmpty(line.Description) || string.IsNullOrEmpty(line.Keywords) || line.Price == null || line.Price <= 0 || string.IsNullOrEmpty(line.BuyUrl) || string.IsNullOrEmpty(line.ImageUrl)) { return(null); } string lineForKeywords = string.Format("{0} {1} {2}", line.Name.ToLower(), line.Keywords.ToLower(), line.Description.ToLower()); foreach (string s in wordsForDiscard) { if (lineForKeywords.Contains(s.ToLower())) { return(null); } } // REVIEW: LINQ queries are more efficient. foreach (Trend trend in trends) { foreach (string keyword in trend.Keywords) { if (lineForKeywords.Contains(keyword.ToLower())) { line.Trends.Add(trend); break; } } } if (line.Trends.Count == 0) { return(null); } // REVIEW: LINQ queries are more efficient. foreach (Silouhette silouhette in silouhettes) { if (lineForKeywords.Contains(silouhette.Description.ToLower())) { line.Silouhette = silouhette; break; } else { foreach (SilouhetteKeywordsByPartner keyword in silouhetteKeywords) { if (keyword.Partner == partner && keyword.Silouhette == silouhette) { foreach (string key in keyword.Keywords.Split(',')) { if (lineForKeywords.Contains(key.Trim().ToLower())) { line.Silouhette = silouhette; // REVIEW: This will lead to continue searching other keywords // REVIEW: We are only leaving the inner for. break; } } } } } } // REVIEW: LINQ queries are more efficient. foreach (Pattern pattern in patterns) { if (lineForKeywords.Contains(pattern.Description.ToLower())) { line.Pattern = pattern; break; } else { foreach (PatternKeywordsByPartner keyword in patternKeywords) { if (keyword.Partner == partner && keyword.Pattern == pattern) { foreach (string key in keyword.Keywords.Split(',')) { if (lineForKeywords.Contains(key.Trim().ToLower())) { line.Pattern = pattern; // REVIEW: This will lead to continue searching other keywords // REVIEW: We are only leaving the inner for. break; } } } } } } // REVIEW: LINQ queries are more efficient. foreach (ColorFamily colorFamily in colorFamilies) { if (lineForKeywords.Contains(colorFamily.Description.ToLower())) { line.ColorFamily = colorFamily; break; } else { foreach (ColorFamilyKeywordsByPartner keyword in colorFamilyKeywords) { if (keyword.Partner == partner && keyword.ColorFamily == colorFamily) { foreach (string key in keyword.Keywords.Split(',')) { if (lineForKeywords.Contains(key.Trim().ToLower())) { line.ColorFamily = colorFamily; // REVIEW: This will lead to continue searching other keywords // REVIEW: We are only leaving the inner for. break; } } } } } } if (line.Silouhette != null && line.Pattern != null && line.ColorFamily != null) { line.Status = OutfitUpdaterStatus.Valid; } int tmpCount = itemIds.Count; itemIds.Add(line.Sku); if (itemIds.Count == tmpCount) { return(null); } return(line); }