Added more options to job changes and elaborated error messages (#775)

* job step type and error message details change

* added newline for both environments

* checked for inner exceptions

* sorted imports
This commit is contained in:
Aditya Bist
2019-03-07 11:42:20 -08:00
committed by GitHub
parent 01bcfd8df9
commit a08666af0f
5 changed files with 71 additions and 22 deletions

View File

@@ -299,6 +299,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
{
result.Success = false;
result.ErrorMessage = e.Message;
Exception exception = e.InnerException;
while (exception != null)
{
result.ErrorMessage += Environment.NewLine + "\t" + exception.Message;
exception = exception.InnerException;
}
await requestContext.SendResult(result);
}
});
@@ -920,7 +926,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
break;
}
}
await ConfigureAgentJobStep(ownerUri, step, configAction, runType);
await ConfigureAgentJobStep(ownerUri, step, configAction, runType, jobData, dataContainer);
}
}
@@ -929,7 +935,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
{
foreach (AgentScheduleInfo schedule in jobInfo.JobSchedules)
{
await ConfigureAgentSchedule(ownerUri, schedule, configAction, runType);
await ConfigureAgentSchedule(ownerUri, schedule, configAction, runType, jobData, dataContainer);
}
}
@@ -939,7 +945,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
foreach (AgentAlertInfo alert in jobInfo.Alerts)
{
alert.JobId = jobData.Job.JobID.ToString();
await ConfigureAgentAlert(ownerUri, alert.Name, alert, configAction, runType);
await ConfigureAgentAlert(ownerUri, alert.Name, alert, configAction, runType, jobData, dataContainer);
}
}
@@ -956,7 +962,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
string ownerUri,
AgentJobStepInfo stepInfo,
ConfigAction configAction,
RunType runType)
RunType runType,
JobData jobData = null,
CDataContainer dataContainer = null)
{
return await Task<Tuple<bool, string>>.Run(() =>
{
@@ -967,9 +975,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
return new Tuple<bool, string>(false, "JobName cannot be null");
}
JobData jobData;
CDataContainer dataContainer;
CreateJobData(ownerUri, stepInfo.JobName, out dataContainer, out jobData);
if (jobData == null)
{
CreateJobData(ownerUri, stepInfo.JobName, out dataContainer, out jobData);
}
using (var actions = new JobStepsActions(dataContainer, jobData, stepInfo, configAction))
{
@@ -991,14 +1000,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
string alertName,
AgentAlertInfo alert,
ConfigAction configAction,
RunType runType)
RunType runType,
JobData jobData = null,
CDataContainer dataContainer = null)
{
return await Task<Tuple<bool, string>>.Run(() =>
{
try
{
CDataContainer dataContainer;
JobData jobData = null;
// If the alert is being created outside of a job
if (string.IsNullOrWhiteSpace(alert.JobName))
{
@@ -1007,9 +1016,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
}
else
{
// If the alert is being created inside a job
CreateJobData(ownerUri, alert.JobName, out dataContainer, out jobData);
{
if (jobData == null)
{
// If the alert is being created inside a job
CreateJobData(ownerUri, alert.JobName, out dataContainer, out jobData);
}
}
STParameters param = new STParameters(dataContainer.Document);
param.SetParam("alert", alertName);
@@ -1095,15 +1107,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
string ownerUri,
AgentScheduleInfo schedule,
ConfigAction configAction,
RunType runType)
RunType runType,
JobData jobData = null,
CDataContainer dataContainer = null)
{
return await Task<bool>.Run(() =>
{
try
{
JobData jobData;
CDataContainer dataContainer;
CreateJobData(ownerUri, schedule.JobName, out dataContainer, out jobData);
if (jobData == null)
{
CreateJobData(ownerUri, schedule.JobName, out dataContainer, out jobData);
}
const string UrnFormatStr = "Server[@Name='{0}']/JobServer[@Name='{0}']/Job[@Name='{1}']/Schedule[@Name='{2}']";
string serverName = dataContainer.Server.Name.ToUpper();