private void ExecuteScript(ScriptAccessor scriptAccessor) { using (var connection = Configuration.GetConnection()) { connection.InfoMessage += InfoMessage; using (var txn = connection.BeginTransaction()) { try { var script = scriptAccessor.Read(); var commands = Regex.Split(script, @"(?m)^\s*GO\s*\d*\s*$", RegexOptions.IgnoreCase); foreach (var c in commands.Where(q => !string.IsNullOrEmpty(q))) { new SqlCommand(c, connection, txn).ExecuteNonQuery(); } txn.Commit(); } catch { txn.Rollback(); throw; } finally { connection.InfoMessage -= InfoMessage; } } } }
private bool ContentHasChanged( SqlConnection connection, ScriptsRunInfo recordedScript, string foundScript) { var found = new ScriptAccessor(foundScript); var foundInfo = new ScriptsRunInfo { ScriptText = found.Read() }; return(foundInfo.ScriptHash != recordedScript.ScriptHash); }