예제 #1
0
        private static string GetExceptionDisplayMessage(Exception x)
        {
            var match = REGEX_MISSING_COLUMN.Match(x.Message);

            if (match.Success)
            {
                try
                {
                    string columnName = match.Groups[1].ToString();
                    if (AnnotationDef.IsAnnotationProperty(columnName))
                    {
                        columnName = AnnotationDef.GetColumnDisplayName(columnName);
                    }
                    else if (RatioPropertyAccessor.IsRatioOrRdotpProperty(columnName))
                    {
                        columnName = RatioPropertyAccessor.GetDisplayName(columnName);
                    }
                    return(string.Format(Resources.ExportReportDlg_GetExceptionDisplayMessage_The_field__0__does_not_exist_in_this_document, columnName));
                }
// ReSharper disable EmptyGeneralCatchClause
                catch
                {
                    // Could throw a variety of SQLiteException & NHibernat exceptions
                }
// ReSharper restore EmptyGeneralCatchClause
            }

            return(x.Message);
        }
예제 #2
0
        protected List <TreeNode> GetTreeNodes(IClassMetadata classMetadata, Identifier identifier)
        {
            List <TreeNode> result = new List <TreeNode>();
            // Add special ratio names in order after the default ratio name
            int lastRatioIndex = -1;

            foreach (String propertyName in classMetadata.PropertyNames)
            {
                IType propertyType = classMetadata.GetPropertyType(propertyName);
                if (propertyType is ManyToOneType)
                {
                    continue;
                }
                var  label   = propertyName;
                bool isRatio = RatioPropertyAccessor.IsRatioOrRdotpProperty(label);
                if (isRatio)
                {
                    label = RatioPropertyAccessor.GetDisplayName(label);
                }
                else if (AnnotationDef.IsAnnotationProperty(label))
                {
                    label = AnnotationDef.GetColumnDisplayName(label);
                }
                else if (label.IndexOf("Ratio", StringComparison.Ordinal) != -1) // Not L10N: Label is only used in this file. Never displayed.
                {
                    lastRatioIndex = result.Count;
                }
                var columnInfo = CreateColumnInfo(identifier, classMetadata, propertyName);
                if (columnInfo.IsHidden)
                {
                    continue;
                }
                TreeNode propertyNode
                    = new TreeNode
                    {
                    Name = propertyName,
                    Text = label,
                    Tag  = columnInfo
                    };
                if (isRatio && lastRatioIndex != -1)
                {
                    result.Insert(++lastRatioIndex, propertyNode);
                }
                else
                {
                    result.Add(propertyNode);
                }
            }
            return(result);
        }
예제 #3
0
        public ColumnInfo GetColumnInfo(Type table, String column)
        {
            var columnInfo = new ColumnInfo
            {
                ReportColumn = new ReportColumn(table, new Identifier(column)),
                Caption      = column
            };

            if (AnnotationDef.IsAnnotationProperty(column))
            {
                var classMetadata = GetClassMetadata(table);
                columnInfo.Caption    = AnnotationDef.GetColumnDisplayName(column);
                columnInfo.ColumnType = classMetadata.GetPropertyType(column).ReturnedClass;
                columnInfo.IsHidden   = !_annotationDefNames.Contains(
                    AnnotationDef.GetColumnKey(column));
            }
            else if (RatioPropertyAccessor.IsRatioOrRdotpProperty(column))
            {
                var classMetadata = GetClassMetadata(table);
                columnInfo.Caption    = RatioPropertyAccessor.GetDisplayName(column);
                columnInfo.ColumnType = classMetadata.GetPropertyType(column).ReturnedClass;
                if (RatioPropertyAccessor.IsRatioGsProperty(column))
                {
                    columnInfo.Format = Formats.GLOBAL_STANDARD_RATIO;
                }
                else if (RatioPropertyAccessor.IsRatioProperty(column))
                {
                    columnInfo.Format = Formats.STANDARD_RATIO;
                }
                else if (RatioPropertyAccessor.IsRdotpProperty(column))
                {
                    columnInfo.Format = Formats.STANDARD_RATIO;
                }
            }
            else
            {
                PropertyInfo propertyInfo = table.GetProperty(column);
                columnInfo.ColumnType = propertyInfo.PropertyType;
                foreach (QueryColumn attr in propertyInfo.GetCustomAttributes(typeof(QueryColumn), true))
                {
                    columnInfo.Caption  = attr.FullName ?? columnInfo.Caption;
                    columnInfo.Format   = attr.Format ?? columnInfo.Format;
                    columnInfo.IsHidden = attr.IsHidden;
                }
            }
            return(columnInfo);
        }