/// <summary>
        /// Initializes the search user and topics
        /// </summary>
        /// <param name="searchInstanceType">type of search instance</param>
        /// <returns>empty</returns>
        private async Task Init(SearchInstanceType searchInstanceType)
        {
            // Guard that ensures Init is executed once only
            lock (this.locker)
            {
                if (this.initStarted == true)
                {
                    return;
                }

                this.initStarted = true;
            }

            // get the connection strings
            string searchServiceName = await this.connectionStringProvider.GetSearchServiceName(searchInstanceType);

            string searchServiceAdminKey = await this.connectionStringProvider.GetSearchServiceAdminKey(searchInstanceType);

            // instantiate the two search interfaces
            this.searchUsers  = new SearchUsers(this.log, searchServiceName, searchServiceAdminKey);
            this.searchTopics = new SearchTopics(this.log, searchServiceName, searchServiceAdminKey);

            // Init done
            this.initDone.Set();
        }
Exemple #2
0
        public IList <User> Handle(SearchUsers message)
        {
            // There a better way to do this?
            const string query =
                @"  SELECT u.Id, u.Email, u.FirstName, u.LastName
                    FROM Users.[User] u
                    WHERE 
                        (@Email IS NOT NULL AND u.Email = @Email) {CompOper}
                        (@FirstName IS NOT NULL AND u.FirstName = @FirstName) {CompOper}
                        (@UserIdIsDefaultValue = 0 AND u.Id = @UserId) {CompOper}
                        (@LastName IS NOT NULL AND u.LastName = @LastName)";

            var operators = new Dictionary <SearchOptions, string>
            {
                { SearchOptions.MatchAny, "OR" },
                { SearchOptions.MatchAll, "AND" }
            };

            var actualQuery = query.Replace("{CompOper}", operators[message.SearchOption]);
            var results     = _UnitOfWork.Query <User>(actualQuery, new
            {
                message.Email,
                message.FirstName,
                message.LastName,
                UserIdIsDefaultValue = message.UserId == default(Guid) ? 1 : 0,
                message.UserId
            });

            return(results.ToList());
        }
Exemple #3
0
        public IEnumerable <UserSearchResult> SearchUsers(SearchUsers search)
        {
            var list = new List <UserSearchResult>();

            var nameCond = search.Name.IsNullOrWhiteSpace() ? "1 = 1" : "Name = @name";

            using (var cmd = _conn.CreateCommand())
            {
                cmd.CommandText =
                    $@"SELECT Name, Role, RegisteredOn
                      FROM Users
                      WHERE {nameCond};";
                if (!search.Name.IsNullOrWhiteSpace())
                {
                    cmd.Parameters.AddWithValue("@name", search.Name);
                }

                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        list.Add(new UserSearchResult()
                        {
                            Name         = reader.GetString(0),
                            Role         = (User.ForumRole)reader.GetInt32(1),
                            RegisteredOn = DateTime.Parse(reader.GetString(2))
                        });
                    }
                }
            }

            return(list);
        }
Exemple #4
0
 /// <summary>
 /// Søger efter brugere
 /// </summary>
 /// <param name="searchString">Søgestring fra code behind</param>
 public void SearchForUsers(String searchString)
 {
     SearchUsers.Clear();                                                   // Listen med søgte brugere nulstilles
     foreach (User user in RegexSearch.SearchUsers(searchString, UserList)) // Der tilføjes brugere ifølge Regexsearch
     {
         if (!user.Equals(CurrentUser))
         {
             SearchUsers.Add(user);
         }
     }
 }
Exemple #5
0
        /// <summary>
        /// Delete the search indices
        /// </summary>
        /// <param name="searchServiceName">name of the search service</param>
        /// <param name="searchServiceAdminKey">admin access key</param>
        /// <returns>delete search task</returns>
        private static async Task DeleteSearch(string searchServiceName, string searchServiceAdminKey)
        {
            Console.WriteLine("Deleting search indices...");

            // instantiate the two search interfaces
            SearchUsers  searchUsers  = new SearchUsers(log, searchServiceName, searchServiceAdminKey);
            SearchTopics searchTopics = new SearchTopics(log, searchServiceName, searchServiceAdminKey);
            await searchTopics.DeleteIndex();

            Console.WriteLine("  Topic search index - Deleted");
            await searchUsers.DeleteIndex();

            Console.WriteLine("  User search index - Deleted");
        }
Exemple #6
0
        /// <summary>
        /// Create the two search indices
        /// </summary>
        /// <param name="searchServiceName">name of the search service</param>
        /// <param name="searchServiceAdminKey">admin access key</param>
        /// <returns>provision search task</returns>
        private static async Task ProvisionSearch(string searchServiceName, string searchServiceAdminKey)
        {
            Console.WriteLine("Creating search indices...");

            // instantiate the two search interfaces
            SearchUsers  searchUsers  = new SearchUsers(log, searchServiceName, searchServiceAdminKey);
            SearchTopics searchTopics = new SearchTopics(log, searchServiceName, searchServiceAdminKey);

            // create the two indices
            await searchUsers.CreateIndex();

            Console.WriteLine("  User search index - Provisioned");
            await searchTopics.CreateIndex();

            Console.WriteLine("  Topic search index - Provisioned");
        }
Exemple #7
0
        public async Task <IActionResult> Search([FromQuery] string firstName, [FromQuery] string lastName, [FromQuery] string offset)
        {
            if (string.IsNullOrWhiteSpace(firstName) && string.IsNullOrWhiteSpace(lastName))
            {
                return(BadRequest(new ValidationProblemDetails {
                    Detail = "Either firstName or lastName query parameters must be specified"
                }));
            }
            var searchUsersQuery = string.IsNullOrWhiteSpace(firstName)
                ? SearchUsers.ByLastName(lastName, offset)
                : SearchUsers.ByFirstName(firstName, offset);
            var userIndex = await _mediator.Send(searchUsersQuery);

            var(_, userIndexDto) = _mapper.MapTo <UserIndexDto>(userIndex);
            return(Ok(userIndexDto));
        }
Exemple #8
0
        private async void RefreshPost()
        {
            if (NavigationContext.QueryString.TryGetValue("query", out query))
            {
                if (Global.query.type == SearchType.PeoplePages)
                {
                    users = await Global.googLib.QueryUser(query, null);

                    ResultListBox.ItemsSource = users.users;
                }
                else if (Global.query.type == SearchType.Sparks)
                {
                    communities = await Global.googLib.QueryCommunity(query, null);

                    ResultListBox.ItemsSource = communities.communities;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Henter alt fra fil(er) (lister af projekter, dimser og brugere)
        /// </summary>
        public async Task LoadEverything()
        {
            Debug.WriteLine("Begynder LoadEverything");
            ProjectList = await JsonReadWrite.LoadProjectsFromJsonAsync();

            UserList = await JsonReadWrite.LoadUsersFromJsonAsync();

            foreach (User user in UserList) // Populates searchUser, så listen er klar når man går ind i edit project
            {
                if (!user.Equals(CurrentUser))
                {
                    SearchUsers.Add(user);
                }
            }

            DoohickeyList = await JsonReadWrite.LoadDoohickeysFromJsonAsync();

            foreach (Doohickey doohickey in DoohickeyList) // Populates searchDoohickey, så listen er klar når man går ind i edit project
            {
                SearchDoohickeys.Add(doohickey);
            }

            Debug.WriteLine("Afslutter LoadEverything");
        }
Exemple #10
0
 public ActionResult Individual(SearchUsers Params)
 {
     return(View());
 }
 public async Task <SearchUsersResult> Search([FromQuery] SearchUsers request) => await _bus.Execute(request);
        private void btnSearchUsers_Click(object sender, EventArgs e)
        {
            var su = new SearchUsers();

            su.Show();
        }
 private bool FilterUser(User user, SearchUsers filter)
 {
     return(FieldMatched(user.FirstName, filter.FirstName) &&
            FieldMatched(user.LastName, filter.LastName) &&
            FieldMatched(user.EmailAddress, filter.EmailAddress));
 }
        public async Task <IEnumerable <UserDto> > Handle(SearchUsers request, CancellationToken cancellationToken)
        {
            var users = await db.GetAsync <User>(u => FilterUser(u, request), request.PageNumber, request.Limit);

            return(mapper.Map <IEnumerable <UserDto> >(users));
        }