Method NewPagingRequest
NewPagingRequest(int, out long, out int, int, IEnumerable<TicketLink>, FilterElement<Ticket>, bool)
Requests tickets in a paged fashion. This method requests a new page.
public IEnumerable<Ticket> NewPagingRequest(int pagesize, out long pagingCookie, out int totalTickets, int pageNumber = 0, IEnumerable<TicketLink> links = null, FilterElement<Ticket> filter = null, bool CacheOnly = false)
Parameters
pagesizeintThe number of tickets that should be retrieved on one page.
pagingCookielongThe paging cookie to use in the NextPagingRequest method to request the next page. If output is 0, no cookie could be created.
totalTicketsintThe total number of tickets this request would result in if done as a regular request (GetTickets). If output is -1, no total number could be calculated.
pageNumberintThe page number you want to retrieve.
linksIEnumerable<TicketLink>The links to be used when searching the tickets.
filterFilterElement<Ticket>The filter to use when searching the tickets.
CacheOnlyboolIndicates whether to only check the cache (true) or also the database (false).
Returns
- IEnumerable<Ticket>
A collection of tickets with the indicated page size, matching the links and filter.
Examples
When you have a system with a lot of tickets, it can be more feasible to retrieve the tickets in a paged fashion, so the client application does not receive a large amount all at once, which it cannot all display anyway.
The following example demonstrates how to use paging.
private static long PagingCookie = -1;
private static int PageSize = 2;
private static int totalTickets = 10;
private IEnumerable<Ticket> RetrieveNextPage()
{
List<Ticket> result;
// The maximum number of tickets retrieved by this method is pageSize * number of DataMiner Agents in the DataMiner System.
if (PagingCookie == -1)
{
result = Helper.NewPagingRequest(PageSize, out PagingCookie, out totalTickets, filter: TicketingExposers.DataMinerID.Equal(123)).ToList();
}
result = Helper.NextPagingRequest(PagingCookie).ToList();
if (result.Count < PageSize)
PagingCookie = -1;
return result;
}
Remarks
Instead of using the page number and calling a NewPagingRequest to retrieve the next page, we advise to use the NextPagingRequest(long) method instead.