From 2f1097028fca69753931c3f6b7f6191afaabb71a Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Thu, 29 Nov 2018 10:47:57 -0800 Subject: [PATCH] Fixed update agent step (#748) * fixed update step * fix new step from edit job * allowed to reorder steps in edit job --- .../Agent/AgentService.cs | 24 ++++++++++++++++++- .../Agent/Jobs/JobStepsActions.cs | 2 +- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs b/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs index 4c24ea7e..017da4ee 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs @@ -893,11 +893,33 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent ExecuteAction(actions, runType); } + + ConnectionInfo connInfo; + ConnectionServiceInstance.TryFindConnection(ownerUri, out connInfo); + if (connInfo != null) + { + dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true); + } + // Execute step actions if they exist if (jobInfo.JobSteps != null && jobInfo.JobSteps.Length > 0) { foreach (AgentJobStepInfo step in jobInfo.JobSteps) - { + { + configAction = ConfigAction.Create; + foreach(JobStep jobStep in dataContainer.Server.JobServer.Jobs[originalJobName].JobSteps) + { + // any changes made to step other than name or ordering + if ((step.StepName == jobStep.Name && step.Id == jobStep.ID) || + // if the step name was changed + (step.StepName != jobStep.Name && step.Id == jobStep.ID) || + // if the step ordering was changed + (step.StepName == jobStep.Name && step.Id != jobStep.ID)) + { + configAction = ConfigAction.Update; + break; + } + } await ConfigureAgentJobStep(ownerUri, step, configAction, runType); } } diff --git a/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobStepsActions.cs b/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobStepsActions.cs index cec82622..c34fbdbf 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobStepsActions.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobStepsActions.cs @@ -42,7 +42,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent // load properties from AgentJobStepInfo this.data.ID = stepInfo.Id; this.data.Name = stepInfo.StepName; - this.data.Command = stepInfo.Script; + this.data.Command = stepInfo.Command; } protected override bool DoPreProcessExecution(RunType runType, out ExecutionMode executionResult)