Exemplo n.º 1
0
 public void PutMaterialize(SqlScriptCompiler cmp)
 {
     if (_materializedName == null) return;
     cmp.PutSmallTitleComment($"Materialize of entity {SqlAlias}");
     cmp.StartTimeMeasure("OP");
     cmp.GenCommandSql(_materializeSelect);
     cmp.PutLogMessage(null, LogOperationType.Materialize, $"@rows rows of {SqlAlias} materialized", "OP");
 }
Exemplo n.º 2
0
 private void RunCoreRound2Reverted(SqlScriptCompiler cmp)
 {
     if (_dbsh.LifetimeHandler.CreateDelete)
     {
         var delete = CompileDelete();
         if (delete != null)
         {
             cmp.StartTimeMeasure("OP");
             cmp.PutSmallTitleComment("DELETE");
             cmp.GenCommandSql(delete);
             cmp.PutLogMessage(this, LogOperationType.Delete, "@rows rows deleted", "OP");
         }
     }
 }
Exemplo n.º 3
0
        private void RunCore(SqlScriptCompiler cmp, bool useTransaction, Action<SqlScriptCompiler> doRun, int round)
        {
            cmp.PutMainTitleComment($"Synchronize entity {SqlAlias} (table {TargetTable}) - round {round}");

            cmp.StartTimeMeasure("TABLE");

            cmp.PutBeginTryCatch(this);
            cmp.Put("&>");
            doRun(cmp);
            cmp.Put("&<");
            cmp.PutEndTryCatch(this, useTransaction);

            cmp.PutLogMessage(this, LogOperationType.TableSynchronized, $"table synchronized - round {round}", "TABLE");
        }
Exemplo n.º 4
0
        private void RunCoreRound1(SqlScriptCompiler cmp)
        {
            if (_dbsh.LifetimeHandler.CreateMarkRelived)
            {
                var update = CompileMarkRelived();
                if (update != null)
                {
                    cmp.StartTimeMeasure("OP");
                    cmp.PutSmallTitleComment("MARK RELIVED");
                    cmp.GenCommandSql(update);
                    cmp.EndCommand();
                    cmp.PutLogMessage(this, LogOperationType.MarkRelived, "@rows rows marked as relived", "OP");
                }
            }

            if (_dbsh.LifetimeHandler.CreateMarkDeleted)
            {
                var update = CompileMarkDeleted();
                if (update != null)
                {
                    cmp.StartTimeMeasure("OP");
                    cmp.PutSmallTitleComment("MARK DELETED");
                    cmp.GenCommandSql(update);
                    cmp.PutLogMessage(this, LogOperationType.MarkDeleted, "@rows rows marked as deleted", "OP");
                }
            }

            if (_dbsh.LifetimeHandler.CreateMarkUpdated)
            {
                var update = CompileMarkUpdated();
                if (update != null)
                {
                    cmp.StartTimeMeasure("OP");
                    cmp.PutSmallTitleComment("MARK UPDATED");
                    cmp.GenCommandSql(update);
                    cmp.PutLogMessage(this, LogOperationType.MarkUpdated, "@rows rows marked as updated", "OP");
                }
            }

            if (_dbsh.LifetimeHandler.CreateInsert)
            {
                var insert = CompileInsert();
                if (insert != null)
                {
                    cmp.StartTimeMeasure("OP");
                    cmp.PutSmallTitleComment("INSERT");
                    bool isIdentity = Structure != null && Structure.Columns.Any(x => x.AutoIncrement && insert.TargetColumns.Contains(x.Name));
                    if (isIdentity) cmp.GenCommandSql(dmp => dmp.AllowIdentityInsert(insert.TargetTable, true));
                    cmp.GenCommandSql(insert);
                    cmp.PutLogMessage(this, LogOperationType.Insert, "@rows rows inserted", "OP");
                    if (isIdentity) cmp.GenCommandSql(dmp => dmp.AllowIdentityInsert(insert.TargetTable, false));
                }
            }

            if (_dbsh.LifetimeHandler.CreateUpdate)
            {
                var update = CompileUpdate();
                if (update != null)
                {
                    cmp.StartTimeMeasure("OP");
                    cmp.PutSmallTitleComment("UPDATE");
                    cmp.GenCommandSql(update);
                    cmp.PutLogMessage(this, LogOperationType.Update, "@rows rows updated", "OP");
                }
            }
        }