コード例 #1
0
        private ICriteria CreateSearchCriteria(ApplicationSearchRequest searchRequest)
        {
            var criteria = Session.CreateCriteria(typeof(Application));
            var name     = searchRequest.NameQuery;

            name += "";
            string[] split = name.Split(new[] { ' ', ',', '.', ':' });

            bool     includeNameQuery = false;
            Junction disjunction      = Restrictions.Disjunction(); // This adds an "or" between each clause instead of an "and"

            foreach (var s in split.Where(s => s.Trim() != ""))
            {
                includeNameQuery = true;
                SimpleExpression applicationNameExp = Restrictions.Like("ApplicationName", s, MatchMode.Anywhere);
                SimpleExpression aliasExp           = Restrictions.Like("Alias", s, MatchMode.Anywhere);
                disjunction.Add(Restrictions.Or(applicationNameExp, aliasExp));
            }
            if (includeNameQuery)
            {
                criteria.Add(disjunction);
            }

            if (searchRequest.SupportTeamId > 0)
            {
                criteria.Add(Restrictions.Eq("SupportTeam.Id", searchRequest.SupportTeamId));
            }

            if (searchRequest.HostId > 0)
            {
                criteria.CreateCriteria("Hosts").Add(Restrictions.Eq("Id", searchRequest.HostId));
            }

            return(criteria);
        }
コード例 #2
0
        public IList <ApplicationDto> Search(ApplicationSearchRequest searchRequest, int offset, int maxEntries)
        {
            ICriteria criteria = CreateSearchCriteria(searchRequest)
                                 .CreateAlias("SupportTeam", "SupportTeam", JoinType.LeftOuterJoin)
                                 //.CreateAlias("Hosts", "Hosts", JoinType.LeftOuterJoin)
                                 .SetProjection(Projections.ProjectionList()
                                                .Add(Projections.Property("Id"), "Id")
                                                .Add(Projections.Property("ApplicationName"), "ApplicationName")
                                                .Add(Projections.Property("ApplicationDescription"), "ApplicationDescription")
                                                .Add(Projections.Property("Alias"), "Alias")
                                                .Add(Projections.Property("SupportTeamId"), "SupportTeamId")
                                                .Add(Projections.Property("SubjectMatterExpertId"), "SubjectMatterExpertId")
                                                .Add(Projections.Property("MaintenanceExpirationDate"), "MaintenanceExpirationDate")
                                                .Add(Projections.Property("SupervisorNotes"), "SupervisorNotes")
                                                .Add(Projections.Property("SupportStaffNotes"), "SupportStaffNotes")
                                                .Add(Projections.Property("ServiceDeskNotes"), "ServiceDeskNotes")
                                                .Add(Projections.Property("PrimaryUrl"), "PrimaryUrl")
                                                .Add(Projections.Property("DocumentationUrl"), "DocumentationUrl")
                                                .Add(Projections.Property("SupportTeamId"), "SupportTeamId")
                                                .Add(Projections.Property("SupportTeam.TeamName"), "SupportTeamName")
                                                .Add(Projections.Property("SupportTeam.PhoneNumber"), "SupportTeamPhoneNumber"));

            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(ApplicationDto)));

            criteria.SetMaxResults(maxEntries).SetFirstResult(offset);

            if (!string.IsNullOrEmpty(searchRequest.SortColumn))
            {
                criteria.AddOrder(searchRequest.SortOrder.StartsWith("A")
                                      ? Order.Asc(searchRequest.SortColumn)
                                      : Order.Desc(searchRequest.SortColumn));
            }

            return(criteria.List <ApplicationDto>());
        }
コード例 #3
0
        public int GetSearchTotal(ApplicationSearchRequest searchRequest)
        {
            var criteria = CreateSearchCriteria(searchRequest);

            criteria.SetProjection(Projections.RowCount());
            return((int)criteria.UniqueResult());
        }
コード例 #4
0
        public virtual void CanGetSearchTotal()
        {
            var searchRequest = new ApplicationSearchRequest { NameQuery = "", HostId = 1 };

            int results = _applicationRepository.GetSearchTotal(searchRequest);
            Assert.That(results >= 1);
        }
コード例 #5
0
        private SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> LoadSearchResults(
            ApplicationSearchRequest searchRequest)
        {
            const int entriesPerPage = 20;
            int       offset         = entriesPerPage * (searchRequest.CurrentPageNumber - 1);

            IList <ApplicationDto> searchResultItems = _applicationRepository.Search(searchRequest, offset,
                                                                                     entriesPerPage);

            SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> searchResultFormViewModel =
                CreateFormViewModel(searchRequest);

            searchResultFormViewModel.PageResultItems = searchResultItems;

            int resultCount = _applicationRepository.GetSearchTotal(searchRequest);

            searchResultFormViewModel.TotalResultCount = resultCount;

            searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber;

            searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage;
            if (resultCount % entriesPerPage > 0)
            {
                searchResultFormViewModel.TotalPageCount++;
            }

            return(searchResultFormViewModel);
        }
コード例 #6
0
        public virtual void CanSearch()
        {
            var searchRequest = new ApplicationSearchRequest { };

            IList<ApplicationDto> results = _applicationRepository.Search(searchRequest, 0, 20);
            Assert.That(results.Count > 0 && results.Count <= 20);
        }
コード例 #7
0
        public virtual void CanSearch()
        {
            var searchRequest = new ApplicationSearchRequest {
            };

            IList <ApplicationDto> results = _applicationRepository.Search(searchRequest, 0, 20);

            Assert.That(results.Count > 0 && results.Count <= 20);
        }
コード例 #8
0
        public virtual void CanGetSearchTotal()
        {
            var searchRequest = new ApplicationSearchRequest {
                NameQuery = "", HostId = 1
            };

            int results = _applicationRepository.GetSearchTotal(searchRequest);

            Assert.That(results >= 1);
        }
コード例 #9
0
        public SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> CreateFormViewModel(
            ApplicationSearchRequest searchRequest)
        {
            var viewModel = new SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> { SearchRequest = searchRequest };
            //searchRequest.Supervisors = _applicationRepository.GetActiveSupervisors(-1, "LastName", "Asc");
            searchRequest.Hosts = _hostManagementService.GetAll();
            searchRequest.SupportTeams = _supportTeamManagementService.GetAll();

            return viewModel;
        }
コード例 #10
0
 public SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> CreateFormViewModel()
 {
     var searchRequest = new ApplicationSearchRequest
                             {
                                 //Supervisors = _applicationRepository.GetActiveSupervisors(-1,"LastName", "Asc")
                                 Hosts = _hostManagementService.GetAll(),
                                 SupportTeams = _supportTeamManagementService.GetAll()
                             };
     SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> viewModel = Search(searchRequest);
     viewModel.SearchRequest = searchRequest;
     return viewModel;
 }
コード例 #11
0
        public SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> CreateFormViewModel(
            ApplicationSearchRequest searchRequest)
        {
            var viewModel = new SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> {
                SearchRequest = searchRequest
            };

            //searchRequest.Supervisors = _applicationRepository.GetActiveSupervisors(-1, "LastName", "Asc");
            searchRequest.Hosts        = _hostManagementService.GetAll();
            searchRequest.SupportTeams = _supportTeamManagementService.GetAll();

            return(viewModel);
        }
コード例 #12
0
        public SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> CreateFormViewModel()
        {
            var searchRequest = new ApplicationSearchRequest
            {
                //Supervisors = _applicationRepository.GetActiveSupervisors(-1,"LastName", "Asc")
                Hosts        = _hostManagementService.GetAll(),
                SupportTeams = _supportTeamManagementService.GetAll()
            };
            SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> viewModel = Search(searchRequest);

            viewModel.SearchRequest = searchRequest;
            return(viewModel);
        }
コード例 #13
0
        public ActionResult Search(ApplicationSearchRequest searchRequest)
        {
            SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> formViewModel = null;

            try
            {
                formViewModel = _applicationSearchManagementService.Search(searchRequest);
                Session.Add(SEARCH_PARAMETERS, searchRequest);
            }
            catch (PreconditionException pde)
            {
                TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = pde.Message;
                formViewModel = _applicationSearchManagementService.CreateFormViewModel(searchRequest);
            }
            return(View("Index", formViewModel));
        }
コード例 #14
0
        public SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> Search(
            ApplicationSearchRequest searchRequest)
        {
            if (searchRequest.CurrentPageNumber == 0)
            {
                searchRequest.CurrentPageNumber = 1;
            }
            if (string.IsNullOrEmpty(searchRequest.SortColumn))
            {
                searchRequest.SortColumn = DEFAULT_SORT_COLUMN;
                searchRequest.SortOrder  = DEFAULT_SORT_ORDER;
            }
            const int entriesPerPage = 20;
            int       offset         = entriesPerPage * (searchRequest.CurrentPageNumber - 1);

            IList <ApplicationDto> searchResultItems = _applicationRepository.Search(searchRequest, offset,
                                                                                     entriesPerPage);

            SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> searchResultFormViewModel =
                CreateFormViewModel(searchRequest);

            searchResultFormViewModel.PageResultItems = searchResultItems;

            int resultCount = _applicationRepository.GetSearchTotal(searchRequest);

            searchResultFormViewModel.TotalResultCount = resultCount;


            searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber;

            searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage;
            if (resultCount % entriesPerPage > 0)
            {
                searchResultFormViewModel.TotalPageCount++;
            }

            return(searchResultFormViewModel);
        }
コード例 #15
0
        public SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> Search(
            ApplicationSearchRequest searchRequest)
        {
            if (searchRequest.CurrentPageNumber == 0)
            {
                searchRequest.CurrentPageNumber = 1;
            }
            if(string.IsNullOrEmpty(searchRequest.SortColumn))
            {
                searchRequest.SortColumn = DEFAULT_SORT_COLUMN;
                searchRequest.SortOrder = DEFAULT_SORT_ORDER;
            }
            const int entriesPerPage = 20;
            int offset = entriesPerPage * (searchRequest.CurrentPageNumber - 1);

            IList<ApplicationDto> searchResultItems = _applicationRepository.Search(searchRequest, offset,
                                                                                    entriesPerPage);

            SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> searchResultFormViewModel =
                CreateFormViewModel(searchRequest);

            searchResultFormViewModel.PageResultItems = searchResultItems;

            int resultCount = _applicationRepository.GetSearchTotal(searchRequest);
            searchResultFormViewModel.TotalResultCount = resultCount;

            searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber;

            searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage;
            if (resultCount % entriesPerPage > 0)
            {
                searchResultFormViewModel.TotalPageCount++;
            }

            return searchResultFormViewModel;
        }
コード例 #16
0
 public SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> Search(
     ApplicationSearchRequest searchRequest)
 {
     throw new NotImplementedException();
 }
コード例 #17
0
        private SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> LoadSearchResults(
            ApplicationSearchRequest searchRequest)
        {
            const int entriesPerPage = 20;
            int offset = entriesPerPage * (searchRequest.CurrentPageNumber - 1);

            IList<ApplicationDto> searchResultItems = _applicationRepository.Search(searchRequest, offset,
                                                                                    entriesPerPage);

            SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> searchResultFormViewModel =
                CreateFormViewModel(searchRequest);

            searchResultFormViewModel.PageResultItems = searchResultItems;

            int resultCount = _applicationRepository.GetSearchTotal(searchRequest);
            searchResultFormViewModel.TotalResultCount = resultCount;

            searchResultFormViewModel.CurrentPageNumber = searchRequest.CurrentPageNumber;

            searchResultFormViewModel.TotalPageCount = resultCount / entriesPerPage;
            if (resultCount % entriesPerPage > 0)
            {
                searchResultFormViewModel.TotalPageCount++;
            }

            return searchResultFormViewModel;
        }
コード例 #18
0
 public SearchResultFormViewModel <ApplicationDto, ApplicationSearchRequest> Search(
     ApplicationSearchRequest searchRequest)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
 public ActionResult Search(ApplicationSearchRequest searchRequest)
 {
     SearchResultFormViewModel<ApplicationDto, ApplicationSearchRequest> formViewModel = null;
     try
     {
         formViewModel = _applicationSearchManagementService.Search(searchRequest);
         Session.Add(SEARCH_PARAMETERS, searchRequest);
     }
     catch (PreconditionException pde)
     {
         TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] = pde.Message;
         formViewModel = _applicationSearchManagementService.CreateFormViewModel(searchRequest);
     }
     return View("Index", formViewModel);
 }