From 626ce354407e0485fe3f5f556d265d943b58a0ab Mon Sep 17 00:00:00 2001 From: Karl Burtram Date: Fri, 13 Jul 2018 09:17:33 -0700 Subject: [PATCH] Add Description property to Agent Job request (#655) * Add Description property to Agent Job request * Fix whitespace --- .../Agent/AgentService.cs | 1 - .../Agent/Common/AgentUtilities.cs | 1 + .../Agent/Jobs/JobFetcher.cs | 7 ++++--- .../Agent/Jobs/JobProperties.cs | 14 ++++++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs b/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs index dfa5118b..f8de2e9f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Agent/AgentService.cs @@ -151,7 +151,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent var agentJobs = new List(); if (this.jobs != null) { - foreach (var job in this.jobs.Values) { agentJobs.Add(AgentUtilities.ConvertToAgentJobInfo(job)); diff --git a/src/Microsoft.SqlTools.ServiceLayer/Agent/Common/AgentUtilities.cs b/src/Microsoft.SqlTools.ServiceLayer/Agent/Common/AgentUtilities.cs index 10008fe7..e1b3ed5f 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Agent/Common/AgentUtilities.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Agent/Common/AgentUtilities.cs @@ -39,6 +39,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent return new AgentJobInfo { Name = job.Name, + Description = job.Description, CurrentExecutionStatus = job.CurrentExecutionStatus, LastRunOutcome = job.LastRunOutcome, CurrentExecutionStep = job.CurrentExecutionStep, diff --git a/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobFetcher.cs b/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobFetcher.cs index 0d28b0e0..47097758 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobFetcher.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobFetcher.cs @@ -369,8 +369,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent request.Urn = urn; request.Fields = new string[] { - "Name", - "IsEnabled", + "Name", + "IsEnabled", "Category", "CategoryID", "CategoryType", @@ -382,7 +382,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent "LastRunDate", "NextRunDate", "LastRunOutcome", - "JobID" + "JobID", + "Description" }; DataTable dt = enumerator.Process(connection, request); diff --git a/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobProperties.cs b/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobProperties.cs index c1535950..5b6c17cc 100644 --- a/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobProperties.cs +++ b/src/Microsoft.SqlTools.ServiceLayer/Agent/Jobs/JobProperties.cs @@ -31,6 +31,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent private DateTime lastRun; private DateTime nextRun; private Guid jobId; + private string description; private JobProperties() { @@ -62,7 +63,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent this.hasStep = Convert.ToBoolean(row["HasStep"], CultureInfo.InvariantCulture); this.hasTarget = Convert.ToBoolean(row["HasServer"], CultureInfo.InvariantCulture); this.lastRunOutcome = Convert.ToInt32(row["LastRunOutcome"], CultureInfo.InvariantCulture); - this.jobId = Guid.Parse(row["JobID"].ToString()); ; + this.jobId = Guid.Parse(row["JobID"].ToString()); + this.description = row["Description"].ToString(); // for a job to be runnable, it must: // 1. have a target server @@ -156,6 +158,14 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent { return this.jobId; } - } + } + + public string Description + { + get + { + return this.description; + } + } } } \ No newline at end of file