[SQL Migration] Properly respect user's encryptConnection and trustServerCertificate settings (#21824)

* WIP

* Always get latest current connection

* Update more references

* Clean up

* Clean up

* vbump

* Update comments

* Address PR feedback

* Separate into helper methods
This commit is contained in:
Raymond Truong
2023-02-08 10:12:11 -08:00
committed by GitHub
parent 99a924dbcd
commit 480d8e2cd0
25 changed files with 206 additions and 154 deletions

View File

@@ -14,6 +14,7 @@ import { WizardController } from '../../wizard/wizardController';
import { getMigrationModeEnum, getMigrationTargetTypeEnum } from '../../constants/helper';
import * as constants from '../../constants/strings';
import { ServiceContextChangeEvent } from '../../dashboard/tabBase';
import { getSourceConnectionProfile } from '../../api/sqlUtils';
export class RetryMigrationDialog {
@@ -27,12 +28,11 @@ export class RetryMigrationDialog {
private async createMigrationStateModel(
serviceContext: MigrationServiceContext,
migration: DatabaseMigration,
connectionId: string,
serverName: string,
api: mssql.IExtension,
location: azureResource.AzureLocation): Promise<MigrationStateModel> {
const stateModel = new MigrationStateModel(this._context, connectionId, api.sqlMigration, api.tdeMigration);
const stateModel = new MigrationStateModel(this._context, api.sqlMigration, api.tdeMigration);
const sourceDatabaseName = migration.properties.sourceDatabaseName;
const savedInfo: SavedInfo = {
closedPage: 0,
@@ -149,29 +149,26 @@ export class RetryMigrationDialog {
}
});
const activeConnection = await azdata.connection.getCurrentConnection();
let connectionId: string = '';
const activeConnection = await getSourceConnectionProfile();
let serverName: string = '';
if (!activeConnection) {
const connection = await azdata.connection.openConnectionDialog();
if (connection) {
connectionId = connection.connectionId;
serverName = connection.options.server;
}
} else {
connectionId = activeConnection.connectionId;
serverName = activeConnection.serverName;
}
const api = (await vscode.extensions.getExtension(mssql.extension.name)?.activate()) as mssql.IExtension;
const stateModel = await this.createMigrationStateModel(this._serviceContext, this._migration, connectionId, serverName, api, location!);
const stateModel = await this.createMigrationStateModel(this._serviceContext, this._migration, serverName, api, location!);
if (await stateModel.loadSavedInfo()) {
const wizardController = new WizardController(
this._context,
stateModel,
this._serviceContextChangedEvent);
await wizardController.openWizard(stateModel.sourceConnectionId);
await wizardController.openWizard();
} else {
void vscode.window.showInformationMessage(constants.MIGRATION_CANNOT_RETRY);
}