mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-13 19:48:34 -05:00
Agent/improvements (#720)
* add steps and schedules to edit job * added alerts to edit data logic * fixed c# style
This commit is contained in:
@@ -25,18 +25,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
private string originalAlertName = null;
|
||||
|
||||
private JobData jobData = null;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor that will be used to create dialog
|
||||
/// </summary>
|
||||
/// <param name="dataContainer"></param>
|
||||
public AgentAlertActions(
|
||||
CDataContainer dataContainer, string originalAlertName,
|
||||
AgentAlertInfo alertInfo, ConfigAction configAction)
|
||||
AgentAlertInfo alertInfo, ConfigAction configAction,
|
||||
JobData jobData = null)
|
||||
{
|
||||
this.originalAlertName = originalAlertName;
|
||||
this.alertInfo = alertInfo;
|
||||
this.DataContainer = dataContainer;
|
||||
this.configAction = configAction;
|
||||
if (jobData != null)
|
||||
{
|
||||
this.jobData = jobData;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetAlertName(CDataContainer container)
|
||||
@@ -92,6 +99,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
if (alert != null)
|
||||
{
|
||||
alert.DropIfExists();
|
||||
if (this.jobData != null)
|
||||
{
|
||||
JobAlertData alertData = new JobAlertData(alert);
|
||||
this.jobData.JobAlerts.DeleteAlert(alertData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,6 +142,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
if (createNewAlert)
|
||||
{
|
||||
alert.Create();
|
||||
if (this.jobData != null)
|
||||
{
|
||||
JobAlertData alertData = new JobAlertData(alert);
|
||||
this.jobData.JobAlerts.AddAlert(alertData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -169,6 +186,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
{
|
||||
throw new ArgumentNullException("alert");
|
||||
}
|
||||
if (this.alertInfo.JobId != null)
|
||||
{
|
||||
alert.JobID = new Guid(this.alertInfo.JobId);
|
||||
}
|
||||
|
||||
alert.DatabaseName = !string.IsNullOrWhiteSpace(this.alertInfo.DatabaseName)
|
||||
? this.alertInfo.DatabaseName : string.Empty;
|
||||
|
||||
Reference in New Issue
Block a user