private void stepFinalize_codeActivity_ExecuteCode(object sender, EventArgs e) { AddNewTreeRefresher addNewTreeRefresher = this.CreateAddNewTreeRefresher(this.EntityToken); IPage newPage = this.GetBinding <IPage>("NewPage"); newPage.SourceCultureName = UserSettings.ActiveLocaleCultureInfo.Name; Guid pageTypeId = newPage.PageTypeId; Guid?defaultPageTemplateId = PageServices.GetDefaultPageTemplateId(pageTypeId); if (defaultPageTemplateId != null) { newPage.TemplateId = defaultPageTemplateId.Value; } string sortOrder = this.GetBinding <string>("SelectedSortOrder"); Guid parentId = GetParentId(); using (new DataScope(DataScopeIdentifier.Administrated)) { IPageInsertionPosition position; if (sortOrder == SortOrder.Top) { position = PageInsertPosition.Top; } else if (sortOrder == SortOrder.Bottom) { position = PageInsertPosition.Bottom; } else if (sortOrder == SortOrder.Alphabetic) { position = PageInsertPosition.Alphabetic; } else if (sortOrder == SortOrder.Relative) { Guid relativeSelectedPageId = this.GetBinding <Guid>("RelativeSelectedPageId"); position = PageInsertPosition.After(relativeSelectedPageId); } else { throw new InvalidOperationException($"Not handled page instert position '{sortOrder}'"); } newPage = newPage.Add(parentId, position); } SetSaveStatus(true); addNewTreeRefresher.PostRefreshMesseges(newPage.GetDataEntityToken()); this.ExecuteWorklow(newPage.GetDataEntityToken(), typeof(EditPageWorkflow)); }
internal void AddPage(VirtualPage page, PageInsertPosition insertPosition) { if (page == null) { throw new ArgumentNullException("page", "TODOOC: An internal error occured while paging data. Page cannot be null."); } // We call clean-up before the call to AddFirst since if we do it afterward and the page is pending fill, we will remove it. this.CleanUpAndDisposeUnused(); if (insertPosition == PageInsertPosition.Front) { m_pageNodes.AddFirst(page); } else { m_pageNodes.AddLast(page); } Debug.WriteLineIf(VirtualPageManager.DebugDataVirtualization, "Added To " + ((insertPosition == PageInsertPosition.Front) ? "Front" : "Back") + ": Page " + page.ToString()); }
internal void AddPage( VirtualPage page, PageInsertPosition insertPosition ) { if( page == null ) throw new ArgumentNullException( "page", "TODOOC: An internal error occured while paging data. Page cannot be null." ); // We call clean-up before the call to AddFirst since if we do // it afterward and the page is pending fill, we will remove it. this.CleanUpAndDisposeUnused(); if( insertPosition == PageInsertPosition.Front ) { m_pageNodes.AddFirst( page ); } else { m_pageNodes.AddLast( page ); } Debug.WriteLineIf( VirtualPageManager.DebugDataVirtualization, "Added To " + ( ( insertPosition == PageInsertPosition.Front ) ? "Front" : "Back" ) + ": Page " + page.ToString() ); }
private IData CloneData <T>(T data) where T : class, IData { IData newdata = DataFacade.BuildNew <T>(); var dataProperties = typeof(T).GetPropertiesRecursively(); foreach (var propertyInfo in dataProperties.Where(f => f.CanWrite)) { if (typeof(T).GetPhysicalKeyProperties().Contains(propertyInfo) && propertyInfo.PropertyType == typeof(Guid)) { propertyInfo.SetValue(newdata, Guid.NewGuid()); } else { propertyInfo.SetValue(newdata, propertyInfo.GetValue(data)); } } var page = data as IPage; if (page != null) { if (IsRootPage(page)) { SetNewValue <T>(page, newdata, dataProperties.First(p => p.Name == nameof(IPage.Title))); } else if (!SetNewValue <T>(page, newdata, dataProperties.First(p => p.Name == nameof(IPage.MenuTitle)))) { SetNewValue <T>(page, newdata, dataProperties.First(p => p.Name == nameof(IPage.Title))); } SetNewValue <T>(page, newdata, dataProperties.First(p => p.Name == nameof(IPage.UrlTitle)), isUrl: true); PageInsertPosition.After(page.Id).CreatePageStructure(newdata as IPage, page.GetParentId()); } else { var labelProperty = typeof(T).GetProperty( DynamicTypeReflectionFacade.GetLabelPropertyName(typeof(T))); if (labelProperty != null && labelProperty.PropertyType == typeof(string)) { SetNewValue <T>(data, newdata, labelProperty); } } if (newdata is IPublishControlled) { (newdata as IPublishControlled).PublicationStatus = GenericPublishProcessController.Draft; } if (newdata is ILocalizedControlled) { (newdata as ILocalizedControlled).SourceCultureName = UserSettings.ActiveLocaleCultureInfo.Name; } newdata = DataFacade.AddNew(newdata); if (data is IPage) { CopyPageData(data as IPage, newdata as IPage); } return(newdata); }