Esempio n. 1
0
        /// <summary>
        /// Builds the script expression.
        /// </summary>
        /// <param name="scriptExpression">The script expression.</param>
        /// <returns>ScriptExpression.</returns>
        private static ScriptExpression BuildScriptExpression(Model.ScriptExpression scriptExpression)
        {
            DatabaseType castType = TypedValueHelper.GetDatabaseType(scriptExpression.ReportExpressionResultType);

            return(new ScriptExpression {
                Script = scriptExpression.ReportScript, ResultType = castType
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Builds the field expression.
        /// </summary>
        /// <param name="fieldExpression">The field expression.</param>
        /// <param name="context"></param>
        /// <returns>ResourceDataColumn.</returns>
        private static ResourceDataColumn BuildFieldExpression(Model.FieldExpression fieldExpression, FromEntityContext context)
        {
            DatabaseType castType = TypedValueHelper.GetDatabaseType(fieldExpression.ReportExpressionResultType);

            if (fieldExpression.FieldExpressionField == null)
            {
                EventLog.Application.WriteWarning(context.DebugInfo + "field was null");
                return(null);
            }

            ResourceDataColumn rdc = new ResourceDataColumn
            {
                FieldId            = fieldExpression.FieldExpressionField,
                CastType           = castType, ExpressionId = Guid.NewGuid(),
                SourceNodeEntityId = fieldExpression.As <NodeExpression>().SourceNode.Id
            };

            return(rdc);
        }
        /// <summary>
        /// Builds the column format rules for the report columns.
        /// </summary>
        /// <param name="reportColumns">The report columns.</param>
        /// <param name="context">The context.</param>
        /// <returns>
        /// List{ColumnFormatting}.
        /// </returns>
        internal static List <ColumnFormatting> BuildColumnFormats(IEntityCollection <ReportColumn> reportColumns, IReportToQueryContext context)
        {
            List <ColumnFormatting> reportColumnFormats = new List <ColumnFormatting>();

            foreach (ReportColumn reportColumn in reportColumns)
            {
                ColumnFormatting columnFormatting = null;
                if (reportColumn.ColumnDisplayFormat != null && reportColumn.ColumnExpression != null)
                {
                    Formatting.ImageFormattingRule imageFormattingRule = null;
                    if (reportColumn.ColumnDisplayFormat.FormatImageScale != null &&
                        reportColumn.ColumnDisplayFormat.FormatImageSize != null)
                    {
                        imageFormattingRule = new Formatting.ImageFormattingRule
                        {
                            ThumbnailSizeId  = new Model.EntityRef(reportColumn.ColumnDisplayFormat.FormatImageSize.Id),
                            ThumbnailScaleId = new Model.EntityRef(reportColumn.ColumnDisplayFormat.FormatImageScale.Id),
                        };
                    }


                    columnFormatting = new ColumnFormatting
                    {
                        EntityId             = reportColumn.Id,
                        ColumnName           = reportColumn.Name,
                        DecimalPlaces        = reportColumn.ColumnDisplayFormat.FormatDecimalPlaces ?? 0,
                        ShowText             = reportColumn.ColumnDisplayFormat.ColumnShowText ?? false,
                        DisableDefaultFormat = reportColumn.ColumnDisplayFormat.DisableDefaultFormat ?? false,
                        Prefix         = reportColumn.ColumnDisplayFormat.FormatPrefix,
                        Suffix         = reportColumn.ColumnDisplayFormat.FormatSuffix,
                        Lines          = reportColumn.ColumnDisplayFormat.MaxLineCount ?? 0,
                        FormattingRule = imageFormattingRule ?? null
                    };
                    // Column Type
                    columnFormatting.ColumnType = TypedValueHelper.GetDatabaseType(reportColumn.ColumnExpression.ReportExpressionResultType);

                    DisplayFormat displayFormat = reportColumn.ColumnDisplayFormat;
                    // Format String
                    if (displayFormat.DateColumnFormat != null)
                    {
                        columnFormatting.DateFormat = displayFormat.DateColumnFormat;
                    }
                    if (displayFormat.DateTimeColumnFormat != null)
                    {
                        columnFormatting.DateTimeFormat = displayFormat.DateTimeColumnFormat;
                    }
                    if (displayFormat.TimeColumnFormat != null)
                    {
                        columnFormatting.TimeFormat = displayFormat.TimeColumnFormat;
                    }

                    // Text Alignment
                    if (displayFormat.FormatAlignment != null)
                    {
                        columnFormatting.Alignment = displayFormat.FormatAlignment;
                    }

                    if (displayFormat.EntityListColumnFormat != null)
                    {
                        columnFormatting.EntityListColumnFormat = displayFormat.EntityListColumnFormat;
                    }
                }
                // Formatting Rule
                if (reportColumn.ColumnFormattingRule != null && reportColumn.ColumnExpression != null)
                {
                    if (columnFormatting == null)
                    {
                        columnFormatting = new ColumnFormatting
                        {
                            EntityId   = reportColumn.Id,
                            ColumnName = reportColumn.Name,
                        }
                    }
                    ;
                    columnFormatting.FormattingRule = BuildColumnFormatRule(reportColumn.ColumnFormattingRule, columnFormatting.ColumnType, context);
                }

                if (columnFormatting != null && reportColumn.ColumnExpression != null)
                {
                    reportColumnFormats.Add(columnFormatting);
                }
            }

            return(reportColumnFormats);
        }