mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-12 19:18:32 -05:00
Agent/edit job logic (#3023)
* lumped stepdata with jobdata in job dialog * fix bug with empty steps * added clumped and update steps and schedules from job dialog * edit data sends one call instead of multiple * cleaned code
This commit is contained in:
@@ -9,6 +9,7 @@ import * as vscode from 'vscode';
|
||||
import * as sqlops from 'sqlops';
|
||||
import { AgentUtils } from '../agentUtils';
|
||||
import { IAgentDialogData, AgentDialogMode } from '../interfaces';
|
||||
import { JobData } from './jobData';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
@@ -45,8 +46,19 @@ export class AlertData implements IAgentDialogData {
|
||||
wmiEventNamespace: string;
|
||||
wmiEventQuery: string;
|
||||
|
||||
constructor(ownerUri:string, alertInfo: sqlops.AgentAlertInfo) {
|
||||
private viaJobDialog: boolean;
|
||||
private jobModel: JobData;
|
||||
|
||||
constructor(
|
||||
ownerUri:string,
|
||||
alertInfo: sqlops.AgentAlertInfo,
|
||||
jobModel?: JobData,
|
||||
viaJobDialog: boolean = false
|
||||
) {
|
||||
this.ownerUri = ownerUri;
|
||||
this.viaJobDialog = viaJobDialog;
|
||||
this.jobModel = jobModel;
|
||||
this.jobName = this.jobName ? this.jobName : this.jobModel.name;
|
||||
|
||||
if (alertInfo) {
|
||||
this.dialogMode = AgentDialogMode.EDIT;
|
||||
@@ -60,7 +72,6 @@ export class AlertData implements IAgentDialogData {
|
||||
this.includeEventDescription = alertInfo.includeEventDescription.toString();
|
||||
this.isEnabled = alertInfo.isEnabled;
|
||||
this.jobId = alertInfo.jobId;
|
||||
this.jobName = alertInfo.jobName;
|
||||
this.lastOccurrenceDate = alertInfo.lastOccurrenceDate;
|
||||
this.lastResponseDate = alertInfo.lastResponseDate;
|
||||
this.messageId = alertInfo.messageId;
|
||||
@@ -82,10 +93,18 @@ export class AlertData implements IAgentDialogData {
|
||||
|
||||
public async save() {
|
||||
let agentService = await AgentUtils.getAgentService();
|
||||
let result = this.dialogMode === AgentDialogMode.CREATE
|
||||
? await agentService.createAlert(this.ownerUri, this.toAgentAlertInfo())
|
||||
: await agentService.updateAlert(this.ownerUri, this.originalName, this.toAgentAlertInfo());
|
||||
|
||||
let result: any;
|
||||
// if it's called via the job dialog, add it to the
|
||||
// job model
|
||||
if (this.viaJobDialog) {
|
||||
if (this.jobModel) {
|
||||
Promise.resolve(this);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// has to be a create alert
|
||||
result = await agentService.createAlert(this.ownerUri, this.toAgentAlertInfo());
|
||||
}
|
||||
if (!result || !result.success) {
|
||||
vscode.window.showErrorMessage(
|
||||
localize('alertData.saveErrorMessage', "Alert update failed '{0}'", result.errorMessage ? result.errorMessage : 'Unknown'));
|
||||
|
||||
Reference in New Issue
Block a user