public void GeneralInventoryManagementViewModel01_Basic()
        {
            var searchFilter = new SearchFilterOptions();

            searchFilter.Initialize();
            Assert.NotNull(searchFilter, nameof(SearchFilterOptions));
            var vm = new GeneralInventoryManagementViewModel();

            Assert.NotNull(vm, nameof(GeneralInventoryManagementViewModel));
            var onSelectionChangedCommand = new UpdateDetailsGeneralInventoryManagementCommand(vm);

            Assert.NotNull(onSelectionChangedCommand, nameof(OnSelectionChangedCommand));
            var searchResultViewModel = new SearchResultViewModel(onSelectionChangedCommand);

            Assert.NotNull(searchResultViewModel, nameof(SearchResultViewModel));
            var searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);

            Assert.NotNull(searchFilterOptionsViewModel);

            searchFilter.SearchFilterEnabled = true;
            searchFilterOptionsViewModel.SearchTextCommand.Execute(null);
            searchFilterOptionsViewModel.SearchFilterCommand.WaitForSearchToComplete();
            Assert.NotNull(searchResultViewModel.Items);
            Assert.GreaterOrEqual(searchResultViewModel.Items.Count, 1);

            searchFilter.SearchText = SampleItemNumber;
            searchFilterOptionsViewModel.SearchTextCommand.Execute(null);
            Assert.NotNull(searchResultViewModel.Items);
            Assert.AreEqual(searchResultViewModel.Items.Count, 1);
        }
        public void NumberOfTotalPagesIsCorrect()
        {
            var expectedTotal = _context.Candidates.Count();
            var options       = new SearchFilterOptions
            {
                Page           = 2,
                ResultsPerPage = 3
            };

            var result = _repo.SearchForCandidates(options);

            Assert.AreEqual(3, result.Results.Count());
            Assert.AreEqual(expectedTotal, result.TotalRows);

            var totalPagesRoundDown = expectedTotal / 3;
            var totalPagesRemainder = expectedTotal % 3;

            if (totalPagesRemainder > 0)
            {
                Assert.AreEqual(totalPagesRoundDown + 1, result.TotalPages);
            }
            else
            {
                Assert.AreEqual(totalPagesRoundDown, result.TotalPages);
            }
        }
        private SearchDetailWindowViewModel GetSearchDetailWindowViewModelForGIM()
        {
            var searchFilter = new SearchFilterOptions();

            searchFilter.Initialize();
            Assert.NotNull(searchFilter, nameof(SearchFilterOptions));

            var vm = new GeneralInventoryManagementViewModel();

            Assert.NotNull(vm, nameof(GeneralInventoryManagementViewModel));

            var onSelectionChangedCommand = new UpdateDetailsGeneralInventoryManagementCommand(vm);

            Assert.NotNull(onSelectionChangedCommand, nameof(OnSelectionChangedCommand));

            var searchResultViewModel = new SearchResultViewModel(onSelectionChangedCommand);

            Assert.NotNull(searchResultViewModel, nameof(SearchResultViewModel));

            var searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);

            Assert.NotNull(searchFilterOptionsViewModel);

            var GIM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, vm);

            return(GIM);
        }
        private void OnGUI()
        {
            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.BeginHorizontal(GUI.skin.box);
            scriptSource = EditorGUILayout.ObjectField("Script: ", scriptSource, typeof(Object), false);
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Find object's directory: Object Reference Approach"))
            {
                var directoryOfChosenObject = FindDirectoryOfObject(scriptSource);
                Debug.Log(directoryOfChosenObject);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            EditorGUILayout.BeginHorizontal(GUI.skin.box);
            searchName = EditorGUILayout.TextField("Search string: ", searchName);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            filterType = (SearchFilterOptions)EditorGUILayout.EnumPopup("Filter the search by: ", filterType);

            if (filterType == SearchFilterOptions.Type)
            {
                typeSearchFilter = (SearchByTypeFilter)EditorGUILayout.EnumPopup("Type to search for: ", typeSearchFilter);
            }
            else
            {
                labelSearchFilter = (SearchByLabelFilter)EditorGUILayout.EnumPopup("Label to search for: ", labelSearchFilter);
            }
            EditorGUILayout.Separator();

            string buttonText = $"Find object's directory: Search Filter Approach - {filterType.ToString()}";

            if (GUILayout.Button(buttonText))
            {
                switch (filterType)
                {
                case SearchFilterOptions.Type:
                    SearchForObjectInAssets(searchName, typeSearchFilter);
                    break;

                case SearchFilterOptions.Label:
                    SearchForObjectInAssets(searchName, labelSearchFilter);
                    break;

                default:
                    break;
                }
            }

            EditorGUILayout.EndVertical();
        }
        /// <summary>
        /// Adds a filter based on a binding path. The given token will resolve to a property at the specified <paramref name="path"/>.
        /// </summary>
        /// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter.</param>
        /// <param name="path">The property this token should resolve to.</param>
        /// <param name="options">The set of filter options.</param>
        public void AddSearchFilterProperty(string token, PropertyPath path, SearchFilterOptions options)
        {
            SearchFilterTokens.Add(token);
            SearchFilterProperties.Add(new SearchFilterProperty(token, path, options));

            foreach (var backend in m_SearchBackends.Values)
            {
                backend.AddSearchFilterProperty(token, path, options);
            }
        }
        public void CanRetrieveAllCandidatesUsingSearch()
        {
            var options = new SearchFilterOptions
            {
                NameSearchString = ""
            };

            var result = _repo.SearchForCandidates(options);

            Assert.AreEqual(_context.Candidates.Count(), result.Results.Count());
        }
Beispiel #7
0
        public void SearchItemsCommandTest()
        {
            var db = DataRepository.GetDataRepository;

            Assert.NotNull(db);
            var user        = db.Load <UserDetail>("steph");
            var userManager = new UserManager(db);

            UserManager.GetUserManager.LoginUser(user);


            var searchFilter = new SearchFilterOptions
            {
                User = UserManager.GetUserManager.CurrentUser(),
                SiteLocationEnabled             = false,
                SearchFilterEnabled             = true,
                SearchText                      = "Airway Kit",
                SelectEquipmentUnitsEnabled     = false,
                SelectItemStatusValuesEnabled   = false,
                SelectItemCategoryValuesEnabled = false
            };

            Assert.NotNull(searchFilter, nameof(SearchFilterOptions));
            var resultVM = new TestDetailsViewModel();

            Assert.NotNull(resultVM, nameof(TestDetailsViewModel));
            var onSelectionChangedCommand = new OnSelectionChangedCommand(resultVM);

            Assert.NotNull(onSelectionChangedCommand, nameof(OnSelectionChangedCommand));
            var searchResultViewModel = new SearchResultViewModel(onSelectionChangedCommand);

            Assert.NotNull(searchResultViewModel, nameof(SearchResultViewModel));
            var searchCmd = new SearchItemsCommand(QueryResultEntitySelector.ItemType, searchResultViewModel);

            Assert.NotNull(searchCmd, nameof(SearchItemsCommand));

            Assert.IsTrue(searchCmd.CanExecute(searchFilter));

            Assert.IsNull(resultVM.CurrentItem);                           // nothing selected to display details of
            Assert.That(searchResultViewModel.Items.Count, Is.EqualTo(0)); // no search results or empty search results
            searchCmd.Execute(searchFilter);
            searchCmd.WaitForSearchToComplete();
            Assert.That(searchResultViewModel.Items.Count, Is.GreaterThan(0));

            searchResultViewModel.SelectedItem = searchResultViewModel.Items.First();
            Assert.NotNull(searchResultViewModel.SelectedItem);
            Assert.NotNull(resultVM.CurrentItem);

            Assert.AreNotEqual(Guid.Empty, resultVM.CurrentItem.id);
            Assert.NotNull(resultVM.CurrentItem.entityType);
            Assert.NotNull(resultVM.CurrentItem.entity);
        }
        private string getConditionFromList(SearchFilterOptions searchFilter, IList <object> selectedList, int maxSelectable, string conditionFormat)
        {
            string queryCondition = "";  // default to all units, ie no additional condition

            if (selectedList != null)
            {
                // if selected count = available count then assume all selected, so no additional condition
                // otherwise limit to results within selected set
                if (selectedList.Count != maxSelectable)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (var i in selectedList)
                    {
                        // get this item's value to match with in DB
                        string name = "";
                        {
                            if (i is ReferenceData refData)
                            {
                                name = refData.name;
                            }

                            if (i is EquipmentUnitType unit)
                            {
                                name = unit.name;
                            }

                            if (i is SiteLocation site)
                            {
                                name = site.name;
                            }

                            if (name == string.Empty)
                            {
                                throw new NotImplementedException("Unexpected type in generating DB query condition from List!");
                            }
                        }

                        {
                            if (sb.Length > 0)
                            {
                                sb.Append(", ");                 // 2nd or more item in list
                            }
                            sb.Append("'");
                            sb.Append(name);
                            sb.Append("'");
                        }
                    }
                    queryCondition = string.Format(conditionFormat, sb.ToString());
                }
            }
            return(queryCondition);
        }
        public void CanRetrieveSpecificCandidatesUsingCaseInsensitiveFirstnameInNameSearch()
        {
            var randy = _context.Candidates.Single(c => c.Firstname == "Randy");

            var options = new SearchFilterOptions
            {
                NameSearchString = "rAnDY"
            };

            var result = _repo.SearchForCandidates(options);

            Assert.AreEqual(randy.Id, result.Results.First().Id);
        }
        async private void GetItemTreeAsync(SearchFilterOptions criteria)
        {
            logger.Info("GetItemTreeAsync");
            await Task.Factory.StartNew(() =>
            {
                try
                {
                    logger.Info("GetItemTreeAsync query");
                    var db    = DataRepository.GetDataRepository;
                    var items = db.GetItemTree(resultEntitySelector, criteria, out GenericItemResult item);

                    // update the view, but do so in WPF dispatcher thread
                    //Dispatcher.BeginInvoke((Action)(() => { searchResultViewModel.Items = items; }));
                    logger.Info($"GetItemTreeAsync:returned {items.Count} items.");
                    searchResultViewModel.Items = items;

                    // set selected item if one was returned to be selected
                    if (item == null)
                    {
                        logger.Info("GetItemTreeAsync: No item auto-selected.");
                    }
                    else
                    {
                        logger.Info($"GetItemTreeAsync: Auto-selected {item.ToString()}");
                    }
                    searchResultViewModel.SelectedItem = item;

                    // updated returned count
                    if (items.Count > 0)
                    {
                        searchResultViewModel.StatusMessage = $"Found {items.First().resultTotal} results.";
                    }
                    else
                    {
                        searchResultViewModel.StatusMessage = "No matches found.";
                    }
                }
                catch (Exception e)
                {
                    logger?.Error(e, $"Failed to load item tree! criteria:{criteria}");
                    return;
                }
                finally
                {
                    searchStatus = SearchStatus.Complete;
                }
            });

            logger.Info("GetItemTreeAsync end");
        }
        public void CanSelectPageOfResultsUsingSearch()
        {
            var expectedTotal = _context.Candidates.Count();
            var options       = new SearchFilterOptions
            {
                Page           = 2,
                ResultsPerPage = 3
            };

            var result = _repo.SearchForCandidates(options);

            Assert.AreEqual(3, result.Results.Count());
            Assert.AreEqual(expectedTotal, result.TotalRows);
        }
        public void CandidateWithoutBehaviourDoesNotAppearWhenFilteredForBehaviour()
        {
            var candidateWithoutBehaviourAssessment = _context.Candidates.First(c => !c.Assessments.Any(a => a.AssessmentType == AssessmentType.Behaviour));
            var options = new SearchFilterOptions
            {
                AssessmentsToFilterFor = new string[]
                {
                    "Behaviour"
                }
            };

            var result = _repo.SearchForCandidates(options);

            Assert.IsTrue(!result.Results.Any(r => r.Id == candidateWithoutBehaviourAssessment.Id));
        }
        public void CanFilterForCandidatesWithSentBehaviourTests()
        {
            var candidateWithBehaviourAssessment = _context.Candidates.First(c => c.Assessments.Any(a => a.AssessmentType == AssessmentType.Behaviour));
            var options = new SearchFilterOptions
            {
                AssessmentsToFilterFor = new string[]
                {
                    "Behaviour"
                }
            };

            var result = _repo.SearchForCandidates(options);

            Assert.IsTrue(result.Results.Any(r => r.Id == candidateWithBehaviourAssessment.Id));
        }
 private ItemAndContainerEnum SearchFilterItemBoolsToEnum(SearchFilterOptions searchFilter)
 {
     try
     {
         return((ItemAndContainerEnum)(
                    (searchFilter.IncludeItems ? ItemAndContainerEnum.Items : 0) |
                    (searchFilter.IncludeModules ? ItemAndContainerEnum.Modules : 0) |
                    (searchFilter.IncludeBins ? ItemAndContainerEnum.Bins : 0)
                    ));
     }
     catch (Exception e)
     {
         logger.Error(e, $"Exception in SearchFilterItemBoolsToEnum() - {e.Message}");
         throw;
     }
 }
Beispiel #15
0
 public void PopulateSearchFilters(HashSet <string> filters)
 {
     SearchFilterOptions.Clear();
     if (filters.Count <= 1 || (CurrentMainPage != PageIndex.PageSearch && CurrentMainPage != PageIndex.PageMangaSearch && CurrentOffPage != PageIndex.PageSearch))
     {
         SearchFilterButtonVisibility = false;
         IsSearchFilterActive         = false;
         return;
     }
     SearchFilterButtonVisibility = true;
     foreach (var filter in filters)
     {
         SearchFilterOptions.Add(filter);
     }
     SearchFilterOptions.Add("None");
     SearchFilterSelectedIndex = SearchFilterOptions.Count - 1;
 }
        public void CanRetrieveMultipleCandidatesUsingNameSearch()
        {
            var ids = _context.Candidates.Where(c => c.Firstname.Contains("Chri")).Select(c => c.Id);

            var options = new SearchFilterOptions
            {
                NameSearchString = "chri"
            };

            var result = _repo.SearchForCandidates(options);

            Assert.AreEqual(ids.Count(), result.Results.Count());
            foreach (var id in ids)
            {
                Assert.IsTrue(result.Results.Any(r => r.Id == id));
            }
        }
        public void WillReturnAnEmptyArrayInsteadOf404WhenNoCandidatesMatchStringSearch()
        {
            var options = new SearchFilterOptions
            {
                NameSearchString = "Does not exist"
            };

            _repo.Setup(r => r.SearchForCandidates(options)).Returns(new SearchResult {
                Results = new List <CandidateSummary>().AsEnumerable()
            });

            var result      = _controller.GetCandidatesWithFilterOptions(options);
            var okResult    = (OkObjectResult)result.Result;
            var resultValue = (SearchResult)okResult.Value;

            _repo.Verify(r => r.SearchForCandidates(options), Times.Once);
            Assert.AreEqual(0, resultValue.Results.Count());
        }
        public void CanRetrieveAllCandidatesUsingSearch()
        {
            var candidates = CreateCandidateSummaries();
            var options    = new SearchFilterOptions
            {
                NameSearchString = ""
            };

            _repo.Setup(r => r.SearchForCandidates(options)).Returns(new SearchResult {
                Results = candidates
            });

            var result      = _controller.GetCandidatesWithFilterOptions(options);
            var okResult    = (OkObjectResult)result.Result;
            var resultValue = (SearchResult)okResult.Value;

            _repo.Verify(r => r.SearchForCandidates(options), Times.Once);
            Assert.AreEqual(candidates.Count(), resultValue.Results.Count());
        }
 public ActionResult <SearchResult> GetCandidatesWithFilterOptions(SearchFilterOptions options)
 {
     return(Ok(_repo.SearchForCandidates(options)));
 }
Beispiel #20
0
 // anything that needs initializing
 public MasterDetailItemWindowViewModelBase(QueryResultEntitySelector resultEntitySelector, SearchFilterOptions SearchFilter) : base(resultEntitySelector, SearchFilter)
 {
     // from this point on, trigger changes based on any changes to our SearchFilter
     PropertyChanged += MasterDetailItemWindowViewModelBase_PropertyChanged;
 }
        /// <summary>
        /// returns a Window derived instance to show
        /// </summary>
        /// <param name="view">which window to return</param>
        /// <param name="searchText">optional, usually null, for windows with a SearchFilter, sets the initial searchText</param>
        /// <returns></returns>
        public static Window GetWindow(string view, string searchText = null, object args = null)
        {
            // needed view models for Search Detail Windows, i.e. windows with search pane, results tree pane, and details pane
            DetailsViewModelBase         detailsPaneVM;
            OnSelectionChangedCommand    onSelectionChangedCommand;
            SearchResultViewModel        searchResultViewModel;
            SearchFilterOptions          searchFilter;
            SearchFilterOptionsViewModel searchFilterOptionsViewModel;
            SearchDetailWindowViewModel  winVM;

            Window win = null;

            switch (view)
            {
            // asset management
            case "GenInvMngt":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText);

                detailsPaneVM                = new GeneralInventoryManagementViewModel();
                onSelectionChangedCommand    = new UpdateDetailsGeneralInventoryManagementCommand(detailsPaneVM);
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new GeneralInventoryManagementWindow(winVM);
                break;

            case "DeployRecoverDetails":
                win = new DeployRecoverDetailsWindow(new DetailsDeployRecoverViewModel(args as DeployEvent));
                break;

            case "DeployRecover":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText, enabled: false);
                searchFilter.SearchFilterVisible = false;
                detailsPaneVM                = new HistoryDeployRecoverViewModel();
                onSelectionChangedCommand    = new UpdateDetailsHistoryDeployRecoverCommand(detailsPaneVM);
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);
                searchFilterOptionsViewModel.StatusAvailable = true;
                searchFilter.SearchFilterEnabled             = true;
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new DeployRecoverHistoryWindow(winVM);
                break;

            case "DamagedMissingDetails":
                win = new DamagedMissingDetailsWindow(new DetailsDamagedMissingViewModel(null));
                break;

            case "DamagedMissing":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText);

                detailsPaneVM                = new HistoryDamagedMissingViewModel();
                onSelectionChangedCommand    = new UpdateDetailsHistoryDamagedMissingCommand(detailsPaneVM);
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new DamagedMissingHistoryWindow(winVM);
                break;

            case "ServiceDetails":
                win = new ServiceDetailsWindow(new DetailsServiceViewModel(null));
                break;

            case "Service":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText);

                detailsPaneVM                = new HistoryServiceViewModel();
                onSelectionChangedCommand    = new UpdateDetailsHistoryServiceCommand(detailsPaneVM);
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new ServiceHistoryWindow(winVM);
                break;

            case "ExpirationDetails":
                win = new ExpirationWindow(new DetailsExpirationReplaceViewModel(null));
                break;

            case "Expiration":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText);

                detailsPaneVM                = new HistoryExpirationReplaceViewModel();
                onSelectionChangedCommand    = new UpdateDetailsHistoryExpirationReplaceCommand(detailsPaneVM);
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new ExpirationHistoryWindow(winVM);
                break;

            // System Administration
            case "ManageUsers":
                win = new ManageUsersWindow();
                break;

            case "Replication":
                win = new ReplicationWindow();
                break;

            case "ManageVendors":
                var manageVendorVM = new ManageVendorsViewModel();
                if (searchText != null)
                {
                    manageVendorVM.SearchVendorText = searchText;
                }
                win = new ManageVendorsWindow(manageVendorVM);
                break;

            case "SiteToEquipMapping":
                win = new SiteToEquipmentUnitMappingWindow();
                break;

            case "ManageItems":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText, SearchFilterOptions.SearchFilterItemInitializeFor.Item);

                detailsPaneVM                = new ItemManagementViewModel();
                onSelectionChangedCommand    = new UpdateDetailsItemManagementCommand(detailsPaneVM, typeof(Item));
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.Item, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new ItemManagementWindow(winVM);
                break;

            case "ManageItemTypes":
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText, SearchFilterOptions.SearchFilterItemInitializeFor.ItemType);

                detailsPaneVM                = new ItemTypeManagementViewModel();
                onSelectionChangedCommand    = new UpdateDetailsItemManagementCommand(detailsPaneVM, typeof(ItemType));
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemType, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new ItemTypeManagementWindow(winVM);
                break;

            case "SelectItemType":
                // TODO this should just be a selection window!!!
                searchFilter = new SearchFilterOptions();
                searchFilter.Initialize(searchText, SearchFilterOptions.SearchFilterItemInitializeFor.ItemType);

                detailsPaneVM                = new ItemTypeManagementViewModel();
                onSelectionChangedCommand    = new UpdateDetailsItemManagementCommand(detailsPaneVM, typeof(ItemType));
                searchResultViewModel        = new SearchResultViewModel(onSelectionChangedCommand);
                searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemType, searchResultViewModel);
                winVM = new SearchDetailWindowViewModel(searchFilterOptionsViewModel, searchResultViewModel, detailsPaneVM);

                win = new ItemTypeManagementWindow(winVM);
                break;

            case "EditReferenceData":
                win = new ReferenceDataWindow();
                break;

            // reports - see MainWindow.xaml.cs
            case "ReportSummary":
                break;

            case "ReportItemStatus":
                break;

            case "ReportVendorCost":
                break;

            case "ReportWeight":
                break;

            case "ReportExpiration":
                break;

            case "ReportService":
                break;

            case "ReportDeployment":
                break;

            case "ReportDamaged":
                break;

            // view/print labels
            case "Labels":
                win = new ViewPrintLabelsWindow();
                break;

            default:
                // nothing to do
                break;
            }

            logger.Debug($"Invoking window {view}");
            return(win);
        }
 public override void AddSearchFilterProperty(string token, PropertyPath path, SearchFilterOptions options)
 {
 }
Beispiel #23
0
        public void ReplaceItemCommand()
        {
            var db = DataRepository.GetDataRepository;

            Assert.NotNull(db);
            var user        = db.Load <UserDetail>("steph");
            var userManager = new UserManager(db);

            UserManager.GetUserManager.LoginUser(user);

            var cmd = new ReplaceItemCommand();

            Assert.NotNull(cmd, nameof(ReplaceItemCommand));

            var item = db.Load <ItemInstance>(SampleItemInstance);

            Assert.NotNull(item);
            // force known value
            item.status = db.ReferenceData[nameof(ItemStatus)].ByName <ItemStatus>("Available");
            db.Save(item);
            item = db.Load <ItemInstance>(SampleItemInstance);
            Assert.That(item.status.name, Is.EqualTo("Available"));

            Assert.IsTrue(cmd.CanExecute(item));
            cmd.Execute(item);
            Assert.That(item.status.name, Is.EqualTo("Out for Service"));

            // verify a new item created
            var searchFilter = new SearchFilterOptions
            {
                User = UserManager.GetUserManager.CurrentUser(),
                SiteLocationEnabled = false,
                SearchFilterEnabled = true,
                SearchText          = SampleItemNumber,
                ItemTypeMatching    = SearchFilterItemMatching.OnlyExact,
                //AllowItemsRemovedFromService = false, // required or query below may return old item instead of new one
                SelectEquipmentUnitsEnabled     = false,
                SelectItemStatusValuesEnabled   = false,
                SelectItemCategoryValuesEnabled = false
            };

            Assert.NotNull(searchFilter, nameof(SearchFilterOptions));
            var resultVM = new TestDetailsViewModel();

            Assert.NotNull(resultVM, nameof(TestDetailsViewModel));
            var onSelectionChangedCommand = new OnSelectionChangedCommand(resultVM);

            Assert.NotNull(onSelectionChangedCommand, nameof(OnSelectionChangedCommand));
            var searchResultViewModel = new SearchResultViewModel(onSelectionChangedCommand);

            Assert.NotNull(searchResultViewModel, nameof(SearchResultViewModel));
            var searchCmd = new SearchItemsCommand(QueryResultEntitySelector.ItemType, searchResultViewModel);

            Assert.NotNull(searchCmd, nameof(SearchItemsCommand));
            //var searchFilterOptionsViewModel = new SearchFilterOptionsViewModel(searchFilter, QueryResultEntitySelector.ItemInstance, searchResultViewModel);
            //Assert.NotNull(searchFilterOptionsViewModel);

            Assert.IsTrue(searchCmd.CanExecute(searchFilter));

            Assert.IsNull(resultVM.CurrentItem);                           // nothing selected to display details of
            Assert.That(searchResultViewModel.Items.Count, Is.EqualTo(0)); // no search results or empty search results
            searchCmd.Execute(searchFilter);
            searchCmd.WaitForSearchToComplete();
            Assert.That(searchResultViewModel.Items.Count, Is.GreaterThan(0));

            searchResultViewModel.SelectedItem = searchResultViewModel.Items.First();
            Assert.NotNull(searchResultViewModel.SelectedItem);
            Assert.NotNull(resultVM.CurrentItem);
            Assert.That(resultVM.CurrentItem.id, Is.Not.EqualTo(item.id));

            // delete new item and restore old item to Available
            var newItem = db.Load <ItemInstance>(resultVM.CurrentItem.id);

            Assert.That(newItem.status.name, Is.EqualTo("Available"));
            item.status             = db.ReferenceData[nameof(ItemStatus)].ByName <ItemStatus>("Available");
            item.removedServiceDate = null;
            db.Delete(newItem);
            Assert.IsFalse(db.Exists(newItem));
            db.Save(item);
            item = db.Load <ItemInstance>(SampleItemInstance);
            Assert.That(item.status.name, Is.EqualTo("Available"));
        }
 public override void AddSearchFilterCallback <TFilter>(string token, Func <TData, TFilter> getFilterDataFunc, SearchFilterOptions options)
 {
 }
Beispiel #25
0
 public SearchFilterOptionsViewModel(SearchFilterOptions searchFilterOptions, QueryResultEntitySelector resultEntitySelector, SearchResultViewModel searchResultViewModel) : base()
 {
     SearchFilterCommand = new SearchItemsCommand(resultEntitySelector, searchResultViewModel);
     this.SearchFilter   = searchFilterOptions;
 }
 public SearchFilterProperty(string token, PropertyPath path, SearchFilterOptions options)
 {
     Token   = token;
     Path    = path;
     Options = options;
 }
 public abstract void AddSearchFilterCallback <TFilter>(string token, Func <TData, TFilter> getFilterDataFunc, SearchFilterOptions options);
 public abstract void AddSearchFilterProperty(string token, PropertyPath path, SearchFilterOptions options);
Beispiel #29
0
 protected void ResetSearchFilter()
 {
     SearchFilterButtonVisibility = false;
     IsSearchFilterActive         = false;
     SearchFilterOptions.Clear();
 }
        /// <summary>
        /// Adds a search filter based on a callback function. The given token will resolve to the result of the specified <paramref name="getSearchFilterFunc"/>.
        /// </summary>
        /// <param name="token">The identifier of the filter. Typically what precedes the operator in a filter.</param>
        /// <param name="getSearchFilterFunc">Callback used to get the object that is used in the filter. Takes an object of type TData and returns an object of type TFilter.</param>
        /// <param name="options">The set of filter options.</param>
        /// <typeparam name="TData">The data type being searched.</typeparam>
        /// <typeparam name="TFilter">The return type for the filter.</typeparam>
        public void AddSearchFilterCallback <TData, TFilter>(string token, Func <TData, TFilter> getSearchFilterFunc, SearchFilterOptions options)
        {
            SearchFilterTokens.Add(token);
            SearchFilterCallbacks.Add(new SearchFilterCallback <TData, TFilter>
            {
                Token = token,
                GetSearchFilterFunc = getSearchFilterFunc,
                Options             = options
            });

            foreach (var backend in m_SearchBackends.Values.OfType <ISearchBackend <TData> >())
            {
                backend.AddSearchFilterCallback(token, getSearchFilterFunc, options);
            }
        }