예제 #1
0
        public void FilterHouseHolding(DocumentSearchResultsData data)
        {
            for (int i = (data.DocumentList.Count - 1); i >= 0; i--)
            {
                Document document = this._documentRepository.GetDocument((data.DocumentList[i].Id).ToString());

                if (document.HouseHold == null)
                {
                    data.DocumentList.RemoveAt(i);
                }
            }
        }
예제 #2
0
 private static PagedResult <IndexedDocumentData> GetPagedResultForQuery(
     int pageNumber, int numberOfItems, DocumentSearchResultsData documents)
 {
     return(new PagedResult <IndexedDocumentData>
     {
         CurrentPage = pageNumber,
         ItemsPerPage = numberOfItems,
         TotalItems =
             documents.RecordsFound > 0
              ? documents.TotalRecordsFound
              : documents.DocumentsFoundOverLimit.Value,
         Results = documents.DocumentList
     });
 }
예제 #3
0
        public void FilterApprovedAndRejected(DocumentSearchResultsData data, string grid)
        {
            var approvedDocs = this.GetDocumentsWithApprovalAndRejection(grid);

            for (int i = (data.DocumentList.Count - 1); i >= 0; i--)
            {
                Document document = approvedDocs.FirstOrDefault(d => d.DocumentId == data.DocumentList[i].Id.ToString());

                if (document.Approval != null || document.Rejection != null)
                {
                    data.DocumentList.RemoveAt(i);
                }
            }
        }
예제 #4
0
        public void GivenDocumentSearchIndexedResultsData_WhenIAskForTheLastPage_AndFilteringHasBeenApplied_IGetCorrectPaginatedResults()
        {
            DocumentSearchResultsData data = new DocumentSearchResultsData()
            {
                DocumentsFoundOverLimit = 0,
                MoreRecords             = 0,
                RecordsFound            = 36,
                DocumentList            = new List <IndexedDocumentData>()
                {
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    }
                }
            };

            const int StartRow     = 5;
            const int EndRow       = 6;
            const int PageNumber   = 3;
            const int ItemsPerPage = 2;

            var pagedResult = _documentEngine.GetPagedResults(StartRow, EndRow, PageNumber, ItemsPerPage, data, true);

            pagedResult.StartRow.Should().Be(5);
            //pagedResult.EndRow.Should().Be(6);
            pagedResult.ItemsPerPage.Should().Be(2);
            pagedResult.Results.Should().HaveCount(2);
        }
예제 #5
0
        public void GivenDocumentSearchIndexedResultsData_WhenIAskForTheLastPage_IGetCorrectPaginatedResults()
        {
            DocumentSearchResultsData data = new DocumentSearchResultsData()
            {
                DocumentsFoundOverLimit = 0,
                MoreRecords             = 0,
                RecordsFound            = 36,
                DocumentList            = new List <IndexedDocumentData>()
                {
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    },
                    new IndexedDocumentData()
                    {
                    }
                }
            };

            const int StartRow     = 21;
            const int EndRow       = 30;
            const int PageNumber   = 3;
            const int ItemsPerPage = 10;

            var pagedResult = _documentEngine.GetPagedResults(StartRow, EndRow, PageNumber, ItemsPerPage, data, false);

            pagedResult.StartRow.Should().Be(21);
            pagedResult.EndRow.Should().Be(26);
            pagedResult.ItemsPerPage.Should().Be(10);
            pagedResult.Results.Should().HaveCount(6);
        }
예제 #6
0
        public PagedResult <IndexedDocumentData> GetPagedResults(int startRow, int endRow, int pageNumber, int itemsPerPage, DocumentSearchResultsData documentSearchResultsData, bool applyFilter = false)
        {
            var documents = (from d in documentSearchResultsData.DocumentList select d).ToList();

            //      Results = documentSearchResultsData.DocumentList.OrderBy(c => c.UserName)
            //.Skip((pageNumber - 1) * numberOfItems)
            //.Take(numberOfItems)
            //.ToList(),

            return(new PagedResult <IndexedDocumentData>()
            {
                CurrentPage = pageNumber,
                ItemsPerPage = itemsPerPage,
                Results = applyFilter ? (from d in documentSearchResultsData.DocumentList select d).Skip((pageNumber - 1) * itemsPerPage).Take(itemsPerPage).ToList() : (from d in documentSearchResultsData.DocumentList select d).ToList(),
                TotalItems = applyFilter ? documents.Count : documentSearchResultsData.TotalRecordsFound,
                StartRow = startRow,
                EndRow = documents.Count < 10 ? (startRow + documents.Count) - 1 : endRow
            });
        }
예제 #7
0
        public void SetUp()
        {
            _archiveService          = new Mock <IDocument>();
            _documentRepository      = new Mock <IDocumentRepository>();
            _indexNameCriteraService = new Mock <IIndexNameCriteraService>();
            _documentEngine          = new Mock <ISearchEngine>();
            _docTypeRepository       = new Mock <IDocTypeRepository>();
            subDocTypeRepository     = new Mock <ISubDocTypeRepository>();
            _manCoRepository         = new Mock <IManCoRepository>();

            _documentService = new DocumentService(
                _archiveService.Object,
                _documentRepository.Object,
                _indexNameCriteraService.Object,
                _documentEngine.Object,
                _docTypeRepository.Object,
                subDocTypeRepository.Object,
                _manCoRepository.Object);

            _documentId  = Guid.NewGuid();
            _documentId2 = Guid.NewGuid();
            _documentId3 = Guid.NewGuid();

            _documentSearchResultsData = new DocumentSearchResultsData()
            {
                DocumentList = new List <IndexedDocumentData>
                {
                    new IndexedDocumentData()
                    {
                        ApplicationCode = "NTGENXX",
                        Id            = _documentId,
                        MappedIndexes = new List <IndexMapped>()
                        {
                            new IndexMapped()
                            {
                                IndexName  = "DocumentType",
                                IndexValue = "Document Type Value"
                            },
                            new IndexMapped()
                            {
                                IndexName  = "DocumentSubType",
                                IndexValue = "Document SubType Value"
                            }
                        }
                    },
                    new IndexedDocumentData()
                    {
                        ApplicationCode = "NTGENXX",
                        Id            = _documentId2,
                        MappedIndexes = new List <IndexMapped>
                        {
                            new IndexMapped()
                            {
                                IndexName  = "DocumentType2",
                                IndexValue = "Document Type Value2"
                            },
                            new IndexMapped()
                            {
                                IndexName  = "DocumentSubType2",
                                IndexValue = "Document SubType Value2"
                            }
                        }
                    }
                    ,
                    new IndexedDocumentData()
                    {
                        ApplicationCode = "NTGENXX",
                        Id            = _documentId3,
                        MappedIndexes = new List <IndexMapped>
                        {
                            new IndexMapped()
                            {
                                IndexName  = "DocumentType3",
                                IndexValue = "Document Type Value3"
                            },
                            new IndexMapped()
                            {
                                IndexName  = "DocumentSubType3",
                                IndexValue = "Document SubType Value3"
                            }
                        }
                    }
                }
            };

            _archiveService.Setup(
                d =>
                d.DocumentSearch(
                    It.IsAny <AuthenticationData>(),
                    It.IsAny <int>(),
                    It.IsAny <int>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <int>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>()))
            .Returns(_documentSearchResultsData);

            _pagedDocuments = new PagedResult <IndexedDocumentData>()
            {
                CurrentPage  = 1,
                EndRow       = 10,
                StartRow     = 1,
                ItemsPerPage = 10,
                Results      =
                    new List <IndexedDocumentData>()
                {
                    new IndexedDocumentData()
                    {
                        ApplicationCode = "NTGENXX",
                        Id            = _documentId,
                        MappedIndexes = new List <IndexMapped>
                        {
                            new IndexMapped()
                            {
                                IndexName  = "DocumentType",
                                IndexValue = "Document Type Value"
                            },
                            new IndexMapped()
                            {
                                IndexName  = "DocumentSubType",
                                IndexValue = "Document SubType Value"
                            }
                        }
                    },
                    new IndexedDocumentData()
                    {
                        ApplicationCode = "NTGENXX",
                        Id            = _documentId2,
                        MappedIndexes = new List <IndexMapped>
                        {
                            new IndexMapped()
                            {
                                IndexName  = "DocumentType2",
                                IndexValue = "Document Type Value2"
                            },
                            new IndexMapped()
                            {
                                IndexName  = "DocumentSubType2",
                                IndexValue = "Document SubType Value2"
                            }
                        }
                    }
                }
            };
        }