private Footer CreateFooter() { RadDocument footerDocument = new RadDocument(); RadDocumentEditor editor = new RadDocumentEditor(footerDocument); editor.InsertTable(1, 2); editor.ChangeStyleName(RadDocumentDefaultStyles.DefaultNormalTableStyleName); editor.Document.Selection.SelectAll(); editor.ChangeFontFamily(new FontFamily("Arial")); editor.ChangeForeColor(Color.FromRgb(29, 192, 34)); editor.ChangeFontSize(Unit.PointToDip(10)); editor.Document.Selection.Clear(); editor.Insert("Copyright © 2002-2015 Telerik. All rights reserved."); var table = editor.Document.EnumerateChildrenOfType <Table>().FirstOrDefault(); editor.Document.CaretPosition.MoveToStartOfDocumentElement(table.Rows.First.Cells.Last); table.Grid.Columns.Last().PreferredWidth = new TableWidthUnit(20); PageField field = new PageField(); editor.InsertField(field, FieldDisplayMode.Result); editor.ChangeParagraphTextAlignment(RadTextAlignment.Right); Footer footer = new Footer() { Body = footerDocument }; return(footer); }
internal void FromPageField(PageField pf) { this.SetAllNull(); if (pf.Field != null) { this.Field = pf.Field.Value; } if (pf.Item != null) { this.Item = pf.Item.Value; } if (pf.Hierarchy != null) { this.Hierarchy = pf.Hierarchy.Value; } if (pf.Name != null) { this.Name = pf.Name.Value; } if (pf.Caption != null) { this.Caption = pf.Caption.Value; } }
/// <summary> /// Adds a new PageField. /// </summary> public PageField AddPageField() { PageField fieldPage = new PageField(); Add(fieldPage); return(fieldPage); }
/// <summary> /// Determines the field data type of a configured page field. /// </summary> /// <param name="field">The page configured field</param> /// <returns>The field data type</returns> public static Field.DBType GetFieldDataType(PageField field) { if (field.Type.Contains("time")) { return(Field.DBType.DateTime); } else if (field.Type.Contains("date")) { return(Field.DBType.Date); } else if (field.Type == "int" || field.Type == "smallint") { return(Field.DBType.Integer); } else if (field.Type == "float" || field.Type == "decimal" || field.Type == "money") { return(Field.DBType.Decimal); } else if (field.Type.Contains("bit")) { return(Field.DBType.Bit); } if (field.Type == "varbinary") { return(Field.DBType.Varbinary); } if (field.Type == "encrypt") { return(Field.DBType.Encrypt); } return(Field.DBType.Varchar); }
public override string GetTitle() { if (!PageField.op_Inequality(this.get_Body(), null) || this.get_Body().get_Page() == null) { return("No page selected"); } return(this.get_Body().get_Page().get_Title()); }
/// <summary> /// Generates a local url for the given page field. /// </summary> /// <param name="app">The application service</param> /// <param name="field">The field</param> /// <returns>The url</returns> public static string Url(this IApplicationService app, PageField field) { if (field != null) { return(Url(app, field.Page)); } return(""); }
/// <summary> /// Creates an Entity representing the join configuration by deserializing the json configured value. /// </summary> /// <param name="field">The page field</param> /// <returns>The entity representing the join config.</returns> public static Entity GetJoinInfoEntity(PageField field) { Entity joinInfo = new Entity(); Dictionary <string, string> props = new JavaScriptSerializer().Deserialize <Dictionary <string, string> >(field.JoinInfo); joinInfo.SetProperties(props); return(joinInfo); }
internal void FromPageField(PageField pf) { this.SetAllNull(); if (pf.Field != null) this.Field = pf.Field.Value; if (pf.Item != null) this.Item = pf.Item.Value; if (pf.Hierarchy != null) this.Hierarchy = pf.Hierarchy.Value; if (pf.Name != null) this.Name = pf.Name.Value; if (pf.Caption != null) this.Caption = pf.Caption.Value; }
/// <summary> /// Deserializes the given field value. /// </summary> /// <param name="field">The page field</param> /// <returns>The value</returns> private object DeserializeValue(PageField field) { var type = App.Fields.GetByType(field.CLRType); if (type != null) { return(JsonConvert.DeserializeObject(field.Value, type.Type)); } return(null); }
internal PageField ToPageField() { PageField pf = new PageField(); pf.Field = this.Field; if (this.Item != null) pf.Item = this.Item.Value; pf.Hierarchy = this.Hierarchy; if (this.Name != null && this.Name.Length > 0) pf.Name = this.Name; if (this.Caption != null && this.Caption.Length > 0) pf.Caption = this.Caption; return pf; }
public async Task <IHttpActionResult> GetByIdAsync(int id, PageField fields, CancellationToken cancellationToken) { var page = await _portalManager.GetPageByIdAsync(id, fields | PageField.Portal, cancellationToken); if (page == null) { return(NotFound()); } await ApiSecurity.AuthorizeAsync(AccessObjectType.Portal, page.Portal.Id, AccessPermission.CanView, cancellationToken); return(Ok(ModelMapper.ToPageDto(page))); }
// Identify Field Properties public void Id_PageFields_Prop(List <StringBuilder> _PageList, Page _Page) { int fieldCount = 0; foreach (StringBuilder field in _PageList) { // Convert StringBuilder to String string _nField = field.ToString(); // ID Field Type string fieldType; if (_Page.IsTest) { fieldType = "Test"; } else if (_nField.EndsWith(":")) { fieldType = "Definition"; } else if (_nField.StartsWith("1.") && _PageList.ToString().Contains("?")) { fieldType = "Question"; } else { fieldType = "Paragraph"; } PageField nField = new PageField { // PageFieldId // Automatic from Constructor // PageId PageId = _Page.PageId, // BooleanQuestionId // FieldType FieldType = fieldType, // Content Content = _nField, // FinalEssay // FieldNumber FieldNumber = fieldCount // FieldTitle // FieldTitle // FieldReference }; fieldCount++; } }
/// <summary> /// Sets the value of a simple single field region. /// </summary> /// <typeparam name="T">The model type</typeparam> /// <param name="model">The model</param> /// <param name="regionId">The region id</param> /// <param name="field">The field</param> private void SetSimpleValue <T>(T model, string regionId, PageField field) where T : Models.Page <T> { if (model is Models.DynamicPage) { ((IDictionary <string, object>)((Models.DynamicPage)(object) model).Regions)[regionId] = DeserializeValue(field); } else { model.GetType().GetProperty(regionId, App.PropertyBindings).SetValue(model, DeserializeValue(field)); } }
/// <summary> /// Deserializes the given field value. /// </summary> /// <param name="field">The page field</param> /// <returns>The value</returns> private object DeserializeValue(PageField field) { var type = App.Fields.GetByType(field.CLRType); if (type != null) { var val = (Extend.IField)App.DeserializeObject(field.Value, type.Type); if (val != null) { val.Init(api); } return(val); } return(null); }
public object Deserialize(string str) { stackVariable0 = new PageField(); if (!String.IsNullOrEmpty(str)) { stackVariable5 = new Guid?(new Guid(str)); } else { V_0 = null; stackVariable5 = V_0; } stackVariable0.set_Id(stackVariable5); return(stackVariable0); }
// [UnitTestFunction] public static void TestFields() { Document doc = new Document(); doc.Info.Author = "K.P."; Section sec = doc.Sections.AddSection(); Paragraph par = sec.AddParagraph(); par.AddBookmark("myBookmark1"); PageRefField prf = par.AddPageRefField("myBookmark1"); prf.Format = "ALPHABETIC"; PageField pf = par.AddPageField(); pf.Format = "ROMAN"; SectionField sf = par.AddSectionField(); sf.Format = "roman"; SectionPagesField spf = par.AddSectionPagesField(); spf.Format = "roman"; NumPagesField npf = par.AddNumPagesField(); npf.Format = "alphabetic"; InfoField inf = par.AddInfoField(InfoFieldType.Author); DateField df = par.AddDateField("D"); df = par.AddDateField("d"); df = par.AddDateField("s"); df = par.AddDateField("r"); df = par.AddDateField("G"); df = par.AddDateField("dddd dd.MM.yyyy"); DocumentRenderer docRndrr = new DocumentRenderer(); docRndrr.Render(doc, "RtfFields.txt", null); File.Copy("RtfFields.txt", "RtfFields.rtf", true); System.Diagnostics.Process.Start("RtfFields.txt"); }
/// <summary> /// Sets the value of a complex region. /// </summary> /// <typeparam name="T">The model</typeparam> /// <param name="model">The model</param> /// <param name="regionId">The region id</param> /// <param name="fieldId">The field id</param> /// <param name="field">The field</param> private void SetComplexValue <T>(T model, string regionId, string fieldId, PageField field) where T : Models.Page <T> { if (model is Models.DynamicPage) { ((IDictionary <string, object>)((IDictionary <string, object>)((Models.DynamicPage)(object) model).Regions)[regionId])[fieldId] = DeserializeValue(field); } else { var obj = model.GetType().GetProperty(regionId, App.PropertyBindings).GetValue(model); if (obj != null) { obj.GetType().GetProperty(fieldId, App.PropertyBindings).SetValue(obj, DeserializeValue(field)); } } }
private void AddPageFooter() { RadDocument document = new RadDocument(); Section sectionf = new Section(); Paragraph paragraphPageField = new Paragraph() { TextAlignment = RadTextAlignment.Right }; PageField pageField = new PageField() { DisplayMode = FieldDisplayMode.Result }; FieldRangeStart pageFieldStart = new FieldRangeStart(); pageFieldStart.Field = pageField; FieldRangeEnd pageFieldEnd = new FieldRangeEnd(); pageFieldEnd.Start = pageFieldStart; paragraphPageField.Inlines.Add(pageFieldStart); paragraphPageField.Inlines.Add(pageFieldEnd); FieldRangeStart numPagesFieldStart = new FieldRangeStart(); numPagesFieldStart.Field = new NumPagesField() { DisplayMode = FieldDisplayMode.Result }; FieldRangeEnd numPagesFieldEnd = new FieldRangeEnd(); numPagesFieldEnd.Start = numPagesFieldStart; paragraphPageField.Inlines.Add(new Span("/")); paragraphPageField.Inlines.Add(numPagesFieldStart); paragraphPageField.Inlines.Add(numPagesFieldEnd); sectionf.Blocks.Add(paragraphPageField); document.Sections.Add(sectionf); Document.Sections.First.Footers.Default.Body = document; //Document.Sections.Last.Blocks.AddAfter(Document.Sections.Last.Blocks.Last, paragraphPageField); //Document.Sections.Last.Footers.Default.Body.InsertFragment(new DocumentFragment(document)); }
internal PageField ToPageField() { var pf = new PageField(); pf.Field = Field; if (Item != null) { pf.Item = Item.Value; } pf.Hierarchy = Hierarchy; if ((Name != null) && (Name.Length > 0)) { pf.Name = Name; } if ((Caption != null) && (Caption.Length > 0)) { pf.Caption = Caption; } return(pf); }
internal PageField ToPageField() { PageField pf = new PageField(); pf.Field = this.Field; if (this.Item != null) { pf.Item = this.Item.Value; } pf.Hierarchy = this.Hierarchy; if (this.Name != null && this.Name.Length > 0) { pf.Name = this.Name; } if (this.Caption != null && this.Caption.Length > 0) { pf.Caption = this.Caption; } return(pf); }
/// <summary> /// Determines if a field contains join information /// </summary> /// <param name="field">The configured field.</param> /// <param name="page">The page config that contains the field.</param> /// <returns>True if the fields contains join info false otherwise.</returns> public static bool IsForeignKey(PageField field, Page page) { return(!string.IsNullOrEmpty(field.JoinInfo)); }
public Teaser() { PageLink = new PageField(); PostLink = new PostField(); }
/// <summary> /// Generates an absolute url for the given page field. /// </summary> /// <param name="app">The application service</param> /// <param name="field">The field</param> /// <returns>The url</returns> public static string AbsoluteUrl(this IApplicationService app, PageField field) { return($"{ AbsoluteUrlStart(app) }{ Url(app, field) }"); }
public void AddField(FieldType fieldType, string description, bool required) { var id = Guid.NewGuid().ToString(); var pageField = new PageField(fieldType, description, id, required); }
public Menu() { PageLink = new PageField(); PostLink = new PostField(); }
private Footer CreateFooter() { RadDocument footerDocument = new RadDocument(); RadDocumentEditor editor = new RadDocumentEditor(footerDocument); editor.InsertTable(1, 2); editor.ChangeStyleName(RadDocumentDefaultStyles.DefaultNormalTableStyleName); editor.Document.Selection.SelectAll(); editor.ChangeFontFamily(new FontFamily("Arial")); editor.ChangeForeColor(Color.FromRgb(29, 192, 34)); editor.ChangeFontSize(Unit.PointToDip(10)); editor.Document.Selection.Clear(); editor.Insert("Copyright © 2002-2015 Telerik. All rights reserved."); var table = editor.Document.EnumerateChildrenOfType<Table>().FirstOrDefault(); editor.Document.CaretPosition.MoveToStartOfDocumentElement(table.Rows.First.Cells.Last); table.Grid.Columns.Last().PreferredWidth = new TableWidthUnit(20); PageField field = new PageField(); editor.InsertField(field, FieldDisplayMode.Result); editor.ChangeParagraphTextAlignment(RadTextAlignment.Right); Footer footer = new Footer() { Body = footerDocument }; return footer; }
public PartnersBlock() { PartnersPage = new PageField(); }
public ArtistsBlock() { ArtistsPage = new PageField(); }
/// <summary> /// Maps a region to the given data entity. /// </summary> /// <typeparam name="T">The model type</typeparam> /// <param name="model">The model</param> /// <param name="page">The data entity</param> /// <param name="region">The region to map</param> /// <param name="regionType">The region type</param> /// <param name="regionId">The region id</param> /// <param name="sortOrder">The optional sort order</param> private IList <Guid> MapRegion <T>(T model, Page page, object region, Models.RegionType regionType, string regionId, int sortOrder = 0) where T : Models.Page <T> { var items = new List <Guid>(); // Now map all of the fields for (var n = 0; n < regionType.Fields.Count; n++) { var fieldDef = regionType.Fields[n]; var fieldType = App.Fields.GetByShorthand(fieldDef.Type); if (fieldType == null) { fieldType = App.Fields.GetByType(fieldDef.Type); } if (fieldType != null) { object fieldValue = null; if (regionType.Fields.Count == 1) { // Get the field value for simple region fieldValue = region; } else { // Get the field value for complex region fieldValue = GetComplexValue(region, fieldDef.Id); } if (fieldValue != null) { // Check that the returned value matches the type specified // for the page type, otherwise deserialization won't work // when the model is retrieved from the database. if (fieldValue.GetType() != fieldType.Type) { throw new ArgumentException("Given page field value does not match the configured page type"); } // Check if we have the current field in the database already var field = page.Fields .SingleOrDefault(f => f.RegionId == regionId && f.FieldId == fieldDef.Id && f.SortOrder == sortOrder); // If not, create a new field if (field == null) { field = new PageField() { Id = Guid.NewGuid(), PageId = page.Id, RegionId = regionId, FieldId = fieldDef.Id }; page.Fields.Add(field); } // Update field info & value field.CLRType = fieldType.TypeName; field.SortOrder = sortOrder; field.Value = App.SerializeObject(fieldValue, fieldType.Type); items.Add(field.Id); } } } return(items); }
/// <summary> /// Convert the whole ResultSet into a Page objects. /// </summary> /// <param name="rs">The ResultSet to process.</param> /// <returns>The Initialize Page objects</returns> public T Handle(DbDataReader rs) { T result = default(T); Page page = null; bool firstTime = true; PageTab prevTab = null; while (rs.Read()) { if (firstTime) { page = processor.ToBean <Page>(rs, typeof(Page)); firstTime = false; } string tabId = rs["TabId"].ToString(); if (!String.IsNullOrEmpty(tabId)) { PageTab currentTab = prevTab; if (prevTab == null || !tabId.Equals(prevTab.TabId)) { currentTab = processor.ToBean <PageTab>(rs, typeof(PageTab)); page.Tabs.Add(currentTab); } string fieldId = rs["FieldId"].ToString(); if (!String.IsNullOrEmpty(fieldId)) { PageField field = processor.ToBean <PageField>(rs, typeof(PageField)); string columnId = rs["ColumnId"].ToString(); if (!String.IsNullOrEmpty(columnId)) { PageGridColumn column = processor.ToBean <PageGridColumn>(rs, typeof(PageGridColumn)); if (String.IsNullOrEmpty(column.ColumnName)) { column.ColumnName = field.FieldName; } if (String.IsNullOrEmpty(column.ColumnLabel)) { column.ColumnLabel = field.Label; } page.GridFields.Add(column); } currentTab.Fields.Add(field); prevTab = currentTab; } } } result = (T)Convert.ChangeType(page, type); return(result); }
public Footer() { PageLink = new PageField(); PostLink = new PostField(); }
/// <summary> /// Adds a new PageField /// </summary> public void Add(PageField pageField) { this.Elements.Add(pageField); }
/// <summary> /// Maps a region to the given data entity. /// </summary> /// <typeparam name="T">The model type</typeparam> /// <param name="model">The model</param> /// <param name="page">The data entity</param> /// <param name="region">The region to map</param> /// <param name="regionType">The region type</param> /// <param name="regionId">The region id</param> /// <param name="sortOrder">The optional sort order</param> /// <param name="transaction">The optional transaction</param> private void MapRegion <T>(T model, Page page, object region, Models.RegionType regionType, string regionId, int sortOrder = 0, IDbTransaction transaction = null) where T : Models.Page <T> { // Now map all of the fields for (var n = 0; n < regionType.Fields.Count; n++) { var isNew = false; var fieldDef = regionType.Fields[n]; var fieldType = App.Fields.GetByShorthand(fieldDef.Type); if (fieldType == null) { fieldType = App.Fields.GetByType(fieldDef.Type); } if (fieldType != null) { object fieldValue = null; if (regionType.Fields.Count == 1) { // Get the field value for simple region fieldValue = region; } else { // Get the field value for complex region fieldValue = GetComplexValue(region, fieldDef.Id); } if (fieldValue != null) { // Check that the returned value matches the type specified // for the page type, otherwise deserialization won't work // when the model is retrieved from the database. if (fieldValue.GetType() != fieldType.Type) { throw new ArgumentException("Given page field value does not match the configured page type"); } // Check if we have the current field in the database already var field = page.Fields .SingleOrDefault(f => f.RegionId == regionId && f.FieldId == fieldDef.Id && f.SortOrder == sortOrder); // If not, create a new field if (field == null) { field = new PageField() { Id = Guid.NewGuid().ToString(), PageId = page.Id, RegionId = regionId, FieldId = fieldDef.Id }; page.Fields.Add(field); isNew = true; } // Update field info & value field.CLRType = fieldType.TypeName; field.SortOrder = sortOrder; field.Value = App.SerializeObject(fieldValue, fieldType.Type); // Save the field if (isNew) { db.Execute("INSERT INTO [Piranha_PageFields] ([Id], [PageId], [RegionId], [FieldId], [CLRType], [SortOrder], [Value]) VALUES(@Id, @PageId, @RegionId, @FieldId, @CLRType, @SortOrder, @Value)", field, transaction: transaction); } else { db.Execute("UPDATE [Piranha_PageFields] Set [PageId]=@PageId, [RegionId]=@RegionId, [FieldId]=@FieldId, [CLRType]=@CLRType, [SortOrder]=@SortOrder, [Value]=@Value WHERE [Id]=@Id", field, transaction: transaction); } } } } }