private async Task DeployToTarget(TargetDatabase target, IEnumerable <SqlScriptFile> scriptFiles, IProgress <ProgressEventArgs> progress) { target.DeploymentStatus = "Initiating connection..."; var couldOpen = await target.TryConnect(); target.DeploymentStatus = "Connected!"; if (couldOpen) { try { await target.DeployAsync(scriptFiles); target.DeploymentStatus = "Success"; target.State = 1; OnProgress(target, progress); } catch (Exception ex) { target.Messages.Add(new ExecutionMessage(ex)); target.DeploymentStatus = "Error"; target.State = 2; OnProgress(target, progress); } } return; }
private async Task DeployToTarget(TargetDatabase target, IEnumerable <SqlScriptFile> scriptFiles, IProgress <ProgressEventArgs> progress, CancellationToken ct) { target.DeploymentStatusMessage = "Initiating connection..."; OnProgress(target, progress); var couldOpen = await target.TryConnect(ct).ConfigureAwait(false); if (couldOpen) { target.DeploymentStatusMessage = "Connected!"; OnProgress(target, progress); try { await target.DeployAsync(scriptFiles, ct).ConfigureAwait(false); target.DeploymentStatusMessage = "Success"; target.DeploymentState = Database.DatabaseDeploymentState.Success; OnProgress(target, progress); } catch (OperationCanceledException ex) { //Deployment.Status = DeploymentStatus.Cancelled; target.Messages.Add(new ExecutionMessage(ex)); target.DeploymentStatusMessage = "Cancelled"; target.DeploymentState = Database.DatabaseDeploymentState.Cancelled; OnProgress(target, progress); } catch (Exception ex) { target.Messages.Add(new ExecutionMessage(ex)); target.DeploymentStatusMessage = "Error"; target.DeploymentState = Database.DatabaseDeploymentState.Error; OnProgress(target, progress); } finally { target?.Dispose(); } } else { target.DeploymentState = Database.DatabaseDeploymentState.Error; OnProgress(target, progress); } }