コード例 #1
0
        /// <summary>
        /// Instantiate CollectionItems to a Paging able collection
        /// </summary>
        protected override void InitProperties()
        {
            base.InitProperties();
            //Assert that CollectionItems implements IPagingArguments
            if (CollectionItems == null || !(CollectionItems is IPagingArguments))
            {
                CollectionItems = new PagingResults <NursingHome>();

                //Instantiate default sorting columns
                var sortColumns = new PagingSortingColumns();
                sortColumns.Add(new PagingSortingColumn()
                {
                    SortMemberPath = "State", SortDirection = ListSortDirection.Ascending
                });
                sortColumns.Add(new PagingSortingColumn()
                {
                    SortMemberPath = "Name", SortDirection = ListSortDirection.Ascending
                });

                //Instantiate all Paging Arguments
                (CollectionItems as PagingResults <NursingHome>)
                .SetPagingArguments(rowsCount: 0, pageSize: 50
                                    , pageIndex: 1, pagingFunction: () => GetPage()
                                    , sortingColumns: sortColumns);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the page.
        /// </summary>
        public void GetPage()
        {
            var args = new PagingResults <Measure>();

            args.SetPagingArguments(TotalCount, 50, 1, () => GetPage());

            var pageArgs = CollectionItems as IPagingArguments ?? args;

            pageArgs.RowsCount = TotalCount;

            using (var session = DataserviceProvider.SessionFactory.OpenSession())
            {
                var allMeasures = session.Query <Measure>()
                                  .OrderBy(x => SelectedDataSet != ALL_DATASETS ? x.Owner.Name : x.Owner.Name)
                                  .Where(FilterClausePredicate)
                                  .Select(x => new Measure
                {
                    Id                    = x.Id,
                    Name                  = x.Name,
                    MeasureTitle          = x.MeasureTitle,
                    MeasureType           = x.MeasureType,
                    Description           = x.Description,
                    HigherScoresAreBetter = x.HigherScoresAreBetter,
                    NQFEndorsed           = x.NQFEndorsed,
                    NQFID                 = x.NQFID,
                    Source                = x.Source,
                    Owner                 = x.Owner
                })
                                  .Skip((pageArgs.PageIndex - 1) * pageArgs.PageSize)
                                  .Take(pageArgs.PageSize)
                                  .ToList();

                var distinctMeasures = allMeasures.DistinctBy(m => m.Name).ToList();

                foreach (var m in distinctMeasures)
                {
                    var topics         = new List <Topic>();
                    var assignedTopics = TopicsStruts.Where(x => x.MeasureCode == m.Name && !string.IsNullOrEmpty(x.TopicName) && !string.IsNullOrEmpty(x.SubTopicName)).ToList();
                    m.WebsitesForMeasureDisplay = WebsiteStructs.Where(x => x.MeasureId == m.Id).Select(w => w.WebsiteName).ToList();

                    m.TopicsForMeasureDisplay = assignedTopics.Count == 0 ? "Topics are not assigned" : string.Join(",", assignedTopics.Select(x => x.TopicName + " > " + x.SubTopicName).ToList());
                }

                CollectionItems = new PagingResults <Measure>(distinctMeasures.ToObservableCollection(), pageArgs);
                SelectedMeasure = distinctMeasures.FirstOrDefault();
                RaisePropertyChanged(() => CollectionItems);
                RaisePropertyChanged(() => HeaderText);
            }
        }
コード例 #3
0
        /// <summary>
        /// Executes the load full recordset.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="states">The states.</param>
        protected void ExecLoadFullRecordset(ISession session, List <string> states)
        {
            var nursingHomes = new List <NursingHome>();

            foreach (var state in states)
            {
                nursingHomes.AddRange(session.Query <NursingHome>().Where(nh => nh.State == state && !nh.IsDeleted).ToList());
            }
            CollectionItems = new PagingResults <NursingHome>(nursingHomes, PagingArguments);
            if (CollectionItems.SortDescriptions == null || CollectionItems.SortDescriptions.Count == 0)
            {
                CollectionItems.SortDescriptions.Add(new SortDescription("State", ListSortDirection.Ascending));
                CollectionItems.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));
            }

            CollectionItems.MoveCurrentToFirst();
            if (!string.IsNullOrEmpty(FilterText))
            {
                CollectionItems.Filter = null;
                CollectionItems.Filter = CompositeFilter;
            }
        }
コード例 #4
0
        /// <summary>
        /// Executes the load recordset page.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="states">The states.</param>
        protected void ExecLoadRecordsetPage(ISession session, List <string> states)
        {
            var fullRecordSet = session.Query <NursingHome>()
                                .Where(nh => !nh.IsDeleted);

            //Filter by state
            fullRecordSet = fullRecordSet.Where(h => states.Contains(h.State));


            //Apply operator's filter
            var filteredRecordSet = fullRecordSet;

            if (!string.IsNullOrEmpty(FilterText))
            {
                filteredRecordSet = fullRecordSet.Where(SelectedFilter.Predicate);
            }

            //Refetch full recordset rows count
            if (PagingArguments != null)
            {
                PagingArguments.RowsCount = filteredRecordSet.Count();
                RaisePropertyChanged(() => TotalRowsCount);
            }

            //Apply Sort
            filteredRecordSet = PagingResults <NursingHome>
                                .ApplySortExpressions(filteredRecordSet, PagingArguments.SortingColumns);

            //Get just one page of the recordset
            var nursingHomesPage = (filteredRecordSet
                                    .Skip((PagingArguments.PageIndex - 1) * PagingArguments.PageSize)
                                    .Take(PagingArguments.PageSize))
                                   .ToList <NursingHome>();

            //Populate DataGrid with new page and copy Paging arguments
            CollectionItems = new PagingResults <NursingHome>(nursingHomesPage, PagingArguments);
        }