Beispiel #1
0
        public MainViewModel(ITwitterContextList contextList, INotifier notifier, IColumnDefinitionList columnList,
                             IColumnFactory columnFactory,
                             IMessenger messenger = null)
            : base(messenger)
        {
            ContextList = contextList;
            ContextList.ContextsChanged += ContextList_ContextsChanged;

            Columns    = new ObservableCollection <IColumnViewModel>();
            Notifier   = notifier;
            Factory    = columnFactory;
            ColumnList = columnList;
            ColumnList.ColumnsChanged += ColumnList_ColumnsChanged;
            ConstructColumns();

            DragDropHandler = new DragDropHandler(columnList, MessengerInstance);
            var rateLimitTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromMinutes(15)
            };

            rateLimitTimer.Tick += RateLimitTimer_Tick;
            rateLimitTimer.Start();

            var statusUpdateTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromSeconds(10)
            };

            statusUpdateTimer.Tick += StatusUpdateTimer_Tick;
            statusUpdateTimer.Start();

            var updateCheckTimer = new DispatcherTimer
            {
                Interval = TimeSpan.FromHours(1)
            };

            updateCheckTimer.Tick += UpdateCheckTimer_Tick;
            updateCheckTimer.Start();
        }
 public ImportCsvFileSourceCommandHandler(
     ISourceRepository repository,
     IEventBus eventBus,
     IApplicationStateService stateService,
     IDataContext dataContext,
     ICsvFileDataAdapter dataAdapter,
     IDataTypeConverterFactory converterFactory,
     IDataLoaderFactory loaderFactory,
     IColumnFactory columnFactory,
     IColumnRepository columnRepository,
     IRowRepository rowRepository)
 {
     _repository       = repository;
     _eventBus         = eventBus;
     _stateService     = stateService;
     _dataContext      = dataContext;
     _dataAdapter      = dataAdapter;
     _converterFactory = converterFactory;
     _loaderFactory    = loaderFactory;
     _columnFactory    = columnFactory;
     _columnRepository = columnRepository;
     _rowRepository    = rowRepository;
 }
Beispiel #3
0
        private void CreateTestableWithAllTypes(string testTable)
        {
            IColumnFactory columnFactory = DbContext.PowerPlant.CreateColumnFactory();
            List <IColumn> columns       = new List <IColumn>
            {
                columnFactory.CreateInstance(ColumnTypeName.Bool, "bool_col", 0, 20, 0, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.Char, "char_col", 2, false, "' '", "Danish_Norwegian_CI_AS"),
                columnFactory.CreateInstance(ColumnTypeName.DateTime, "date_col", false, "convert(datetime,'19000101',112)"),
                columnFactory.CreateInstance(ColumnTypeName.Float, "float_col", 0, 30, 8, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.Guid, "guid_col", true, ""),
                columnFactory.CreateInstance(ColumnTypeName.Int, "int_col", 0, 15, 0, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.Int8, "int8_col", 0, 3, 0, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.Int16, "int16_col", 0, 5, 0, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.Int64, "int64_col", 0, 20, 0, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.LongText, "longtext_col", 0, false, "' '", "Danish_Norwegian_CI_AS"),
                columnFactory.CreateInstance(ColumnTypeName.Money, "money_col", 0, 30, 3, false, false, "0", ""),
                columnFactory.CreateInstance(ColumnTypeName.Blob, "blob_col", true, ""),
                columnFactory.CreateInstance(ColumnTypeName.NVarchar, "nvarchar_col", 50, false, "' '", "Danish_Norwegian_CI_AS"),
                columnFactory.CreateInstance(ColumnTypeName.Varchar, "varchar_col", 50, false, "' '", "Danish_Norwegian_CI_AS")
            };
            TableDefinition tableDefinition = new TableDefinition(testTable, columns, "");

            DbSchema.CreateTable(tableDefinition);
            string stmt =
                $"insert into {testTable} (bool_col, char_col, date_col, float_col, guid_col, int_col, int8_col, int16_col, int64_col, longtext_col, money_col, blob_col, nvarchar_col, varchar_col) ";

            if (DbContext.DbType == DbTypeName.SqlServer)
            {
                stmt += "values (1,'NO', 'Feb 23 1900', 123.12345678, '3f2504e0-4f89-11d3-9a0c-0305e82c3301', 1234567890, 150, 12345, 123456789012345, N'Very long text with æøå', 123.123, convert(varbinary, 'Lots of bytes'), N'A unicode ﺽ string', 'A varchar string')";
            }
            else
            {
                stmt += "values (1,'NO', to_date('Feb 23 1900', 'Mon DD YYYY'), 123.12345678, hextoraw('3f2504e04f8911d39a0c0305e82c3301'), 1234567890, 150, 12345, 123456789012345, 'Very long text with æøå', 123.123, utl_raw.cast_to_raw('Lots of bytes'), 'A unicode ﺽ string', 'A varchar string')";
            }
            Commands.ExecuteNonQuery(stmt);
        }
Beispiel #4
0
 public void Setup()
 {
     Document = Substitute.For <IDocument>();
     Factory  = Substitute.For <IColumnFactory>();
     Parser   = new Parser(Factory);
 }
Beispiel #5
0
        public override ITableDefinition GetTableDefinition(IColumnTypeConverter columnTypeConverter, string tableName)
        {
            string selectStmt = "";

            selectStmt += "SELECT c.name, " + "\n";
            selectStmt += "       t.name AS t_name, " + "\n";
            selectStmt += "       isnull(c.max_length, 0) as length, " + "\n";
            selectStmt += "       isnull(c.precision, 0) as prec, " + "\n";
            selectStmt += "       isnull(c.scale, 0) as scale, " + "\n";
            selectStmt += "       c.is_nullable, " + "\n";
            selectStmt += "       convert(varchar(256), isnull(c.collation_name, '')) as collation, " + "\n";
            selectStmt += "       isnull(object_definition(c.default_object_id), '') as def, " + "\n";
            selectStmt += "       c.is_identity " + "\n";
            selectStmt += "FROM   sys.columns c " + "\n";
            selectStmt += "       JOIN sys.types t " + "\n";
            selectStmt += "         ON c.user_type_id = t.user_type_id " + "\n";
            selectStmt += string.Format("WHERE  c.object_id = Object_id('{0}') ", tableName) + "\n";
            selectStmt += "ORDER  BY c.column_id ";

            IColumnFactory columnFactory      = DbContext.PowerPlant.CreateColumnFactory();
            List <IColumn> columns            = new List <IColumn>();
            bool           tableHasBlobColumn = false;
            IDataCursor    cursor             = null;

            try
            {
                cursor = DbContext.PowerPlant.CreateDataCursor();
                IDataReader reader = cursor.ExecuteReader(selectStmt);
                while (reader.Read())
                {
                    string name   = reader.GetString(0);
                    string type   = reader.GetString(1);
                    int    length = reader.GetInt16(2);
                    if (length != -1 && (type == "nvarchar" || type == "nchar"))
                    {
                        length /= 2;
                    }
                    int prec  = reader.GetByte(3);
                    int scale = reader.GetByte(4);
                    if (scale != 0 && type == "datetime2")
                    {
                        prec = 0;
                    }
                    bool           isNullable = reader.GetBoolean(5);
                    string         collation  = reader.GetString(6);
                    string         def        = reader.GetString(7);
                    bool           isIdentity = reader.GetBoolean(8);
                    string         sourceType = type.AddParameters();
                    ColumnTypeName colType    = columnTypeConverter.GetDestinationType(sourceType, ref length, ref prec, ref scale).ColumnTypeName(length);
                    if (colType == ColumnTypeName.Blob || colType == ColumnTypeName.OldBlob)
                    {
                        tableHasBlobColumn = true;
                    }
                    columns.Add(
                        columnFactory.CreateInstance(
                            colType,
                            name,
                            length,
                            prec,
                            scale,
                            isNullable,
                            isIdentity,
                            def,
                            collation)
                        );
                }
            }
            catch (Exception ex)
            {
                throw new ADatabaseException("ERROR when Get TableDefinition: " + selectStmt, ex);
            }
            finally
            {
                if (cursor != null)
                {
                    cursor.Close();
                }
            }

            ITableDefinition tableDefinition = DbContext.PowerPlant.CreateTableDefinition(tableName, columns, GetSegmentName(tableName));

            tableDefinition.HasBlobColumn = tableHasBlobColumn;

            tableDefinition.Columns.RemoveAll(c => c.Name == "agrtid");

            return(tableDefinition);
        }
Beispiel #6
0
 public Parser(IColumnFactory factory)
 {
     Factory = factory;
 }
Beispiel #7
0
 public void Setup()
 {
     _columnFactory = new SqlServerColumnFactory();
     _dataFileName  = "testdatafile.adata";
 }