Пример #1
0
        private TableColumnType CreateTableColumn(string width)
        {
            var tableColumn = new TableColumnType();

            tableColumn.Items = new object[] { width };
            return(tableColumn);
        }
        private TableColumnType CreateTableColumn()
        {
            TableColumnType tableColumn = new TableColumnType();

            tableColumn.Items = new object[] { "2in" };
            return(tableColumn);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TableColumn"/> class.
 /// </summary>
 /// <param name="header">The <see cref="string"/> instance to use as the table column header.</param>
 public TableColumn(string header,
                    TableColumnType columnType     = TableColumnType.Default,
                    TableColumnAlignment alignment = TableColumnAlignment.Left)
 {
     Header     = header ?? throw new ArgumentNullException(nameof(header));
     Alignment  = alignment;
     ColumnType = columnType;
 }
 public PublicStringTableColumn(
     TableColumnType columnType,
     string columnIdentifierName,
     string title,
     Expression <Func <T, string> > lambdaExpression)
     : base(columnType, columnIdentifierName, title)
 {
     _lambdaExpression = lambdaExpression;
 }
Пример #5
0
 /// <summary>
 /// ctor
 /// </summary>
 /// <param name="name"></param>
 /// <param name="tableColumnType"></param>
 /// <param name="isIdentity"></param>
 /// <param name="defaultValue"></param>
 public TableColumnAttribute(string name, TableColumnType tableColumnType = TableColumnType.None, bool isIdentity = false, string defaultValue = "", string Comments = "", string foreignKeyDec = "", string tableColumnProcess = "")
 {
     this.Name               = name;
     this.ColumnType         = tableColumnType;
     this.IsIdentity         = isIdentity;
     this.DefaultValue       = defaultValue;
     this.Comments           = Comments;
     this.ForeignKeyDec      = foreignKeyDec;
     this.TableColumnProcess = tableColumnProcess;
 }
        protected override void UpdateTableColumn(ColumnModel columnModel, TableColumnType tableColumnType)
        {
            //for system column deleted and created
            switch (tableColumnType)
            {
            case TableColumnType.Deleted:
                columnModel.DefaultValue = 0;
                break;

            case TableColumnType.UpdatedAt:
                columnModel.DefaultValue = DateTime.Now;
                break;
            }
            base.UpdateTableColumn(columnModel, tableColumnType);
        }
Пример #7
0
        protected override string BuildColumnType(ColumnModel columnModel)
        {
            if (columnModel == null)
            {
                throw new ArgumentNullException("columnModel");
            }

            TableColumnType tableColumnType = this.GetTableColumnType(columnModel);

            if (tableColumnType != TableColumnType.None)
            {
                this.UpdateTableColumn(columnModel, tableColumnType);
            }

            return(base.BuildColumnType(columnModel));
        }
Пример #8
0
            public CellStyleIndex GetFooterCellStyle(TableColumnType cellType)
            {
                switch (cellType)
                {
                case TableColumnType.HeaderColumn:
                    switch (GroupLevel)
                    {
                    case 0: return(CellStyleIndex.Group1FooterHeader);

                    case 1: return(CellStyleIndex.Group2FooterHeader);

                    default:
                    case 2: return(CellStyleIndex.Group3FooterHeader);
                    }

                case TableColumnType.FooterColumn:
                    switch (GroupLevel)
                    {
                    case 0: return(CellStyleIndex.Group1FooterFooter);

                    case 1: return(CellStyleIndex.Group2FooterFooter);

                    default:
                    case 2: return(CellStyleIndex.Group3FooterFooter);
                    }

                case TableColumnType.Normal:
                    switch (GroupLevel)
                    {
                    case 0: return(CellStyleIndex.Group1Footer);

                    case 1: return(CellStyleIndex.Group2Footer);

                    default:
                    case 2: return(CellStyleIndex.Group3Footer);
                    }

                default:
                    throw new InvalidOperationException();
                }
            }
Пример #9
0
        protected override void Generate(CreateTableOperation createTableOperation)
        {
            if (createTableOperation == null)
            {
                throw new ArgumentNullException("createTableOperation");
            }

            bool   createUpdatedAtTrigger = false;
            string updatedAtColumnName    = null;
            string idColumnName           = null;

            foreach (ColumnModel column in createTableOperation.Columns)
            {
                TableColumnType tableColumnType = this.GetTableColumnType(column);
                switch (tableColumnType)
                {
                case TableColumnType.Id:
                    idColumnName = column.Name;
                    break;

                case TableColumnType.UpdatedAt:
                    createUpdatedAtTrigger = true;
                    updatedAtColumnName    = column.Name;
                    break;

                case TableColumnType.CreatedAt:
                    // If we have this column then use that to create a clustered index for instead of the Id column
                    createTableOperation.PrimaryKey.IsClustered = false;
                    break;
                }
            }

            base.Generate(createTableOperation);

            if (createUpdatedAtTrigger && !string.IsNullOrEmpty(idColumnName) && !string.IsNullOrEmpty(updatedAtColumnName))
            {
                string trigger = this.GetTrigger(createTableOperation.Name, idColumnName, updatedAtColumnName);
                this.Statement(trigger);
            }
        }
        protected virtual void UpdateTableColumn(ColumnModel columnModel, TableColumnType tableColumnType)
        {
            if (columnModel == null)
            {
                throw new ArgumentNullException("columnModel");
            }

            // We don't try to set default value if the user has already set it or the store type has been set explicitly.
            if (columnModel == null || columnModel.ClrType == null || columnModel.DefaultValueSql != null || columnModel.StoreType != null)
            {
                return;
            }

            switch (tableColumnType)
            {
                case TableColumnType.Id:
                    columnModel.DefaultValueSql = "NEWID()";
                    break;

                case TableColumnType.CreatedAt:
                    columnModel.DefaultValueSql = "SYSUTCDATETIME()";
                    break;
            }
        }
Пример #11
0
        protected virtual void UpdateTableColumn(ColumnModel columnModel, TableColumnType tableColumnType)
        {
            if (columnModel == null)
            {
                throw new ArgumentNullException("columnModel");
            }

            // We don't try to set default value if the user has already set it or the store type has been set explicitly.
            if (columnModel == null || columnModel.ClrType == null || columnModel.DefaultValueSql != null || columnModel.StoreType != null)
            {
                return;
            }

            switch (tableColumnType)
            {
            case TableColumnType.Id:
                columnModel.DefaultValueSql = "NEWID()";
                break;

            case TableColumnType.CreatedAt:
                columnModel.DefaultValueSql = "SYSUTCDATETIME()";
                break;
            }
        }
Пример #12
0
 public TableColumnAttribute(string columnName, TableColumnType columnType)
 {
     this.ColumnName = columnName;
     this.ColumnType = columnType;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TableColumnAttribute"/> with a given <paramref name="columnType"/>.
 /// </summary>
 /// <param name="columnType">The <see cref="TableColumnType"/> for property this attribute is applied to.</param>
 public TableColumnAttribute(TableColumnType columnType)
 {
     this.ColumnType = columnType;
 }
Пример #14
0
 public TableColElement(TableColumnType type)
 {
 }
Пример #15
0
 public TableColumnIdentifier(string additionalData, TableColumnType columnType)
 {
     AdditionalData = additionalData;
     ColumnType     = columnType;
 }
Пример #16
0
 public TableColElement(TableColumnType type)
 {
 }
Пример #17
0
 protected StringMultiselectTableColumn(TableColumnType columnType, string columnIdentifierName, string title)
     : base(columnType, columnIdentifierName, title)
 {
 }
Пример #18
0
 protected IntTableColumn(TableColumnType columnType, string columnIdentifierName, string title)
     : base(columnType, columnIdentifierName, title)
 {
 }
Пример #19
0
 protected EnumTableColumn(TableColumnType columnType, string columnIdentifierName, string title)
     : base(columnType, columnIdentifierName, title)
 {
     _stringValidValues = EnumHelper.CreateEnumDescriptionDictionary <TEnum>().Select(e => e.Value).ToList();
 }
Пример #20
0
 protected StringMultiselectTableColumn(TableColumnType columnType, string columnIdentifierName, string title, List <string> stringValidValues)
     : base(columnType, columnIdentifierName, title)
 {
     _stringValidValues = stringValidValues;
 }
Пример #21
0
 public TableColumnAttribute(string columnName, TableColumnType columnType)
 {
     this.ColumnName = columnName;
     this.ColumnType = columnType;
 }
Пример #22
0
 public CellStyleIndex GetHeaderCellStyle(TableColumnType cellType)
 {
     switch (cellType)
     {
         case TableColumnType.HeaderColumn:
             switch (GroupLevel)
             {
                 case 0: return CellStyleIndex.Group1HeaderHeader;
                 case 1: return CellStyleIndex.Group2HeaderHeader;
                 default:
                 case 2: return CellStyleIndex.Group3HeaderHeader;
             }
         case TableColumnType.FooterColumn:
             switch (GroupLevel)
             {
                 case 0: return CellStyleIndex.Group1HeaderFooter;
                 case 1: return CellStyleIndex.Group2HeaderFooter;
                 default:
                 case 2: return CellStyleIndex.Group3HeaderFooter;
             }
         case TableColumnType.Normal:
             switch (GroupLevel)
             {
                 case 0: return CellStyleIndex.Group1Header;
                 case 1: return CellStyleIndex.Group2Header;
                 default:
                 case 2: return CellStyleIndex.Group3Header;
             }
         default:
             throw new InvalidOperationException();
     }
 }
Пример #23
0
 public extern HTMLTableColElement(TableColumnType type);
Пример #24
0
        // Attributes

        public static IElement <TableColumn> Type(this IElement <TableColumn> element, TableColumnType type) => element.Attribute("type", type);
        public void Property_IsMarkedWithColumnType <TProperty>(Expression <Func <EntityData, TProperty> > property, TableColumnType expected)
        {
            // Arrange
            PropertyInfo propertyInfo = PropertyAssert.GetPropertyInfo <EntityData, TProperty>(property);

            // Act
            TableColumnAttribute attr = propertyInfo.GetCustomAttributes <TableColumnAttribute>().Single();

            // Assert
            Assert.Equal(attr.ColumnType, expected);
        }
Пример #26
0
 /// <summary>
 /// Adds a column to the table.
 /// </summary>
 /// <param name="column">The column to add.</param>
 /// <returns>The same instance so that multiple calls can be chained.</returns>
 public Table AddColumn(string header,
                        TableColumnType columnType     = TableColumnType.Default,
                        TableColumnAlignment alignment = TableColumnAlignment.Left)
 => AddColumn(new TableColumn(header, columnType, alignment));
        private static void MakeTable([JetBrains.Annotations.NotNull] string headline, [JetBrains.Annotations.NotNull] Section sec, [JetBrains.Annotations.NotNull] out ParagraphFormat format, [JetBrains.Annotations.NotNull] out Table table,
                                      TableColumnType tableColumnType)
        {
            var para = sec.AddParagraph();

            para.Format.Alignment   = ParagraphAlignment.Justify;
            para.Format.Font.Name   = "Times New Roman";
            para.Format.Font.Size   = 16;
            para.Format.Font.Bold   = true;
            para.Format.SpaceAfter  = "0.5cm";
            para.Format.SpaceBefore = "1cm";
            para.Format.Font.Color  = Colors.DarkGray;
            para.AddText(headline);

            format = new ParagraphFormat {
                Font = { Size = 12 }, SpaceBefore = "0.2cm", SpaceAfter = "0.2cm"
            };
            table = new Table {
                Borders = { Width = 0.75 }
            };
            int[]    measurements;
            bool[]   alignments;
            string[] headers;
            switch (tableColumnType)
            {
            case TableColumnType.Values:
                alignments   = new[] { false, true, false };
                measurements = new[] { 5, 5, 5 };
                headers      = new[] { "Load Type", "Value", "Unit" };
                break;

            case TableColumnType.SettlementValues:
                measurements = new[] { 4, 5, 3, 3 };
                alignments   = new[] { false, false, true, false };
                headers      = new[] { "Household", "Load Type", "Value", "Unit" };
                break;

            case TableColumnType.MinMax:
                measurements = new[] { 5, 3, 3, 3 };
                alignments   = new[] { false, true, true, false };
                headers      = new[] { "Household", "Minimum", "Maximum", "Unit" };
                break;

            default: throw new LPGException("Forgotten TableColumnType");
            }

            for (var i = 0; i < measurements.Length; i++)
            {
                var column0 = table.AddColumn(Unit.FromCentimeter(measurements[i]));
                if (alignments[i])
                {
                    column0.Format.Alignment = ParagraphAlignment.Right;
                }
                else
                {
                    column0.Format.Alignment = ParagraphAlignment.Left;
                }
            }

            var row = table.AddRow();

            row.Shading.Color = Colors.AliceBlue;
            for (var i = 0; i < headers.Length; i++)
            {
                var cell = row.Cells[i];
                cell.AddParagraph(headers[i]);
                cell.Format = format.Clone();
            }
        }
Пример #28
0
 protected TableColumn(TableColumnType columnType, string columnIdentifierName, string title)
 {
     Title      = title;
     Identifier = new TableColumnIdentifier(columnIdentifierName, columnType);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TableColumnAttribute"/> with a given <paramref name="columnType"/>.
 /// </summary>
 /// <param name="columnType">The <see cref="TableColumnType"/> for property this attribute is applied to.</param>
 public TableColumnAttribute(TableColumnType columnType)
 {
     this.ColumnType = columnType;
 }