Seal.Model.MetaColumn.SetStandardFormat C# (CSharp) 메소드

SetStandardFormat() 공개 메소드

public SetStandardFormat ( ) : void
리턴 void
        public void SetStandardFormat()
        {
            ColumnType type = Type;
            if (this is ReportElement)
            {
                //Force the type of the ReportElement
                ReportElement element = (ReportElement)this;
                if (element.IsDateTime) type = ColumnType.DateTime;
                else if (element.IsNumeric) type = ColumnType.Numeric;
                else type = ColumnType.Text;
            }
            SetDefaultFormat();
            if (type == ColumnType.Numeric && NumericStandardFormat != NumericStandardFormat.Custom && NumericStandardFormat != NumericStandardFormat.Default)
            {
                _format = Helper.ConvertNumericStandardFormat(NumericStandardFormat);
            }
            else if (type == ColumnType.DateTime && DateTimeStandardFormat != DateTimeStandardFormat.Custom && DateTimeStandardFormat != DateTimeStandardFormat.Default)
            {
                _format = Helper.ConvertDateTimeStandardFormat(DateTimeStandardFormat);
            }
        }

Usage Example

예제 #1
0
        /// <summary>
        /// Fill a list of columns from a table catalog
        /// </summary>
        public void AddColumnsFromCatalog(List <MetaColumn> columns, DbConnection connection, MetaTable table)
        {
            if (table.Name == null)
            {
                throw new Exception("No table name has been defined...");
            }

            //handle if table name = dbname.owner.tablename
            string name = table.Name.Replace("[", "").Replace("]", "");

            string[]  names         = name.Split('.');
            DataTable schemaColumns = null;

            Helper.ExecutePrePostSQL(connection, ReportModel.ClearCommonRestrictions(table.PreSQL), table, table.IgnorePrePostError);
            if (names.Length == 3)
            {
                schemaColumns = connection.GetSchema("Columns", names);
            }
            else if (names.Length == 2)
            {
                schemaColumns = connection.GetSchema("Columns", new string[] { null, names[0], names[1] });
            }
            else
            {
                schemaColumns = connection.GetSchema("Columns", new string[] { null, null, name });
            }
            Helper.ExecutePrePostSQL(connection, ReportModel.ClearCommonRestrictions(table.PostSQL), table, table.IgnorePrePostError);

            foreach (DataRow row in schemaColumns.Rows)
            {
                try
                {
                    string     tableName = (!string.IsNullOrEmpty(table.AliasName) ? table.AliasName : Helper.DBNameToDisplayName(row["TABLE_NAME"].ToString().Trim()));
                    MetaColumn column    = MetaColumn.Create(tableName + "." + GetColumnName(row["COLUMN_NAME"].ToString()));
                    column.DisplayName  = table.KeepColumnNames ? row["COLUMN_NAME"].ToString().Trim() : Helper.DBNameToDisplayName(row["COLUMN_NAME"].ToString().Trim());
                    column.DisplayOrder = table.GetLastDisplayOrder();

                    MetaColumn col = table.Columns.FirstOrDefault();
                    if (col != null)
                    {
                        column.Category = col.Category;
                    }
                    else
                    {
                        column.Category = !string.IsNullOrEmpty(table.AliasName) ? table.AliasName : Helper.DBNameToDisplayName(table.Name.Trim());
                    }
                    column.Source = this;
                    string dbType = "";
                    if (row.Table.Columns.Contains("TYPE_NAME"))
                    {
                        dbType = row["TYPE_NAME"].ToString();
                    }
                    if (connection is OdbcConnection)
                    {
                        column.Type = Helper.ODBCToNetTypeConverter(dbType);
                    }
                    else if (connection is SqlConnection)
                    {
                        column.Type = Helper.ODBCToNetTypeConverter(row["DATA_TYPE"].ToString());
                    }
                    else
                    {
                        column.Type = Helper.DatabaseToNetTypeConverter(row["DATA_TYPE"]);
                    }
                    column.SetStandardFormat();
                    if (!columns.Exists(i => i.Name == column.Name))
                    {
                        columns.Add(column);
                    }
                }
                catch { }
            }
        }
All Usage Examples Of Seal.Model.MetaColumn::SetStandardFormat