Defining how a property of MainTableDataSource should be rendered as a column's cell.
示例#1
0
        private static void applyAggregateFunction(PropertyInfo property, ColumnAttributes columnAttributes)
        {
            var aggregateFunction = property.GetAggregateFunctionAttribute();
            if (aggregateFunction != null)
                columnAttributes.AggregateFunction = new AggregateProvider(aggregateFunction.Value);

            if (columnAttributes.AggregateFunction == null)
            {
                var customAggregateFunction = property.GetPdfRptColumnCustomAggregateFunctionAttribute();
                if (customAggregateFunction != null)
                    columnAttributes.AggregateFunction = Activator.CreateInstance(customAggregateFunction) as IAggregateFunction;
            }
        }
        private static void applyCalculatedField(PropertyInfo property, ColumnAttributes columnAttributes, FieldInfo[] fieldsInfo)
        {
            var isCalculatedField = property.GetColumnIsCalculatedFieldAttribute();
            if (isCalculatedField != null)
                columnAttributes.IsCalculatedField = isCalculatedField.Value;

            if (columnAttributes.IsCalculatedField)
            {
                var calculatedFieldFormula = fieldsInfo.GetCalculatedFieldFormulaAttribute(property.Name);
                if (calculatedFieldFormula != null)
                    columnAttributes.CalculatedFieldFormula = calculatedFieldFormula;
            }
        }
示例#3
0
 private static void applyColumnIsVisible(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var isVisible = property.GetColumnIsVisibleAttribute();
     if (isVisible.HasValue)
         columnAttributes.IsVisible = isVisible.Value;
 }
示例#4
0
 private static void applyCellsHorizontalAlignment(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var cellsHorizontalAlignment = property.GetCellsHorizontalAlignmentAttribute();
     if (cellsHorizontalAlignment != null)
         columnAttributes.CellsHorizontalAlignment = cellsHorizontalAlignment.Value;
 }
示例#5
0
 private static void applyWidth(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var columnWidth = property.GetColumnWidthAttribute();
     if (columnWidth != null)
         columnAttributes.Width = columnWidth.Value;
 }
示例#6
0
        private static void applyPropertyName(PropertyInfo property, ColumnAttributes columnAttributes, bool areColumnsAdHoc)
        {
            if (columnAttributes.HeaderCell == null)
                columnAttributes.HeaderCell = new HeadingCell();

            if (string.IsNullOrEmpty(columnAttributes.HeaderCell.Caption) || areColumnsAdHoc)
            {
                var caption = property.GetColumnPropertyNameAttribute();
                if (!string.IsNullOrEmpty(caption))
                    columnAttributes.HeaderCell.Caption = caption;
            }

            if (string.IsNullOrEmpty(columnAttributes.HeaderCell.Caption))
                columnAttributes.HeaderCell.Caption = property.Name;
        }
示例#7
0
 private static void applyOrder(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var order = property.GetColumnOrderAttribute();
     if (order != null)
         columnAttributes.Order = order.Value;
 }
        private bool setColumnAggregateFunc(string columnName, ColumnAttributes colDef)
        {
            if (_conventions == null || _conventions.ColumnNamesAggregateFunctions == null) return false;

            var func = _conventions.ColumnNamesAggregateFunctions.FirstOrDefault(x => x.Key == columnName);
            if (func.Value == null) return false;
            colDef.AggregateFunction = func.Value;
            return true;
        }
示例#9
0
        private static void applyIncludedGroupFieldEqualityComparer(PropertyInfo property, ColumnAttributes columnAttributes, FieldInfo[] fieldsInfo)
        {
            var includeInGrouping = property.GetColumnIncludeInGroupingAttribute();
            if (includeInGrouping.HasValue)
                columnAttributes.IncludeInGrouping = includeInGrouping.Value;

            if (columnAttributes.IncludeInGrouping)
            {
                var equalityComparer = fieldsInfo.GetIncludedGroupFieldEqualityComparerAttribute(property.Name);
                if (equalityComparer != null)
                    columnAttributes.IncludedGroupFieldEqualityComparer = equalityComparer;
            }
        }
示例#10
0
 private static void applyFixedHeight(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var fixedHeight = property.GetFixedHeightAttribute();
     if (fixedHeight.HasValue)
         columnAttributes.FixedHeight = fixedHeight.Value;
 }
示例#11
0
 private static void applyDataFormatString(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var dataFormatString = property.GetDataFormatStringAttribute();
     if (!string.IsNullOrEmpty(dataFormatString))
     {
         columnAttributes.ColumnItemsTemplate.BasicProperties.DisplayFormatFormula = data => string.Format(CultureInfo.InvariantCulture, dataFormatString, data);
         if (columnAttributes.AggregateFunction != null)
             columnAttributes.AggregateFunction.DisplayFormatFormula = data => string.Format(CultureInfo.InvariantCulture, dataFormatString, data);
     }
 }
        // Private Methods (1)
        private static void checkProperty(int columnNumber, ColumnAttributes col)
        {
            if (col == null)
                throw new ArgumentNullException("col");

            if (string.IsNullOrEmpty(col.PropertyName))
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "pdfColumnsDefinitions[{0}].PropertyName is empty.", columnNumber));
            }
        }
示例#13
0
 private void setHorizontalAlignment(ColumnAttributes item)
 {
     if (item.CellsHorizontalAlignment == null)
         item.CellsHorizontalAlignment = HorizontalAlignment.Center;
     _worksheet.Cells[_row, _col].Style.HorizontalAlignment = _horizontalAlignment[item.CellsHorizontalAlignment.Value];
     _worksheet.Cells[_row, _col].Style.Font.Bold = true;
 }
        // Public Methods (1)
        /// <summary>
        /// Creates PdfColumnDefinitions list based on the PdfRptAdHocColumnsConventions
        /// </summary>
        /// <returns>PdfColumnDefinitions list</returns>
        public IList<ColumnAttributes> CreatePdfColumnDefinitions()
        {
            var result = new List<ColumnAttributes>();

            if (_bodyDataSource == null || !_bodyDataSource.Rows().Any())
            {
                result.Add(getRowNoCol());
                return result;
            }

            tryShowRowNumberColumn(result);

            var firstRowCells = _bodyDataSource.Rows().FirstOrDefault();
            if (firstRowCells == null)
            {
                result.Add(getRowNoCol());
                return result;
            }

            var order = 2;
            foreach (var cellData in firstRowCells)
            {
                Type type = null;
                if (cellData.PropertyValue != null)
                    type = cellData.PropertyValue.GetType();

                if (type != null && type.BaseType == typeof(MulticastDelegate))
                    continue;

                var itemsTemplate = getColumnItemsTemplate(cellData.PropertyName, type);
                if (itemsTemplate.BasicProperties == null)
                    itemsTemplate.BasicProperties = new CellBasicProperties();

                setDisplayFormatFormula(cellData.PropertyName, type, itemsTemplate);
                var colDef = new ColumnAttributes
                {
                    HeaderCell = new HeadingCell
                    {
                        Caption = cellData.PropertyName
                    },
                    ColumnItemsTemplate = itemsTemplate,
                    Width = 1,
                    PropertyName = cellData.PropertyName,
                    IsVisible = true,
                    Order = order++,
                    CellsHorizontalAlignment = HorizontalAlignment.Center
                };

                setAggregateFunc(cellData.PropertyName, colDef, type);

                result.Add(colDef);
            }

            if (!result.Any())
            {
                result.Add(getRowNoCol());
            }

            return result;
        }
示例#15
0
 private static void applyColumnItemsTemplate(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var columnItemsTemplateType = property.GetPdfRptColumnTemplateAttribute();
     if (columnItemsTemplateType != null)
         columnAttributes.ColumnItemsTemplate = Activator.CreateInstance(columnItemsTemplateType) as IColumnItemsTemplate;
 }
示例#16
0
 private static void applyMinimumHeight(PropertyInfo property, ColumnAttributes columnAttributes)
 {
     var minimumHeight = property.GetMinimumHeightAttribute();
     if (minimumHeight.HasValue)
         columnAttributes.MinimumHeight = minimumHeight.Value;
 }
示例#17
0
        private void updateAggregates(ColumnAttributes col, CellAttributes cell)
        {
            if (cell == null || col.AggregateFunction == null) return;

            col.AggregateFunction.CellAdded(cell.RowData.Value, CurrentRowInfoData.IsNewGroupStarted);

            var columnRowSummary = new SummaryCellData
            {
                CellData = new CellData
                {
                    PropertyName = col.PropertyName,
                    PropertyValue = cell.RowData.Value
                },
                GroupAggregateValue = FuncHelper.ApplyFormula(col.AggregateFunction.DisplayFormatFormula, col.AggregateFunction.GroupValue),
                GroupRowNumber = CurrentRowInfoData.LastGroupRowNumber,
                OverallAggregateValue = FuncHelper.ApplyFormula(col.AggregateFunction.DisplayFormatFormula, col.AggregateFunction.OverallValue),
                OverallRowNumber = CurrentRowInfoData.LastOverallDataRowNumber,
                GroupNumber = CurrentRowInfoData.LastGroupNumber
            };
            SharedData.ColumnCellsSummaryData.Add(columnRowSummary);
        }
        private void setAggregateFunc(string columnName, ColumnAttributes colDef, Type type)
        {
            if (setColumnAggregateFunc(columnName, colDef)) return;
            if (_conventions == null || _conventions.TypesAggregateFunctions == null || type == null) return;

            var func = _conventions.TypesAggregateFunctions.FirstOrDefault(x => x.Key == type);
            if (func.Value != null)
            {
                colDef.AggregateFunction = func.Value;
            }
        }