public IActionResult BookCatalogByGenre(int?genreId, string selectionType, int page = 1) { BookCatalogViewModel cvm = null; string uri = UriHelper.GetEncodedPathAndQuery(Request); switch (selectionType) { case "text": if (genreId != null || db.Genres.Find(genreId) != null) { IEnumerable <Book> genreTextBooks = db.TextBooks .AsEnumerable() .Where(b => BooksFilteringHelper.GenresContains(b.Genres, genreId)) .OrderBy(b => b.BookName); cvm = new BookCatalogViewModel { Title = "Все книги жанра \"" + db.Genres.Find(genreId).Name + "\"", Books = genreTextBooks .Skip((page - 1) * pageSize) .Take(pageSize), PageInfo = new PageInfo { BaseUrl = PagingHelpers.RemovePageQuery(uri), PageNumber = page, PageSize = pageSize, TotalItems = genreTextBooks.Count() } }; } else { return(NotFound()); } return(View("~/Views/Catalog/TextBookCatalog.cshtml", cvm)); case "audio": if (genreId != null || db.Genres.Find(genreId) != null) { IEnumerable <Book> genreAudioBooks = db.AudioBooks .AsEnumerable() .Where(b => BooksFilteringHelper.GenresContains(b.Genres, "Книги о программировании")) .OrderBy(b => b.BookName); cvm = new BookCatalogViewModel { Title = "Все аудиокниги жанра \"" + db.Genres.Find(genreId).Name + "\"", Books = genreAudioBooks .Skip((page - 1) * pageSize) .Take(pageSize), PageInfo = new PageInfo { BaseUrl = PagingHelpers.RemovePageQuery(uri), PageNumber = page, PageSize = pageSize, TotalItems = genreAudioBooks.Count() } }; } else { return(NotFound()); } return(View("~/Views/Catalog/AudioBookCatalog.cshtml", cvm)); } return(NotFound()); }
public async Task <IActionResult> Index( string sort, string order, string pagination, string keyword, string firstName, string lastName, string personalId, string birthDate, string gender, string city, string phone, string connectedCustomer, int?page) { int recordPage = 4; if (!page.HasValue) { page = 1; if (string.IsNullOrWhiteSpace(order) || order.Equals("asc")) { order = "desc"; } else { order = "asc"; } } if (!string.IsNullOrWhiteSpace(sort) && !sort.Equals(pagination, StringComparison.CurrentCultureIgnoreCase)) { order = "asc"; } ViewBag.order = order; ViewBag.sort = sort; ViewBag.keyword = keyword; ViewBag.firstName = firstName; ViewBag.lastName = lastName; ViewBag.personalId = personalId; ViewBag.birthDate = birthDate; ViewBag.gender = gender; ViewBag.city = city; ViewBag.phone = phone; ViewBag.connectedCustomer = connectedCustomer; var customers = await _customerService.GetAll(); customers = PagingHelpers.Sort(customers, sort, order); customers = PagingHelpers.Search(customers, keyword); customers = PagingHelpers.Search(customers, firstName, lastName, personalId, birthDate, gender, city, phone, connectedCustomer); var finalResult = customers.ToPagedList(page.Value, recordPage); return(View(finalResult)); }
// Workshop details: name, project, employee and list of attendees with // professional development hours. public ActionResult Details(int id = 0, int p = 1, int ps = 50) { var pageNumber = PagingHelpers.ValidatePageNumber(p); var pageSize = PagingHelpers.ValidatePageSize(ps); if (id == 0) { return(RedirectToAction(nameof(Index), new { p = pageNumber, ps = pageSize })); } // Store page number and size for return to list of workshops ViewData["PageNumber"] = pageNumber; ViewData["PageSize"] = pageSize; // Get the workshop and the employee/contact and project var workshopViewModel = _workshopService.Get(id); workshopViewModel.Employee = _employeeService.Get(workshopViewModel.EmployeeId); workshopViewModel.Project = _projectService.Get(workshopViewModel.ProjectId); workshopViewModel.ProviderCode = _providerCodeService.Get(workshopViewModel.ProviderCodeId); // Get sign-out sheet Id's workshopViewModel.SignOutSheets = _signOutSheetUploadService.GetIdsByWorkshop(id); // Get all attendees with professional development hours workshopViewModel.WorkshopAttendeeHours = _workshopService.GetWorkshopAttendeeHours(id); return(View(workshopViewModel)); }
public static FeedLink[] CreatePagingLinks(PageInfo normalizedPageInfo, int totalCount, string requestUriWithoutQuery) { List <FeedLink> links = new List <FeedLink>(); PageInfo firstPageInfo = PagingHelpers.GetFirstPageInfo(normalizedPageInfo, totalCount); links.Add(new FeedLink(string.Format("{0}?startIndex={1}&count={2}", requestUriWithoutQuery, firstPageInfo.StartIndex, firstPageInfo.Count), LinkType.First, MediaType.Atom, "First Page")); PageInfo lastPageInfo = PagingHelpers.GetLastPageInfo(normalizedPageInfo, totalCount); links.Add(new FeedLink(string.Format("{0}?startIndex={1}&count={2}", requestUriWithoutQuery, lastPageInfo.StartIndex, lastPageInfo.Count), LinkType.Last, MediaType.Atom, "Last Page")); PageInfo nextPageInfo = PagingHelpers.GetNextPageInfo(normalizedPageInfo, totalCount); if (null != nextPageInfo) { links.Add(new FeedLink(string.Format("{0}?startIndex={1}&count={2}", requestUriWithoutQuery, nextPageInfo.StartIndex, nextPageInfo.Count), LinkType.Next, MediaType.Atom, "Next Page")); } PageInfo previousPageInfo = PagingHelpers.GetPreviousPageInfo(normalizedPageInfo); if (null != previousPageInfo) { links.Add(new FeedLink(string.Format("{0}?startIndex={1}&count={2}", requestUriWithoutQuery, previousPageInfo.StartIndex, previousPageInfo.Count), LinkType.Previous, MediaType.Atom, "Previous Page")); } return(links.ToArray()); }
/// <summary> /// Formats the specified node. /// </summary> /// <param name="node">The node.</param> /// <returns>The formatted sql string.</returns> public SqlDataResponse Format(PageNode node) { if (node == null) { return(null); } const string Sql = "OFFSET @offset LIMIT @limit"; var skip = PagingHelpers.GetSkip(node.Page, node.ItemsPerPage); return(new SqlDataResponse { Sql = Sql, Params = new List <SqlWhereParam> { new SqlWhereParam { VarName = "offset", Value = skip }, new SqlWhereParam { VarName = "limit", Value = node.ItemsPerPage }, }, }); }
public PagingModel(int pageNum, int pageSize, int totalItems, string controller, string action) { PageNum = PagingHelpers.ValidatePageNumber(pageNum); PageSize = PagingHelpers.ValidatePageSize(pageSize); TotalItems = totalItems; Controller = controller; Action = action; }
public async Task PaginateResultsAsync(IQueryable <TModel> data) { Total = await data.CountAsync(); PageCount = PagingHelpers.GetPageCount(Total, PageSize); HasPrevious = CurrentPage > 1; HasNext = CurrentPage < PageCount; var skip = PagingHelpers.CalculateSkip(PageSize, CurrentPage); Data = await data.Skip(skip).Take(PageSize).ToListAsync(); }
public TagBuilder CreateTag(int pageNumber, IUrlHelper urlHelper) { TagBuilder link = new TagBuilder("a"); if (pageNumber == this.PageModel.PageNumber) { link.AddCssClass("selected_page"); } else { link.Attributes["href"] = PagingHelpers.GetPageLink(PageModel.BaseUrl, pageNumber); } link.InnerHtml.Append(pageNumber.ToString()); return(link); }
public void PageLinksTest_CanGeneratePageLinks() { HtmlHelper htmlHelper = null; PagingInfo pagingInfo = new PagingInfo { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 }; Func <int, string> pageUrlDelegate = i => "Page" + i; MvcHtmlString expected = MvcHtmlString.Create(@"<a href=""Page1"">1</a><a class=""selected"" href=""Page2"">2</a><a href=""Page3"">3</a>"); MvcHtmlString actual = PagingHelpers.PageLinks(htmlHelper, pagingInfo, pageUrlDelegate); Assert.AreNotEqual(expected, actual);//two different objects Assert.AreEqual(expected.ToString(), actual.ToString()); }
public void Can_Generate_Page_Links() { PagingInfo pagingInfo = new PagingInfo { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 }; Func <int, string> pageUrlDelegate = i => "Page" + i; HtmlString result = PagingHelpers.PageLinks(null, pagingInfo, pageUrlDelegate); string html = @"<a class=""btn btn-default"" href=""Page1"">1</a>" + @"<a class=""btn btn-default btn-primary selected"" href=""Page2"">2</a>" + @"<a class=""btn btn-default"" href=""Page3"">3</a>"; Assert.AreEqual(html, result.ToString()); }
public void CheckPageLinks() { // arrange var pagingInfo = new PagingInfo() { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 }; // act var mvcHtmlString = PagingHelpers.PageLinks(null, pagingInfo, i => "Page" + i); // assert Assert.AreEqual(mvcHtmlString.ToString(), @"<a href=""Page1"">1</a>" + @"<a class=""selected"" href=""Page2"">2</a>" + @"<a href=""Page3"">3</a>"); }
public IActionResult BookCatalogBySearch(string search, string selectionType, int page = 1) { BookCatalogViewModel cvm = null; string uri = UriHelper.GetEncodedPathAndQuery(Request); switch (selectionType) { case "text": IEnumerable <Book> textBooks = db.TextBooks .AsEnumerable() .Where(b => BooksFilteringHelper.IsSearchedBook(b, search)) .OrderBy(b => b.BookName); cvm = new BookCatalogViewModel { Title = "Все книги", Books = textBooks .Skip((page - 1) * pageSize) .Take(pageSize), PageInfo = new PageInfo { BaseUrl = PagingHelpers.RemovePageQuery(uri), PageNumber = page, PageSize = pageSize, TotalItems = textBooks.Count() } }; return(View("~/Views/Catalog/TextBookCatalog.cshtml", cvm)); case "audio": IEnumerable <Book> audioBooks = db.AudioBooks .AsEnumerable() .Where(b => BooksFilteringHelper.IsSearchedBook(b, search)) .OrderBy(b => b.BookName); cvm = new BookCatalogViewModel { Title = "Все аудиокниги", Books = audioBooks .Skip((page - 1) * pageSize) .Take(pageSize), PageInfo = new PageInfo { BaseUrl = PagingHelpers.RemovePageQuery(uri), PageNumber = page, PageSize = pageSize, TotalItems = audioBooks.Count() } }; return(View("~/Views/Catalog/AudioBookCatalog.cshtml", cvm)); } return(NotFound()); }
public void Can_Generate_Page_Links() { // Arrange - define an HTML helper - we need to do this // in order to apply the extension method HtmlHelper myHelper = null; // Arrange - create PagingInfo data PagingInfo pagingInfo = new PagingInfo { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 }; // Arrange - set up the delegate using a lambda expression Func <int, string> pageUrlDelegate = i => "Page" + i; // Act MvcHtmlString result = PagingHelpers.PageLinks(myHelper, pagingInfo, pageUrlDelegate); // Assert Assert.AreEqual(result.ToString(), @"<a href=""Page1"">1</a>" + @"<a class=""selected"" href=""Page2"">2</a>" + @"<a href=""Page3"">3</a>"); }
public void CanGeneratePageLinks() // Создание ссылок на страницы { // Организация - создание данных PagingInfo var pagingInfo = new PagingInfo { CurrentPage = 2, TotalItems = 28, ItemsPerPage = 10 }; // Организация - настройка делегата с помощью лямбда-выражения Func <int, string> pageUrlFunc = i => string.Format("Page{0}", i); // Действие var result = PagingHelpers.PageLinks(pagingInfo, pageUrlFunc); // Утверждение Assert.AreEqual( "<a class=\"btn btn-default\" href=\"Page1\">1</a><a class=\"btn btn-default btn-primary selected\" href=\"Page2\">2</a><a class=\"btn btn-default\" href=\"Page3\">3</a>", result.ToString()); }
public void Can_add_page_link() { PagingInfo vpagingInfo = new PagingInfo() { TotalItems = 11, ItemsPerPage = 3, CurrentPage = 2 }; Func <int, string> vpageUrl = m => "Page:" + m; MvcHtmlString resulthtml = PagingHelpers.PageLinks(null, vpagingInfo, vpageUrl); string target = resulthtml.ToString(); //<a href=""Page:1"" class=""selected"" /> string expected = @"<a href=""Page:1"">1</a>" + @"<a class=""selected"" href=""Page:2"">2</a>" + @"<a href=""Page:3"">3</a>"; Assert.AreEqual(expected, target); }
public void GetTrackingState(IRequest request) { lock (_asyncStateObj) { if (null == _asyncStateObj.Tracking) { throw new InvalidOperationException("Performer has not been started."); } if (_asyncStateObj.Tracking.Phase == TrackingPhase.FINISH) { PageInfo normalizedPageInfo = PagingHelpers.Normalize(request.Uri.StartIndex, request.Uri.Count, _asyncStateObj.CorrelatedResSyncInfos.Count); SdataContext sdataContext = _requestContext.SdataContext; request.Response.ContentType = MediaType.Atom; //request.Response.Serializer = FeedComponentFactory.GetSerializer<ISyncSourceFeed>(); request.Response.Feed = _asyncPerformer.GetFeed(_requestContext.Config, normalizedPageInfo); } else if (_asyncStateObj.Tracking.Phase == TrackingPhase.ERROR) { //request.Response.Xml = NorthwindFeedSerializer.GetXml(_asyncStateObj.Tracking); //request.Response.ContentType = MediaType.Xml; //request.Response.Serializer = new Sage.Common.Syndication.XmlSerializer(); request.Response.Tracking = _asyncStateObj.Tracking; request.Response.StatusCode = HttpStatusCode.InternalServerError; request.Response.Protocol.SendUnknownResponseHeader("location", String.Format("{0}{1}/$syncSource('{2}')", _requestContext.DatasetLink, _requestContext.ResourceKind.ToString(), _requestContext.TrackingId)); } else { //request.Response.Xml = NorthwindFeedSerializer.GetXml(_asyncStateObj.Tracking); //request.Response.ContentType = MediaType.Xml; //request.Response.Serializer = new Sage.Common.Syndication.XmlSerializer(); request.Response.Tracking = _asyncStateObj.Tracking; request.Response.StatusCode = HttpStatusCode.Accepted; request.Response.Protocol.SendUnknownResponseHeader("location", String.Format("{0}{1}/$syncSource('{2}')", _requestContext.DatasetLink, _requestContext.ResourceKind.ToString(), _requestContext.TrackingId)); } } }
public string PageLinksForAuthorTab(int totalPages, int pageNumber) { var result = PagingHelpers.PageLinksHtml(totalPages, pageNumber, "UpdateAuthorsContentWithPage"); return(new HtmlString(result).ToHtmlString()); }
public IActionResult BookCatalogBySet(string setName, string selectionType, int page = 1) { BookCatalogViewModel cvm = null; string uri = UriHelper.GetEncodedPathAndQuery(Request); switch (selectionType) { case "text": switch (setName) { case "novelty": IEnumerable <Book> noveltyTextBooks = db.TextBooks .AsEnumerable() .Where(b => BooksFilteringHelper.BookIsNew(b, 30)) .OrderBy(b => b.BookName); cvm = new BookCatalogViewModel { Title = "Все новинки", Books = noveltyTextBooks .Skip((page - 1) * pageSize) .Take(pageSize), PageInfo = new PageInfo { BaseUrl = PagingHelpers.RemovePageQuery(uri), PageNumber = page, PageSize = pageSize, TotalItems = noveltyTextBooks.Count() } }; break; } if (cvm == null) { return(NotFound()); } return(View("~/Views/Catalog/TextBookCatalog.cshtml", cvm)); case "audio": switch (setName) { case "novelty": IEnumerable <Book> noveltyAudioBooks = db.AudioBooks .AsEnumerable() .Where(b => BooksFilteringHelper.BookIsNew(b, 30)) .OrderBy(b => b.BookName); cvm = new BookCatalogViewModel { Title = "Все новинки", Books = noveltyAudioBooks .Skip((page - 1) * pageSize) .Take(pageSize), PageInfo = new PageInfo { BaseUrl = PagingHelpers.RemovePageQuery(uri), PageNumber = page, PageSize = pageSize, TotalItems = noveltyAudioBooks.Count() } }; break; } if (cvm == null) { return(NotFound()); } return(View("~/Views/Catalog/AudioBookCatalog.cshtml", cvm)); } return(NotFound()); }
public void Read() { string resourceKindName; EntryRequestType entryRequestType; // Multi or Single bool includeResourcePayloads; ICorrelatedResSyncInfoStore correlatedResSyncStore; CorrelatedResSyncInfo[] correlatedResSyncInfos; int totalResult; // number of correlations found PageInfo normalizedPageInfo; // normalized pageInfo -> will be used for paging, etc. resourceKindName = _requestContext.ResourceKind.ToString(); // multi or single entry request? entryRequestType = (String.IsNullOrEmpty(_requestContext.ResourceKey)) ? EntryRequestType.Multi : EntryRequestType.Single; // get store to request the correlations correlatedResSyncStore = NorthwindAdapter.StoreLocator.GetCorrelatedResSyncStore(_requestContext.SdataContext); // receive correlated resource synchronization entries if (entryRequestType == EntryRequestType.Multi) { int pageNumber = PagingHelpers.GetPageNumber(_request.Uri.StartIndex, _request.Uri.Count); correlatedResSyncInfos = correlatedResSyncStore.GetPaged(resourceKindName, pageNumber, (int)(_request.Uri.Count ?? DEFAULT_ITEMS_PER_PAGE), out totalResult); } else { Guid uuid = (Guid)TypeDescriptor.GetConverter(typeof(Guid)).ConvertFrom(_requestContext.ResourceKey); correlatedResSyncInfos = correlatedResSyncStore.GetByUuid(resourceKindName, new Guid[] { uuid }); totalResult = correlatedResSyncInfos.Length; if (totalResult > 1) { throw new ApplicationException("More than one resource for uuid exists."); } if (totalResult == 0) { throw new RequestException("No resource found"); } } // If the service consumer only needs to retrieve the URL, not the actual payload, // it may do so by adding an empty select parameter to its request: // a) select parameter not exist -> return deep resource payload // b) select exists and empty -> return no resource payload // c) select exists and not empty -> return deep resource payload as we do not yet support payload filtering // with select parameter. string tmpValue; // ?select includeResourcePayloads = true; // default value, but check for select parameter now if (_requestContext.SdataUri.QueryArgs.TryGetValue("select", out tmpValue)) { if (string.IsNullOrEmpty(_requestContext.SdataUri.QueryArgs["select"])) { includeResourcePayloads = false; } } if (entryRequestType == EntryRequestType.Single) { IFeedEntryEntityWrapper wrapper = null; //if (includeResourcePayloads) //TODO: Comment this in as soon as there is a possibility to send empty payload objects wrapper = FeedEntryWrapperFactory.Create(_requestContext.ResourceKind, _requestContext); _request.Response.FeedEntry = this.BuildFeedEntryForCorrelation(correlatedResSyncInfos[0], wrapper); _request.Response.ContentType = MediaType.AtomEntry; } else { // Create an empty feed Feed <FeedEntry> feed = new Feed <FeedEntry>(); feed.Author = new FeedAuthor(); feed.Author.Name = "Northwind Adapter"; feed.Category = new FeedCategory("http://schemas.sage.com/sdata/categories", "collection", "Resource Collection"); DateTime updateTime = DateTime.Now; string feedUrl = _requestContext.SdataUri.ToString(); // the url requested string feedUrlWithoutQuery = (new Uri(feedUrl)).GetLeftPart(UriPartial.Path); // the url without query normalizedPageInfo = PagingHelpers.Normalize(_request.Uri.StartIndex, _request.Uri.Count, totalResult); IFeedEntryEntityWrapper wrapper = null; //if (includeResourcePayloads) //TODO: Comment this in as soon as there is a possibility to send empty payload objects wrapper = FeedEntryWrapperFactory.Create(_requestContext.ResourceKind, _requestContext); // create a feed entry for each correlation. IEnumerator <CorrelatedResSyncInfo> pagedCorrelationEnumerator = PagingHelpers.GetPagedEnumerator <CorrelatedResSyncInfo>(normalizedPageInfo, correlatedResSyncInfos); while (pagedCorrelationEnumerator.MoveNext()) { // Create and append a feed entry per each id FeedEntry entry = this.BuildFeedEntryForCorrelation(pagedCorrelationEnumerator.Current, wrapper); if (entry != null) { feed.Entries.Add(entry); } } // set feed title feed.Title = string.Format("{0} linked {1}", feed.Entries.Count, resourceKindName); // set feed update feed.Updated = updateTime; // set id feed.Id = feedUrl; // add links (general) feed.Links.AddRange(LinkFactory.CreateFeedLinks(_requestContext, feedUrl)); #region PAGING & OPENSEARCH // add links (paging) feed.Links.AddRange(LinkFactory.CreatePagingLinks(normalizedPageInfo, totalResult, feedUrlWithoutQuery)); /* OPENSEARCH */ feed.ItemsPerPage = normalizedPageInfo.Count; feed.StartIndex = normalizedPageInfo.StartIndex; feed.TotalResults = totalResult; #endregion _request.Response.Feed = feed; _request.Response.ContentType = MediaType.Atom; } }
/// <summary> /// /// </summary> /// <param name="config"></param> /// <returns></returns> /// <remarks>This method is not threadsafe as the performer must be finished when calling this method.</remarks> public Feed <FeedEntry> GetFeed(NorthwindConfig config, PageInfo normalizedPageInfo) { Feed <FeedEntry> syncTargetFeed = new Feed <FeedEntry>(); syncTargetFeed.Author = new FeedAuthor(); syncTargetFeed.Author.Name = "Northwind Adapter"; syncTargetFeed.Category = new FeedCategory("http://schemas.sage.com/sdata/categories", "collection", "Resource Collection"); SdataContext sdataContext; SupportedResourceKinds resource; string resourceKind; string EndPoint; Guid trackingId; List <SdataTransactionResult> transactinResults; sdataContext = _parentPerformer._requestContext.SdataContext; resource = _parentPerformer._requestContext.ResourceKind; resourceKind = resource.ToString(); transactinResults = _parentPerformer._asyncStateObj.TransactionResults; EndPoint = _parentPerformer._requestContext.DatasetLink + resourceKind;; trackingId = _parentPerformer._requestContext.TrackingId; // Create a new Feed instance // retrieve the data connection wrapper IFeedEntryEntityWrapper wrapper = FeedEntryWrapperFactory.Create(resource, _parentPerformer._requestContext); IEnumerator <SdataTransactionResult> transactionResultEnumerator = PagingHelpers.GetPagedEnumerator <SdataTransactionResult>(normalizedPageInfo, transactinResults.ToArray()); while (transactionResultEnumerator.MoveNext()) { syncTargetFeed.Entries.Add(this.BuildFeedEntry(transactionResultEnumerator.Current, wrapper)); } // initialize the feed string feedUrl = string.Format("{0}/$syncTarget('{1}')", EndPoint, trackingId); string feedUrlWithoutQuery = (new Uri(feedUrl)).GetLeftPart(UriPartial.Path); // the url without query // set id tag syncTargetFeed.Id = feedUrl; // set title tag syncTargetFeed.Title = string.Format("{0} synchronization target feed {1}", resourceKind.ToString(), trackingId); // set update #warning implement this //syncTargetFeed.Updated = DateTime.Now; // set syncMode syncTargetFeed.SyncMode = SyncMode.catchUp; // add links (general) syncTargetFeed.Links.AddRange(LinkFactory.CreateFeedLinks(_parentPerformer._requestContext, feedUrl)); #region PAGING & OPENSEARCH // add links (paging) syncTargetFeed.Links.AddRange(LinkFactory.CreatePagingLinks(normalizedPageInfo, transactinResults.Count, feedUrlWithoutQuery)); /* OPENSEARCH */ syncTargetFeed.ItemsPerPage = normalizedPageInfo.Count; syncTargetFeed.StartIndex = normalizedPageInfo.StartIndex; syncTargetFeed.TotalResults = transactinResults.Count; #endregion return(syncTargetFeed); }
/// <summary> /// /// </summary> /// <param name="config"></param> /// <returns></returns> /// <remarks>This method is not threadsafe as the performer must be finished when calling this method.</remarks> public Feed <FeedEntry> GetFeed(NorthwindConfig config, PageInfo normalizedPageInfo) { Feed <FeedEntry> syncSourceFeed; SdataContext sdataContext; SupportedResourceKinds resource; string resourceKind; string EndPoint; Guid trackingId; List <CorrelatedResSyncInfo> correlatedResSyncInfos; sdataContext = _parentPerformer._requestContext.SdataContext; resource = _parentPerformer._requestContext.ResourceKind; resourceKind = resource.ToString(); correlatedResSyncInfos = _parentPerformer._asyncStateObj.CorrelatedResSyncInfos; EndPoint = _parentPerformer._requestContext.DatasetLink + resourceKind; trackingId = _parentPerformer._requestContext.TrackingId; //ISyncSyncDigestInfoStore syncDigestStore = RequestReceiver.NorthwindAdapter.StoreLocator.GetSyncDigestStore(sdataContext); ISyncSyncDigestInfoStore syncDigestStore = NorthwindAdapter.StoreLocator.GetSyncDigestStore(sdataContext); SyncDigestInfo syncDigestInfo = syncDigestStore.Get(resourceKind); // Create a new Feed instance syncSourceFeed = new Feed <FeedEntry>();//FeedComponentFactory.Create<ISyncSourceFeed>(); syncSourceFeed.Author = new FeedAuthor(); syncSourceFeed.Author.Name = "Northwind Adapter"; syncSourceFeed.Category = new FeedCategory("http://schemas.sage.com/sdata/categories", "collection", "Resource Collection"); #region Digest syncSourceFeed.Digest = new Digest(); syncSourceFeed.Digest.Entries = (syncDigestInfo == null) ? new DigestEntry[0] : new DigestEntry[syncDigestInfo.Count]; // set digest origin syncSourceFeed.Digest.Origin = _parentPerformer._requestContext.OriginEndPoint; if (syncDigestInfo != null) { // convert and set digest entries from synch store object to feed object for (int i = 0; i < syncDigestInfo.Count; i++) { syncSourceFeed.Digest.Entries[i] = new DigestEntry(); syncSourceFeed.Digest.Entries[i].ConflictPriority = syncDigestInfo[i].ConflictPriority; syncSourceFeed.Digest.Entries[i].EndPoint = syncDigestInfo[i].EndPoint; syncSourceFeed.Digest.Entries[i].Tick = (int)syncDigestInfo[i].Tick; syncSourceFeed.Digest.Entries[i].Stamp = DateTime.Now; } } #endregion #region Entries // retrieve the data connection wrapper IFeedEntryEntityWrapper wrapper = FeedEntryWrapperFactory.Create(resource, _parentPerformer._requestContext); IEnumerator <CorrelatedResSyncInfo> correlationEnumerator = PagingHelpers.GetPagedEnumerator <CorrelatedResSyncInfo>(normalizedPageInfo, correlatedResSyncInfos.ToArray()); while (correlationEnumerator.MoveNext()) { syncSourceFeed.Entries.Add(this.BuildFeedEntry(correlationEnumerator.Current, wrapper)); } #endregion // initialize the feed string feedUrl = string.Format("{0}/$syncSource('{1}')", EndPoint, trackingId); string feedUrlWithoutQuery = (new Uri(feedUrl)).GetLeftPart(UriPartial.Path); // the url without query // set id tag syncSourceFeed.Id = feedUrl; // set title tag syncSourceFeed.Title = string.Format("{0} synchronization source feed {1}", resourceKind.ToString(), trackingId); // set update // syncSourceFeed.Updated = DateTime.Now; // set syncMode syncSourceFeed.SyncMode = SyncMode.catchUp;// syncModeenum.catchUp; // add links (general) syncSourceFeed.Links.AddRange(LinkFactory.CreateFeedLinks(_parentPerformer._requestContext, feedUrl)); #region PAGING & OPENSEARCH // add links (paging) syncSourceFeed.Links.AddRange(LinkFactory.CreatePagingLinks(normalizedPageInfo, correlatedResSyncInfos.Count, feedUrlWithoutQuery)); /* OPENSEARCH */ syncSourceFeed.ItemsPerPage = normalizedPageInfo.Count; syncSourceFeed.StartIndex = normalizedPageInfo.StartIndex; syncSourceFeed.TotalResults = correlatedResSyncInfos.Count; #endregion return(syncSourceFeed); }