public static void DeactivateRoute(int id) { bool needsReindex = false; using (var context = new DataContext()) { var route = context.Routes.FirstOrDefault(x => x.ID == id); if (route != null) { if (route.Status == (int)StatusEnum.ActiveAndIndexed) { // remove from search index needsReindex = true; var routePieces = route.RoutePieces.ToList(); while (routePieces.Count > 0) { var routePiecesToProcess = routePieces.Take(200).ToList(); routePieces.RemoveAll(x => routePiecesToProcess.Contains(x)); List<SearchIndex> indexes = context.SearchIndexes.Where(x => routePiecesToProcess.Select(y => y.ID).Contains(x.RoutePieceID) || routePiecesToProcess.Select(y => y.ID).Contains(x.RoutePiece2ID)).ToList(); context.SearchIndexes.DeleteAllOnSubmit(indexes); context.SubmitChanges(); } } route.Status = (int)StatusEnum.New; context.SubmitChanges(); } } if (needsReindex) { ViaDFGraph.SetReloadFlag(); } }
public Searcher(ViaDFGraph g) { graph = g; aStar = new AStar.AStar(graph); nameCache = new Dictionary <string, string>(); routePieceCache = new Dictionary <int, RoutePiece>(); routeCache = new Dictionary <int, Route>(); }
public static void ClearIndex() { using (var context = new DataContext()) { context.ExecuteCommand("TRUNCATE TABLE SearchIndex"); foreach (var route in context.Routes.Where(x => x.Status == (int)StatusEnum.ActiveAndIndexed)) { route.Status = (int)StatusEnum.Active; context.SubmitChanges(); } } ViaDFGraph.SetReloadFlag(); }
public static void RefreshIndex() { ViaDFGraph.SetReloadFlag(); }