コード例 #1
0
ファイル: SqlEtl.cs プロジェクト: sashatim125/ravendb
        public SqlEtlTestScriptResult RunTest(DocumentsOperationContext context, IEnumerable <SqlTableWithRecords> toWrite, bool performRolledBackTransaction)
        {
            var summaries = new List <TableQuerySummary>();

            if (performRolledBackTransaction)
            {
                try
                {
                    using (var writer = new RelationalDatabaseWriter(this, Database))
                    {
                        foreach (var records in toWrite)
                        {
                            var commands = new List <DbCommand>();

                            writer.Write(records, commands, CancellationToken);

                            summaries.Add(TableQuerySummary.GenerateSummaryFromCommands(records.TableName, commands));
                        }

                        writer.Rollback();
                    }
                }
                catch (Exception e)
                {
                    Statistics.RecordLoadError(e.ToString(), documentId: null, count: 1);
                }
            }
            else
            {
                var simulatedWriter = new RelationalDatabaseWriterSimulator(Configuration);

                foreach (var records in toWrite)
                {
                    var commands = simulatedWriter.SimulateExecuteCommandText(records, CancellationToken).Select(x => new TableQuerySummary.CommandData
                    {
                        CommandText = x
                    }).ToArray();

                    summaries.Add(new TableQuerySummary
                    {
                        TableName = records.TableName,
                        Commands  = commands
                    });
                }
            }

            return(new SqlEtlTestScriptResult
            {
                TransformationErrors = Statistics.TransformationErrorsInCurrentBatch.Errors.ToList(),
                LoadErrors = Statistics.LastLoadErrorsInCurrentBatch.Errors.ToList(),
                SlowSqlWarnings = Statistics.LastSlowSqlWarningsInCurrentBatch.Statements.ToList(),
                Summary = summaries
            });
        }
コード例 #2
0
ファイル: SqlEtl.cs プロジェクト: jeason0813/ravendb
        protected override void LoadInternal(IEnumerable <SqlTableWithRecords> records, JsonOperationContext context)
        {
            using (var writer = new RelationalDatabaseWriter(this, Database))
            {
                foreach (var table in records)
                {
                    var stats = writer.Write(table, null, CancellationToken);

                    LogStats(stats, table);
                }

                writer.Commit();
            }
        }
コード例 #3
0
ファイル: SqlEtl.cs プロジェクト: jeason0813/ravendb
        public SqlEtlSimulationResult Simulate(SimulateSqlEtl simulateSqlEtl, DocumentsOperationContext context, IEnumerable <SqlTableWithRecords> toWrite)
        {
            var summaries = new List <TableQuerySummary>();

            if (simulateSqlEtl.PerformRolledBackTransaction)
            {
                using (var writer = new RelationalDatabaseWriter(this, Database))
                {
                    foreach (var records in toWrite)
                    {
                        var commands = new List <DbCommand>();

                        writer.Write(records, commands, CancellationToken);

                        summaries.Add(TableQuerySummary.GenerateSummaryFromCommands(records.TableName, commands));
                    }

                    writer.Rollback();
                }
            }
            else
            {
                var simulatedwriter = new RelationalDatabaseWriterSimulator(Configuration);

                foreach (var records in toWrite)
                {
                    var commands = simulatedwriter.SimulateExecuteCommandText(records, CancellationToken).Select(x => new TableQuerySummary.CommandData
                    {
                        CommandText = x
                    }).ToArray();

                    summaries.Add(new TableQuerySummary
                    {
                        TableName = records.TableName,
                        Commands  = commands
                    });
                }
            }

            return(new SqlEtlSimulationResult
            {
                LastAlert = Statistics.LastAlert,
                Summary = summaries
            });
        }
コード例 #4
0
ファイル: SqlEtl.cs プロジェクト: yitaom2/ravendb
        protected override int LoadInternal(IEnumerable <SqlTableWithRecords> records, DocumentsOperationContext context)
        {
            var count = 0;

            using (var writer = new RelationalDatabaseWriter(this, Database))
            {
                foreach (var table in records)
                {
                    var stats = writer.Write(table, null, CancellationToken);

                    LogStats(stats, table);

                    count += stats.DeletedRecordsCount + stats.InsertedRecordsCount;
                }

                writer.Commit();
            }

            return(count);
        }