public Task <List <PageMetadataProvider> > GetPageTypesAsync(IPageCollection collection) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } var basePageType = pageMetadataManager.FindPageMetadataByName(collection.PageTypeName); if (basePageType == null) { throw new InvalidOperationException(); } var result = new List <PageMetadataProvider>(); foreach (var pageType in basePageType.GetDerivedMetadataWithHierarhy(true)) { if (pageType.ContentType.IsAbstract) { continue; } result.Add(pageType); } return(Task.FromResult(result)); }
public MetadataManager(IPageManager pageAllocator, HeapWithOffsets <char[]> stringHeap, IBootPageAllocator bootPageAllocator, ILogManager logManager) { this.pageAllocator = pageAllocator; this.stringHeap = stringHeap; this.logManager = logManager; if (!bootPageAllocator.BootPageInitialized()) { using (ITransaction tran = this.logManager.CreateTransaction(this.pageAllocator, false, "GET_BOOT_PAGE")) using (Releaser releaser = tran.AcquireLock(IBootPageAllocator.BootPageId, LockManager.LockTypeEnum.Exclusive).Result) { bootPageAllocator.AllocatePageBootPage(PageType.MixedPage, this.masterPageColumnDefinition, tran); this.masterMetadataCollection = new PageListCollection(this.pageAllocator, this.masterPageColumnDefinition, IBootPageAllocator.BootPageId); tran.Commit(); } MetadataInitialSetup(); } else { using (ITransaction tran = this.logManager.CreateTransaction(this.pageAllocator, false, "GET_BOOT_PAGE")) { using Releaser releaser = tran.AcquireLock(IBootPageAllocator.BootPageId, LockManager.LockTypeEnum.Exclusive).Result; this.masterMetadataCollection = new PageListCollection(this.pageAllocator, this.masterPageColumnDefinition, IBootPageAllocator.BootPageId); tran.Commit(); } } }
private void Load(IDocumentData data) { var flags = FlagsManager.LoadFlags(DefaultMerger.AddDefaults(data.DocumentWideFlags)); this.pageCollection = this.elementFactory.CreatePageCollection(flags); this.pageCollection.SetCursor(false, this.cursor); }
public async Task <bool> MoveNextAsync(CancellationToken cancellationToken) { if (currentPageCollection == null) { return(false); } if (currentEnumerator.MoveNext()) { return(true); } if (currentPageCollection.NextUri == null) { return(false); } currentPageCollection = await currentPageCollection.ReadNextAsync(cancellationToken).ConfigureAwait(false); if (currentPageCollection == null) { return(false); } currentEnumerator.Dispose(); currentEnumerator = currentPageCollection.GetEnumerator(); return(currentEnumerator.MoveNext()); }
public async Task <IPage> CreatePageAsync(IPageCollection collection, string pageType = null, string pageHeader = null, CancellationToken cancellationToken = default) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (pageType == null) { pageType = collection.PageTypeName; } var basePageMetadata = pageMetadataManager.GetMetadata(collection.PageTypeName); var pageMetadata = pageMetadataManager.GetMetadata(pageType); if (!pageMetadata.AllowCreateModel) { throw new InvalidOperationException($"Нельзя создать страницу с типом {pageMetadata.Name}, так как её тип контент является абстрактным."); } if (!pageMetadata.IsInheritedOrEqual(basePageMetadata)) { throw new ArgumentException($"Тип страницы {pageType} не подходит для коллекции {collection.Title} ({collection.Id})."); } var pageContent = pageMetadata.CreatePageModel(); ApplyDefaultDataToContentModel(pageMetadata, pageContent, pageHeader); var pageContentData = pageMetadata.ContentMetadata.ConvertContentModelToDictionary(pageContent); pageHeader = pageMetadata.GetPageHeader(pageContent); var page = await pageRepositiry.CreatePageAsync(collection.WebsiteId, collection.Id, pageMetadata.Name, pageHeader, pageContentData, cancellationToken); if (collection.CustomSorting) { switch (collection.SortMode) { case PageSortMode.FirstNew: { await UpPagePositionAsync(page, null, cancellationToken); break; } case PageSortMode.FirstOld: { await DownPagePositionAsync(page, null, cancellationToken); break; } default: throw new Exception(); } } return(page); }
private void New() { var flags = FlagsManager.LoadFlags(Defaults.DocumentWideFlags); this.pageCollection = this.elementFactory.CreatePageCollection(flags); // TODO: Set back to page collection this.pageCollection.Region.SetParent(this.frame); this.pageCollection.Region.SetPoint(FramePoint.TOPLEFT, this.frame, FramePoint.TOPLEFT, 20, -20); this.pageCollection.SetCursor(false, this.cursor); }
public PageCollectionReadToEndEnumerable(IPageCollection <T> pageCollection) { if (pageCollection == null) { throw new ArgumentNullException(nameof(pageCollection)); } this.pageCollection = pageCollection; }
public CurrentConfig(IConfig config) { _config = config; SetSiteConfig(_config.Environment.Site); SetBrowserConfig(_config.Environment.Browser); SetLoginConfig(_config.Environment.Login); Pages = new PageCollection(); }
public MetadataColumnsManager(IAllocateMixedPage pageAllocator, MixedPage firstPage, HeapWithOffsets <char[]> stringHeap) { if (pageAllocator == null || firstPage == null) { throw new ArgumentNullException(); } this.pageListCollection = new PageListCollection(pageAllocator, columnDefinitions, firstPage.PageId()); this.stringHeap = stringHeap; }
public PageCollectionReadToEndEnumerator(IPageCollection <T> pageCollection) { if (pageCollection == null) { throw new ArgumentNullException(nameof(pageCollection)); } this.initialPageCollection = pageCollection; this.currentPageCollection = pageCollection; this.currentEnumerator = pageCollection.GetEnumerator(); }
public Task UpdateCollectionAsync(IPageCollection collection, CancellationToken cancellationToken = default) { if (!collectionIds.TryGetValue(collection.Id, out int index)) { throw new InvalidOperationException(); } collections[index] = (PageCollection)collection; return(Task.CompletedTask); }
public void OnRemoveCollection(IPageCollection pageCollection) { var pages = pagesByCollections[pageCollection.Id]; if (pages.Count > 0) { throw new InvalidOperationException("Нельзя удалить коллекцию страниц, так как она содержит страницы."); } collectionsByPages[pageCollection.PageId ?? Guid.Empty].Remove(pageCollection); pagesByCollections.Remove(pageCollection.Id); }
public MetadataTablesManager(IAllocateMixedPage pageAllocator, MixedPage firstPage, HeapWithOffsets <char[]> stringHeap, IMetadataObjectManager <MetadataColumn, ColumnCreateDefinition, Tuple <int, int> > columnManager) { if (pageAllocator == null || firstPage == null || columnManager == null) { throw new ArgumentNullException(); } this.pageListCollection = new PageListCollection(pageAllocator, columnDefinitions, firstPage.PageId()); this.stringHeap = stringHeap; this.columnManager = columnManager; this.pageAllocator = pageAllocator; }
private PageCollectionModel GetPageCollectionModel(IPageCollection pageCollection) { return(new PageCollectionModel { Id = pageCollection.Id, CreatedDate = pageCollection.CreatedDate, PageId = pageCollection.PageId, Title = pageCollection.Title, PageType = pageCollection.PageTypeName, Sort = pageCollection.SortMode }); }
public async Task <Result> UpdateCollectionAsync(IPageCollection collection, CancellationToken cancellationToken = default) { try { await repositiry.UpdateCollectionAsync(collection, cancellationToken); return(Result.Success); } catch (Exception ex) { return(Result.Failed(ex)); } }
public Task DeleteCollectionAsync(IPageCollection collection, CancellationToken cancellationToken = default) { if (!collectionIds.TryGetValue(collection.Id, out int index)) { throw new InvalidOperationException(); } pageHierarhy.OnRemoveCollection(collection); collectionIds.Remove(collection.Id); collections.Remove(index); return(Task.CompletedTask); }
public async Task DeleteCollectionAsync(IPageCollection collection, CancellationToken cancellationToken = default) { var collectionDocument = (PageCollectionDocument)collection; var curVersion = collectionDocument.Version; collectionDocument.Version++; var deleteResult = await documents.DeleteOneAsync(it => it.Id == collection.Id && it.Version == curVersion, cancellationToken : cancellationToken); if (deleteResult.DeletedCount != 1) { throw new InvalidOperationException(); } }
public PhyOpScan(IPageCollection <RowHolder> collection, ITransaction tran, MetadataColumn[] scanColumnInfo, string collectionName) { this.source = collection; this.tran = tran; this.collectionName = collectionName; this.scanColumnInfo = new MetadataColumn[scanColumnInfo.Length]; for (int i = 0; i < scanColumnInfo.Length; i++) { this.scanColumnInfo[i] = new MetadataColumn( scanColumnInfo[i].ColumnId, scanColumnInfo[i].TableId, collectionName + "." + scanColumnInfo[i].ColumnName, scanColumnInfo[i].ColumnType); } }
public static void SetConfig(string configPath) { _config = new CurrentConfig(GetConfig.UseJsonFile(configPath) .UseTypeParser(new DictionaryParser()) .Build()); Site = _config.Site; Browser = _config.Browser; Pages = _config.Pages; if (_config.Login == null) { return; } Login = _config.Login; }
protected override async Task OnInitializeAsync() { if (!RouteData.Values.TryGetValue("id", out object pageCollectionIdValue)) { AddErrors("Not valid id."); return; } if (!Guid.TryParse(pageCollectionIdValue.ToString(), out Guid pageCollectionId)) { AddErrors("Not valid id."); return; } pageCollection = await pageCollectionService.FindCollectiondByIdAsync(pageCollectionId); if (pageCollection == null) { AddErrors("Not found page collection."); return; } }
protected override async Task OnInitializeAsync() { if (!Request.Query.TryGetValue("collectionId", out string pageCollectionIdValue)) { AddErrors("Not valid id."); return; } if (!Guid.TryParse(pageCollectionIdValue, out Guid pageCollectionId)) { AddErrors("Not valid id."); return; } pageCollection = await pageCollectionService.FindCollectiondByIdAsync(pageCollectionId); if (pageCollection == null) { AddErrors("Not found page collection."); return; } }
private async Task <PageCollectionModel> GetPageCollectionModelAsync(IPageCollection pageCollection) { string pageUrl = "/"; if (pageCollection.PageId.HasValue) { IPage page = await pageService.FindPageByIdAsync(pageCollection.PageId.Value); pageUrl = await pageLinkGenerator.GetPathAsync(page); } return(new PageCollectionModel { Id = pageCollection.Id, CreatedDate = pageCollection.CreatedDate, PageId = pageCollection.PageId, Title = pageCollection.Title, PageType = pageCollection.PageTypeName, Sort = pageCollection.SortMode, CustomSorting = pageCollection.CustomSorting, PageUrl = pageUrl }); }
public void OnAddCollection(Guid?pageId, IPageCollection pageCollection) { if (pageId.HasValue) { if (!collectionsByPages.TryGetValue(pageId.Value, out IList <IPageCollection> pageCollectionsByPages)) { throw new InvalidOperationException(); } pageCollectionsByPages.Add(pageCollection); } else { if (!collectionsByWebSites.TryGetValue(pageCollection.WebsiteId, out IList <IPageCollection> pageCollectionsByWebsites)) { collectionsByWebSites.Add(pageCollection.WebsiteId, pageCollectionsByWebsites = new List <IPageCollection>()); } pageCollectionsByWebsites.Add(pageCollection); } pagesByCollections.Add(pageCollection.Id, new List <IPage>()); }
public async Task <Result> DeleteCollectionAsync(IPageCollection collection, CancellationToken cancellationToken = default) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } if (await pageRepositiry.HasPagesAsync(collection.Id)) { return(Result.Failed("Нельзя удалить коллекцию страниц, которая содержит страницы.")); } try { await repositiry.DeleteCollectionAsync(collection, cancellationToken); return(Result.Success); } catch (Exception ex) { return(Result.Failed(ex)); } }
public static Task <IPage> CreatePageAsync <TContent>(this IPageService pageService, IPageCollection collection, TContent pageContent, CancellationToken cancellationToken = default) where TContent : class { return(pageService.CreatePageAsync(collection, pageContent, cancellationToken)); }
/// <summary> /// 转换分页实体 /// </summary> /// <typeparam name="TSource">原类型</typeparam> /// <typeparam name="TTarget">目标类型</typeparam> /// <param name="sourcePageCollection">源分页实体</param> /// <param name="convert">转换的方法</param> /// <returns></returns> public static IPageCollection <TTarget> Convert <TSource, TTarget>(this IPageCollection <TSource> sourcePageCollection, Func <TSource, TTarget> convert) { return(new PageCollection <TTarget>(sourcePageCollection.Data.Select(a => convert(a)), sourcePageCollection.RecordCount, sourcePageCollection.PageIndex, sourcePageCollection.PageSize)); }
public PhyOpTableInsert(IPageCollection <RowHolder> pageCollection, IPhysicalOperator <RowHolder> input) { this.pageCollection = pageCollection; this.input = input; }