mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Additional edit alert updates (#652)
This commit is contained in:
@@ -818,6 +818,23 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
#region "Helpers"
|
||||
|
||||
internal void ExecuteAction(ManagementActionBase action, RunType runType)
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(action);
|
||||
executionHandler.RunNow(runType, this);
|
||||
if (executionHandler.ExecutionResult == ExecutionMode.Failure)
|
||||
{
|
||||
if (executionHandler.ExecutionFailureException != null)
|
||||
{
|
||||
throw executionHandler.ExecutionFailureException;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Failed to execute action");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal async Task<Tuple<bool, string>> ConfigureAgentJob(
|
||||
string ownerUri,
|
||||
AgentJobInfo jobInfo,
|
||||
@@ -832,10 +849,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
CDataContainer dataContainer;
|
||||
CreateJobData(ownerUri, jobInfo.Name, out dataContainer, out jobData, jobInfo);
|
||||
|
||||
using (JobActions jobActions = new JobActions(dataContainer, jobData, configAction))
|
||||
using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(jobActions);
|
||||
executionHandler.RunNow(runType, this);
|
||||
ExecuteAction(actions, runType);
|
||||
}
|
||||
|
||||
return new Tuple<bool, string>(true, string.Empty);
|
||||
@@ -866,10 +882,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
CDataContainer dataContainer;
|
||||
CreateJobData(ownerUri, stepInfo.JobName, out dataContainer, out jobData);
|
||||
|
||||
using (var jobStep = new JobStepsActions(dataContainer, jobData, stepInfo, configAction))
|
||||
using (var actions = new JobStepsActions(dataContainer, jobData, stepInfo, configAction))
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(jobStep);
|
||||
executionHandler.RunNow(runType, this);
|
||||
ExecuteAction(actions, runType);
|
||||
}
|
||||
|
||||
return new Tuple<bool, string>(true, string.Empty);
|
||||
@@ -901,10 +916,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
if (alert != null)
|
||||
{
|
||||
using (AgentAlertActions agentAlert = new AgentAlertActions(dataContainer, alertName, alert, configAction))
|
||||
using (AgentAlertActions actions = new AgentAlertActions(dataContainer, alertName, alert, configAction))
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(agentAlert);
|
||||
executionHandler.RunNow(runType, this);
|
||||
ExecuteAction(actions, runType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -933,10 +947,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
STParameters param = new STParameters(dataContainer.Document);
|
||||
param.SetParam("operator", operatorInfo.Name);
|
||||
|
||||
using (AgentOperatorActions agentOperator = new AgentOperatorActions(dataContainer, operatorInfo, configAction))
|
||||
using (AgentOperatorActions actions = new AgentOperatorActions(dataContainer, operatorInfo, configAction))
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(agentOperator);
|
||||
executionHandler.RunNow(runType, this);
|
||||
ExecuteAction(actions, runType);
|
||||
}
|
||||
|
||||
return new Tuple<bool, string>(true, string.Empty);
|
||||
@@ -965,10 +978,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
STParameters param = new STParameters(dataContainer.Document);
|
||||
param.SetParam("proxyaccount", accountName);
|
||||
|
||||
using (AgentProxyAccountActions agentProxy = new AgentProxyAccountActions(dataContainer, proxy, configAction))
|
||||
using (AgentProxyAccountActions actions = new AgentProxyAccountActions(dataContainer, proxy, configAction))
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(agentProxy);
|
||||
executionHandler.RunNow(runType, this);
|
||||
ExecuteAction(actions, runType);
|
||||
}
|
||||
|
||||
return new Tuple<bool, string>(true, string.Empty);
|
||||
@@ -1003,8 +1015,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
using (JobSchedulesActions actions = new JobSchedulesActions(dataContainer, jobData, schedule, configAction))
|
||||
{
|
||||
var executionHandler = new ExecutonHandler(actions);
|
||||
executionHandler.RunNow(runType, this);
|
||||
ExecuteAction(actions, runType);
|
||||
}
|
||||
|
||||
return new Tuple<bool, string>(true, string.Empty);
|
||||
|
||||
@@ -182,12 +182,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
if (alertInfo.AlertType == Contracts.AlertType.SqlServerEvent)
|
||||
{
|
||||
if (this.alertInfo.MessageId.HasValue)
|
||||
if (this.alertInfo.MessageId.HasValue && this.alertInfo.MessageId > 0)
|
||||
{
|
||||
alert.Severity = 0;
|
||||
alert.MessageID = this.alertInfo.MessageId.Value;
|
||||
}
|
||||
else if (this.alertInfo.Severity.HasValue)
|
||||
else if (this.alertInfo.Severity.HasValue && this.alertInfo.Severity > 0)
|
||||
{
|
||||
alert.Severity = this.alertInfo.Severity.Value;
|
||||
alert.MessageID = 0;
|
||||
|
||||
@@ -123,6 +123,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
/// </summary>
|
||||
private ExecutionMode executionResult;
|
||||
|
||||
/// <summary>
|
||||
/// exception that caused execution failure
|
||||
/// </summary>
|
||||
private Exception executionFailureException;
|
||||
|
||||
/// <summary>
|
||||
/// text of the generated script if RunNow method was called last time with scripting option
|
||||
/// </summary>
|
||||
@@ -155,6 +160,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// exception that caused execution failure
|
||||
/// </summary>
|
||||
public Exception ExecutionFailureException
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.executionFailureException;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// text of the generated script if RunNow method was called last time with scripting option
|
||||
/// </summary>
|
||||
@@ -326,6 +342,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Management
|
||||
{
|
||||
// show the error
|
||||
this.executionResult = ExecutionMode.Failure;
|
||||
this.executionFailureException = ex;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user