Beispiel #1
0
        public DynamicJsonValue SimulateSqlReplicationSqlQueries(SimulateSqlReplication simulateSqlReplication, DocumentsOperationContext context)
        {
            try
            {
                var document       = _database.DocumentsStorage.Get(context, simulateSqlReplication.DocumentId);
                var sqlReplication = new SqlReplication(_database, simulateSqlReplication.Configuration);

                var result = sqlReplication.ApplyConversionScript(new List <Document> {
                    document
                }, context);

                if (sqlReplication.PrepareSqlReplicationConfig(_connections, false) == false)
                {
                    return(new DynamicJsonValue
                    {
                        ["LastAlert"] = sqlReplication.Statistics.LastAlert,
                    });
                }

                return(sqlReplication.Simulate(simulateSqlReplication, context, result));
            }
            catch (Exception e)
            {
                return(new DynamicJsonValue
                {
                    ["LastAlert"] = new Alert
                    {
                        Type = AlertType.SqlReplicationError,
                        Severity = AlertSeverity.Error,
                        CreatedAt = SystemTime.UtcNow,
                        Key = simulateSqlReplication.Configuration.Name,
                        Message = "SQL replication error",
                        Content = new ExceptionAlertContent
                        {
                            Message = "Last SQL replication operation for " + simulateSqlReplication.Configuration.Name + " was failed",
                            Exception = e.ToString()
                        }
                    }
                });
            }
        }