public new void SetUp() { Pages = new PagesList(Driver); Driver.Navigate().GoToUrl("http://atqc-shop.epizy.com/"); Pages.HomePage .GoToLoginPage(); }
public async Task CreateWebDataListFromGoogleResultsAsync(CancellationToken cancellationToken) { foreach (GoogleSearchResult googleResult in GoogleSearchEngine.Instance.SearchResults) { bool isPageInList = PagesList.Any(page => googleResult.Url.Contains(page.Url)); cancellationToken.ThrowIfCancellationRequested(); if (!isPageInList) { IWebDataSource dataSource = WebDataSourceFactory.CreateWebDataSource(googleResult); if (dataSource != null) { IPage page = await m_PagesMemoryCache.GetOrCreate(googleResult.Url, async() => await dataSource.ParseDataAndGetPageAsync()); cancellationToken.ThrowIfCancellationRequested(); PagesList.Add(page); OnPageAdded(page); } } } m_TimeoutTimer.Stop(); }
public EventApiResponse(IUrlHelper uriHelper, string methodName, PagesList <EventModel> models, EventSourceParameters parameters) { var uriHelper1 = uriHelper; PageNumber = models.CurrentPage; Models = models; NextPage = models.HasNext ? new Uri(uriHelper1.Link(methodName, new { keyPhrase = parameters.KeyPhrase, personids = parameters.PersonIds, pageNumber = models.CurrentPage + 1, pageSize = models.PageSize })) : null; PreviousPage = models.HasPrevious ? PreviousPage = new Uri(uriHelper1.Link(methodName, new { keyPhrase = parameters.KeyPhrase, personids = parameters.PersonIds, pageNumber = models.CurrentPage - 1, pageSize = models.PageSize })) : null; }
// GET: ChildList public ActionResult Index() { Item contextItem = RenderingContext.Current.ContextItem; var database = contextItem.Database; var indexName = string.Format("sitecore_{0}_index", database); try { var index = ContentSearchManager.GetIndex(indexName); var model = new PagesList(); using (var context = index.CreateSearchContext()) { var results = context.GetQueryable <PageDetails>() .Where(i => i.Paths.Contains(contextItem.ID)) .Where(i => i.Language == contextItem.Language.Name) .GetResults(); model.Pages = results.Hits.Select(h => h.Document).ToList(); model.TotalResultCount = results.TotalSearchResults; } return(View(model)); } catch (Exception e) { return(new EmptyResult()); } }
public async Task <PagesList <LikeDTO> > GetUserLikes(LikeParams likeParams) { var users = _context.Users.OrderBy(u => u.UserName).AsQueryable(); var likes = _context.Likes.AsQueryable(); if (likeParams.Predicate == "liked") { likes = likes.Where(like => like.SourceUserId == likeParams.UserId); users = likes.Select(like => like.LikedUser); } if (likeParams.Predicate == "likedBy") { likes = likes.Where(like => like.LikedUserId == likeParams.UserId); users = likes.Select(like => like.SourceUser); } var userLikes = users.Select(user => new LikeDTO { Username = user.UserName, Age = user.DateOfBirth.CalculateAge(), KnownAs = user.KnownAs, PhotoUrl = user.Photos.FirstOrDefault(p => p.IsMain).Url, City = user.City, Id = user.Id }); return(await PagesList <LikeDTO> .CreateAsync(userLikes, likeParams.PageNumber, likeParams.PageSize)); }
public async Task <PagesList <Message> > GetMessagesForUser(MessageParams messageParams) { var messages = _context.Messages .Include(u => u.Sender).ThenInclude(p => p.Photos) .Include(u => u.Recipient).ThenInclude(p => p.Photos) .AsQueryable(); switch (messageParams.MessageContainer) { case "Inbox": messages = messages.Where(u => u.RecipientId == messageParams.UserId && u.RecipientDeleted == false); break; case "Outbox": messages = messages.Where(u => u.SenderId == messageParams.UserId && u.SenderDeleted == false); break; default: messages = messages.Where(u => u.RecipientId == messageParams.UserId && u.RecipientDeleted == false && u.IsRead == false); break; } messages = messages.OrderByDescending(d => d.MessageSent); return(await PagesList <Message> .CreateAsync(messages, messageParams.PageNumber, messageParams.PageSize)); }
public async Task <PagesList <Adventure> > GetAdventures(AdventureParams adventureParams) { var adventures = _context.Adventures .Include(aP => aP.AdventurePhotos) .OrderByDescending(a => a.DateAdded) .AsQueryable(); // adventures = adventures.Where(a => a.Id == adventureParams.AdventureId); if (adventureParams.MinDistance != 0 || adventureParams.MaxDistance != 10000) { var minDistance = (adventureParams.MinDistance); var maxDistance = (adventureParams.MaxDistance); adventures = adventures.Where(a => a.Distance >= minDistance && a.Distance <= maxDistance); } if (adventureParams.TypeBicycle != "Wszystkie") { adventures = adventures.Where(a => a.TypeBicycle == adventureParams.TypeBicycle); } if (adventureParams.UserLikesAdventure) { // var UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var userLikesAdventure = await GetAdventureLikes(adventureParams.UserId, adventureParams.AdventureIsLiked); adventures = adventures.Where(u => userLikesAdventure.Contains(u.Id)); } if (adventureParams.AdventureIsLiked) { // var UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var adventureIsLiked = await GetAdventureLikes(adventureParams.UserId, adventureParams.UserLikesAdventure); adventures = adventures.Where(u => adventureIsLiked.Contains(u.Id)); } if (!string.IsNullOrEmpty(adventureParams.OrderBy)) { switch (adventureParams.OrderBy) { case "dateAdded": adventures = adventures.OrderByDescending(a => a.DateAdded); break; default: adventures = adventures.OrderByDescending(a => a.Distance); break; } } return(await PagesList <Adventure> .CreateListAsync(adventures, adventureParams.PageNumber, adventureParams.PageSize)); }
public async Task <PagesList <SellBicycle> > GetSellBicycles(SellBicycleParams sellBicycleParams) { var sellBicycles = _context.SellBicycles.Include(s => s.SellBicyclePhotos).Include(u => u.User).OrderByDescending(s => s.DateAdded).AsQueryable(); if (sellBicycleParams.MinPrice != 0 || sellBicycleParams.MaxPrice != 10000) { var minPrice = (sellBicycleParams.MinPrice); var maxPrice = (sellBicycleParams.MaxPrice); sellBicycles = sellBicycles.Where(s => s.Price >= minPrice && s.Price <= maxPrice); } if (sellBicycleParams.TypeBicycle != "Wszystkie") { sellBicycles = sellBicycles.Where(a => a.TypeBicycle == sellBicycleParams.TypeBicycle); } if (sellBicycleParams.UserLikesSellBicycle) { // var UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var userLikesAdventure = await GetSellBicycleLikes(sellBicycleParams.UserId, sellBicycleParams.SellBicycleIsLiked); sellBicycles = sellBicycles.Where(u => userLikesAdventure.Contains(u.Id)); } if (sellBicycleParams.SellBicycleIsLiked) { // var UserId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var adventureIsLiked = await GetSellBicycleLikes(sellBicycleParams.UserId, sellBicycleParams.UserLikesSellBicycle); sellBicycles = sellBicycles.Where(u => adventureIsLiked.Contains(u.Id)); } if (!string.IsNullOrEmpty(sellBicycleParams.OrderBy)) { switch (sellBicycleParams.OrderBy) { case "dateAdded": sellBicycles = sellBicycles.OrderByDescending(a => a.DateAdded); break; default: sellBicycles = sellBicycles.OrderBy(a => a.Price); break; } } return(await PagesList <SellBicycle> .CreateListAsync(sellBicycles, sellBicycleParams.PageNumber, sellBicycleParams.PageSize)); }
/// <summary> /// Converter to convert PagesList value to control /// </summary> /// <param name="_page"> page to convert </param> /// <returns> new control or null </returns> public static IContentControl Convert(PagesList _page) { switch (_page) { case PagesList.LoginPage: return(new LoginControl()); case PagesList.MainPage: return(new MainPage()); default: return(null); } }
/// <inheritdoc/> public async Task <PagesListModel <UserDto> > GetUsersAsync(UserQueryParam param) { var users = ObjMapper.Map <IList <User>, IList <UserDto> >(await _userManager.Users.ToListAsync()); var usersPagesList = await PagesList <UserDto> .GetPagesListAsync(users.AsQueryable(), param); foreach (var user in usersPagesList) { user.Roles = await _rolesService.GetUserRolesAsync(user.Id); } var result = ObjMapper.Map <PagesList <UserDto>, PagesListModel <UserDto> >(usersPagesList); return(result); }
public async Task <PagesList <User> > GetUsers(UserParams userParams) { var users = _context.Users.Include(p => p.Photos) .OrderByDescending(u => u.LastActive).AsQueryable(); users = users.Where(u => u.Id != userParams.UserId); users = users.Where(u => u.Gender == userParams.Gender); if (userParams.Likers) { var userLikers = await GetUserLikes(userParams.UserId, userParams.Likers); users = users.Where(u => userLikers.Contains(u.Id)); } if (userParams.Likees) { var userLikees = await GetUserLikes(userParams.UserId, userParams.Likers); users = users.Where(u => userLikees.Contains(u.Id)); } if (userParams.MinAge != 18 || userParams.MaxAge != 99) { var minDob = DateTime.Today.AddYears(-userParams.MaxAge - 1); var maxDob = DateTime.Today.AddYears(-userParams.MinAge); users = users.Where(u => u.DateOfBirth >= minDob && u.DateOfBirth <= maxDob); } if (!string.IsNullOrEmpty(userParams.OrderBy)) { switch (userParams.OrderBy) { case "created": users = users.OrderByDescending(u => u.Created); break; default: users = users.OrderByDescending(u => u.LastActive); break; } } return(await PagesList <User> .CreateAsync(users, userParams.PageNumber, userParams.PageSize)); }
public async Task <AlfredResponse> SearchAsync(IAlfredInput i_Input) { m_TimeoutTimer.Enabled = true; PagesList.Clear(); GoogleSearchEngine.Instance.ClearResults(); m_CancellationTokenSource?.Dispose(); m_CancellationTokenSource = new CancellationTokenSource(); try { if (i_Input.ProjectType != null) { await GoogleSearchEngine.Instance.AddSearchResultsFromQueryAsync(String.Format("site: {0} {1} {2}", r_WebSitesUrls[eWebSite.Stackoverflow], i_Input.Description, i_Input.ProjectType)); } await GoogleSearchEngine.Instance.AddSearchResultsFromQueryAsync(String.Format("site: {0} {1}", r_WebSitesUrls[eWebSite.Stackoverflow], i_Input.Description)); await GoogleSearchEngine.Instance.AddSearchResultsFromQueryAsync(String.Format("site: {0} \"{1}\"", r_WebSitesUrls[eWebSite.Microsoft], i_Input.ErrorCode)); await Task.Run(() => CreateWebDataListFromGoogleResultsAsync(m_CancellationTokenSource.Token), m_CancellationTokenSource.Token); } catch (WebException) { StopSearch(); throw new WebException("No internet connection"); } catch (OperationCanceledException) { StopSearch(); throw new OperationCanceledException("Operation canceled - timeout expired"); } catch (Exception) { StopSearch(); throw new WebException("Uunexpected error"); } return(Response); }
public async Task <PagesList <MessageDTO> > GetMessagesForUser(MessageParams messageParams) { var query = _context.Messages .OrderByDescending(m => m.MessageSent) .AsQueryable(); query = messageParams.Container switch { "Inbox" => query.Where(u => u.Recipient.UserName == messageParams.Username && u.RecipientDeleted == false), "Outbox" => query.Where(u => u.Sender.UserName == messageParams.Username && u.SenderDeleted == false), _ => query.Where(u => u.Recipient.UserName == messageParams.Username && u.RecipientDeleted == false && u.DateRead == null) }; var messages = query.ProjectTo <MessageDTO>(_mapper.ConfigurationProvider); return(await PagesList <MessageDTO> .CreateAsync(messages, messageParams.PageNumber, messageParams.PageSize)); }
public CollectionOperationResult <EventModel> GetRecords(EventSourceParameters parameters) { try { var rawModels = Repository .GetAsync(i => (parameters.PersonIds.Any() || parameters.PersonIds.Contains(i.PersonId)) && (String.IsNullOrEmpty(parameters.KeyPhrase) || i.Content.Contains(parameters.KeyPhrase, StringComparison.InvariantCultureIgnoreCase))) .Result; var orderedModels = rawModels.OrderByDescending(model => model.EventDate).AsQueryable(); var pagedModels = PagesList <EventModel> .Init(orderedModels, parameters.PageNumber, parameters.PerPage); return(CollectionSuccess(OperationTypes.Read, pagedModels)); } catch (Exception e) { return(CollectionError(OperationTypes.Read, ServerMessages.CannotLoadRecords)); } }
public async Task <PagesList <MemberDTO> > GetMembersDtoAsync(UserParams userParams) { var query = _context.Users.AsQueryable(); query = query.Where(u => u.UserName != userParams.CurrentUserName); query = query.Where(g => g.Gender == userParams.Gender); var MinDob = DateTime.Today.AddYears(-userParams.MaxAge).AddDays(-1); var MaxDob = DateTime.Today.AddYears(-userParams.MinAge); query = query.Where(u => u.DateOfBirth >= MinDob && u.DateOfBirth <= MaxDob); query = userParams.OrderBy switch { "created" => query.OrderByDescending(u => u.Created), _ => query.OrderByDescending(u => u.LastActive) }; return(await PagesList <MemberDTO> .CreateAsync(query.ProjectTo <MemberDTO> (_mapper.ConfigurationProvider).AsNoTracking(), userParams.PageNumber, userParams.PageSize)); }
/// <summary> /// Get default operation result with errors for collection /// </summary> /// <param name="operation">Operation Type</param> /// <param name="models">Collection of models that have been used for operation</param> /// <returns>Operation result (Collection/Error)</returns> protected CollectionOperationResult <TModel> CollectionError(OperationTypes operation, PagesList <TModel> models) { var message = string.Empty; foreach (var model in models) { message += string.Format("{0} ", SingleError(operation, model)); } return(new CollectionOperationResult <TModel>(operation, false, message, models)); }
private PagesList <PersonModel> ToPagesList(List <PersonModel> result) { //TODO return(PagesList <PersonModel> .Init(result, 1, result.Count())); }
/// <summary> /// Get successful operation result for collection /// </summary> /// <param name="operation">Operation Type</param> /// <param name="models">Collection of models that have been used for operation</param> /// <returns>Operation result (Collection/Success)</returns> protected CollectionOperationResult <TModel> CollectionSuccess(OperationTypes operation, PagesList <TModel> models) { return(new CollectionOperationResult <TModel>(operation, true, ServerMessages.DataDownloaded, models)); }
public void SetUp() { LoggingLog.InitializationLogging(); pages = new PagesList(Driver); Driver.Navigate().GoToUrl("http://atqc-shop.epizy.com/"); }
public virtual async Task <PagesList <T> > GetByQueryParamAsync(QueryParameters parameters) { var data = FindAll(); return(await PagesList <T> .GetPagesListAsync(data, parameters)); }
public CollectionOperationResult(OperationTypes operationType, bool wasSuccessful, string message, PagesList <TModel> models) : base(operationType, wasSuccessful, message) { Records = models; }
//Load book ... pretty straightforward public void LoadBook(string FilePath, int p = 1) { Pages.Clear(); currentBook.CurrentPage = p; currentBook.Name = System.IO.Path.GetFileName(FilePath); currentBook.Type = Path.GetExtension(FilePath).ToLower(); currentBook.Path = FilePath; // use the apropriate function for compressed or pdf file if (currentBook.Type == ".pdf") { //Call the function to load the pdf (not the pages) //the function that load the page is called within the reader.cs //since on a pdf the page is loaded on demand for memory efficiency purpose Program.LoadPDF(FilePath); currentBook.TotalPages = Program.PDFBook.TotalPage; } else { ArchiveLoader(FilePath); } // Get The Reading direction from metadate and set it string ReadDirection = ReadMetadata(FilePath, "ReadDirection"); // MessageBox.Show(ReadMetadata(FilePath, "ReadDirection")); if (ReadDirection == "RtL") { SetDirection("RtL"); } else { SetDirection("LtR"); } // Get The View Mode from metadate and set it string v = ReadMetadata(FilePath, "Viewer"); // MessageBox.Show(ReadMetadata(FilePath, "ReadDirection")); if (v == "DPdc") { currentViewerOption = "dc"; } else { currentViewerOption = "sc"; } Viewer("Start"); GC.Collect(); ShowReader(); PagesList.Clear(); cPageMini2.ItemsSource = null; GenerateMiniPage(); cPageMini2.ItemsSource = PagesList; cPageMini2.UpdateLayout(); cPageMini2.SelectedIndex = 12; cPageMini2.ScrollToCenterOfView(cPageMini2.SelectedIndex); void GenerateMiniPage() { int i = 0; foreach (KeyValuePair <int, byte[]> entry in Pages) { // do something with entry.Value or entry.Key PagesList.Add(entry.Key, CreatePage(entry.Key, "Mini")); } } void ArchiveLoader(string Path) { int i = 0; var archive = ArchiveFactory.Open(Path); foreach (var entry in archive.Entries) { //Check if the entries in the File are : not a directoy AND contain in their name .jpg OR .png if (!entry.IsDirectory & (entry.Key.ToLower().Contains(".jpg") | entry.Key.ToLower().Contains(".png"))) { i++; //SortedOrder.FindIndex(s => s.Equals(entry.ToString())); using (MemoryStream MemStream = new MemoryStream()) { entry.WriteTo(MemStream); MemStream.Seek(0, SeekOrigin.Begin); byte[] bytes = MemStream.ToArray(); Pages.Add(i, bytes); bytes = null; } } } archive = null; currentBook.TotalPages = i; } }
public async Task <PagesList <User> > GetUsers(UserParams userParams) { var users = _context.Users.Include(p => p.UserPhotos) .Include(a => a.Adventures) .Include(s => s.SellBicycles) .OrderByDescending(u => u.LastActive) .AsQueryable(); users = users.Where(u => u.Id != userParams.UserId); //users = users.Where(u => u.Gender == userParams.Gender); //wybieranie płci => UsersController if (userParams.Gender != "Wszystkie") { users = users.Where(u => u.Gender == userParams.Gender); } if (userParams.UserLikes) { var userLikes = await GetUserLikes(userParams.UserId, userParams.UserLikes); users = users.Where(u => userLikes.Contains(u.Id)); } if (userParams.UserIsLiked) { var UserIsLiked = await GetUserLikes(userParams.UserId, userParams.UserLikes); users = users.Where(u => UserIsLiked.Contains(u.Id)); } if (userParams.AdventureIsLiked) { var AdventureIsLiked = await GetUserLikesAdventure(userParams.UserId, userParams.UserLikesAdventure); users = users.Where(u => AdventureIsLiked.Contains(u.Id)); } if (userParams.UserLikesAdventure) { var userLikesAdventure = await GetUserLikesAdventure(userParams.UserId, userParams.UserLikesAdventure); users = users.Where(u => userLikesAdventure.Contains(u.Id)); } if (userParams.MinAge != 0 || userParams.MaxAge != 100) { var minDate = DateTime.Today.AddYears(-userParams.MaxAge - 1); var maxDate = DateTime.Today.AddYears(-userParams.MinAge); users = users.Where(u => u.DateOfBirth >= minDate && u.DateOfBirth <= maxDate); } if (userParams.TypeBicycle != "Wszystkie") { users = users.Where(u => u.TypeBicycle == userParams.TypeBicycle); } if (!string.IsNullOrEmpty(userParams.OrderBy)) { switch (userParams.OrderBy) { case "created": users = users.OrderByDescending(u => u.Created); break; default: users = users.OrderByDescending(u => u.LastActive); break; } } return(await PagesList <User> .CreateListAsync(users, userParams.PageNumber, userParams.PageSize)); }
public override async Task <PagesList <Order> > GetByQueryParamAsync(QueryParameters parameters) { var orders = _context.Set <Order>().AsNoTracking().Include(order => order.Canvas); return(await PagesList <Order> .GetPagesListAsync(orders, parameters)); }
//collection success protected CollectionOperationResult <TModel> CollectionSuccess(OperationTypes operation, PagesList <TModel> models, Func <OperationTypes, IEnumerable <TModel>, bool, string> retrieveMessageFunc) { var message = retrieveMessageFunc(operation, models, true); return(new CollectionOperationResult <TModel>(operation, true, message, models)); }