public async Task <IPage <SimpleDocument <T> > > PageAsync(int pageSize, byte[] pagingState, Guid?tenantId = null, MetaData metaData = null) { if (metaData == null) { return(await base.PageAsync(pageSize, pagingState, tenantId)); } byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(tenantId); records = Filter(records, metaData); var slice = records.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <SimpleDocument <T> >(currentPagingState, pagingState, slice); return(page); }
public async Task <Store.Core.Models.IPage <ClaimHandle> > PageClaimsAsync(Guid userId, int pageSize, byte[] pagingState, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var session = CassandraSession; IMapper mapper = new Mapper(session); IPage <ClaimHandle> page; string cqlQuery = string.Format("Where userid={0}", userId.ToString()); if (pagingState == null) { page = await mapper.FetchPageAsync <ClaimHandle>( Cql.New(cqlQuery).WithOptions(opt => opt.SetPageSize(pageSize))); } else { page = await mapper.FetchPageAsync <ClaimHandle>( Cql.New(cqlQuery).WithOptions(opt => opt.SetPageSize(pageSize).SetPagingState(pagingState))); } // var result = CreatePageProxy(page); var result = new PageProxy <ClaimHandle>(page); return(result); }
public async Task <Store.Core.Models.IPage <CassandraUser> > PageUsersOfAllTenantsAsync(int pageSize, byte[] pagingState, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); var session = CassandraSession; IMapper mapper = new Mapper(session); IPage <CassandraUser> page; string cqlQuery = string.Format("SELECT * FROM users"); if (pagingState == null) { page = await mapper.FetchPageAsync <CassandraUser>( Cql.New(cqlQuery).WithOptions(opt => opt.SetPageSize(pageSize))); } else { page = await mapper.FetchPageAsync <CassandraUser>( Cql.New(cqlQuery).WithOptions(opt => opt.SetPageSize(pageSize).SetPagingState(pagingState))); } // var result = CreatePageProxy(page); var result = new PageProxy <CassandraUser>(page); return(result); }
/// <summary> /// Generates HTML link tags to include CSS for all stylesheets needed on the page (coming from the theme). /// Provides an alternative for MVC where resources are inserted as pure HTML link tags instead of a ResourceLinks control, which is the case in the /// WebForms and hybrid modes. /// </summary> /// <param name="theme">The name of the theme</param> /// <returns></returns> private string ResourceRegistrations(string theme) { var pageProxy = new PageProxy(theme); var resources = ThemeController.GetGlobalStyles(pageProxy); if (resources == null) { return(null); } StringBuilder sb = new StringBuilder(); this.AppendStylesheetResourceTag(pageProxy, ref sb, "Telerik.Sitefinity.Resources.Reference", "Telerik.Sitefinity.Resources.Themes.LayoutsBasics.css"); foreach (var link in resources.Links) { this.AppendStylesheetResourceTag(pageProxy, ref sb, link.AssemblyInfo, link.Name); } string appPath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath; if (!appPath.EndsWith("/")) { appPath = string.Concat(appPath, "/"); } sb.Append(String.Concat("\t<script type=\"text/javascript\">var sf_appPath='", appPath, "';</script>")); // add the scripts for personalization in the page sb.Append("\t<script src=\""); sb.Append(pageProxy.ClientScript.GetWebResourceUrl(typeof(PageStatisticsJSClient), "Telerik.Sitefinity.Clients.JS.StatsClient.min.js")); sb.Append("\" type=\"text/javascript\"></script>"); return(sb.ToString()); }
private void RescanPages() { string[] propertiesToEdit = richTextBox1.Lines; StringBuilder sb = new StringBuilder(); for (int i = 0; i < listBox1.Items.Count; i++) { if (listBox1.GetSelected(i)) { PageProxy pp = (PageProxy)listBox1.Items[i]; foreach (string s in propertiesToEdit) { GSCore prop = pp.page.GetPropertyValue(s); if (!(prop is GSVoid)) { sb.AppendFormat("@{0},{1}\n{2}\n", pp.page.Id, s, prop.getStringValue()); } } } } if (sb.ToString().Equals(richTextBox2.Text)) { return; } richTextBox2.Text = sb.ToString(); }
public async Task <Store.Core.Models.IPage <Scope> > PageScopesAsync(int pageSize, byte[] pagingState, CancellationToken cancellationToken = default(CancellationToken)) { try { MyMappings.Init(); cancellationToken.ThrowIfCancellationRequested(); var session = CassandraSession; IMapper mapper = new Mapper(session); IPage <Scope> page; if (pagingState == null) { page = await mapper.FetchPageAsync <Scope>( Cql.New(SelectScopeQuery).WithOptions(opt => opt.SetPageSize(pageSize))); } else { page = await mapper.FetchPageAsync <Scope>( Cql.New(SelectScopeQuery).WithOptions(opt => opt.SetPageSize(pageSize).SetPagingState(pagingState))); } // var result = CreatePageProxy(page); var result = new PageProxy <Scope>(page); return(result); } catch (Exception e) { // only here to catch during a debug unit test. throw; } }
public async Task <P5.Store.Core.Models.IPage <DocumentRecord> > PageFlattenedDocumentsAsync( int pageSize, byte[] pagingState, CancellationToken cancellationToken = default(CancellationToken)) { try { cancellationToken.ThrowIfCancellationRequested(); var session = CassandraSession; IMapper mapper = new Mapper(session); Cassandra.Mapping.IPage <DocumentRecord> page; if (pagingState == null) { page = await mapper.FetchPageAsync <DocumentRecord>( Cql.New(FindFlattenedDocumentQuery).WithOptions(opt => opt.SetPageSize(pageSize))); } else { page = await mapper.FetchPageAsync <DocumentRecord>( Cql.New(FindFlattenedDocumentQuery).WithOptions(opt => opt.SetPageSize(pageSize).SetPagingState(pagingState))); } // var result = CreatePageProxy(page); var result = new PageProxy <DocumentRecord>(page); return(result); } catch (Exception e) { // only here to catch during a debug unit test. throw; } }
public async Task <IPage <T> > PageAsync( int pageSize, byte[] pagingState, Guid?tenantId = null) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(tenantId); var slice = records.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <T>(currentPagingState, pagingState, slice); return(page); }
public void InitializeDropdowns(string groupId, string reportId, string pageName) { if (cbGroup.Items.Count == 0) { return; } foreach (GroupProxy group in cbGroup.Items) { if (@group.Value.Id.ToUpper() != groupId.ToUpper()) { continue; } cbGroup.SelectedItem = group; cbReport.Items.Clear(); foreach (var report in group.Value.Reports) { var reportProxy = new ReportProxy { Text = report.Name, Value = report }; cbReport.Items.Add(reportProxy); } break; } foreach (ReportProxy report in cbReport.Items) { if (report.Value.Id.ToUpper() != reportId.ToUpper()) { continue; } cbReport.SelectedItem = report; cbPage.Items.Clear(); foreach (var page in report.Value.Pages) { var pageProxy = new PageProxy { Text = page.DisplayName, Value = page }; cbPage.Items.Add(pageProxy); } break; } foreach (PageProxy page in cbPage.Items) { if (page.Value.Name != pageName) { continue; } cbPage.SelectedItem = page; break; } }
/// <summary> /// Appends the CSS resource tag. /// </summary> /// <param name="pageProxy">The page proxy.</param> /// <param name="sb">The sb.</param> /// <param name="resourceAssemblyInfo">The resource assembly information.</param> /// <param name="resourceName">Name of the resource.</param> private void AppendStylesheetResourceTag(PageProxy pageProxy, ref StringBuilder sb, string resourceAssemblyInfo, string resourceName) { sb.AppendLine(); sb.Append("\t<link rel=\"stylesheet\" href=\""); if (resourceName.StartsWith("~/")) { sb.Append(VirtualPathUtility.ToAbsolute(resourceName)); } else { sb.Append(pageProxy.ClientScript.GetWebResourceUrl(TypeResolutionService.ResolveType(resourceAssemblyInfo), resourceName)); } sb.Append("\" type=\"text/css\" />"); }
public async Task <IPage <SimpleDocument <Blog> > > PageAsync(int pageSize, byte[] pagingState, DateTime?timeStampLowerBoundary = null, DateTime?timeStampUpperBoundary = null, string[] categories = null, string[] tags = null) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(); records = records.OrderBy(o => o.Document.TimeStamp).ToList(); var predicate = PredicateBuilder.True <SimpleDocument <Blog> >(); if (timeStampLowerBoundary != null) { predicate = predicate.And(i => i.Document.TimeStamp >= timeStampLowerBoundary); } if (timeStampUpperBoundary != null) { predicate = predicate.And(i => i.Document.TimeStamp <= timeStampUpperBoundary); } // this is an AND that return an OR match for tags and categories. List <string> safeTagList = (tags == null) ? null : new List <string>(tags); List <string> safeCategoriesList = (categories == null) ? null : new List <string>(categories); predicate = predicate.And(i => DelegateContainsAnyInTagsOrCategories(i.Document, safeTagList, safeCategoriesList)); var filtered = records.Where(predicate.Compile()).Select(i => i); var slice = filtered.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <SimpleDocument <Blog> >(currentPagingState, pagingState, slice); return(page); }
public async Task <IPage <SimpleDocument <RazorLocation> > > PageAsync(int pageSize, byte[] pagingState, DateTime?timeStampLowerBoundary = null, DateTime?timeStampUpperBoundary = null) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(); records = records.OrderBy(o => o.Document.LastModified).ToList(); var predicate = PredicateBuilder.True <SimpleDocument <RazorLocation> >(); if (timeStampLowerBoundary != null) { predicate = predicate.And(i => i.Document.LastModified >= timeStampLowerBoundary); } if (timeStampUpperBoundary != null) { predicate = predicate.And(i => i.Document.LastModified <= timeStampUpperBoundary); } var filtered = records.Where(predicate.Compile()).Select(i => i); var slice = filtered.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } var page = new PageProxy <SimpleDocument <RazorLocation> >(currentPagingState, pagingState, slice); return(page); }
/// <summary> /// Generates scripts tag needed on the page. Doesn't include any resources for the default themes as opposite to the hybrid mode which always includes the default frontend theme. /// </summary> /// <returns></returns> private string ResourceRegistrations() { var pageProxy = new PageProxy(string.Empty); StringBuilder sb = new StringBuilder(); string appPath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath; if (!appPath.EndsWith("/", StringComparison.Ordinal)) { appPath = string.Concat(appPath, "/"); } sb.Append(string.Concat("\t<script type=\"text/javascript\">var sf_appPath='", appPath, "';</script>")); // add the scripts for personalization in the page sb.Append("\t<script src=\""); sb.Append(pageProxy.ClientScript.GetWebResourceUrl(typeof(PageStatisticsJSClient), "Telerik.Sitefinity.Clients.JS.StatsClient.min.js")); sb.Append("\" type=\"text/javascript\"></script>"); return(sb.ToString()); }
public async Task <IPage <Client> > PageAsync(int pageSize, byte[] pagingState) { byte[] currentPagingState = pagingState; PagingState ps = pagingState.DeserializePageState(); var records = await RetrieveAsync(); records = records.OrderBy(o => o.Id).ToList(); var predicate = PredicateBuilder.True <ClientDocument>(); var filtered = records.Where(predicate.Compile()).Select(i => i); var slice = filtered.Skip(ps.CurrentIndex).Take(pageSize).ToList(); if (slice.Count < pageSize) { // we are at the end pagingState = null; } else { ps.CurrentIndex += pageSize; pagingState = ps.Serialize(); } List <Client> clientSlice = new List <Client>(); foreach (var item in slice) { var client = await item.MakeClientAsync(); clientSlice.Add(client); } var page = new PageProxy <Client>(currentPagingState, pagingState, clientSlice); return(page); }
public string GetTextWithoutPropertyTitle() { string[] propertiesToEdit = richTextBox1.Lines; StringBuilder sb = new StringBuilder(); for (int i = 0; i < listBox1.Items.Count; i++) { if (listBox1.GetSelected(i)) { PageProxy pp = (PageProxy)listBox1.Items[i]; foreach (string s in propertiesToEdit) { GSCore prop = pp.page.GetPropertyValue(s); if (!(prop is GSVoid)) { sb.AppendLine(); sb.AppendLine(prop.getStringValue()); } } } } sb.AppendLine(); return(sb.ToString()); }
private void cbReport_SelectedIndexChanged(object sender, EventArgs e) { if (cbReport.SelectedItem == null) { return; } var selectedReport = ((ReportProxy)cbReport.SelectedItem).Value; tbPbiUrl.Text = selectedReport.EmbedUrl.Split(new[] { "/reportEmbed" }, StringSplitOptions.None).FirstOrDefault(); tbReportId.Text = selectedReport.Id; tbPbiPage.Text = ""; cbPage.Items.Clear(); foreach (var page in selectedReport.Pages) { var pageProxy = new PageProxy { Text = page.DisplayName, Value = page }; cbPage.Items.Add(pageProxy); } }
public void CloseThisModal() { PageProxy.PopModal(); }
/// <summary> /// Generates HTML link tags to include CSS for all stylesheets needed on the page (coming from the theme). /// Provides an alternative for MVC where resources are inserted as pure HTML link tags instead of a ResourceLinks control, which is the case in the /// WebForms and hybrid modes. /// </summary> /// <param name="theme">The name of the theme</param> /// <returns></returns> private string ResourceRegistrations(string theme) { var pageProxy = new PageProxy(theme); var resources = ThemeController.GetGlobalStyles(pageProxy); if (resources == null) return null; StringBuilder sb = new StringBuilder(); this.AppendStylesheetResourceTag(pageProxy, ref sb, "Telerik.Sitefinity.Resources.Reference", "Telerik.Sitefinity.Resources.Themes.LayoutsBasics.css"); foreach (var link in resources.Links) { this.AppendStylesheetResourceTag(pageProxy, ref sb, link.AssemblyInfo, link.Name); } string appPath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath; if (!appPath.EndsWith("/")) appPath = string.Concat(appPath, "/"); sb.Append(String.Concat("\t<script type=\"text/javascript\">var sf_appPath='", appPath, "';</script>")); // add the scripts for personalization in the page sb.Append("\t<script src=\""); sb.Append(pageProxy.ClientScript.GetWebResourceUrl(typeof(PageStatisticsJSClient), "Telerik.Sitefinity.Clients.JS.StatsClient.min.js")); sb.Append("\" type=\"text/javascript\"></script>"); return sb.ToString(); }
/// <summary> /// Appends the CSS resource tag. /// </summary> /// <param name="pageProxy">The page proxy.</param> /// <param name="sb">The sb.</param> /// <param name="resourceAssemblyInfo">The resource assembly information.</param> /// <param name="resourceName">Name of the resource.</param> private void AppendStylesheetResourceTag(PageProxy pageProxy, ref StringBuilder sb, string resourceAssemblyInfo, string resourceName) { sb.AppendLine(); sb.Append("\t<link rel=\"stylesheet\" href=\""); if (resourceName.StartsWith("~/")) sb.Append(VirtualPathUtility.ToAbsolute(resourceName)); else sb.Append(pageProxy.ClientScript.GetWebResourceUrl(TypeResolutionService.ResolveType(resourceAssemblyInfo), resourceName)); sb.Append("\" type=\"text/css\" />"); }
/// <summary> /// Generates scripts tag needed on the page. Doesn't include any resources for the default themes as opposite to the hybrid mode which always includes the default frontend theme. /// </summary> /// <returns></returns> private string ResourceRegistrations() { var pageProxy = new PageProxy(string.Empty); StringBuilder sb = new StringBuilder(); string appPath = System.Web.Hosting.HostingEnvironment.ApplicationVirtualPath; if (!appPath.EndsWith("/", StringComparison.Ordinal)) appPath = string.Concat(appPath, "/"); sb.Append(string.Concat("\t<script type=\"text/javascript\">var sf_appPath='", appPath, "';</script>")); // add the scripts for personalization in the page sb.Append("\t<script src=\""); sb.Append(pageProxy.ClientScript.GetWebResourceUrl(typeof(PageStatisticsJSClient), "Telerik.Sitefinity.Clients.JS.StatsClient.min.js")); sb.Append("\" type=\"text/javascript\"></script>"); return sb.ToString(); }