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