Example #1
0
 public CsvReader(TableInfo structure, LumenWorks.Framework.IO.Csv.CsvReader reader, DataFormatSettings dataFormat)
     : base(structure)
 {
     _reader     = reader;
     _array      = new string[structure.ColumnCount];
     _dataFormat = dataFormat ?? new DataFormatSettings();
 }
Example #2
0
 public XmlWriterImpl(System.Xml.XmlWriter writer, bool closeWriter, DataFormatSettings dataFormat, bool useAttributes, string rowElementName)
 {
     _writer         = writer;
     _dataFormat     = dataFormat;
     _formatter      = new CdlValueFormatter(_dataFormat ?? new DataFormatSettings());
     _useAttributes  = useAttributes;
     _closeWriter    = closeWriter;
     _rowElementName = rowElementName;
 }
Example #3
0
        public void WriteStart(StreamWriter fw, ITableStructure table, ref object manager)
        {
            var fmtset = new DataFormatSettings();

            SettingsTool.CopySettingsPage(FormatSettings, fmtset);
            fmtset.DateTimeFormat = "s";
            fw.Write(IoRes.excelxml_start.Replace("#HDRCOLOR#", m_headerColor.ToWebName()));
            WriteHeaders(fw, table, m_sheetName);
            manager = new Manager {
                formatter = new BedValueFormatter(fmtset)
            };
        }
Example #4
0
 public CsvWriter(TextWriter stream, char delimiter, char quote, char escape, char comment, CsvQuotingMode qmode, string lineEnds, DataFormatSettings dataFormat)
 {
     _stream     = stream;
     _lineEnds   = lineEnds;
     _delimiter  = delimiter;
     _quote      = quote;
     _escape     = escape;
     _comment    = comment;
     _qmode      = qmode;
     _dataFormat = dataFormat;
     _formatter  = new CdlValueFormatter(_dataFormat ?? new DataFormatSettings());
 }
Example #5
0
        public ICdlWriter CreateWriter(TableInfo inputRowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
        {
            var connection = GetConnectionProvider(context);

            using (var conn = connection.Connect())
            {
                var db = new DatabaseInfo();
                db.LinkedInfo = LinkedInfo;
                var tbl = inputRowFormat.CloneTable(db);
                tbl.FullName = GetFullName(context);
                foreach (var col in tbl.Columns)
                {
                    col.AutoIncrement = false;
                }
                tbl.ForeignKeys.Clear();
                if (tbl.PrimaryKey != null)
                {
                    tbl.PrimaryKey.ConstraintName = null;
                }
                tbl.AfterLoadLink();

                if (IdentityColumn != null)
                {
                    var col = new ColumnInfo(tbl);
                    col.Name          = IdentityColumn;
                    col.DataType      = "int";
                    col.AutoIncrement = true;
                    col.NotNull       = true;
                    var pk = new PrimaryKeyInfo(tbl);
                    pk.Columns.Add(new ColumnReference {
                        RefColumn = col
                    });
                    pk.ConstraintName = "PK_" + tbl.Name;
                    tbl.PrimaryKey    = pk;
                    tbl.Columns.Insert(0, col);
                }

                //var sw = new StringWriter();
                var so  = new ConnectionSqlOutputStream(conn, null, connection.Factory.CreateDialect());
                var dmp = connection.Factory.CreateDumper(so, new SqlFormatProperties());
                if (DropIfExists)
                {
                    dmp.DropTable(tbl, true);
                }

                bool useExistingTable = false;
                if (UseIfExists)
                {
                    var ts = context.GetDatabaseStructure(connection.ProviderString);
                    useExistingTable = ts.FindTableLike(tbl.FullName.Schema, tbl.FullName.Name) != null;
                }

                if (!useExistingTable)
                {
                    tbl.Columns.ForEach(x => x.EnsureDataType(connection.Factory.CreateSqlTypeProvider()));
                    dmp.CreateTable(tbl);
                }
                //using (var cmd = conn.CreateCommand())
                //{
                //    cmd.CommandText = sw.ToString();
                //    cmd.ExecuteNonQuery();
                //}

                return(new TableWriter(context, connection, GetFullName(context), inputRowFormat, options, useExistingTable ? null : tbl, LinkedInfo, sourceDataFormat));
            }
        }
Example #6
0
        ICdlWriter ITabularDataTarget.CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
        {
            string file = GetName(context);

            file = context.ResolveFile(file, ResolveFileMode.Output);
            context.Info("Writing file " + Path.GetFullPath(file));
            return(new CdlFileWriter(file, rowFormat));
        }
Example #7
0
        ICdlWriter ITabularDataTarget.CreateWriter(TableInfo inputRowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
        {
            var  writer      = GetModel(context);
            bool closeWriter = false;

            if (writer == null)
            {
                closeWriter = true;
                writer      = CreateWriter(context.ResolveFile(context.Replace(File), ResolveFileMode.Output));
            }
            var impl = new XmlWriterImpl(writer, closeWriter, sourceDataFormat, UseAttributes, RowElementName);

            return(impl);
        }
Example #8
0
        public TableWriter(IShellContext context, IConnectionProvider connection, NameWithSchema name, TableInfo inputRowFormat, CopyTableTargetOptions options, TableInfo destinationTableOverride = null, LinkedDatabaseInfo linkedInfo = null, DataFormatSettings sourceDataFormat = null)
        {
            _connectionProvider = connection;
            _linkedInfo         = linkedInfo;
            _name           = name;
            _inputRowFormat = inputRowFormat;
            _queue          = new CdlDataQueue(inputRowFormat);
            _context        = context;

            _inserter = connection.Factory.CreateBulkInserter();
            _inserter.SourceDataFormat = sourceDataFormat;
            _connection          = _connectionProvider.Connect();
            _inserter.Connection = _connection;
            _inserter.Factory    = connection.Factory;
            _inserter.LinkedInfo = _linkedInfo;
            var db = context.GetDatabaseStructure(connection.ProviderString);

            _inserter.DestinationTable = destinationTableOverride ?? db.FindTableLike(_name.Schema, _name.Name);
            _inserter.CopyOptions      = options;
            _inserter.MessageLogger    = _context;
            _inserter.ServiceProvider  = context.ServiceProvider;

            _thread = new Thread(Run);
            _thread.Start();
        }
Example #9
0
 public ICdlWriter CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
 {
     return(GetModel(context).CreateWriter(rowFormat, context.Replace(SheetName)));
 }
Example #10
0
        ICdlWriter ITabularDataTarget.CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
        {
            string file = context.ResolveFile(GetName(context), ResolveFileMode.Output);

            context.GetLogger <CsvFile>().LogInformation("Writing file {file}", Path.GetFullPath(file));
            context.Info("Writing file " + Path.GetFullPath(file));
            var fs     = System.IO.File.OpenWrite(file);
            var fw     = new StreamWriter(fs, Encoding);
            var writer = new CsvWriter(fw, Delimiter, Quote, Escape, Comment, QuotingMode, EndOfLine, DataFormat);

            if (HasHeaders)
            {
                writer.WriteRow(rowFormat.Columns.Select(c => c.Name));
            }
            return(writer);
        }
Example #11
0
 public CdlValueConvertor(DataFormatSettings settings)
 {
     m_parser    = new CdlValueParser(settings);
     m_formatter = new CdlValueFormatter(settings);
 }
Example #12
0
 public ExcelWriter(TableInfo rowFormat, ExcelWorksheet sheet, DataFormatSettings dataFormat)
 {
     _rowFormat = rowFormat;
     _sheet     = sheet;
     _formatter = new CdlValueFormatter(dataFormat ?? new DataFormatSettings());
 }
Example #13
0
 ICdlWriter ITabularDataTarget.CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
 {
     return(CreateTarget(context).CreateWriter(rowFormat, options, context, sourceDataFormat));
 }
Example #14
0
        public ICdlWriter CreateWriter(TableInfo rowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
        {
            string file     = context.ResolveFile(context.Replace(File), ResolveFileMode.Output);
            var    fw       = new StreamWriter(System.IO.File.OpenWrite(file));
            var    provider = GetConnectionProvider(context);

            return(new SqlFileWriter(fw, provider.Factory, InsertSeparatorAfterRows));
        }
Example #15
0
 ICdlWriter ITabularDataTarget.CreateWriter(TableInfo inputRowFormat, CopyTableTargetOptions options, IShellContext context, DataFormatSettings sourceDataFormat)
 {
     return(new TableWriter(context, GetConnectionProvider(context), GetFullName(context), inputRowFormat, options, StructureOverride, LinkedInfo, sourceDataFormat));
 }
Example #16
0
 public CdlValueConvertor(DataFormatSettings settings)
 {
     m_parser = new CdlValueParser(settings);
     m_formatter = new CdlValueFormatter(settings);
 }
Example #17
0
 public RecordToDbAdapter(TargetColumnMap columnMap, IDatabaseFactory targetFactory, DataFormatSettings formatSettings)
 {
     _columnMap  = columnMap;
     _dda        = targetFactory.CreateDataAdapter();
     _outputConv = new CdlValueConvertor(formatSettings);
 }