public SearchHandlerRenderer(SearchHandler searchHandler)
        {
            Element = searchHandler;
            Control = new NSearchBar(Forms.NativeParent)
            {
                IsSingleLine = true,
            };
            Control.Show();
            Control.SetInputPanelReturnKeyType(InputPanelReturnKeyType.Search);
            Control.TextChanged += OnTextChanged;
            Control.Activated   += OnActivated;
            Control.Focused     += OnFocused;
            Control.Unfocused   += OnFocused;

            Element.FocusChangeRequested += OnFocusChangedRequested;
            Element.PropertyChanged      += OnElementPropertyChanged;
            (Element as ISearchHandlerController).ListProxyChanged += OnSearchResultListChanged;

            UpdateKeyboard();
            UpdatePlaceholder();
            UpdatePlaceholderColor();
            UpdateHorizontalTextAlignment();
            UpdateTextColor();
            UpdateFontAttributes();
            UpdateFontFamily();
            UpdateFontSize();
            UpdateBackgroundColor();
            UpdateQuery();
            UpdateIsSearchEnabled();

            UpdateSearchResult();
        }
Beispiel #2
0
        void ITextWatcher.AfterTextChanged(IEditable s)
        {
            var text = _textBlock.Text;

            if (text == ShellSearchViewAdapter.DoNotUpdateMarker)
            {
                return;
            }

            UpdateClearButtonState();

            SearchHandler.SetValueCore(SearchHandler.QueryProperty, text);

            if (SearchHandler.ShowsResults)
            {
                if (string.IsNullOrEmpty(text))
                {
                    _textBlock.DismissDropDown();
                }
                else
                {
                    _textBlock.ShowDropDown();
                }
            }
        }
        /// <summary>
        ///     Searches available lobbies based on the search criteria chosen in the <see cref="LobbySearchQuery" /> member
        ///     functions.
        ///     Lobbies that meet the criteria are then globally filtered, and can be accessed via iteration with
        ///     <see cref="LobbyCount" /> and <see cref="GetLobbyId" />.
        ///     The callback fires when the list of lobbies is stable and ready for iteration.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="callback"></param>
        public void Search(LobbySearchQuery query, SearchHandler callback)
        {
            GCHandle wrapped = GCHandle.Alloc(callback);

            Methods.Search(methodsPtr, query.MethodsPtr, GCHandle.ToIntPtr(wrapped), SearchCallbackImpl);
            query.MethodsPtr = IntPtr.Zero;
        }
        public SearchHandlerTests()
        {
            Mapper.Reset();
            Mapper.Initialize(cfg => cfg.AddProfiles(GetType().Assembly));
            var context = new ApiContext(ApiContext.InMemoryOptions);

            context.People.AddRange(
                new Person {
                FirstName = "Lana", LastName = "Turner"
            },
                new Person {
                FirstName = "Jimmy", LastName = "Durante"
            },
                new Person {
                FirstName = "Monty", LastName = "Wooley"
            },
                new Person {
                FirstName = "Cary", LastName = "Grant"
            },
                new Person {
                FirstName = "Betty", LastName = "Davis"
            },
                new Person {
                FirstName = "Katheryn", LastName = "Hepburn"
            }
                );
            context.SaveChanges();
            _handler = new SearchHandler(context);
        }
        public void ApplySortCorrectly()
        {
            List <ItemForHandler_Mock> list = new List <ItemForHandler_Mock>
            {
                new ItemForHandler_Mock("ABC", -1),
                new ItemForHandler_Mock("DEF", -10),
                new ItemForHandler_Mock("GHI", 30),
                new ItemForHandler_Mock("JKL", 5),
            };

            var searchHandler = new SearchHandler <ItemForHandler_Mock>(
                sortingTypes: new [] { "NAME", "VALUE" }, filterPredicate: null);

            searchHandler.SetSearchableList(list);

            bool sortCalled = false;

            void ResultFilterOdd(List <ItemForHandler_Mock> sortedList)
            {
                sortCalled = true;
                Assert.AreEqual("JKL", sortedList[0].name);
                Assert.AreEqual("GHI", sortedList[1].name);
                Assert.AreEqual("DEF", sortedList[2].name);
                Assert.AreEqual("ABC", sortedList[3].name);
            }

            searchHandler.OnSearchChanged += ResultFilterOdd;
            searchHandler.NotifySortOrderChanged(false);
            Assert.IsTrue(sortCalled);
        }
        public void Then_an_exception_is_not_thrown()
        {
            RegisterQueryRepository.Setup(c => c.GetAllOrganisationStandardByOrganisationId("EPA0050"))
            .ReturnsAsync(new List <OrganisationStandardSummary>
            {
                new OrganisationStandardSummary {
                    StandardCode = 12
                },
                new OrganisationStandardSummary {
                    StandardCode = 13
                },
                new OrganisationStandardSummary {
                    StandardCode = 14
                }
            });

            CertificateRepository.Setup(c => c.GetDraftAndCompletedCertificatesFor(It.IsAny <long>()))
            .ReturnsAsync(new List <Certificate>());

            SearchHandler
            .Handle(new SearchQuery()
            {
                Surname = "smith", EpaOrgId = "99999", Uln = 12345, Username = "******"
            },
                    new CancellationToken()).Wait();
        }
 public ShellSearchViewAdapter(SearchHandler searchHandler, IShellContext shellContext)
 {
     _searchHandler = searchHandler ?? throw new ArgumentNullException(nameof(searchHandler));
     _shellContext  = shellContext ?? throw new ArgumentNullException(nameof(shellContext));
     SearchController.ListProxyChanged += OnListPropxyChanged;
     _searchHandler.PropertyChanged    += OnSearchHandlerPropertyChanged;
 }
Beispiel #8
0
        protected void joinQueue_Click(object sender, EventArgs e)
        {
            var bizId = Request["businessId"];

            var validSubmit = int.TryParse(bizId, out int id);

            // Get Patron Id
            var sessionId = Request.Cookies["SessionInfo"].Value;

            var userSearchHandler = new SearchHandler();
            var patronId          = userSearchHandler.GetPatronIdBySessionId(sessionId);

            if (validSubmit)
            {
                var queueHandler = new QueueLedger();
                queueHandler.AddCustomerToQueue(new QueueInstruction()
                {
                    BusinessId        = id,
                    QueueJoinTime     = DateTime.Now,
                    ExpectedEntryTime = DateTime.Now,
                    ActualEntryTime   = DateTime.Now,
                    PatronId          = patronId
                });

                disableJoinQueueButton = true;
                enableLeaveQueueButton = true;
                UserMessage            = "Please click Leave button before leaving our premises.";
            }
        }
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;

            if (disposing)
            {
                if (_uiSearchBar != null)
                {
                    _uiSearchBar.OnEditingStarted -= OnEditingStarted;
                    _uiSearchBar.OnEditingStopped -= OnEditingEnded;
                    _uiSearchBar.TextChanged      -= OnTextChanged;
                }
                if (_searchHandler != null)
                {
                    _searchHandler.FocusChangeRequested -= SearchHandlerFocusChangeRequested;
                    _searchHandler.PropertyChanged      -= SearchHandlerPropertyChanged;
                }
                _searchHandler = null;
                _uiSearchBar   = null;
            }
        }
Beispiel #10
0
        private void Search_Click(object sender, RoutedEventArgs e)
        {
            DataList = new ObservableCollection <SearchResultItem>();
            var searchHandler = new SearchHandler(clientContext);
            var result        = searchHandler.Search(SearchTextBox.Text.ToString());

            foreach (var item in result.Value)
            {
                foreach (var res in item.ResultRows)
                {
                    try
                    {
                        var searchItem = new SearchResultItem()
                        {
                            Title       = res["Title"].ToString(),
                            Description = res["Description"].ToString(),
                            ParentUrl   = res["ParentLink"].ToString(),
                        };
                        DataList.Add(searchItem);
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            searchListGrid.ItemsSource = DataList;
        }
        public object Any(ProductTypeahead request)
        {
            var resp           = new Dto <List <Product> >();
            var productHandler = new ProductHandler(Db);
            var searchHandler  = new SearchHandler(Db, CurrentSession);

            List <Models.Product> intermediate;

            if (request.Query.IsNullOrEmpty())
            {
                intermediate = productHandler.List(0, int.MaxValue);
            }
            else
            {
                intermediate = productHandler.Typeahead(request.Query, request.IncludeDeleted);
            }

            resp.Result = intermediate.Map(product =>
            {
                var p            = product.ConvertTo <Product>();
                p.QuantityOnHand = InventoryHandler.GetQuantityOnHand(p.Id);
                return(p);
            });

            return(resp);
        }
        public async Task ItShouldReturnTheRepositoryResultsForTheQuery()
        {
            var searchQuery = new SearchQuery
            {
                SearchTerm = "nhs",
                SearchType = SearchCategory.Account,
                Page       = 1
            };

            var ecpectedResult = new List <AccountSearchModel>
            {
                new AccountSearchModel
                {
                    Account    = "NHS",
                    SearchType = SearchCategory.Account
                }
            };

            _mockSearchProvider
            .Setup(x => x.FindAccounts(searchQuery.SearchTerm, searchQuery.SearchType, searchQuery.PageSize,
                                       searchQuery.Page))
            .Returns(new PagedSearchResponse <AccountSearchModel>
            {
                Results = ecpectedResult
            });


            _unit   = new SearchHandler(_mockSearchProvider.Object, Mock.Of <ILog>());
            _actual = await _unit.Handle(searchQuery);

            CollectionAssert.IsNotEmpty(_actual.AccountSearchResult.Results);
            Assert.AreEqual(ecpectedResult.Count, _actual.AccountSearchResult.Results.ToList().Count);
        }
Beispiel #13
0
        /// <summary>
        /// Sends a request to the USDA food search API for user specified input in either branded or unbranded database.
        ///     Results are displayed in a view component below search area
        /// </summary>
        /// <remarks>
        /// Makes use of the <see cref="SearchHandler"/> class for organizing API requests
        /// </remarks>
        /// <param name="foodName">The string input name used during the food search</param>
        /// <param name="targetDatabase">The user-chosen database to be searched, either branded or unbranded</param>
        /// <returns>The FoodSearchResult ViewComponent if search returns results - a message otherwise</returns>
        public IActionResult SearchFoods(string foodName, string targetDatabase)
        {
            SearchHandler handler = new SearchHandler();

            var client = HttpClientAccessor.HttpClient;

            HttpResponseMessage response = client.GetAsync(handler.OrganizeSearchQ(foodName, targetDatabase)).Result;

            if (response.IsSuccessStatusCode)
            {
                var dataObjects = response.Content.ReadAsStringAsync().Result;

                JObject responseStatus = JObject.Parse(dataObjects);

                if (responseStatus["errors"] != null)
                {
                    return(new ContentResult
                    {
                        ContentType = "text/html",
                        Content = $"<strong style='color:red'>Couldn't find '{foodName}'. Please try again.</strong>"
                    });
                }
                /* Thread sleep used for mimicking slow response time in deployed environment, mainly for testing wait spinner modals */
                //System.Threading.Thread.Sleep(3000);
                return(ViewComponent("FoodSearchResult", handler.StoreSearchReturns(dataObjects)));
            }
            else
            {
                return(new ContentResult
                {
                    ContentType = "text/html",
                    Content = $"<strong style='color:red'>Couldn't find '{foodName}'. Please try again.</strong>"
                });
            }
        }
Beispiel #14
0
 void UpdateSearchHandler(SearchHandler searchHandler)
 {
     if (_currentSearchHandler != null)
     {
         _currentSearchHandler.PropertyChanged -= SearchHandler_PropertyChanged;
     }
     _currentSearchHandler = searchHandler;
     if (AutoSuggestBox == null)
     {
         return;
     }
     if (searchHandler != null)
     {
         searchHandler.PropertyChanged     += SearchHandler_PropertyChanged;
         AutoSuggestBox.Visibility          = searchHandler.SearchBoxVisibility == SearchBoxVisibility.Hidden ? global::Windows.UI.Xaml.Visibility.Collapsed : global::Windows.UI.Xaml.Visibility.Visible;
         AutoSuggestBox.HorizontalAlignment = global::Windows.UI.Xaml.HorizontalAlignment.Stretch;
         AutoSuggestBox.PlaceholderText     = searchHandler.Placeholder;
         AutoSuggestBox.IsEnabled           = searchHandler.IsSearchEnabled;
         AutoSuggestBox.ItemsSource         = _currentSearchHandler.ItemsSource;
         ToggleSearchBoxVisibility();
         UpdateQueryIcon();
         IsPaneVisible = true;
     }
     else
     {
         IsPaneVisible             = ShellSectionController.GetItems().Count > 1;
         AutoSuggestBox.Visibility = global::Windows.UI.Xaml.Visibility.Collapsed;
     }
 }
Beispiel #15
0
        public static void Switch(GPSPClient client, Dictionary <string, string> recv)
        {
            string command = recv.Keys.First();

            try
            {
                switch (command)
                {
                case "search":
                    SearchHandler.SearchUsers(client, recv);
                    break;

                case "valid":
                    ValidHandler.IsEmailValid(client, recv);
                    break;

                case "nicks":
                    NickHandler.SearchNicks(client, recv);
                    break;

                case "pmatch":
                    PmatchHandler.PlayerMatch(client, recv);
                    break;

                case "check":
                    CheckHandler.CheckProfileid(client, recv);
                    break;

                case "newuser":
                    NewUserHandler.NewUser(client, recv);
                    break;

                case "searchunique":
                    SearchUniqueHandler.SearchProfileWithUniquenick(client, recv);
                    break;

                case "others":
                    OthersHandler.SearchOtherBuddy(client, recv);
                    break;

                case "otherslist":
                    OthersListHandler.SearchOtherBuddyList(client, recv);
                    break;

                case "uniquesearch":
                    UniqueSearchHandler.SuggestUniqueNickname(client, recv);
                    break;

                default:
                    LogWriter.Log.Write("[GPSP] received unknown data " + command, LogLevel.Debug);
                    GameSpyUtils.PrintReceivedGPDictToLogger(command, recv);
                    GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "An invalid request was sended.");
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }
        }
Beispiel #16
0
        /// <summary>
        /// Handles the retrieval of <see cref="Nutrient"/> data for all selected food items in the meal to be logged
        /// </summary>
        /// <remarks>
        /// Makes use of the <see cref="SearchHandler"/> class for organizing API request and storing nutrient data.
        ///     Nutrient data isn't stored originally because food search API responses don't include these details
        /// </remarks>
        /// <param name="ndbnos">A list of all food identifiers to be included in nutritional data API queries</param>
        /// <returns>A populated <see cref="FoodViewModel"/></returns>
        public FoodViewModel AddNutrientData(List <string> ndbnos)
        {
            SearchHandler handler = new SearchHandler();

            var client = HttpClientAccessor.HttpClient;

            List <Food> foodItems = new List <Food>();

            foreach (string n in ndbnos)
            {
                HttpResponseMessage response = client.GetAsync(handler.OrganizeReportQ(n)).Result;

                if (response.IsSuccessStatusCode)
                {
                    JObject dataObject = JObject.Parse(response.Content.ReadAsStringAsync().Result);

                    Food f = new Food();

                    foodItems.Add(handler.StoreMealNutrientDetails(f, dataObject, "full"));
                }
                else
                {
                    // handle failure
                }
            }

            FoodViewModel fvm = new FoodViewModel()
            {
                Foods = foodItems
            };

            return(fvm);
        }
 public HandlerProvider()
 {
     ImportHandler       = new ImportHandler();
     SearchHandler       = new SearchHandler();
     AutoCompleteHandler = new AutoCompleteHandler();
     DeleteHandler       = new DeleteHandler();
 }
Beispiel #18
0
        /// <summary>
        /// The search files method.
        /// </summary>
        public virtual CCFileList[] StartFileSearch()
        {
            if (!processing)
            {
                try
                {
                    stopTimerSearch = false;
                    CCFileList[] fileCollections = SearchHandler.SearchFiles(CurrentProfile);
                    SearchedFiles(ref fileCollections);

                    if (fileCollections != null)
                    {
                        foreach (CCFileList fc in fileCollections)
                        {
                            Application.DoEvents();
                            if (stopTimerSearch)
                            {
                                SearchHandler.StopSearch();
                                return(null);
                            }

                            currentCollection = null;
                            if (fc != null)
                            {
                                //-- Create a collection definition --\\
                                currentCollection             = CollectionsCreator.FromImages(workDir, CurrentProfile.KeepFileName, CurrentProfile.MultiPagePerForm, !CurrentProfile.CopySourceFiles, fc.KeyFile);
                                currentCollection.Attachments = fc.Files;


                                //-- fire 'PreCreateCollection' event --\\
                                PreCreateCollection();
                                Application.DoEvents();
                                if (stopTimerSearch)
                                {
                                    SearchHandler.StopSearch();
                                    return(null);
                                }


                                if (currentCollection != null)
                                {
                                    int errCode = 0;
                                    //--<< if all is set, create the collection >>--\\
                                    String[] res = CollectionsCreator.CreateCollections(CSM, out errCode, currentCollection);
                                    PostCreateCollection(res != null && res.Length > 0 ? res[0] : String.Empty);//-- Fire post create collection event --\\
                                }
                            }
                        }
                    }
                    return(fileCollections);
                }
                catch (Exception ex)
                {
                    ILog.LogError(ex);
                    if (this.CurrentProfile.ThrowAllExceptions)
                    {
                        throw (ex);
                    }
                }
            }
 public static LuceneContentSearchHandler CreateInstance(SearchHandler searchHandler, IContentRepository contentRepository, IContentTypeRepository contentTypeRepository, LanguageSelectorFactory languageSelectorFactory, SearchIndexConfig searchIndexConfig)
 {
     return(new LuceneContentSearchHandler(searchHandler, contentRepository, contentTypeRepository, languageSelectorFactory, searchIndexConfig)
     {
         ServiceActive = SearchSettings.Config.Active
     });
 }
Beispiel #20
0
    public SectionSearchHandler()
    {
        scenesSearchHandler = new SearchHandler <ISearchInfo>(scenesSortTypes, (item) =>
        {
            bool result = true;
            if (filterContributor)
            {
                result = item.isContributor;
            }
            if (filterOperator && result)
            {
                result = item.isOperator;
            }
            if (filterOwner && result)
            {
                result = item.isOwner;
            }
            return(result);
        });

        scenesSearchHandler.OnSearchChanged += list =>
        {
            OnUpdated?.Invoke();
            OnResult?.Invoke(list);
        };
    }
Beispiel #21
0
        /// <summary>
        /// Default Constructor.
        /// </summary>
        /// <param name="passedFileInfo"></param>
        /// <param name="passedDirectoryInfo"></param>
        /// <param name="passedTreeView"></param>
        /// <param name="passedListView"></param>
        /// <param name="passedHEImageList"></param>
        public DocumentWorkspace(FileInfo passedFileInfo, DirectoryInfo passedDirectoryInfo,
            TreeView passedTreeView, ListView passedListView, EmbeddedImages_ImageList passedHEImageList)
        {
            // Initialise the GameData, SolarSystem and SearchHandler objects.
            if (passedFileInfo == null || passedDirectoryInfo == null
                || !passedFileInfo.Exists || !passedDirectoryInfo.Exists)
                throw new InvalidOperationException("DocumentWorkspace Constructor: A problem occurred with a passed parameter - something doesn't exist.");
            else
            {
                // Create the core objects.
                GameData = new GameData(passedFileInfo, passedDirectoryInfo);
                SolarSystem = new SolarSystem(GameData);
                SearchHandler = new SearchHandler(GameData, SolarSystem);


                // Add the parameters related to the MainForm controls.
                _mainFormTreeView = passedTreeView ?? throw new NullReferenceException("passedTreeView was null.");
                _mainFormListView = passedListView ?? throw new NullReferenceException("passedListView was null.");
                _mainProgramHEImageList = passedHEImageList ?? throw new NullReferenceException("passedHEImageList was null.");

                InitialiseTreeView(_mainFormTreeView, _mainProgramHEImageList.IconImageList);
                InitialiseListView(_mainFormListView, _mainProgramHEImageList.IconImageList);

                IsWorkspaceReady = true;
            }
        }
        /// <summary>
        /// Queries database for the parameters and returns partial view of the mobile cards
        /// </summary>
        /// <param name="pageNum">number of page</param>
        /// <param name="manufacturer">search for manufacturer</param>
        /// <param name="priceFrom">start price</param>
        /// <param name="priceTo">end price</param>
        /// <returns>returns partial view of mobile cards</returns>
        public IActionResult GetPhonesPartial(Int32 pageNum,
                                              String name,
                                              String manufacturer = null,
                                              Double?priceFrom    = null,
                                              Double?priceTo      = null,
                                              Int32 itemsPerPage  = 10)
        {
            try
            {
                var searcher = new SearchHandler();

                var phones = searcher.Search(pageNum, name, manufacturer, priceFrom, priceTo, itemsPerPage);

                var phoneModels = new List <PhoneModel>();

                foreach (var phone in phones.Values)
                {
                    phoneModels.Add(new PhoneModel(phone));
                }

                ViewBag.TotalCount = phones.Count;

                return(PartialView("_PhonesPartial", phoneModels));
            }
            catch (Exception)
            {
                return(RedirectToAction("Error"));
            }
        }
Beispiel #23
0
 private void cboSearch_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (SearchHandler == null)
     {
         return;
     }
     SearchHandler.cboSearch_SelectedIndexChanged(sender, e);
 }
        private static void SearchCallbackImpl(IntPtr ptr, Result result)
        {
            GCHandle      h        = GCHandle.FromIntPtr(ptr);
            SearchHandler callback = (SearchHandler)h.Target;

            h.Free();
            callback(result);
        }
Beispiel #25
0
        private void Sh_OnSearch(object sender, SearchHandler e)
        {
            if (e.SameSearch)
            {
                return;
            }

            e.SeachFound = searchItem(e.SearchedString);
        }
Beispiel #26
0
        public async Task ResetWordTest()
        {
            IWordModel    model    = new WordModel(target);
            SearchHandler searcher = new SearchHandler(model, (IList <string> s) => Task.CompletedTask, () => Task.CompletedTask);
            await searcher.Reset();

            Assert.Empty(model.AddedWords);
            Assert.True(model.AvailableWordList.SequenceEqual(target.OrderBy(str => str))); //AvailableWordList is "Sorted"Set.
        }
Beispiel #27
0
 public Octree(T space, AddHandler addHandler, RemoveHandler removeHandler, SearchHandler searchHandler, SetRootHandler setRootHandler, RemoveAllHandler removeAllHandler)
 {
     this.space = space;
     this.AddHandlerCallback       = addHandler;
     this.RemoveHandlerCallback    = removeHandler;
     this.SearchHandlerCallback    = searchHandler;
     this.SetRootHandlerCallback   = setRootHandler;
     this.RemoveAllHandlerCallback = removeAllHandler;
 }
 public SearchService(
     SearchHandler searchHandler,
     ContentSearchHandler contentSearchHandler,
     IUrlResolver urlResolver)
 {
     _searchHandler        = searchHandler;
     _contentSearchHandler = contentSearchHandler;
     _urlResolver          = urlResolver;
 }
 private static void SetIcon(SearchHandler element, string fontFamily, string glyph, Color color)
 {
     element.QueryIcon = new FontImageSource
     {
         Glyph      = glyph,
         FontFamily = fontFamily,
         Color      = color
     };
 }
Beispiel #30
0
        public static string SearchMls(string request, string searchUrl = "")
        {


            if (string.IsNullOrEmpty(searchUrl))
                searchUrl = ConfigurationManager.AppSettings["TcsQaUrl"];
            var searchHandler = new SearchHandler(searchUrl);
            return searchHandler.SearchMls(request);
        }
 public SearchService(SearchHandler searchHandler, IContentLoader contentLoader)
 {
     _searchHandler = searchHandler;
     _contentLoader = contentLoader;
 }