private SearchResults FilterHistoryView(string queryString, ViewFilter view, int count, Direction direction, ulong?referenceId) { int totalCount; var result = searcher.Filter(queryString, view, count, direction, referenceId, out totalCount); return(new SearchResults(totalCount, result)); }
public IEnumerable <LogEntry> Filter(string queryString, ViewFilter view, int count, Direction direction, ulong?referenceId, out int totalCount) { var context = new IncermentalSearchContext(count, direction, referenceId); var parser = new CustomQueryParser(LuceneNet.Util.Version.LUCENE_30, MessageFieldName, analyzer); var sortBy = new Sort(new SortField(IdFieldName, SortField.LONG, direction == Direction.Backward)); while (true) { var combinedQueryString = Searcher.CombineQuery(queryString, view, context.Range); if (combinedQueryString.Length == 0) { totalCount = 0; return(new LogEntry[0]); } var query = parser.Parse(combinedQueryString); lock (searcherLock) { var searchResults = searcher.Search(query, null, count, sortBy); totalCount = searchResults.TotalHits; var result = searchResults.ScoreDocs.Take(count).Select(d => searcher.Doc(d.Doc)).Select(x => converter.ToLogEntry(x)); context.UpdateResult(result); if (context.IsFinished) { return((direction == Direction.Backward) ? context.Result.Reverse() : context.Result); } context.UpdateRange(); } } }
CatalogViewModel(ViewFilter <ProductItem> viewFilter, IQueryable <ProductItem> productItems, PaginatedList <ProductItem> paginateProductItems, double maxPrice) { ViewFilterProductItems = viewFilter; ProductItems = productItems; PaginateProductItems = paginateProductItems; MaxPrice = maxPrice; }
/// <summary>Install a new view filter for the given view. This method calls your /// CreateViewFilter method.</summary> public virtual int OnNewView(IVsTextView newView) { ViewFilter filter = this.service.CreateViewFilter(this, newView); if (filter != null) { this.viewFilters.Add(filter); } return(NativeMethods.S_OK); }
public StreamView() { using (new CodeTimer("StreamView/Constructor")) { InitializeComponent(); selection = new List <Message>(); dropHelper = new DropHelper(StreamListView); dropHelper.Drop += StreamListView_Drop; DataContext = this; viewFilter = ViewFilter.Current; viewFilter.Filter.FilterChanged += State_CurrentViewChanged; selectionFlipper = new Flipper(TimeSpan.FromMilliseconds(200), () => State.SelectedMessages.ReplaceWithCast(StreamListView.SelectedItems)); EventBroker.Subscribe(AppEvents.RebuildOverview, () => Thread.CurrentThread.ExecuteOnUIThread(CreateChannelsSelection)); VirtualMailBox.Current.InboxLoadComplete += delegate { using (new ThreadFlag()) StreamListView.SelectedIndex = 0; }; EventBroker.Subscribe(AppEvents.TabChanged, delegate(string newTab) { if (newTab == "DockControl") { // Switched to overview isOverviewActive = true; if (selection.Count > 0) { State.SelectedMessages.Replace(selection); } } else { // Switched to any other tab if (isOverviewActive) { // Save selection selection.Clear(); selection.AddRange(State.SelectedMessages); } isOverviewActive = false; } }); } }
private SearchResults Find(string queryString, ViewFilter view, int count, Direction direction, ulong?referenceId) { ulong foundId; int totalFound; var result = searcher.Find(queryString, view, count, direction, referenceId, out foundId, out totalFound); return(new SearchResults(totalFound, result) { FoundId = foundId }); }
/// <include file='doc\CodeWindowManager.uex' path='docs/doc[@for="CodeWindowManager.OnNewView"]/*' /> /// <summary>Install a new view filter for the given view. This method calls your /// CreateViewFilter method.</summary> public virtual int OnNewView(IVsTextView newView) { #if LANGTRACE Trace.WriteLine("CodeWindowManager::OnNewView"); #endif ViewFilter filter = this.service.CreateViewFilter(this, newView); if (filter != null) { this.viewFilters.Add(filter); } return(NativeMethods.S_OK); }
private ulong?FindFirstId(string queryString, ViewFilter view, Direction direction, ulong?referenceId, out int totalCount) { if (direction == Direction.Backward) { if (referenceId.HasValue && referenceId.Value > 0) { referenceId--; } } else { if (referenceId.HasValue && referenceId.Value < ulong.MaxValue) { referenceId++; } } var context = new IncermentalSearchContext(1, direction, referenceId); while (true) { var combinedQueryString = Searcher.CombineQuery(queryString, view, context.Range); if (combinedQueryString.Length == 0) { totalCount = 0; return(null); } var parser = new CustomQueryParser(LuceneNet.Util.Version.LUCENE_30, MessageFieldName, analyzer); var query = parser.Parse(combinedQueryString); var sortBy = new Sort(new SortField(IdFieldName, SortField.LONG, direction == Direction.Backward)); lock (searcherLock) { var searchResults = searcher.Search(query, null, 1, sortBy); var firstResult = searchResults.ScoreDocs.FirstOrDefault(); totalCount = searchResults.TotalHits; if (firstResult != null) { return(converter.ToLogEntry(searcher.Doc(firstResult.Doc)).Id); } if (context.IsFinished) { return(null); } context.UpdateRange(); } } }
public static async Task <CatalogViewModel> CreateAsync(ViewFilter <ProductItem> viewFilter, IQueryable <ProductItem> source, int pageIndex, string sortOrder) { double max = default; PaginatedList <ProductItem> paginateProductItems = default; if (source != null && source.Any()) { max = await source.MaxAsync(p => p.Price); var filteredSource = viewFilter.Filter(source); var sortedSource = SortOrder <ProductItem> .Create(filteredSource, sortOrder); paginateProductItems = await PaginatedList <ProductItem> .CreateAsync(sortedSource, pageIndex, pageSize); } return(new CatalogViewModel(viewFilter, source, paginateProductItems, max)); }
private async Task LoadEntriesAsync(ProgressMonitor progressMonitor, Direction direction, Action afterCallback = null) { var view = new ViewFilter { LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text }; using (var progress = progressMonitor.Start("Filtering log...")) { var referenceId = (direction == Direction.Backward) ? listViewLog.FirstItemId : listViewLog.LastItemId; var entries = await luceneStore.FilterHistoryViewAsync(filterTextEntry.Text, view, pageSize, direction, referenceId); if (entries.Entries.Any()) { if (direction == Direction.Backward) { ApplicationExtensions.InvokeInUIThread(() => { foreach (var entry in entries.Entries.Where(e => e.Id < referenceId).Reverse()) { listViewLog.InsertItem(entry, false, maxPageCount * pageSize); } }); } else { ApplicationExtensions.InvokeInUIThread(() => { foreach (var entry in entries.Entries.Where(e => e.Id > referenceId)) { listViewLog.AddItem(entry, false, maxPageCount * pageSize); } }); } } } if (afterCallback != null) { afterCallback(); } }
private async Task SearchEntriesAsync(ProgressMonitor progressMonitor, Direction direction) { using (var progress = progressMonitor.Start("Searching in log...")) { var view = new ViewFilter { LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text }; var entries = await luceneStore.FindAsync(searchTextEntry.Text, view, 2 *pageSize, direction, searchContext != null?searchContext.PreviousResultId : null); if (entries.Entries == null) { ApplicationExtensions.InvokeInUIThread(() => MessageDialog.ShowWarning("No results found!")); ResetSearch(false); return; } if (searchContext == null) { searchContext = new SearchContext(entries.TotalHits); } else { searchContext.Advance(direction); } searchContext.PreviousResultId = entries.FoundId; ApplicationExtensions.InvokeInUIThread(() => { listViewLog.ClearItems(); foreach (var entry in entries.Entries) { listViewLog.AddItem(entry, entries.FoundId == entry.Id); } searchLabel.Text = string.Format("Showing result: {0} / {1}", searchContext.CurrentResult, searchContext.ResultsCount); nextSearchResultButton.Sensitive = (searchContext.CurrentResult > 1); prevSearchResultButton.Sensitive = (searchContext.CurrentResult < searchContext.ResultsCount); }); } }
public ConversationsState() { viewFilter = ViewFilter.Current; ActivityViewSource = new CollectionViewSource { Source = viewFilter.Messages }; SelectedMessages = new AdvancedObservableCollection <Message>(); SelectedMessages.CollectionChanged += delegate { OnPropertyChanged("SelectedMessage"); OnSelectionChanged(); }; flipper = new Flipper(TimeSpan.FromSeconds(25), delegate { // Todo run readstates syncornization if no receive task is currently running }); }
private async Task FilterEntriesAsync(ProgressMonitor progressMonitor, bool selectLastAddedItem = false) { using (var progress = progressMonitor.Start("Filtering log...")) { var view = new ViewFilter { LogLevels = levels.ToList(), CustomFilter = filterTextEntry.Text }; var entries = await luceneStore.FilterHistoryViewAsync(filterTextEntry.Text, view, maxPageCount *pageSize, Direction.Backward); ApplicationExtensions.InvokeInUIThread(() => { listViewLog.ClearItems(); foreach (var entry in entries.Entries) { listViewLog.AddItem(entry, selectLastAddedItem, maxPageCount * pageSize); } RefreshPaging(entries.TotalHits); }); } }
private static string CombineQuery(string queryString, ViewFilter view, Range forcedRange) { var values = new List <string>(); var viewQueryString = view.GenerateQueryString(); if (!string.IsNullOrEmpty(viewQueryString)) { values.Add(viewQueryString); } if (!string.IsNullOrEmpty(queryString)) { values.Add(queryString); } if (forcedRange != null) { values.Add(forcedRange.GenerateQueryString()); } return(string.Join(" AND ", values.Select(x => string.Format("({0})", x)))); }
public IEnumerable <LogEntry> Find(string queryString, ViewFilter view, int count, Direction direction, ulong?referenceId, out ulong foundId, out int totalFound) { int fake; var findFirstResult = FindFirstId(queryString, view, direction, referenceId, out totalFound); if (findFirstResult == null) { foundId = 0; return(null); } foundId = findFirstResult.Value; var resultsBefore = Filter(string.Empty, view, count, Direction.Backward, foundId, out fake).ToList(); var resultsAfter = Filter(string.Empty, view, count, Direction.Forward, foundId, out fake).Skip(1).ToList(); var foundResult = resultsBefore.Last(); resultsBefore.Remove(foundResult); IEnumerable <LogEntry> result; if (resultsBefore.Count < (count / 2)) { result = resultsBefore.Concat(new [] { foundResult }).Concat(resultsAfter).Take(count).ToList(); } else if (resultsAfter.Count < ((count - 1) / 2)) { result = resultsBefore.Concat(new [] { foundResult }).Concat(resultsAfter).ToList(); result = result.Skip(((List <LogEntry>)result).Count - count).ToList(); } else { result = resultsBefore.Skip(resultsBefore.Count - (count / 2)).Concat(new [] { foundResult }).Concat(resultsAfter.Take((count - 1) / 2)).ToList(); } return(result); }
public FoldersControl() { mailbox = VirtualMailBox.Current; viewFilter = ViewFilter.Current; labels = new ThreadSafeCollection <LabelsContainer>(); LabelsViewSource = new CollectionViewSource { Source = labels }; LabelsViewSource.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Descending)); LabelsViewSource.View.Filter = IsLabelVisible; InitializeComponent(); signal = new AutoResetEvent(false); workerThread = new Thread(UpdateCounters) { Name = "Counter update thread", IsBackground = true, Priority = ThreadPriority.BelowNormal }; workerThread.Start(); DataContext = this; VirtualMailBox.Current.LoadComplete += delegate { UpdateCountersAsync(); }; EventBroker.Subscribe(AppEvents.RebuildOverview, UpdateCountersAsync); EventBroker.Subscribe(AppEvents.ReceiveMessagesFinished, UpdateCountersAsync); EventBroker.Subscribe(AppEvents.MessageUpdated, UpdateCountersAsync); EventBroker.Subscribe(AppEvents.View, delegate(ActivityView view) { ClientState.Current.ViewController.MoveTo(WellKnownView.Overview); // Find the radio-button with the requested view LogicalTreeWalker.Walk(this, delegate(RadioButton rb) { if (GetActivityView(rb) == view) { rb.IsChecked = true; } }); viewFilter.Filter.CurrentView = view; viewFilter.RebuildCurrentViewAsync(); EventBroker.Publish(AppEvents.RequestFocus); }); EventBroker.Subscribe(AppEvents.View, delegate(Label label) { EventBroker.Publish(AppEvents.View, ActivityView.Label); viewFilter.Filter.Label = label.Labelname; viewFilter.RebuildCurrentViewAsync(); EventBroker.Publish(AppEvents.RequestFocus); }); EventBroker.Subscribe(AppEvents.ShuttingDown, () => Thread.CurrentThread.ExecuteOnUIThread(delegate { // Save settings during shutdown SettingsManager.ClientSettings.AppConfiguration.ShowProductivityColumn = ProductivityExpander.IsExpanded; SettingsManager.ClientSettings.AppConfiguration.ShowLabelsColumn = LabelsExpander.IsExpanded; SettingsManager.Save(); })); EventBroker.Subscribe(AppEvents.LabelCreated, (string label) => labels.Add(new LabelsContainer(label))); }
public Task <SearchResults> FindAsync(string searchQueryString, ViewFilter view, int count, Direction direction, ulong?referenceId = null) { return(Task.Run <SearchResults>(() => Find(searchQueryString, view, count, direction, referenceId))); }
public NoOutputsNotificationPolicy(BehaviorGraph graph, ViewFilter viewFilter) { _graph = graph; _viewFilter = viewFilter; }
private void CollectFilters() { try { var viewFilters = new List <ViewFilter>(); foreach (var view in new FilteredElementCollector(_doc) .OfClass(typeof(View)) .Cast <View>() .Where(v => v.AreGraphicsOverridesAllowed())) { try { foreach (var elementId in view.GetFilters().Where(e => e != ElementId.InvalidElementId)) { var filterElement = _doc.GetElement(elementId); var existFilter = viewFilters.FirstOrDefault(f => f.Id.IntegerValue == filterElement.Id.IntegerValue); if (existFilter != null) { if (view.IsTemplate) { existFilter.OwnerViewTemplates.Add(view.Name); } else { existFilter.OwnerViews.Add(view.Name); } } else { var newFilter = new ViewFilter(filterElement); if (view.IsTemplate) { newFilter.OwnerViewTemplates.Add(view.Name); } else { newFilter.OwnerViews.Add(view.Name); } newFilter.PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(ViewFilter.IsSelected)) { OnPropertyChanged(nameof(CanClean)); OnPropertyChanged(nameof(SelectedCount)); } }; viewFilters.Add(newFilter); } } } catch (Autodesk.Revit.Exceptions.InvalidOperationException) { // ignore exceptions "View does not belong to a project document" and // "The view type does not support Visibility/Graphics Overriddes" } } ViewFilters = new ObservableCollection <ViewFilter>( viewFilters.OrderBy(v => v.Name, new OrdinalStringComparer())); OnPropertyChanged(nameof(ViewFilters)); OnPropertyChanged(nameof(CanClean)); OnPropertyChanged(nameof(SelectedCount)); } catch (Exception exception) { ExceptionBox.Show(exception); } }
public async Task <IActionResult> SaveView(string favOnly, string thegoodlife = "", string healthbeyondthehospital = "", string robustfuture = "", string convenienceproductivity = "", string softwareai = "", string sensing = "", string robotics = "", string products = "", string advancedmaterials = "", string businessprocess = "", string city = "", string country = "", string viewname = "") { if (string.IsNullOrEmpty(viewname)) { return(Forbid()); } string userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; UserView thisView = new UserView { UserId = userId, Name = viewname }; _context.UserView.Add(thisView); await _context.SaveChangesAsync(); if (!string.IsNullOrEmpty(thegoodlife)) { ViewFilter filter = new ViewFilter { FilterName = "thegoodlife", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(healthbeyondthehospital)) { ViewFilter filter = new ViewFilter { FilterName = "healthbeyondthehospital", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(robustfuture)) { ViewFilter filter = new ViewFilter { FilterName = "robustfuture", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(convenienceproductivity)) { ViewFilter filter = new ViewFilter { FilterName = "convenienceproductivity", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(softwareai)) { ViewFilter filter = new ViewFilter { FilterName = "softwareai", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(sensing)) { ViewFilter filter = new ViewFilter { FilterName = "sensing", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(robotics)) { ViewFilter filter = new ViewFilter { FilterName = "robotics", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(products)) { ViewFilter filter = new ViewFilter { FilterName = "products", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(advancedmaterials)) { ViewFilter filter = new ViewFilter { FilterName = "advancedmaterials", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(businessprocess)) { ViewFilter filter = new ViewFilter { FilterName = "businessprocess", FilterValue = "true", ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(city)) { ViewFilter filter = new ViewFilter { FilterName = "city", FilterValue = city, ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } if (!string.IsNullOrEmpty(country)) { ViewFilter filter = new ViewFilter { FilterName = "country", FilterValue = country, ViewId = thisView.Id }; _context.ViewFilter.Add(filter); } await _context.SaveChangesAsync(); return(Redirect($"/Launchpad/ViewDashboard?favOnly={favOnly}&thegoodlife={thegoodlife}&healthbeyondthehospital={healthbeyondthehospital}" + $"&robustfuture={robustfuture}&convenienceproductivity={convenienceproductivity}&softwareai={softwareai}" + $"&sensing={sensing}&robotics={robotics}&products={products}&advancedmaterials{advancedmaterials}&businessprocess={businessprocess}" + $"&city={city}&country={country}")); }