Agent/improvements (#720)

* add steps and schedules to edit job

* added alerts to edit data logic

* fixed c# style
This commit is contained in:
Aditya Bist
2018-10-31 16:40:17 -07:00
committed by GitHub
parent 6153279840
commit 4f148a583b
2 changed files with 66 additions and 7 deletions

View File

@@ -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;