mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Update dacpac and schema compare extensions to use getConnections() (#6131)
* update dacpac and schema compare extensions to use getConnections * use more const * make MSSQL a const * changing name of mssql const * add comment for name of parameter
This commit is contained in:
@@ -46,7 +46,7 @@ export abstract class BasePage {
|
|||||||
public abstract setupNavigationValidator();
|
public abstract setupNavigationValidator();
|
||||||
|
|
||||||
protected async getServerValues(): Promise<{ connection, displayName, name }[]> {
|
protected async getServerValues(): Promise<{ connection, displayName, name }[]> {
|
||||||
let cons = await azdata.connection.getActiveConnections();
|
let cons = await azdata.connection.getConnections(/* activeConnectionsOnly */ true);
|
||||||
// This user has no active connections ABORT MISSION
|
// This user has no active connections ABORT MISSION
|
||||||
if (!cons || cons.length === 0) {
|
if (!cons || cons.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|||||||
@@ -167,6 +167,6 @@ export abstract class DacFxConfigPage extends BasePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ConnectionDropdownValue extends azdata.CategoryValue {
|
interface ConnectionDropdownValue extends azdata.CategoryValue {
|
||||||
connection: azdata.connection.Connection;
|
connection: azdata.connection.ConnectionProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import * as azdata from 'azdata';
|
|||||||
* Data model to communicate between DacFx pages
|
* Data model to communicate between DacFx pages
|
||||||
*/
|
*/
|
||||||
export interface DacFxDataModel {
|
export interface DacFxDataModel {
|
||||||
server: azdata.connection.Connection;
|
server: azdata.connection.ConnectionProfile;
|
||||||
database: string;
|
database: string;
|
||||||
serverName: string;
|
serverName: string;
|
||||||
serverId: string;
|
serverId: string;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { DacFxDataModel } from './api/models';
|
|||||||
import { BasePage } from './api/basePage';
|
import { BasePage } from './api/basePage';
|
||||||
|
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
const msSqlProvider = 'MSSQL';
|
||||||
class Page {
|
class Page {
|
||||||
wizardPage: azdata.window.WizardPage;
|
wizardPage: azdata.window.WizardPage;
|
||||||
dacFxPage: BasePage;
|
dacFxPage: BasePage;
|
||||||
@@ -252,10 +252,10 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async deploy() {
|
private async deploy() {
|
||||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||||
|
|
||||||
let result = await service.deployDacpac(this.model.filePath, this.model.database, this.model.upgradeExisting, ownerUri, azdata.TaskExecutionMode.execute);
|
const result = await service.deployDacpac(this.model.filePath, this.model.database, this.model.upgradeExisting, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
localize('alertData.deployErrorMessage', "Deploy failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
localize('alertData.deployErrorMessage', "Deploy failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||||
@@ -263,10 +263,10 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async extract() {
|
private async extract() {
|
||||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||||
|
|
||||||
let result = await service.extractDacpac(this.model.database, this.model.filePath, this.model.database, this.model.version, ownerUri, azdata.TaskExecutionMode.execute);
|
const result = await service.extractDacpac(this.model.database, this.model.filePath, this.model.database, this.model.version, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
localize('alertData.extractErrorMessage', "Extract failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
localize('alertData.extractErrorMessage', "Extract failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||||
@@ -274,10 +274,10 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async export() {
|
private async export() {
|
||||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||||
|
|
||||||
let result = await service.exportBacpac(this.model.database, this.model.filePath, ownerUri, azdata.TaskExecutionMode.execute);
|
const result = await service.exportBacpac(this.model.database, this.model.filePath, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
localize('alertData.exportErrorMessage', "Export failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
localize('alertData.exportErrorMessage', "Export failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||||
@@ -285,10 +285,10 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async import() {
|
private async import() {
|
||||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||||
|
|
||||||
let result = await service.importBacpac(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
const result = await service.importBacpac(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
localize('alertData.importErrorMessage', "Import failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
localize('alertData.importErrorMessage', "Import failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||||
@@ -296,15 +296,15 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async generateDeployScript() {
|
private async generateDeployScript() {
|
||||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||||
this.wizard.message = {
|
this.wizard.message = {
|
||||||
text: localize('dacfx.scriptGeneratingMessage', 'You can view the status of script generation in the Tasks View once the wizard is closed. The generated script will open when complete.'),
|
text: localize('dacfx.scriptGeneratingMessage', 'You can view the status of script generation in the Tasks View once the wizard is closed. The generated script will open when complete.'),
|
||||||
level: azdata.window.MessageLevel.Information,
|
level: azdata.window.MessageLevel.Information,
|
||||||
description: ''
|
description: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = await service.generateDeployScript(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.script);
|
const result = await service.generateDeployScript(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.script);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
localize('alertData.deployErrorMessage', "Deploy failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
localize('alertData.deployErrorMessage', "Deploy failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||||
@@ -351,10 +351,10 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async generateDeployPlan(): Promise<string> {
|
public async generateDeployPlan(): Promise<string> {
|
||||||
let service = await DataTierApplicationWizard.getService(this.model.server.providerName);
|
const service = await DataTierApplicationWizard.getService(msSqlProvider);
|
||||||
let ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
const ownerUri = await azdata.connection.getUriForConnection(this.model.server.connectionId);
|
||||||
|
|
||||||
let result = await service.generateDeployPlan(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
const result = await service.generateDeployPlan(this.model.filePath, this.model.database, ownerUri, azdata.TaskExecutionMode.execute);
|
||||||
|
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
vscode.window.showErrorMessage(
|
vscode.window.showErrorMessage(
|
||||||
@@ -365,7 +365,7 @@ export class DataTierApplicationWizard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async getService(providerName: string): Promise<azdata.DacFxServicesProvider> {
|
private static async getService(providerName: string): Promise<azdata.DacFxServicesProvider> {
|
||||||
let service = azdata.dataprotocol.getProvider<azdata.DacFxServicesProvider>(providerName, azdata.DataProviderType.DacFxServicesProvider);
|
const service = azdata.dataprotocol.getProvider<azdata.DacFxServicesProvider>(providerName, azdata.DataProviderType.DacFxServicesProvider);
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -513,8 +513,8 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async getServerValues(isTarget: boolean): Promise<{ connection: azdata.connection.Connection, displayName: string, name: string }[]> {
|
protected async getServerValues(isTarget: boolean): Promise<{ connection: azdata.connection.ConnectionProfile, displayName: string, name: string }[]> {
|
||||||
let cons = await azdata.connection.getActiveConnections();
|
let cons = await azdata.connection.getConnections(/* activeConnectionsOnly */ true);
|
||||||
// This user has no active connections
|
// This user has no active connections
|
||||||
if (!cons || cons.length === 0) {
|
if (!cons || cons.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -668,5 +668,5 @@ export class SchemaCompareDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface ConnectionDropdownValue extends azdata.CategoryValue {
|
interface ConnectionDropdownValue extends azdata.CategoryValue {
|
||||||
connection: azdata.connection.Connection;
|
connection: azdata.connection.ConnectionProfile;
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,7 @@ import { getTelemetryErrorType, getEndpointName } from './utils';
|
|||||||
import { SchemaCompareDialog } from './dialogs/schemaCompareDialog';
|
import { SchemaCompareDialog } from './dialogs/schemaCompareDialog';
|
||||||
import { isNullOrUndefined } from 'util';
|
import { isNullOrUndefined } from 'util';
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
const msSqlProvider = 'MSSQL';
|
||||||
const diffEditorTitle = localize('schemaCompare.CompareDetailsTitle', 'Compare Details');
|
const diffEditorTitle = localize('schemaCompare.CompareDetailsTitle', 'Compare Details');
|
||||||
const applyConfirmation = localize('schemaCompare.ApplyConfirmation', 'Are you sure you want to update the target?');
|
const applyConfirmation = localize('schemaCompare.ApplyConfirmation', 'Are you sure you want to update the target?');
|
||||||
const reCompareToRefeshMessage = localize('schemaCompare.RecompareToRefresh', 'Press Compare to refresh the comparison.');
|
const reCompareToRefeshMessage = localize('schemaCompare.RecompareToRefresh', 'Press Compare to refresh the comparison.');
|
||||||
@@ -252,7 +253,7 @@ export class SchemaCompareResult {
|
|||||||
this.deploymentOptions = this.schemaCompareOptionDialog.deploymentOptions;
|
this.deploymentOptions = this.schemaCompareOptionDialog.deploymentOptions;
|
||||||
}
|
}
|
||||||
Telemetry.sendTelemetryEvent('SchemaComparisonStarted');
|
Telemetry.sendTelemetryEvent('SchemaComparisonStarted');
|
||||||
const service = await SchemaCompareResult.getService('MSSQL');
|
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||||
if (!this.operationId) {
|
if (!this.operationId) {
|
||||||
// create once per page
|
// create once per page
|
||||||
this.operationId = generateGuid();
|
this.operationId = generateGuid();
|
||||||
@@ -545,7 +546,7 @@ export class SchemaCompareResult {
|
|||||||
|
|
||||||
// cancel compare
|
// cancel compare
|
||||||
if (this.operationId) {
|
if (this.operationId) {
|
||||||
const service = await SchemaCompareResult.getService('MSSQL');
|
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||||
const result = await service.schemaCompareCancel(this.operationId);
|
const result = await service.schemaCompareCancel(this.operationId);
|
||||||
|
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
@@ -577,7 +578,7 @@ export class SchemaCompareResult {
|
|||||||
'startTime:': Date.now().toString(),
|
'startTime:': Date.now().toString(),
|
||||||
'operationId': this.comparisonResult.operationId
|
'operationId': this.comparisonResult.operationId
|
||||||
});
|
});
|
||||||
const service = await SchemaCompareResult.getService('MSSQL');
|
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||||
const result = await service.schemaCompareGenerateScript(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.script);
|
const result = await service.schemaCompareGenerateScript(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.script);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
Telemetry.sendTelemetryEvent('SchemaCompareGenerateScriptFailed', {
|
Telemetry.sendTelemetryEvent('SchemaCompareGenerateScriptFailed', {
|
||||||
@@ -642,7 +643,7 @@ export class SchemaCompareResult {
|
|||||||
// disable apply and generate script buttons because the results are no longer valid after applying the changes
|
// disable apply and generate script buttons because the results are no longer valid after applying the changes
|
||||||
this.setButtonsForRecompare();
|
this.setButtonsForRecompare();
|
||||||
|
|
||||||
const service = await SchemaCompareResult.getService('MSSQL');
|
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||||
const result = await service.schemaComparePublishChanges(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.execute);
|
const result = await service.schemaComparePublishChanges(this.comparisonResult.operationId, this.targetEndpointInfo.serverName, this.targetEndpointInfo.databaseName, azdata.TaskExecutionMode.execute);
|
||||||
if (!result || !result.success) {
|
if (!result || !result.success) {
|
||||||
Telemetry.sendTelemetryEvent('SchemaCompareApplyFailed', {
|
Telemetry.sendTelemetryEvent('SchemaCompareApplyFailed', {
|
||||||
@@ -777,7 +778,7 @@ export class SchemaCompareResult {
|
|||||||
|
|
||||||
private async GetDefaultDeploymentOptions(): Promise<void> {
|
private async GetDefaultDeploymentOptions(): Promise<void> {
|
||||||
// Same as dacfx default options
|
// Same as dacfx default options
|
||||||
const service = await SchemaCompareResult.getService('MSSQL');
|
const service = await SchemaCompareResult.getService(msSqlProvider);
|
||||||
let result = await service.schemaCompareGetDefaultOptions();
|
let result = await service.schemaCompareGetDefaultOptions();
|
||||||
this.deploymentOptions = result.defaultDeploymentOptions;
|
this.deploymentOptions = result.defaultDeploymentOptions;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user