public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            WaLinuxAgentLogParsedResult parsedResult = tableData.QueryOutput <WaLinuxAgentLogParsedResult>(
                DataOutputPath.Create(SourceParserIds.WaLinuxAgentLog, WaLinuxAgentDataCooker.CookerId, "ParsedResult"));
            var logEntries = parsedResult.LogEntries;

            var baseProjection = Projection.Index(logEntries);

            var fileNameProjection   = baseProjection.Compose(x => x.FilePath);
            var lineNumberProjection = baseProjection.Compose(x => x.LineNumber);
            var eventTimeProjection  = baseProjection.Compose(x => x.EventTimestamp);
            var logLevelProjection   = baseProjection.Compose(x => x.LogLevel);
            var logProjection        = baseProjection.Compose(x => x.Log);

            //
            // Table Configurations describe how your table should be presented to the user:
            // the columns to show, what order to show them, which columns to aggregate, and which columns to graph.
            // You may provide a number of columns in your table, but only want to show a subset of them by default so as not to overwhelm the user.
            // The user can still open the table properties in UI to turn on or off columns.
            // The table configuration class also exposes four (4) columns that UI explicitly recognizes: Pivot Column, Graph Column, Left Freeze Column, Right Freeze Column
            // For more information about what these columns do, go to "Advanced Topics" -> "Table Configuration" in our Wiki. Link can be found in README.md
            //

            var config = new TableConfiguration("Default")
            {
                Columns = new[]
                {
                    LogLevelColumn,
                    TableConfiguration.PivotColumn,
                    LineNumberColumn,
                    LogColumn,
                    EventTimestampDateTimeColumn,
                    TableConfiguration.GraphColumn,
                    EventTimestampColumn,
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.StartTime, EventTimestampColumn);

            //
            //
            //  Use the table builder to build the table.
            //  Add and set table configuration if applicable.
            //  Then set the row count (we have one row per file) and then add the columns using AddColumn.
            //
            tableBuilder
            .AddTableConfiguration(config)
            .SetDefaultTableConfiguration(config)
            .SetRowCount(logEntries.Count)
            .AddColumn(FileNameColumn, fileNameProjection)
            .AddColumn(LineNumberColumn, lineNumberProjection)
            .AddColumn(EventTimestampColumn, eventTimeProjection)
            .AddColumn(LogLevelColumn, logLevelProjection)
            .AddColumn(LogColumn, logProjection);
        }
 private static EntityTypeBuilder <TEntity> ToTable <TEntity>(
     this EntityTypeBuilder <TEntity> entityTypeBuilder,
     TableConfiguration configuration)
     where TEntity : class
 {
     return(string.IsNullOrWhiteSpace(configuration.Schema) ?
            entityTypeBuilder.ToTable(configuration.Name) :
            entityTypeBuilder
            .ToTable(configuration.Name, configuration.Schema));
 }
예제 #3
0
        public void CanBeInstanstiatedWithConfiguration()
        {
            var tableConfig = new TableConfiguration(1000, 2000, 30, 100000);
            var table       = new Table(tableConfig);

            Assert.AreEqual(table.TableConfig.BigBlindSize, tableConfig.BigBlindSize);
            Assert.AreEqual(table.TableConfig.SmallBlindSize, tableConfig.SmallBlindSize);
            Assert.AreEqual(table.TableConfig.PlayerTimeout, tableConfig.PlayerTimeout);
            Assert.AreEqual(table.TableConfig.StartingChipCount, tableConfig.StartingChipCount);
        }
예제 #4
0
        /// <summary>
        /// Constructs new table configurator
        /// </summary>
        public Configurator()
        {
            PropertyInfo[] sourceColumns;
            ReflectionCache.GetCachedProperties <TTableData>(out _tableColumns, out _tableColumnsDictionary);
            ReflectionCache.GetCachedProperties <TSourceData>(out sourceColumns, out _sourceColumnsDictionary);

            _tableConfiguration = new TableConfiguration();
            InitializeColumnsConfiguration();
            RegisterCommandHandler <DefaultCommandHandler>(DefaultCommandHandler.CommandId);
        }
예제 #5
0
        private static EntityTypeBuilder <TEntity> ToTable <TEntity>(this EntityTypeBuilder <TEntity> entityTypeBuilder,
                                                                     TableConfiguration configuration, string prefix = null)
            where TEntity : class
        {
            prefix = prefix ?? "Abp";

            return(string.IsNullOrWhiteSpace(configuration.Schema)
                ? entityTypeBuilder.ToTable(prefix + configuration.Name)
                : entityTypeBuilder.ToTable(prefix + configuration.Name, configuration.Schema));
        }
        public void OneTimeSetup(IConfiguration configuration)
        {
            _options = configuration.GetSection("IdentityContextTableStorageOptions")
                       .Get <IdentityContextTableStorageOptions>();

            _tableConfig = new TableConfiguration(_options);
            var result = _tableConfig.ConfigureTables().ToEither().Result;

            result.IsRight.Should().BeTrue("Azure Storage should be configured correctly");
        }
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            var threads = tableData.QueryOutput <IReadOnlyList <IThread> >(
                DataOutputPath.Create(LTTngThreadDataCooker.CookerPath + "/Threads"));

            if (threads.Count == 0)
            {
                return;
            }

            var config = new TableConfiguration("ThreadsByProcessId")
            {
                Columns = new[]
                {
                    processIdColumn,
                    threadIdColumn,
                    commandColumn,
                    TableConfiguration.PivotColumn,
                    threadExecTimeColumn,
                    threadReadyTimeColumn,
                    threadRunningTimeColumn,
                    threadSleepTimeColumn,
                    threadDiskSleepTimeColumn,
                    threadWaitingTimeColumn,
                    threadIdleTimeColumn,
                    TableConfiguration.GraphColumn,
                    threadStartTimeColumn,
                    threadExitTimeColumn
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.StartTime, threadStartTimeColumn);
            config.AddColumnRole(ColumnRole.EndTime, threadExitTimeColumn);

            var table = tableBuilder.AddTableConfiguration(config)
                        .SetDefaultTableConfiguration(config)
                        .SetRowCount(threads.Count);

            table.AddColumn(threadIdColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ThreadId));
            table.AddColumn(processIdColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ProcessId));
            table.AddColumn(commandColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].Command));
            table.AddColumn(threadExecTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ExecTime));
            table.AddColumn(threadReadyTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ReadyTime));
            table.AddColumn(threadRunningTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ExecTime + threads[i].ReadyTime));
            table.AddColumn(threadSleepTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].SleepTime));
            table.AddColumn(threadDiskSleepTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].DiskSleepTime));
            table.AddColumn(threadWaitingTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].SleepTime + threads[i].DiskSleepTime));
            table.AddColumn(threadStoppedTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].StoppedTime));
            table.AddColumn(threadParkedTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ParkedTime));
            table.AddColumn(threadIdleTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].IdleTime));
            table.AddColumn(threadStartTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].StartTime));
            table.AddColumn(threadExitTimeColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ExitTime));
            table.AddColumn(threadLifespanColumn, Projection.CreateUsingFuncAdaptor((i) => threads[i].ExitTime - threads[i].StartTime));
        }
예제 #8
0
        // column choice table
        private static void MultiColumnTable(string title, string[] descriptionLines, string[] options, int numberOfColumns)
        {
            // info column
            ColumnHeader titleHeader = new ColumnHeader(title, Alignment.Left, Alignment.Center);
            Table        infoTable   = new Table(titleHeader);

            infoTable.AddRow("                                                      ");
            foreach (string descriptionLine in descriptionLines)
            {
                infoTable.AddRow(descriptionLine);
            }

            infoTable.Config = TableConfiguration.UnicodeAlt();

            // options column table
            Table optionsTable = new Table();

            //  - header: empty lines space
            for (int i = 0; i < numberOfColumns; i++)
            {
                string emptyHeaderSpace = " ";
                optionsTable.AddColumn(emptyHeaderSpace);
            }

            // - columns: options

            // - add rows
            int maxRows = options.Length / numberOfColumns;

            for (int row = 1; row <= maxRows; row++)
            {
                int maxOptionsRow = numberOfColumns;
                var maxIndex      = maxOptionsRow * row;
                var minIdex       = maxIndex - maxOptionsRow;

                var optionsRow = new List <string>();

                for (int index = minIdex; index < maxIndex; index++)
                {
                    optionsRow.Add(options[index]);
                }

                optionsTable.AddRow(optionsRow.ToArray());
            }

            optionsTable.AddRow("", "", "", "");

            infoTable.Config    = TableConfiguration.UnicodeAlt();
            optionsTable.Config = TableConfiguration.Markdown();

            DefaultTitile();
            Console.Write(infoTable.ToString());
            Console.Write(optionsTable.ToString());
        }
예제 #9
0
        public ITableBuilder AddTableConfiguration(TableConfiguration configuration)
        {
            if (tableConfigurations.Any(f => f.Name == configuration.Name))
            {
                throw new Exception("TableConfiguration: Already existing name");
            }

            tableConfigurations.Add(configuration);

            return(this);
        }
예제 #10
0
        public void Post([FromBody] Reminder reminder)
        {
            var tableConfiguration = new TableConfiguration
            {
                ConfigurationString = @"DefaultEndpointsProtocol=https;AccountName=grace1002;AccountKey=oxFfz+dgsWONgXbVTX0KKeH0L5X4kBANp10siMiobJTt9Q6P8TXHw9wb7RDx3f3ALwMCjS4rpYu9Zwe8trYNPg==;EndpointSuffix=core.windows.net",
                TableName           = "Reminders"
            };

            var repository = new ReminderRepository(tableConfiguration);

            repository.AddReminder(reminder);
        }
예제 #11
0
        public IEnumerable <Reminder> Get()
        {
            var tableConfiguration = new TableConfiguration
            {
                ConfigurationString = @"DefaultEndpointsProtocol=https;AccountName=grace1002;AccountKey=oxFfz+dgsWONgXbVTX0KKeH0L5X4kBANp10siMiobJTt9Q6P8TXHw9wb7RDx3f3ALwMCjS4rpYu9Zwe8trYNPg==;EndpointSuffix=core.windows.net",
                TableName           = "Reminders"
            };

            var repository = new ReminderRepository(tableConfiguration);

            return(repository.GetReminders(new DateTime(1950, 01, 01), DateTime.Now));
        }
예제 #12
0
        protected override void CorePublishImpl(TableConfiguration configuration, IUnitOfWork destinationUnitOfWork, IDataReader sourceDataReader, out long rowsCopied)
        {
            IEnumerable <IResultset> resultsets;
            long _rowsCopied = 0;

            if ((object)configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if ((object)destinationUnitOfWork == null)
            {
                throw new ArgumentNullException("destinationUnitOfWork");
            }

            if ((object)sourceDataReader == null)
            {
                throw new ArgumentNullException("sourceDataReader");
            }

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "ExecuteCommandText"));
            }

            // ?
            {
                IDbDataParameter commandParameter;
                IDictionary <string, IDbDataParameter> commandParameters;

                commandParameters = new Dictionary <string, IDbDataParameter>();

                while (sourceDataReader.Read())
                {
                    commandParameters.Clear();

                    foreach (ColumnConfiguration columnConfiguration in configuration.ColumnConfigurations)
                    {
                        commandParameter = destinationUnitOfWork.CreateParameter(ParameterDirection.Input, DbType.AnsiString, 0, 0, 0, true, string.Format("@{0}", columnConfiguration.ColumnName), sourceDataReader[columnConfiguration.ColumnName]);
                        commandParameters.Add(columnConfiguration.ColumnName, commandParameter);
                    }

                    resultsets = destinationUnitOfWork.ExecuteResultsets(this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandType ?? CommandType.Text, this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText, commandParameters.Values.ToArray());
                    resultsets.ToArray();

                    _rowsCopied++;
                }
            }

            rowsCopied = _rowsCopied;

            Console.WriteLine("DESTINATION (update): rowsCopied={0}", rowsCopied);
        }
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            CloudInitLogParsedResult parsedResult = tableData.QueryOutput <CloudInitLogParsedResult>(
                DataOutputPath.Create(SourceParserIds.CloudInitLog, CloudInitDataCooker.CookerId, "ParsedResult"));
            var logEntries = parsedResult.LogEntries;

            var baseProjection = Projection.Index(logEntries);

            var fileNameProjection   = baseProjection.Compose(x => x.FilePath);
            var lineNumberProjection = baseProjection.Compose(x => x.LineNumber);
            var eventTimeProjection  = baseProjection.Compose(x => x.EventTimestamp);
            var pythonFileProjection = baseProjection.Compose(x => x.PythonFile);
            var logLevelProjection   = baseProjection.Compose(x => x.LogLevel);
            var logProjection        = baseProjection.Compose(x => x.Log);

            var config = new TableConfiguration("Default")
            {
                Columns = new[]
                {
                    FileNameColumn,
                    LogLevelColumn,
                    TableConfiguration.PivotColumn,
                    PythonFileColumn,
                    LineNumberColumn,
                    LogColumn,
                    EventTimestampDateTimeColumn,
                    TableConfiguration.GraphColumn,
                    EventTimestampColumn,
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.StartTime, EventTimestampColumn);

            //
            //
            //  Use the table builder to build the table.
            //  Add and set table configuration if applicable.
            //  Then set the row count (we have one row per file) and then add the columns using AddColumn.
            //
            tableBuilder
            .AddTableConfiguration(config)
            .SetDefaultTableConfiguration(config)
            .SetRowCount(logEntries.Count)
            .AddColumn(FileNameColumn, fileNameProjection)
            .AddColumn(LineNumberColumn, lineNumberProjection)
            .AddColumn(EventTimestampColumn, eventTimeProjection)
            .AddColumn(PythonFileColumn, pythonFileProjection)
            .AddColumn(LogLevelColumn, logLevelProjection)
            .AddColumn(LogColumn, logProjection)
            ;
        }
예제 #14
0
        protected override IEnumerable <IDictionary <string, object> > CorePullData(TableConfiguration tableConfiguration)
        {
            IEnumerable <IDictionary <string, object> > sourceDataEnumerable;

            if ((object)tableConfiguration == null)
            {
                throw new ArgumentNullException("tableConfiguration");
            }

            sourceDataEnumerable = this.DelimitedTextReader.ReadRecords();

            return(sourceDataEnumerable);
        }
예제 #15
0
        static void Main(string[] args)
        {
            var headers = new string[] { "C1", "C2", "C3" };
            var data    = new List <string[]>()
            {
                new string[] { "Mark Ramprakash", "40", "Some house" },
                new string[] { "Kumar Sangakkarra", "39", "Another house" },
                new string[] { "Moeen Ali", "33", "A house" },
            };

            var data2 = new List <object[]>()
            {
                new object[] { 111, "Hi", 12.00 },
                new object[] { 444, 555, 6666 },
                new object[] { 777, 888, 999 }
            };

            var myObjOne   = new MyObject(1, 2, 3);
            var myObjTwo   = new MyObject(4, 5, 6);
            var myObjThree = new MyObject(7, 8, 9);

            var objectt = new object[] { "12", 12, 12.00 };

            var objectData = new IRowConvertable[] { myObjOne, myObjThree, myObjTwo };

            var config = TableConfiguration.Create()
                         .WithHeaderDivider()
                         .WithColumnBorders()
                         .WithRowNumbers()
                         .WithRowBorders()
                         .WithColumnSpacing(9);

            ConsoleTable.Create()
            .WithHeaders(headers)
            .WithData(data2)
            .AddDataRow(myObjTwo)
            .AddDataRow <int>(new int[] { 1, 2, 500000001, 4 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500000003 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500003465 })
            .AddDataRow <int>(new int[] { 1, 2, 500006456 })
            .AddDataRow <int>(new int[] { 1, 2, 500000345 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow <int>(new int[] { 1, 2, 500000000 })
            .AddDataRow(objectt)
            .WithConfiguration(config)
            .PrintTable();
        }
예제 #16
0
        public string JsonConfig <TStaticData>(string rootId, TStaticData staticData = null, string prefix = "lt") where TStaticData : class
        {
            TableConfiguration tc = TableConfiguration;

            tc.TableRootId = rootId;
            tc.Prefix      = prefix;
            if (staticData != null)
            {
                tc.StaticData = JsonConvert.SerializeObject(staticData);
            }
            string json = JsonConvert.SerializeObject(tc, SerializationSettings.ResponseSerializationSettings);

            return(json);
        }
 private static void DoCheckConfiguration(TableConfiguration tconf,
                                          Action <EditorConfigurationWrapper <CheckEditorUiConfig> > config, string colName)
 {
     tconf.UpdatePluginConfig <EditorUiConfig>(EditorExtensions.PluginId, c =>
     {
         var conf =
             c.Configuration.GetOrReplaceEditorConfig <CheckEditorUiConfig>(colName);
         var wrapper = new EditorConfigurationWrapper <CheckEditorUiConfig>(conf);
         if (config != null)
         {
             config(wrapper);
         }
     });
 }
예제 #18
0
        protected override void CorePushData(TableConfiguration tableConfiguration, IEnumerable <IDictionary <string, object> > sourceDataEnumerable)
        {
            if ((object)tableConfiguration == null)
            {
                throw new ArgumentNullException("tableConfiguration");
            }

            if ((object)sourceDataEnumerable == null)
            {
                throw new ArgumentNullException("sourceDataEnumerable");
            }

            this.DelimitedTextWriter.WriteRecords(sourceDataEnumerable);
        }
예제 #19
0
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            var parsedResult = tableData.QueryOutput <AndroidLogcatParsedResult>(
                DataOutputPath.ForSource(SourceParserIds.AndroidLogcatLog, AndroidLogcatDataCooker.CookerId, nameof(AndroidLogcatDataCooker.ParsedResult)));
            var logEntries = parsedResult.LogEntries;

            var baseProjection = Projection.Index(logEntries);

            var timestampProjection  = baseProjection.Compose(x => x.Timestamp);
            var fileNameProjection   = baseProjection.Compose(x => x.FilePath);
            var lineNumberProjection = baseProjection.Compose(x => x.LineNumber);
            var pidProjection        = baseProjection.Compose(x => x.PID);
            var tidProjection        = baseProjection.Compose(x => x.TID);
            var priorityProjection   = baseProjection.Compose(x => x.Priority);
            var tagProjection        = baseProjection.Compose(x => x.Tag);
            var messageProjection    = baseProjection.Compose(x => x.Message);

            var config = new TableConfiguration("Default")
            {
                Columns = new[]
                {
                    FileNameColumn,
                    TableConfiguration.PivotColumn,
                    LineNumberColumn,
                    TimestampAbsColumn,
                    PIDColumn,
                    TIDColumn,
                    PriorityColumn,
                    TagColumn,
                    MessageColumn,
                    TableConfiguration.RightFreezeColumn,
                    TableConfiguration.GraphColumn,
                    TimestampColumn
                },
            };

            config.AddColumnRole(ColumnRole.StartTime, TimestampColumn);

            tableBuilder.AddTableConfiguration(config)
            .SetDefaultTableConfiguration(config)
            .SetRowCount(logEntries.Count)
            .AddColumn(FileNameColumn, fileNameProjection)
            .AddColumn(LineNumberColumn, lineNumberProjection)
            .AddColumn(PIDColumn, pidProjection)
            .AddColumn(TIDColumn, pidProjection)
            .AddColumn(PriorityColumn, priorityProjection)
            .AddColumn(MessageColumn, messageProjection)
            .AddColumn(TimestampColumn, timestampProjection)
            .AddColumn(TagColumn, tagProjection);
        }
예제 #20
0
        private static void PrintResult(IBenchmarkResult result)
        {
            Table table = new Table("Name", "Total Ticks", "Average", "Min", "Max");

            table.AddRow(
                result.Name,
                TickHelper.ToHumanReadableTime(result.TotalTicks),
                TickHelper.ToHumanReadableTime(Convert.ToInt64(result.AverageTicks)),
                TickHelper.ToHumanReadableTime(result.MinimumTicks),
                TickHelper.ToHumanReadableTime(result.MaximumTicks));

            foreach (IBenchmarkResult metric in result.Results)
            {
                table.AddRow(
                    metric.Name,
                    TickHelper.ToHumanReadableTime(metric.TotalTicks),
                    TickHelper.ToHumanReadableTime(Convert.ToInt64(metric.AverageTicks)),
                    TickHelper.ToHumanReadableTime(metric.MinimumTicks),
                    TickHelper.ToHumanReadableTime(metric.MaximumTicks));
            }

            table.Config = TableConfiguration.UnicodeAlt();

            Console.WriteLine(table.ToString());

            table = new Table("Name", "Total Ticks", "Average", "Min", "Max");

            table.AddRow(
                result.Name,
                result.TotalTicks,
                result.AverageTicks,
                result.MinimumTicks,
                result.MaximumTicks);

            foreach (IBenchmarkResult metric in result.Results)
            {
                table.AddRow(
                    metric.Name,
                    metric.TotalTicks,
                    metric.AverageTicks,
                    metric.MinimumTicks,
                    metric.MaximumTicks);
            }

            table.Config = TableConfiguration.UnicodeAlt();

            Console.WriteLine(table.ToString());
            Console.Read();
        }
예제 #21
0
        public static void Run()
        {
            Console.OutputEncoding = Encoding.UTF8;

            Clock.BenchmarkTime(() =>
            {
                Table table  = new Table("One", "Two", "Three");
                table.Config = TableConfiguration.Unicode();
                table.AddRow("1", "2", "3");
                table.AddRow("Short", "item", "Here");
                table.AddRow("Longer items go here", "stuff", "stuff");

                string tableString = table.ToString();
            }, 100, 500);
        }
        private static void ShowExampleGeneratedTable()
        {
            DataStuff[] objects = new DataStuff[10];
            Random      random  = new Random();

            for (int i = 0; i < 10; i++)
            {
                objects[i] = new DataStuff(random);
            }
            Table table = new Table(TableConfiguration.MySql());

            table.From <DataStuff>(objects);

            Console.Write(table.ToString());
        }
        protected override void CorePublishImpl(TableConfiguration configuration, IUnitOfWork destinationUnitOfWork, IDataReader sourceDataReader, out long rowsCopied)
        {
            long _rowsCopied = 0;

            //SqlRowsCopiedEventHandler callback;

            if ((object)configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if ((object)destinationUnitOfWork == null)
            {
                throw new ArgumentNullException("destinationUnitOfWork");
            }

            if ((object)sourceDataReader == null)
            {
                throw new ArgumentNullException("sourceDataReader");
            }

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText))
            {
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "ExecuteCommandText"));
            }

            using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy((SqlConnection)destinationUnitOfWork.Connection, SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints | SqlBulkCopyOptions.KeepIdentity | SqlBulkCopyOptions.KeepNulls, (SqlTransaction)destinationUnitOfWork.Transaction))
            {
                //callback = (sender, e) => Console.WriteLine(_rowsCopied = e.RowsCopied);

                foreach (ColumnConfiguration columnConfiguration in configuration.ColumnConfigurations)
                {
                    sqlBulkCopy.ColumnMappings.Add(columnConfiguration.ColumnName, columnConfiguration.ColumnName);
                }

                sqlBulkCopy.EnableStreaming = true;
                sqlBulkCopy.BatchSize       = 2500;
                sqlBulkCopy.NotifyAfter     = 2500;
                //sqlBulkCopy.SqlRowsCopied += callback;
                sqlBulkCopy.DestinationTableName = this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText;

                sqlBulkCopy.WriteToServer(sourceDataReader);

                //sqlBulkCopy.SqlRowsCopied -= callback;
            }

            rowsCopied = _rowsCopied;
        }
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            var syscalls = tableData.QueryOutput <IReadOnlyList <ISyscall> >(
                DataOutputPath.Create(LTTngSyscallDataCooker.CookerPath + '/' + nameof(LTTngSyscallDataCooker.Syscalls)));

            if (syscalls.Count == 0)
            {
                return;
            }

            var defaultConfig = new TableConfiguration("Individual Syscalls")
            {
                Columns = new[]
                {
                    syscallNumberColumn,
                    TableConfiguration.PivotColumn,
                    syscallNameColumn,
                    syscallDurationColumn,
                    syscallArgumentsColumn,
                    syscallReturnValueColumn,
                    syscallThreadIdColumn,
                    syscallCommandColumn,
                    syscallProcessIdColumn,
                    TableConfiguration.GraphColumn,
                    syscallStartTimeColumn,
                    syscallEndTimeColumn
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            defaultConfig.AddColumnRole(ColumnRole.StartTime, syscallStartTimeColumn);
            defaultConfig.AddColumnRole(ColumnRole.EndTime, syscallEndTimeColumn);

            var table = tableBuilder.AddTableConfiguration(defaultConfig)
                        .SetDefaultTableConfiguration(defaultConfig)
                        .SetRowCount(syscalls.Count);

            table.AddColumn(syscallNameColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].Name));
            table.AddColumn(syscallThreadIdColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].ThreadId));
            table.AddColumn(syscallProcessIdColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].ProcessId));
            table.AddColumn(syscallCommandColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].ProcessCommand));
            table.AddColumn(syscallNumberColumn, Projection.CreateUsingFuncAdaptor((i) => i + 1));
            table.AddColumn(syscallStartTimeColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].StartTime));
            table.AddColumn(syscallEndTimeColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].EndTime));
            table.AddColumn(syscallDurationColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].EndTime - syscalls[i].StartTime));
            table.AddColumn(syscallReturnValueColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].ReturnValue));
            table.AddColumn(syscallArgumentsColumn, Projection.CreateUsingFuncAdaptor((i) => syscalls[i].Arguments));
        }
예제 #25
0
        /// <summary>
        /// Create table
        /// </summary>
        /// <param name="columns"></param>
        /// <param name="rows"></param>
        /// <param name="outputType"></param>
        /// <param name="hasInnerRows"></param>
        /// <returns></returns>
        private static string Create(IEnumerable <ColumnHeader> columns,
                                     IEnumerable <object[]> rows,
                                     TableOutputType outputType,
                                     bool hasInnerRows)
        {
            string ret;

            if (rows.Count() == 0)
            {
                ret = "";
            }
            else if (outputType == TableOutputType.Html)
            {
                ret = ToHtml(columns, rows);
            }
            else if (outputType == TableOutputType.Json)
            {
                ret = ToJson(columns.ToArray(), rows, false);
            }
            else if (outputType == TableOutputType.JsonPretty)
            {
                ret = ToJson(columns.ToArray(), rows, true);
            }
            else
            {
                var table = new Table(columns.ToArray());

                switch (outputType)
                {
                case TableOutputType.Text: table.Config = TableConfiguration.Default(); break;

                case TableOutputType.Unicode: table.Config = TableConfiguration.Unicode(); break;

                case TableOutputType.UnicodeAlt: table.Config = TableConfiguration.UnicodeAlt(); break;

                case TableOutputType.Markdown: table.Config = TableConfiguration.Markdown(); break;

                default: break;
                }

                table.Config.hasInnerRows = hasInnerRows;
                table.AddRows(rows);
                ret = table.ToString();
            }

            return(ret);
        }
예제 #26
0
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            DmesgIsoLogParsedResult parsedResult = tableData.QueryOutput <DmesgIsoLogParsedResult>(
                DataOutputPath.Create(SourceParserIds.DmesgIsoLog, DmesgIsoDataCooker.CookerId, "ParsedResult"));
            var logEntries = parsedResult.LogEntries;

            var baseProjection = Projection.Index(logEntries);

            var fileNameProjection   = baseProjection.Compose(x => x.filePath);
            var lineNumberProjection = baseProjection.Compose(x => x.lineNumber);
            var entityProjection     = baseProjection.Compose(x => x.entity);
            var topicProjection      = baseProjection.Compose(x => x.topic);
            var timestampProjection  = baseProjection.Compose(x => x.timestamp);
            var metadataProjection   = baseProjection.Compose(x => x.metadata);
            var messageProjection    = baseProjection.Compose(x => x.message);

            var config = new TableConfiguration("Default")
            {
                Columns = new[]
                {
                    FileNameColumn,
                    EntityColumn,
                    TableConfiguration.PivotColumn,
                    MessageNumberColumn,
                    TopicColumn,
                    MessageColumn,
                    MetadataColumn,
                    TableConfiguration.GraphColumn,
                    TimestampColumn
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.StartTime, TimestampColumn);
            config.AddColumnRole(ColumnRole.EndTime, TimestampColumn);

            tableBuilder.AddTableConfiguration(config)
            .SetDefaultTableConfiguration(config)
            .SetRowCount(logEntries.Count)
            .AddColumn(FileNameColumn, fileNameProjection)
            .AddColumn(MessageNumberColumn, lineNumberProjection)
            .AddColumn(EntityColumn, entityProjection)
            .AddColumn(TopicColumn, topicProjection)
            .AddColumn(MessageColumn, messageProjection)
            .AddColumn(TimestampColumn, timestampProjection)
            .AddColumn(MetadataColumn, metadataProjection);
        }
        public static void BuildTable(ITableBuilder tableBuilder, IDataExtensionRetrieval tableData)
        {
            var fileEvents = tableData.QueryOutput <IReadOnlyList <IFileEvent> >(
                DataOutputPath.Create(LTTngDiskDataCooker.CookerPath + '/' + nameof(LTTngDiskDataCooker.FileEvents)));

            if (fileEvents.Count == 0)
            {
                return;
            }

            var config = new TableConfiguration("EventsBySyscallType")
            {
                Columns = new[]
                {
                    fileEventNameColumn,
                    TableConfiguration.PivotColumn,
                    fileEventThreadIdColumn,
                    fileEventProcessIdColumn,
                    fileEventCommandColumn,
                    fileEventFilePathColumn,
                    fileEventSizeColumn,
                    fileEventDurationColumn,
                    TableConfiguration.GraphColumn,
                    fileEventStartTimeColumn,
                    fileEventEndTimeColumn
                },
                Layout = TableLayoutStyle.GraphAndTable,
            };

            config.AddColumnRole(ColumnRole.StartTime, fileEventStartTimeColumn);
            config.AddColumnRole(ColumnRole.EndTime, fileEventEndTimeColumn);

            var table = tableBuilder.AddTableConfiguration(config)
                        .SetDefaultTableConfiguration(config)
                        .SetRowCount(fileEvents.Count);

            table.AddColumn(fileEventNameColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].Name));
            table.AddColumn(fileEventThreadIdColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].ThreadId));
            table.AddColumn(fileEventProcessIdColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].ProcessId));
            table.AddColumn(fileEventCommandColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].ProcessCommand));
            table.AddColumn(fileEventFilePathColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].Filepath));
            table.AddColumn(fileEventStartTimeColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].StartTime));
            table.AddColumn(fileEventEndTimeColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].EndTime));
            table.AddColumn(fileEventDurationColumn, Projection.CreateUsingFuncAdaptor((i) => fileEvents[i].EndTime - fileEvents[i].StartTime));
            table.AddColumn(fileEventSizeColumn, new FileActivitySizeProjection(Projection.CreateUsingFuncAdaptor((i) => fileEvents[i])));
        }
예제 #28
0
        protected override void CorePushData(TableConfiguration tableConfiguration, IEnumerable <IDictionary <string, object> > sourceDataEnumerable)
        {
            if ((object)tableConfiguration == null)
            {
                throw new ArgumentNullException("tableConfiguration");
            }

            if ((object)sourceDataEnumerable == null)
            {
                throw new ArgumentNullException("sourceDataEnumerable");
            }

            foreach (IDictionary <string, object> sourceDataItem in sourceDataEnumerable)
            {
                // do nothing
            }
        }
        /// <summary>
        /// Creates a new MSDBValueAndLogProvider
        /// </summary>
        /// <param name="connectionString">ConnectionString needed to connect to the database</param>
        /// <param name="partTableName">Name of the table to store parts in (gets created if it doesn't exist)</param>
        /// <param name="localeTableName">Name of the table to store locales in (gets created if it doesn't exist)</param>
        /// <param name="valueTableName">Name of the table to store values in (gets created if it doesn't exist)</param>
        /// <param name="logTableName">Name of the table to store logs in (gets created if it doesn't exist)</param>
        /// <param name="schema">Schema to find or create all the tables in (null = default schema)</param>
        /// <param name="insertDummyValues">If set to true, will not throw ValueNotFoundExceptions (which trigger the Notifier), but create dummy values instead.</param>
        public MSDBValueAndLogProvider(String connectionString, String partTableName, String localeTableName, String valueTableName, String logTableName, String schema = null, bool insertDummyValues = false)
        {
            // instantly test connection & get database name
            _connectionString = connectionString;
            using (var conn = new SqlConnection(connectionString)) {
                conn.Open();
                _databaseName = conn.Database;
                schema = schema ?? GetDatabase(GetServer(conn)).DefaultSchema;
            }

            _tableConfiguration = new TableConfiguration(partTableName, localeTableName, valueTableName, logTableName, schema);
            _insertDummyValues = insertDummyValues;

            Reload();
            _flushLog = new Thread(FlushLog);
            _flushLog.Start();
        }
        protected override void CorePublishImpl(TableConfiguration configuration, IUnitOfWork destinationUnitOfWork, IDataReader sourceDataReader, out long rowsCopied)
        {
            IEnumerable<IResultset> resultsets;
            long _rowsCopied = 0;

            if ((object)configuration == null)
                throw new ArgumentNullException("configuration");

            if ((object)destinationUnitOfWork == null)
                throw new ArgumentNullException("destinationUnitOfWork");

            if ((object)sourceDataReader == null)
                throw new ArgumentNullException("sourceDataReader");

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText))
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "ExecuteCommandText"));

            // ?
            {
                IDbDataParameter commandParameter;
                IDictionary<string, IDbDataParameter> commandParameters;

                commandParameters = new Dictionary<string, IDbDataParameter>();

                while (sourceDataReader.Read())
                {
                    commandParameters.Clear();

                    foreach (ColumnConfiguration columnConfiguration in configuration.ColumnConfigurations)
                    {
                        commandParameter = destinationUnitOfWork.CreateParameter(ParameterDirection.Input, DbType.AnsiString, 0, 0, 0, true, string.Format("@{0}", columnConfiguration.ColumnName), sourceDataReader[columnConfiguration.ColumnName]);
                        commandParameters.Add(columnConfiguration.ColumnName, commandParameter);
                    }

                    resultsets = destinationUnitOfWork.ExecuteResultsets(this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandType ?? CommandType.Text, this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText, commandParameters.Values.ToArray());
                    resultsets.ToArray();

                    _rowsCopied++;
                }
            }

            rowsCopied = _rowsCopied;

            Console.WriteLine("DESTINATION (update): rowsCopied={0}", rowsCopied);
        }
예제 #31
0
        private static void ShowAlignedTables()
        {
            Console.WriteLine();
            Table1();
            Console.WriteLine();
            Table2();
            Console.WriteLine();

            void Table1()
            {
                ColumnHeader[] headers = new[]
                {
                    new ColumnHeader("Left"),
                    new ColumnHeader("Right", Alignment.Right, Alignment.Right),
                    new ColumnHeader("Center", Alignment.Center, Alignment.Center),
                };

                Table table = new Table(headers);

                table.Config = TableConfiguration.MySqlSimple();
                table.AddRow("1", "2", "3");
                table.AddRow("Short", "item", "Here");
                table.AddRow("Longer items go here", "stuff stuff", "some centered thing");

                Console.Write(table.ToString());
            }

            void Table2()
            {
                ColumnHeader[] headers = new[]
                {
                    new ColumnHeader("Left"),
                    new ColumnHeader("Left Header", Alignment.Right),
                    new ColumnHeader("Right Header", Alignment.Center, Alignment.Right),
                };
                Table table = new Table(headers);

                table.Config = TableConfiguration.MySqlSimple();
                table.AddRow("1", "2", "3");
                table.AddRow("Short", "item", "Here");
                table.AddRow("Longer items go here", "Right Contents", "Centered Contents");

                Console.Write(table.ToString());
            }
        }
예제 #32
0
        /// <summary>
        /// Helper method to write the machine learning pipeline to the console.
        /// </summary>
        /// <param name="preview">The data preview to write.</param>
        /// <param name="numberOfRows">The maximum number of rows to write.</param>
        public static void WritePreview(DataDebuggerPreview preview, int numberOfRows = 10)
        {
            // set up a console table
            var table = new Table(
                TableConfiguration.Unicode(),
                (from c in preview.ColumnView select c.Column.Name).ToArray());

            // fill the table with results
            foreach (var row in preview.RowView)
            {
                table.AddRow((from c in row.Values
                              select c.Value is VBuffer <float>? "<vector>" : c.Value
                              ).ToArray());
            }

            // write the table
            Console.WriteLine(table.ToString());
        }
        protected override void CorePublishImpl(TableConfiguration configuration, IUnitOfWork destinationUnitOfWork, IDataReader sourceDataReader, out long rowsCopied)
        {
            long _rowsCopied = 0;
            //SqlRowsCopiedEventHandler callback;

            if ((object)configuration == null)
                throw new ArgumentNullException("configuration");

            if ((object)destinationUnitOfWork == null)
                throw new ArgumentNullException("destinationUnitOfWork");

            if ((object)sourceDataReader == null)
                throw new ArgumentNullException("sourceDataReader");

            if (DataTypeFascade.Instance.IsNullOrWhiteSpace(this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText))
                throw new InvalidOperationException(string.Format("Configuration missing: '{0}'.", "ExecuteCommandText"));

            using (SqlBulkCopy sqlBulkCopy = new SqlBulkCopy((SqlConnection)destinationUnitOfWork.Connection, SqlBulkCopyOptions.FireTriggers | SqlBulkCopyOptions.CheckConstraints | SqlBulkCopyOptions.KeepIdentity | SqlBulkCopyOptions.KeepNulls, (SqlTransaction)destinationUnitOfWork.Transaction))
            {
                //callback = (sender, e) => Console.WriteLine(_rowsCopied = e.RowsCopied);

                foreach (ColumnConfiguration columnConfiguration in configuration.ColumnConfigurations)
                    sqlBulkCopy.ColumnMappings.Add(columnConfiguration.ColumnName, columnConfiguration.ColumnName);

                sqlBulkCopy.EnableStreaming = true;
                sqlBulkCopy.BatchSize = 2500;
                sqlBulkCopy.NotifyAfter = 2500;
                //sqlBulkCopy.SqlRowsCopied += callback;
                sqlBulkCopy.DestinationTableName = this.AdapterConfiguration.AdapterSpecificConfiguration.ExecuteCommandText;

                sqlBulkCopy.WriteToServer(sourceDataReader);

                //sqlBulkCopy.SqlRowsCopied -= callback;
            }

            rowsCopied = _rowsCopied;
        }
            public LogTable(Database database, TableConfiguration configuration)
            {
                _table = database.Tables.Cast<Table>().SingleOrDefault(table => table.ToString() == configuration.LogTableQualifier)
                    ?? CreateTable(database, configuration);

                Validate();
            }
            private static Table CreateTable(Database database, TableConfiguration configuration)
            {
                var table = new Table(database, configuration.LogTableName, configuration.Schema);
                table.Columns.Add(new Column(table, PartIdColumn, DataType.BigInt));
                table.Columns.Add(new Column(table, LocaleIdColumn, DataType.Int));
                table.Columns.Add(new Column(table, KeyColumn, DataType.VarChar(500)));
                table.Columns.Add(new Column(table, DateColumn, DataType.DateTime));

                var index = new Index(table, "IX_" + configuration.LogTableName) { IndexKeyType = IndexKeyType.None };
                index.IndexedColumns.Add(new IndexedColumn(index, PartIdColumn));
                index.IndexedColumns.Add(new IndexedColumn(index, LocaleIdColumn));
                index.IndexedColumns.Add(new IndexedColumn(index, KeyColumn));
                table.Indexes.Add(index);

                database.Tables.Add(table);
                table.Create();
                var partLink = new ForeignKey(table, "FK_" + configuration.LogTableName + "_" + configuration.PartTableName) {
                    ReferencedTable = configuration.PartTableName,
                    ReferencedTableSchema = configuration.Schema
                };
                partLink.Columns.Add(new ForeignKeyColumn(partLink, PartIdColumn, PartTable.IdColumn));
                table.ForeignKeys.Add(partLink);
                partLink.Create();

                var localeLink = new ForeignKey(table, "FK_" + configuration.LogTableName + "_" + configuration.LocaleTableName) {
                    ReferencedTable = configuration.LocaleTableName,
                    ReferencedTableSchema = configuration.Schema
                };
                localeLink.Columns.Add(new ForeignKeyColumn(localeLink, LocaleIdColumn, LocaleTable.IdColumn));
                table.ForeignKeys.Add(localeLink);
                localeLink.Create();

                return table;
            }
            private static Table CreateTable(Database database, TableConfiguration configuration)
            {
                var table = new Table(database, configuration.PartTableName, configuration.Schema);
                table.Columns.Add(new Column(table, IdColumn, DataType.BigInt) {Identity = true});
                table.Columns.Add(new Column(table, NameColumn, DataType.VarChar(500)));
                table.Columns.Add(new Column(table, ParentIdColumn, DataType.BigInt) { Nullable = true });

                var primaryKey = new Index(table, "PK_" + configuration.PartTableName) { IndexKeyType = IndexKeyType.DriPrimaryKey };
                primaryKey.IndexedColumns.Add(new IndexedColumn(primaryKey, IdColumn));
                table.Indexes.Add(primaryKey);

                var uniqueKey = new Index(table, "UQ_" + configuration.PartTableName + "_" + ParentIdColumn + "_" + NameColumn) { IndexKeyType = IndexKeyType.DriUniqueKey };
                uniqueKey.IndexedColumns.Add(new IndexedColumn(uniqueKey, ParentIdColumn));
                uniqueKey.IndexedColumns.Add(new IndexedColumn(uniqueKey, NameColumn));
                table.Indexes.Add(uniqueKey);

                var selfLink = new ForeignKey(table, "FK_" + configuration.PartTableName + "_" + configuration.PartTableName) {
                    ReferencedTable = configuration.PartTableName,
                    ReferencedTableSchema = configuration.Schema
                };
                selfLink.Columns.Add(new ForeignKeyColumn(selfLink, ParentIdColumn, IdColumn));
                table.ForeignKeys.Add(selfLink);

                database.Tables.Add(table);
                table.Create();
                return table;
            }
            private static Table CreateTable(Database database, TableConfiguration configuration)
            {
                var table = new Table(database, configuration.LocaleTableName, configuration.Schema);
                table.Columns.Add(new Column(table, IdColumn, DataType.Int) { Identity = true });
                table.Columns.Add(new Column(table, NameColumn, DataType.VarChar(500)));

                var primaryKey = new Index(table, "PK_" + configuration.LocaleTableName) { IndexKeyType = IndexKeyType.DriPrimaryKey };
                primaryKey.IndexedColumns.Add(new IndexedColumn(primaryKey, IdColumn));
                table.Indexes.Add(primaryKey);

                var uniqueKey = new Index(table, "UQ_" + configuration.LocaleTableName + "_" + NameColumn) { IndexKeyType = IndexKeyType.DriUniqueKey };
                uniqueKey.IndexedColumns.Add(new IndexedColumn(uniqueKey, NameColumn));
                table.Indexes.Add(uniqueKey);

                database.Tables.Add(table);
                table.Create();
                return table;
            }
            private static Table CreateTable(Database database, TableConfiguration configuration)
            {
                var table = new Table(database, configuration.ValueTableName, configuration.Schema);
                table.Columns.Add(new Column(table, PartIdColumn, DataType.BigInt));
                table.Columns.Add(new Column(table, LocaleIdColumn, DataType.Int));
                table.Columns.Add(new Column(table, KeyColumn, DataType.VarChar(500)));
                table.Columns.Add(new Column(table, ContentColumn, DataType.VarCharMax));

                var primaryKey = new Index(table, "PK_" + configuration.ValueTableName) { IndexKeyType = IndexKeyType.DriPrimaryKey };
                primaryKey.IndexedColumns.Add(new IndexedColumn(primaryKey, PartIdColumn));
                primaryKey.IndexedColumns.Add(new IndexedColumn(primaryKey, LocaleIdColumn));
                primaryKey.IndexedColumns.Add(new IndexedColumn(primaryKey, KeyColumn));
                table.Indexes.Add(primaryKey);

                database.Tables.Add(table);
                table.Create();
                var partLink = new ForeignKey(table, "FK_" + configuration.ValueTableName + "_" + configuration.PartTableName) {
                    ReferencedTable = configuration.PartTableName,
                    ReferencedTableSchema = configuration.Schema
                };
                partLink.Columns.Add(new ForeignKeyColumn(partLink, PartIdColumn, PartTable.IdColumn));
                table.ForeignKeys.Add(partLink);
                partLink.Create();

                var localeLink = new ForeignKey(table, "FK_" + configuration.ValueTableName + "_" + configuration.LocaleTableName) {
                    ReferencedTable = configuration.LocaleTableName,
                    ReferencedTableSchema = configuration.Schema
                };
                localeLink.Columns.Add(new ForeignKeyColumn(localeLink, LocaleIdColumn, LocaleTable.IdColumn));
                table.ForeignKeys.Add(localeLink);
                localeLink.Create();

                return table;
            }
            public PartTable(SqlConnection connection, Database database, TableConfiguration configuration)
            {
                _table = database.Tables.Cast<Table>().SingleOrDefault(table => table.ToString() == configuration.PartTableQualifier)
                    ?? CreateTable(database, configuration);

                Validate();
                ReloadParts(connection);
            }