mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-17 02:51:45 -05:00
Fix Agent Job rename (#657)
This commit is contained in:
@@ -275,6 +275,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
{
|
{
|
||||||
var result = await ConfigureAgentJob(
|
var result = await ConfigureAgentJob(
|
||||||
parameters.OwnerUri,
|
parameters.OwnerUri,
|
||||||
|
parameters.Job.Name,
|
||||||
parameters.Job,
|
parameters.Job,
|
||||||
ConfigAction.Create,
|
ConfigAction.Create,
|
||||||
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
||||||
@@ -290,6 +291,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
{
|
{
|
||||||
var result = await ConfigureAgentJob(
|
var result = await ConfigureAgentJob(
|
||||||
parameters.OwnerUri,
|
parameters.OwnerUri,
|
||||||
|
parameters.OriginalJobName,
|
||||||
parameters.Job,
|
parameters.Job,
|
||||||
ConfigAction.Update,
|
ConfigAction.Update,
|
||||||
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
||||||
@@ -305,6 +307,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
{
|
{
|
||||||
var result = await ConfigureAgentJob(
|
var result = await ConfigureAgentJob(
|
||||||
parameters.OwnerUri,
|
parameters.OwnerUri,
|
||||||
|
parameters.Job.Name,
|
||||||
parameters.Job,
|
parameters.Job,
|
||||||
ConfigAction.Drop,
|
ConfigAction.Drop,
|
||||||
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
||||||
@@ -837,6 +840,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
|
|
||||||
internal async Task<Tuple<bool, string>> ConfigureAgentJob(
|
internal async Task<Tuple<bool, string>> ConfigureAgentJob(
|
||||||
string ownerUri,
|
string ownerUri,
|
||||||
|
string originalJobName,
|
||||||
AgentJobInfo jobInfo,
|
AgentJobInfo jobInfo,
|
||||||
ConfigAction configAction,
|
ConfigAction configAction,
|
||||||
RunType runType)
|
RunType runType)
|
||||||
@@ -847,7 +851,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
{
|
{
|
||||||
JobData jobData;
|
JobData jobData;
|
||||||
CDataContainer dataContainer;
|
CDataContainer dataContainer;
|
||||||
CreateJobData(ownerUri, jobInfo.Name, out dataContainer, out jobData, jobInfo);
|
CreateJobData(ownerUri, originalJobName, out dataContainer, out jobData, configAction, jobInfo);
|
||||||
|
|
||||||
using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
|
using (JobActions actions = new JobActions(dataContainer, jobData, configAction))
|
||||||
{
|
{
|
||||||
@@ -1032,6 +1036,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
string jobName,
|
string jobName,
|
||||||
out CDataContainer dataContainer,
|
out CDataContainer dataContainer,
|
||||||
out JobData jobData,
|
out JobData jobData,
|
||||||
|
ConfigAction configAction = ConfigAction.Create,
|
||||||
AgentJobInfo jobInfo = null)
|
AgentJobInfo jobInfo = null)
|
||||||
{
|
{
|
||||||
ConnectionInfo connInfo;
|
ConnectionInfo connInfo;
|
||||||
@@ -1042,10 +1047,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
dataContainer.Init(jobDoc.InnerXml);
|
dataContainer.Init(jobDoc.InnerXml);
|
||||||
|
|
||||||
STParameters param = new STParameters(dataContainer.Document);
|
STParameters param = new STParameters(dataContainer.Document);
|
||||||
param.SetParam("job", string.Empty);
|
string originalName = jobInfo != null && !string.Equals(jobName, jobInfo.Name) ? jobName : string.Empty;
|
||||||
|
param.SetParam("job", configAction == ConfigAction.Update ? jobName : string.Empty);
|
||||||
param.SetParam("jobid", string.Empty);
|
param.SetParam("jobid", string.Empty);
|
||||||
|
|
||||||
jobData = new JobData(dataContainer, jobInfo);
|
jobData = new JobData(dataContainer, jobInfo, configAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static XmlDocument CreateJobXmlDocument(string svrName, string jobName)
|
public static XmlDocument CreateJobXmlDocument(string svrName, string jobName)
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String Description
|
public string Description
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -601,7 +601,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region construction
|
#region construction
|
||||||
public JobData(CDataContainer data, AgentJobInfo jobInfo = null)
|
public JobData(CDataContainer data, AgentJobInfo jobInfo = null, ConfigAction configAction = ConfigAction.Create)
|
||||||
{
|
{
|
||||||
this.context = data;
|
this.context = data;
|
||||||
|
|
||||||
@@ -632,10 +632,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
this.targetLocalServer = false;
|
this.targetLocalServer = false;
|
||||||
}
|
}
|
||||||
// we are in properties mode.
|
// we are in properties mode.
|
||||||
if (this.originalName.Length > 0 || !string.IsNullOrEmpty(this.jobIdString))
|
if (configAction == ConfigAction.Update)
|
||||||
{
|
{
|
||||||
this.mode = ActionMode.Edit;
|
this.mode = ActionMode.Edit;
|
||||||
|
CheckAndLoadGeneralData();
|
||||||
}
|
}
|
||||||
else if (this.script.Length > 0)
|
else if (this.script.Length > 0)
|
||||||
{
|
{
|
||||||
@@ -660,6 +660,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
this.currentName = jobInfo.Name;
|
this.currentName = jobInfo.Name;
|
||||||
this.owner = jobInfo.Owner;
|
this.owner = jobInfo.Owner;
|
||||||
this.description = jobInfo.Description;
|
this.description = jobInfo.Description;
|
||||||
|
this.enabled = jobInfo.Enabled;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -758,7 +759,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
|
|
||||||
Job job = this.Job;
|
Job job = this.Job;
|
||||||
|
|
||||||
this.currentName = this.originalName;
|
this.currentName = job.Name;
|
||||||
this.description = job.Description;
|
this.description = job.Description;
|
||||||
this.enabled = job.IsEnabled;
|
this.enabled = job.IsEnabled;
|
||||||
// this.source = job.Source;
|
// this.source = job.Source;
|
||||||
@@ -1112,8 +1113,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
|
|
||||||
this.mode = creating ? ActionMode.Create : ActionMode.Edit;
|
this.mode = creating ? ActionMode.Create : ActionMode.Edit;
|
||||||
|
|
||||||
///Before any job posting if donem make sure that if this is an MSX job that the user has selected at
|
// Before any job posting if donem make sure that if this is an MSX job that the user has selected at
|
||||||
///least one Target Server.
|
// least one Target Server.
|
||||||
if (!this.targetLocalServer)
|
if (!this.targetLocalServer)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.AvailableTargetServers.Length; ++i)
|
for (int i = 0; i < this.AvailableTargetServers.Length; ++i)
|
||||||
@@ -1126,7 +1127,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
}
|
}
|
||||||
if (!targetServerSelected)
|
if (!targetServerSelected)
|
||||||
{
|
{
|
||||||
///Not target servers selected. Throw error.
|
// Not target servers selected. Throw error.
|
||||||
throw new ApplicationException(SR.TargetServerNotSelected);
|
throw new ApplicationException(SR.TargetServerNotSelected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user