public bool ProcessFoundCombinations(StyleRule sr) { bool found = false; if (flavorCombinations.Count == 0) { return(found); } IEnumerable <Combination> limitCombinations = (from fc in flavorCombinations orderby fc.EditorRating descending select fc).Take( MAX_COMBINATIONS_PER_LAYER); if (lstAccesories.Count != 0) { logger.DebugFormat("Joinining {0} combinations with {1} accesories", limitCombinations.Count(), lstAccesories.Count); if (createRecords) { fileName = Guid.NewGuid() + ".txt"; } foreach (int i in sr.AccessoriesAmount) { switch (i) { case 1: // Only ACC1. IncludeAccesories(limitCombinations, accesories1, 1); break; case 2: // Only ACC1, ACC2. IncludeAccesories(limitCombinations, accesories2, 2); IncludeAccesories(limitCombinations, accesories23, 2); IncludeAccesories(limitCombinations, accesories24, 2); IncludeAccesories(limitCombinations, accesories25, 2); IncludeAccesories(limitCombinations, accesories26, 2); IncludeAccesories(limitCombinations, accesories27, 2); IncludeAccesories(limitCombinations, accesories28, 2); break; case 3: // Only ACC1, ACC2, ACC3. IncludeAccesories(limitCombinations, accesories3, 3); break; case 4: // Only ACC1, ACC2, ACC3, ACC4. IncludeAccesories(limitCombinations, accesories4, 4); break; case 5: // Only ACC1, ACC2, ACC3, ACC4, ACC5. IncludeAccesories(limitCombinations, accesories5, 5); IncludeAccesories(limitCombinations, accesories6, 6); IncludeAccesories(limitCombinations, accesories7, 7); IncludeAccesories(limitCombinations, accesories8, 8); break; } // Don't keep processing if we are not going to save them. if (!createRecords && outfits.Count > 0) { return(true); } IEnumerable <PreOutfit> limitedOutfits = outfits.Take(MAX_COMBINATIONS_PER_LAYER * 4); logger.DebugFormat("Found {0} outfits for {1} accesories.", limitedOutfits.Count(), i); // Save each combination while processing. if (outfits.Count > 0) { found = true; if (createRecords) { logger.DebugFormat("Import to database with file: {0}", fileName); SaveToFile(limitedOutfits); _closetRepository.ProcessClosetFile(Path.Combine(LocalDatabasePath, fileName)); logger.DebugFormat("Update database with file: {0}", fileName); _closetRepository.CompleteClosetCreation(Closet.Id); logger.DebugFormat("End update database with file: {0}", fileName); } } outfits.Clear(); } } if (found) { logger.DebugFormat("Creating index file"); _outfitIndexingService.IndexPendingOutfits(Closet); } flavorCombinations.Clear(); return(found); }
public bool ProcessFoundCombinations(StyleRule sr) { bool found = false; if (flavorCombinations.Count == 0) { return(found); } var limitCombinations = (from fc in flavorCombinations orderby fc.EditorRating descending select fc).Take(5000); if (lstAccesories.Count != 0) { logger.DebugFormat("Joinining {0} combinations with {1} accesories", flavorCombinations.Count, lstAccesories.Count); if (createRecords) { this.fileName = Guid.NewGuid().ToString() + ".txt"; } foreach (int i in sr.AccessoriesAmount) { switch (i) { case 1: // Only ACC1. this.IncludeAccesories(limitCombinations, accesories1, 1); break; case 2: // Only ACC1, ACC2. this.IncludeAccesories(limitCombinations, accesories2, 2); break; case 3: // Only ACC1, ACC2, ACC3. this.IncludeAccesories(limitCombinations, accesories3, 3); break; case 4: // Only ACC1, ACC2, ACC3, ACC4. this.IncludeAccesories(limitCombinations, accesories4, 4); break; case 5: // Only ACC1, ACC2, ACC3, ACC4, ACC5. this.IncludeAccesories(limitCombinations, accesories5, 5); this.IncludeAccesories(limitCombinations, accesories6, 6); this.IncludeAccesories(limitCombinations, accesories7, 7); this.IncludeAccesories(limitCombinations, accesories8, 8); break; } // Don't keep processing if we are not going to save them. if (!createRecords && this.outfits.Count > 0) { return(true); } logger.DebugFormat("Found {0} outfits for {1} accesories.", outfits.Count, i); // Save each combination while processing. if (outfits.Count > 0) { found = true; if (createRecords) { logger.DebugFormat("Import to database with file: {0}", fileName); SaveToFile(); closetRepository.ProcessClosetFile(Path.Combine(this.LocalDatabasePath, fileName)); logger.DebugFormat("Update database with file: {0}", fileName); closetRepository.CompleteClosetCreation(this.Closet.Id); logger.DebugFormat("End update database with file: {0}", fileName); } } outfits.Clear(); } } flavorCombinations.Clear(); return(found); }