Exemplo n.º 1
0
        ITableStructure GetStructure(CsvReader cr)
        {
            TableStructure res = new TableStructure();

            if (m_hasHeaders)
            {
                try
                {
                    foreach (string col in cr.GetFieldHeaders())
                    {
                        res.AddColumn(col, new DbTypeString(DefaultStringLength));
                    }
                }
                catch (CsvDuplicateColumnName err)
                {
                    throw new InvalidInputError(Texts.Get("s_duplicate_column_name_try_change_config$column", "column", err.Column));
                }
            }
            else
            {
                for (int i = 1; i <= cr.FieldCount; i++)
                {
                    res.AddColumn(String.Format("#{0}", i), new DbTypeString(DefaultStringLength));
                }
            }
            return(res);
        }
Exemplo n.º 2
0
        private InMemoryTable ChartDataToTable(ChartData data)
        {
            var ts = new TableStructure();

            ts.AddColumn(Texts.Get("s_label"), new DbTypeString());
            foreach (var item in data.ValueDefs)
            {
                ts.AddColumn(item.Label, new DbTypeFloat {
                    Bytes = 8
                });
            }
            var res = new InMemoryTable(ts);

            foreach (var item in data.Items)
            {
                var rec = new ArrayDataRecord(ts);
                rec.SeekValue(0);
                rec.SetString(item.Label);
                for (int i = 0; i < data.ValueDefs.Length; i++)
                {
                    rec.SeekValue(i + 1);
                    rec.SetDouble(item.Values[i]);
                }
                res.Rows.Add(rec);
            }
            return(res);
        }
Exemplo n.º 3
0
 public void FillDataColumns(TableStructure table)
 {
     foreach (string datacol in DataCols)
     {
         table.AddColumn(Model.Columns[datacol], false);
     }
 }
Exemplo n.º 4
0
 protected override void ProcessTableColumnsTable(TableStructure table, DataTable columns)
 {
     foreach (DataRow row in columns.Rows)
     {
         ColumnStructure col = table.AddColumn(row["COLUMN_NAME"].ToString(), AnalyseType(new DataRowAdapter(row), m_conn, false));
         LoadTableColumn(col, row);
     }
 }
Exemplo n.º 5
0
        ITableStructure GetStructure(DbfFile dbf)
        {
            var res = new TableStructure();

            //output column names
            for (int i = 0; i < dbf.Header.ColumnCount; i++)
            {
                DbTypeBase type;
                // convert DBF type to DA type
                switch (dbf.Header[i].ColumnType)
                {
                case DbfColumn.DbfColumnType.Binary:
                    type = new DbTypeBlob();
                    break;

                case DbfColumn.DbfColumnType.Boolean:
                    type = new DbTypeLogical();
                    break;

                case DbfColumn.DbfColumnType.Date:
                    type = new DbTypeDatetime {
                        SubType = DbDatetimeSubType.Date
                    };
                    break;

                case DbfColumn.DbfColumnType.Character:
                    type = new DbTypeString {
                        Length = dbf.Header[i].Length
                    };
                    break;

                case DbfColumn.DbfColumnType.Integer:
                    type = new DbTypeInt();
                    break;

                case DbfColumn.DbfColumnType.Memo:
                    type = new DbTypeText();
                    break;

                case DbfColumn.DbfColumnType.Number:
                    type = new DbTypeNumeric {
                        Precision = dbf.Header[i].DecimalCount
                    };
                    break;

                default:
                    type = new DbTypeString();
                    break;
                }
                res.AddColumn(dbf.Header[i].Name, type);
            }
            return(res);
        }
Exemplo n.º 6
0
 public void FillKey(TableStructure table)
 {
     foreach (string keycol in KeyCols)
     {
         table.AddColumn(Model.Columns[keycol], false);
     }
     if (KeyCols.Length > 0)
     {
         var pk = new PrimaryKey();
         foreach (string keycol in KeyCols)
         {
             pk.Columns.Add(new ColumnReference(keycol));
         }
         table._Constraints.Add(pk);
     }
 }
Exemplo n.º 7
0
        public ITableStructure GetTableStructure(SynQueryType qtype)
        {
            var res = new TableStructure();

            FillKey(res);
            switch (qtype)
            {
            case SynQueryType.SelectAll:
                FillDataColumns(res);
                break;

            case SynQueryType.SelectKeyNull:
            case SynQueryType.SelectKeyMd5:
                res.AddColumn(new ColumnStructure {
                    DataType = new DbTypeString(), ColumnName = "HashColumn"
                }, true);
                break;
            }
            return(res);
        }