Esempio n. 1
0
        public void DontCountAllMatchesOnFirstPage()
        {
            // Create a test index with one cab file.
            StackHashTestIndexData testIndexData = new StackHashTestIndexData();

            testIndexData.NumberOfProducts      = 1;
            testIndexData.NumberOfFiles         = 1;
            testIndexData.NumberOfEvents        = 2;
            testIndexData.NumberOfEventInfos    = 1;
            testIndexData.NumberOfCabs          = 1;
            testIndexData.NumberOfScriptResults = 1;
            testIndexData.UseLargeCab           = false;

            StackHashSearchCriteria criteria1 = new StackHashSearchCriteria();

            criteria1.SearchFieldOptions = new StackHashSearchOptionCollection();
            criteria1.SearchFieldOptions.Add(new IntSearchOption()
            {
                ObjectType = StackHashObjectType.Event, FieldName = "Id", SearchOptionType = StackHashSearchOptionType.GreaterThan, Start = 0, End = 0
            });
            criteria1.SearchFieldOptions.Add(new StringSearchOption()
            {
                ObjectType = StackHashObjectType.Script, FieldName = "Content", SearchOptionType = StackHashSearchOptionType.StringContains, Start = "Script", End = null, CaseSensitive = false
            });

            StackHashSearchCriteriaCollection allSearchCriteria = new StackHashSearchCriteriaCollection();

            allSearchCriteria.Add(criteria1);

            StackHashSortOrderCollection sortOrder = new StackHashSortOrderCollection();

            sortOrder.Add(new StackHashSortOrder()
            {
                ObjectType = StackHashObjectType.Event, FieldName = "Id", Ascending = true
            });

            long startRow        = 1;
            long numRows         = 1;
            bool countAllMatches = false;
            StackHashSearchDirection direction = StackHashSearchDirection.Forwards;

            GetWindowedEventPackageResponse eventPackageResp =
                windowSearch(ErrorIndexType.SqlExpress, testIndexData, allSearchCriteria, startRow, numRows, sortOrder, direction, countAllMatches);

            Assert.AreEqual(1, eventPackageResp.EventPackages.Count);
            Assert.AreEqual(1, eventPackageResp.MinimumRowNumber);
            Assert.AreEqual(1, eventPackageResp.MaximumRowNumber);
            Assert.AreEqual(numRows, eventPackageResp.TotalRows);
        }
Esempio n. 2
0
        private void listViewEventsHeader_Click(object sender, RoutedEventArgs e)
        {
            GridViewColumnHeader header = e.OriginalSource as GridViewColumnHeader;

            if (header != null)
            {
                // can only sort columns with an associated tag
                string tagName = header.Tag as string;
                if (!string.IsNullOrEmpty(tagName))
                {
                    // remove previous sort adorner
                    if ((_lastSortColumn != null) && (_lastSortAdorner != null))
                    {
                        AdornerLayer.GetAdornerLayer(_lastSortColumn).Remove(_lastSortAdorner);
                    }
                    _lastSortAdorner = null;

                    ListSortDirection direction = ListSortDirection.Descending;

                    if (header == _lastSortColumn)
                    {
                        if (_lastSortDirection == ListSortDirection.Ascending)
                        {
                            direction = ListSortDirection.Descending;
                        }
                        else
                        {
                            direction = ListSortDirection.Ascending;
                        }
                    }

                    // to be applied after the event packages are fetched
                    _nextSortAdorner = new SortDirectionAdorner(header, direction);

                    _lastSortDirection = direction;
                    _lastSortColumn    = header;

                    StackHashSortOrder sortOrder = new StackHashSortOrder();
                    sortOrder.Ascending = (direction == ListSortDirection.Ascending);
                    sortOrder.FieldName = tagName;

                    switch (tagName)
                    {
                    case "Id":
                    case "TotalHits":
                    case "CabCount":
                    case "BugId":
                    case "PlugInBugId":
                    case "EventTypeName":
                    case "DateCreatedLocal":
                    case "DateModifiedLocal":
                    case "WorkFlowStatusName":
                        // these fields are from the event
                        sortOrder.ObjectType = StackHashObjectType.Event;
                        break;

                    default:
                        // all other tags are from the event signature
                        sortOrder.ObjectType = StackHashObjectType.EventSignature;
                        break;
                    }

                    StackHashSortOrderCollection sort = new StackHashSortOrderCollection();
                    sort.Add(sortOrder);

                    ClientLogic clientLogic = this.DataContext as ClientLogic;
                    Debug.Assert(clientLogic != null);

                    // run the sort, returning to the first page
                    clientLogic.PopulateEventPackages(clientLogic.CurrentProduct,
                                                      clientLogic.LastEventsSearch,
                                                      sort,
                                                      1,
                                                      UserSettings.Settings.EventPageSize,
                                                      clientLogic.CurrentProduct == null ?
                                                      UserSettings.Settings.GetDisplayHitThreshold(UserSettings.InvalidContextId) :
                                                      UserSettings.Settings.GetDisplayHitThreshold(clientLogic.CurrentProduct.Id),
                                                      ClientLogicView.EventList,
                                                      PageIntention.First,
                                                      UserSettings.Settings.ShowEventsWithoutCabs);
                }
            }
        }