public HomePage() { _userService = new UserService(); _userSearchService = new UserSearchService(_userService); InitializeComponent(); _searchResult = new UserSearchResult(); }
public ResultPage(UserSearchResult userResult) { _userResult = userResult; _context = new UserContext(); _dbServise = new DbServise(_context); InitializeComponent(); Loaded += ResultPage_Loaded; }
public void SearchUsers_forGivenSearchQuery_correctlyReturnsListOfUsers() { var query = config.GetSection(this.GetType().Name).GetSection("test_search_user_query").Value; var sut = new UserClient(symBotClient); UserSearchResult searchUsers = sut.searchUsers(query, false, 0, 10, null); Assert.IsNotNull(searchUsers); Assert.IsTrue(searchUsers.users.Count >= 1); }
public UserEntityViewModel(UserSearchResult user) { this.User = user; this.GroupId = user.GroupID; this.GroupName = user.Group; this.FullName = user.FullName; this.Description = user.Description; this.Username = user.Username; this.UserId = user.UserID; }
public void search_service_must_return_expected_users_when_we_search_by_last_name() { var searchService = ServiceLocator.Current.GetInstance <ISearchService>(); UserSearchResult result = searchService.SearchUsers("Test5", 0, 100); Assert.IsNotNull(result, "Service must return results with user list"); Assert.AreEqual(1, result.AllResults, "Service must return proper amount of users when we search by last name"); Assert.AreEqual(1, result.Users.Count(x => x.LastName.Contains("Test5")), "Service must return all expected users when we search by last name"); }
public void search_service_must_return_expected_amount_of_users_when_we_specify_page() { var searchService = ServiceLocator.Current.GetInstance <ISearchService>(); UserSearchResult result = searchService.SearchUsers("usertest", 1, 3); Assert.IsNotNull(result, "Service must return results with user list"); Assert.AreEqual(10, result.AllResults, "Service must return proper amount of users"); Assert.AreEqual(3, result.Users.Count(x => x.UserName.Contains("usertest")), "Service must return all expected users"); }
public void FromBytes(byte[] buffer, int index) { try { SearchType = buffer[index++]; if (SearchType_User == SearchType) { List <UserSearchResult> temp = new List <UserSearchResult>(); try { int count = BitConverter.ToInt32(buffer, index); index += 4; for (int i = 0; i < count; ++i) { UserSearchResult user = new UserSearchResult(); user.FromBytes(buffer, ref index); temp.Add(user); } } catch { } SearchResult = temp.ToArray(); } else { List <GroupSearchResult> temp = new List <GroupSearchResult>(); try { int count = BitConverter.ToInt32(buffer, index); index += 4; for (int i = 0; i < count; ++i) { GroupSearchResult group = new GroupSearchResult(); group.FromBytes(buffer, ref index); temp.Add(group); } } catch { } SearchResult = temp.ToArray(); } } catch { } }
public void ResetPassword(UserSearchResult user) { if (_checkSecurePasswords(SecurePassword, ConfirmSecurePassword)) { _adService.ResetUserPassword(SelectedUser.UserName, SecurePassword, _shouldPassAutoExpire, SetResultMessage); } else { SetResultMessage("Passwords do not match."); } }
public SendPage(UserSearchResult userSearchResult) { _messageServise = new MessageServise(); _blacklistService = new BlacklistService(new PathService()); _sendService = new SendService(_messageServise, new UserService(), _blacklistService); InitializeComponent(); InitTimer(); _userSearchResult = userSearchResult; _sendModel = new SendModel(); }
private async void Button_Click_Results(object sender, RoutedEventArgs e) { UserSearchModel searchModel = GetSearchModelFromUserInput(); var client = await Client.GetClient(); _searchResult = await _userSearchService.Find(client, searchModel); ResultPage result = new ResultPage(_searchResult); NavigationService.Navigate(result); }
public IActionResult Get(string partialUserName) { if (!string.IsNullOrWhiteSpace(partialUserName)) { UserSearchResult logicResult = UserSearcherLogic.SearchUsersByPartialUserName(partialUserName.ToLower()); return(new JsonResult(logicResult)); } else { return(new JsonResult(new { success = false, errors = new string[] { "No search string was provided." } })); } }
public ActionResult Prize(long id = 0) { PrizeViewModel model = new PrizeViewModel(); ActivityDTO activity = new ActivityDTO(); if (id == 0) { return(Redirect("/home/index")); } if (!activityService.ExistActivity(id)) { return(Redirect("/home/index")); } else if (!activityService.IsCurrentAct(id)) { return(Redirect("/home/index")); } else { activity = activityService.GetById(id); } model.ActivityId = activity.Id; model.ActivityName = activity.Name; model.PrizeName = activity.PrizeName; model.PrizeImgUrl = activity.PrizeImgUrl; model.PrizeTime = activity.RewardTime.ToString("yyyy-MM-dd HH:mm"); model.PrizeFirstUrl = settingService.GetValue("前端奖品图片地址"); model.StatusName = activity.StatusName; //var users = userService.GetByActivityIdIsWon1(activity.Id); if (activity.RewardTime <= DateTime.Now) { UserSearchResult result = userService.GetByActivityIdIsWon(activity.Id, null, null); List <IsWonUser> winUsers = new List <IsWonUser>(); foreach (var user in result.Users) { IsWonUser winUser = new IsWonUser(); winUser.UserName = CommonHelper.FormatUserName(user.Name); winUser.Mobile = CommonHelper.FormatMoblie(user.Mobile); winUser.Gender = user.Gender ? "先生" : "女士"; winUsers.Add(winUser); } model.Users = winUsers; model.winCount = (int)result.TotalCount; } else { model.winCount = 0; } //string mobile = (string)Session["Mobile"]; //model.UserIsWon = userService.UserIsWonByMobile(mobile); return(View(model)); }
public void AddDefinedUsers(UserSearchResult userResult) { foreach (var user in userResult.Users) { if (!_context.SearchResult.Contains(user)) { _context.SearchResult.Add(user); } } _context?.SearchResult.Load(); _context?.SearchResult.OrderBy(u => u.FirstName); _context.SaveChanges(); }
public UserSearchResult SearchUsers([FromBody] SearchParameters searchData) { UserSearchResult objUserSearchResult = new UserSearchResult(); // Must be a Administrator to call this Method if (!UtilitySecurity.IsAdministrator(this.User.Identity.Name, GetConnectionString())) { objUserSearchResult.errorMessage = "Must be a Administrator to call this Method"; return(objUserSearchResult); } return(SearchUsersMethod(searchData, GetConnectionString())); }
public async Task <UserDTO> GetModelByMobileAsync(string mobile) { using (MyDbContext dbc = new MyDbContext()) { UserSearchResult result = new UserSearchResult(); var user = await dbc.GetAll <UserEntity>().AsNoTracking().FirstOrDefaultAsync(u => u.Mobile == mobile); if (user == null) { return(null); } return(ToDTO(user)); } }
public async Task <UserSearchResult> GetActivateListAsync(int pageIndex, int pageSize) { using (MyDbContext dbc = new MyDbContext()) { UserSearchResult result = new UserSearchResult(); var users = dbc.GetAll <UserEntity>().AsNoTracking().Where(u => u.IsUpgraded == false); result.PageCount = (int)Math.Ceiling((await users.LongCountAsync()) * 1.0f / pageSize); var userResult = await users.OrderByDescending(a => a.CreateTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync(); result.Users = userResult.Select(a => ToDTO(a)).ToArray(); return(result); } }
void searchService_utilsSearchUserCompleted(object sender, Remwave.Client.RSIFeaturesWS.utilsSearchUserCompletedEventArgs e) { try { btnUserFind.Enabled = true; pbarSearchProgressBar.Visible = false; pbarSearchProgressBar.EndWaiting(); List <UserSearchResult> searchResult = new List <UserSearchResult>(); if (e.Error != null) { return; } if (e.Result != null) { string[] result = e.Result; if (result[0].Length < 7) { return; } foreach (string item in result) { UserSearchResult resultItem = new UserSearchResult(); try { string[] items = item.Split(new string[] { ";" }, StringSplitOptions.None); //$first_name.";".$last_name.";".$city.";".$company.";".$country_name.";".$username.";".$comment_data resultItem.Company = items[3] == null ? "" : items[3]; resultItem.FirstName = items[0] == null ? "" : items[0]; resultItem.LastName = items[1] == null ? "" : items[1]; resultItem.Region = items[2] == null ? "" : items[2]; resultItem.Country = items[4] == null ? "" : items[4]; resultItem.Username = items[5] == null ? "" : items[5]; resultItem.Comment = items[6] == null ? "" : items[6]; searchResult.Add(resultItem); } catch (Exception) { } } DisplayResults(searchResult); } } catch (Exception) { } }
public async Task OnGet() { if (!String.IsNullOrEmpty(Keyword)) { SearchResult = await _userSearchService.GetUserSearchResults(Keyword, ResultsPerPage, CurrentPage); if (SearchResult.Total_Count > 1000) { NumberOfPages = _userSearchService.GetNumberOfPages(1000, ResultsPerPage); } else { NumberOfPages = _userSearchService.GetNumberOfPages(SearchResult.Total_Count, ResultsPerPage); } } }
public async Task OnPost() { if (ModelState.IsValid) { SearchResult = await _userSearchService.GetUserSearchResults(Keyword, ResultsPerPage, CurrentPage); if (SearchResult.Total_Count > 1000) { NumberOfPages = _userSearchService.GetNumberOfPages(1000, ResultsPerPage); } else { NumberOfPages = _userSearchService.GetNumberOfPages(SearchResult.Total_Count, ResultsPerPage); } } }
public UserSearchResult SearchUsers(string s, int page, int amountOnPage) { IQueryable <User> allFoundQuery = _userRepository.FindAll() .Where(x => x.FirstName.Contains(s) || x.LastName.Contains(s) || x.UserName.Contains(s)); int allResults = allFoundQuery.Count(); IQueryable <User> partResultQuery = allFoundQuery.OrderBy(x => x.CreationDate).Skip(page * amountOnPage).Take(amountOnPage); var userSearchResult = new UserSearchResult { AmountOnPage = amountOnPage, Page = page, AllResults = allResults, Users = partResultQuery.ToList() }; return(userSearchResult); }
public SearchViewModel CreateSearchViewModel(Guid watcherUserId, string s) { UserSearchResult userSearchResult = _searchService.SearchUsers(s, 0, 20); var usersViewModel = _usersViewModelService.CreateUsersViewModel(userSearchResult.Users, watcherUserId); UserMessageSearchResult userMessageSearchResult = _searchService.SearchMessages(s, 0, 20); var timelineViewModel = _messagesViewModelService.CreateTimelineViewModel(null, watcherUserId, userMessageSearchResult.UserMessages); var viewModel = new SearchViewModel { Query = s, AmountOfUsers = userSearchResult.AllResults, AmountOfMessages = userMessageSearchResult.AllResults, Users = usersViewModel, TimelineViewModel = timelineViewModel }; return(viewModel); }
public PartialViewResult PartialPeople(UserQuery query, IEnumerable <int> users) { UserSearchResult model = null; // get selected users ViewBag.Selected = new List <User>(); if (users != null && users.Any()) { ViewBag.Selected = UserService.Get(users); } // no search criteria, try to fetch most recently contacted people instead if (query.Text.IsNullOrEmpty()) { var conversations = ConversationService.Search(new ConversationQuery { UserId = User.Id, SearchRooms = false, OrderBy = "LastMessageAt DESC", Top = 10 }); List <int> ids = new List <int>(); foreach (var c in conversations) { ids.Add(c.MemberIds.FirstOrDefault(x => x != User.Id)); } var recent = UserService.Get(ids).Where(x => !x.IsSuspended && !x.IsTrashed()); if (recent.Any()) { model = new UserSearchResult(new UserQuery(), recent, recent.Count()); } } // perform normal search if (model == null) { query.Suspended = false; query.Trashed = false; query.OrderBy = "Name"; query.Count = true; query.Top = 10; model = UserService.Search(query); } return(PartialView("_People", model)); }
/// <summary> /// 通过活动id查询出已经获奖的用户 /// </summary> /// <param name="id"></param> /// <param name="currentIndex">跳过的条数((当前页数-1)*每页数)</param> /// <param name="pageSize">每页数</param> /// <returns></returns> public UserSearchResult GetByActivityIdIsWon(long id, int currentIndex, int pageSize) { using (MyDbContext dbc = new MyDbContext()) { CommonService <ActivityEntity> cs = new CommonService <ActivityEntity>(dbc); var activity = cs.GetAll().SingleOrDefault(a => a.Id == id); if (activity == null) { return(null); } var users = from u in dbc.Users from a in u.Activities where a.Id == id && u.IsDeleted == false && u.IsWon == true select u; UserSearchResult result = new UserSearchResult(); result.TotalCount = users.LongCount(); result.Users = users.OrderByDescending(u => u.CreateDateTime).Skip(currentIndex).Take(pageSize).ToList().Select(u => ToDTO(u)).ToArray(); return(result); } }
private void btnUserAdd_Click(object sender, EventArgs e) { try { if (dataGridViewSearchResult.SelectedRows.Count > 0) { UserSearchResult selected = mySearchUserResult[dataGridViewSearchResult.SelectedRows[0].Index]; selectedContact = new NTContact(); selectedContact.NTCompanyName = selected.Company; selectedContact.NTJabberID = selected.Username; selectedContact.NTFirstName = selected.FirstName; selectedContact.NTLastName = selected.LastName; selectedContact.NTHomeAddressCity = selected.Region; selectedContact.NTHomeAddressCountry = selected.Country; } } catch (Exception) { } this.Close(); }
public UserStatsReportOptions(User user) { InitializeComponent(); this.User = user; UserSearchResult allUsers = new UserSearchResult { Username = "******", FullName = "", UserID = -1 }; var service = new SupportService(user); var model = service.GetUsers(); model.Insert(0, allUsers); cmbUser.ItemsSource = model; cmbUser.SelectedIndex = 0; StartDate = DateTime.Now; EndDate = DateTime.Now; this.DataContext = this; }
// Attempts to find a user by the inputted name, returns search result. TODO make this not user based but ID based? public UserSearchResult GetUserByName(string Name, Discord.Channel ChannelToSearch) { // Create default struct and set it to not found in case nothing was found later on. UserSearchResult SearchResult = new UserSearchResult(); SearchResult.WasFound = false; // Go through all the users in a given channel and try to find a user by the specified name. foreach (Discord.User User in ChannelToSearch.Users) { // If the user with a matching name or nickname is found... if (User.Name == Name || User.Nickname == Name) { // Save the user into a variable, set it to found and exit the loop. SearchResult.User = User; SearchResult.WasFound = true; break; } } return(SearchResult); }
public UserSearchResult GetUserByID(ulong UserID, Discord.Server ServerToSearch) { // Create default struct and set it to not found in case nothing was found later on. UserSearchResult SearchResult = new UserSearchResult(); SearchResult.WasFound = false; // Go through all the users in a given server. foreach (Discord.User User in ServerToSearch.Users) { // If a user with a matching ID was found... if (User.Id == UserID) { // Set the searchresult to this user, signal that it was found and exit the loop. SearchResult.User = User; SearchResult.WasFound = true; break; } } return(SearchResult); }
public ActionResult PrizeSearch(long id, DateTime?startTime, DateTime?endTime, string keyWord, int pageIndex = 1) { if (id <= 0) { return(Json(new AjaxResult { Status = "error", ErrorMsg = "不存在这个答题活动" })); } PrizeSetModel model = new PrizeSetModel(); UserSearchResult result = userService.GetUsersByActivityId(id, startTime, endTime, keyWord, (pageIndex - 1) * 20, 20); Pagination pager = new Pagination(); pager.CurrentLinkClassName = "curPager"; pager.MaxPagerCount = 10; pager.PageIndex = pageIndex;//这些数据,cshtml不知道,就必须让Action传递给我们 //对于所有cshtml要用到,但是又获取不到的数据,都由Action来获取,然后放到ViewBag或者Model中传递给cshtml pager.PageSize = 20; pager.TotalCount = result.TotalCount; pager.UrlPattern = "javascript:getPage({pn});"; model.ActivityId = id; model.Users = result.Users; model.TotalCount = result.TotalCount; model.WinCount = result.WinCount; if (result.TotalCount <= 20) { model.Page = ""; } else { model.Page = pager.GetPagerHtml(); } return(Json(new AjaxResult { Status = "success", Data = model })); }
public async Task <ActionResult> Index(string username, string firstName, string lastName, string mail, int pageIndex = 0, int pageSize = 10) { var users = await this.usersServiceProxy.SearchUsersAsync(username, firstName, lastName, mail, default(CancellationToken)); var count = users.Count(); users = users.OrderBy(v => v.Username); if (pageIndex >= 0 && pageSize > 0) { users = users.Skip(pageIndex * pageSize).Take(pageSize); } var result = new UserSearchResult(users, count, pageIndex, pageSize) { UsernameFilter = username, LastNameFilter = lastName, FirstNameFilter = firstName, MailFilter = mail }; return(View(result)); }
public static UserSearchResult SearchUsersMethod(SearchParameters searchData, string ConnectionString) { UserSearchResult objUserSearchResult = new UserSearchResult(); objUserSearchResult.userList = new List <DTOUser>(); var optionsBuilder = new DbContextOptionsBuilder <ADefHelpDeskContext>(); optionsBuilder.UseSqlServer(ConnectionString); using (var context = new ADefHelpDeskContext(optionsBuilder.Options)) { // Get all possible roles to reduce database calls later var AllRoles = (from role in context.AdefHelpDeskRoles select role).ToList(); // Perform Search IQueryable <AdefHelpDeskUsers> Result; if (searchData.searchString.Trim() != "") { // A search string was passed // Filter results Result = (from user in context.AdefHelpDeskUsers .Include(roles => roles.AdefHelpDeskUserRoles) where user.FirstName.Contains(searchData.searchString) || user.LastName.Contains(searchData.searchString) || user.Username.Contains(searchData.searchString) || user.Email.Contains(searchData.searchString) select user); } else { // No search string was passed Result = (from user in context.AdefHelpDeskUsers .Include(role => role.AdefHelpDeskUserRoles) select user); } // Paginate results var QueryResult = (from user in Result select user).OrderByDescending(x => x.LastName) .Skip(searchData.rowsPerPage * (searchData.pageNumber - 1)) .Take(searchData.rowsPerPage).ToList(); List <DTOUser> colDTOUser = new List <DTOUser>(); foreach (var item in QueryResult) { DTOUser objDTOUser = new DTOUser(); objDTOUser.userId = item.UserId; objDTOUser.userName = item.Username; objDTOUser.firstName = item.FirstName; objDTOUser.lastName = item.LastName; objDTOUser.isSuperUser = item.IsSuperUser; objDTOUser.email = item.Email; objDTOUser.password = item.Password; objDTOUser.riapassword = item.Riapassword; objDTOUser.verificationCode = item.VerificationCode; objDTOUser.userRoles = new List <RoleDTO>(); foreach (var itemRole in item.AdefHelpDeskUserRoles) { var objUserRole = AllRoles.Where(x => x.Id == itemRole.RoleId).FirstOrDefault(); RoleDTO objRoleDTO = new RoleDTO(); objRoleDTO.iD = objUserRole.Id; objRoleDTO.portalID = objUserRole.PortalId; objRoleDTO.roleName = objUserRole.RoleName; objDTOUser.userRoles.Add(objRoleDTO); } colDTOUser.Add(objDTOUser); } objUserSearchResult.userList = colDTOUser; objUserSearchResult.totalRows = Result.Count(); objUserSearchResult.errorMessage = string.Empty; } return(objUserSearchResult); }
void searchService_utilsSearchUserCompleted(object sender, Remwave.Client.RSIFeaturesWS.utilsSearchUserCompletedEventArgs e) { try { btnUserFind.Enabled = true; pbarSearchProgressBar.Visible = false; pbarSearchProgressBar.EndWaiting(); List<UserSearchResult> searchResult = new List<UserSearchResult>(); if (e.Error != null) return; if (e.Result != null) { string[] result = e.Result; if (result[0].Length<7) return; foreach (string item in result) { UserSearchResult resultItem = new UserSearchResult(); try { string[] items = item.Split(new string[] { ";" }, StringSplitOptions.None); //$first_name.";".$last_name.";".$city.";".$company.";".$country_name.";".$username.";".$comment_data resultItem.Company = items[3] == null ? "" : items[3]; resultItem.FirstName = items[0] == null ? "" : items[0]; resultItem.LastName = items[1] == null ? "" : items[1]; resultItem.Region = items[2] == null ? "" : items[2]; resultItem.Country = items[4] == null ? "" : items[4]; resultItem.Username = items[5] == null ? "" : items[5]; resultItem.Comment = items[6] == null ? "" : items[6]; searchResult.Add(resultItem); } catch (Exception) { } } DisplayResults(searchResult); } } catch (Exception) { } }