private void CreateIndex(Closet closet) { #if !DEBUG //if (closet.Id == 144 || closet.Id == 30 || closet.Id == 11 || closet.Id == 2) // return; //if (closet.Id != 144 && closet.Id != 30 && closet.Id != 11 && closet.Id != 2) // return; #endif using (SearchEngineService ses = SearchEngineService.GetByCloset(closet.Id)) { int start = 0; int count = _closetOutfitRepository.GetCountByCloset(closet.Id); while (start < count) { IList <SearchEngineEntry> lst = new List <SearchEngineEntry>(); IList <ClosetOutfit> lstOutfits = _closetOutfitRepository.GetByClosetPaged(closet.Id, start, Quantity); if (lstOutfits == null) { break; } foreach (ClosetOutfit closetOutfit in lstOutfits) { SearchEngineEntry see = closetOutfit.ToSearchEngineEntry(); lst.Add(see); } ses.AddEntries(lst); start += Quantity; GC.Collect(); } } NHibernateSession.Current.Clear(); GC.Collect(); }
public void IndexPendingOutfits(Closet closet) { IList <SearchEngineEntry> entries = new List <SearchEngineEntry>(); var propertyValues = new Dictionary <string, object>(); propertyValues.Add("Closet.Id", closet.Id); propertyValues.Add("Status", ClosetOutfitStatus.NotIndexed); IList <ClosetOutfit> lstNewOutfits = _closetOutfitRepository.FindAll(propertyValues); if (lstNewOutfits.Count > 0) { foreach (ClosetOutfit ou in lstNewOutfits) { entries.Add(ou.ToSearchEngineEntry()); } using (SearchEngineService ses = SearchEngineService.GetByCloset(closet.Id)) ses.AddEntries(entries); _closetOutfitRepository.ChangeStatus(closet.Id, ClosetOutfitStatus.NotIndexed, ClosetOutfitStatus.Ready); } }