Update Agent contracts to match SQL Ops definitons (#633)

* WIP 2

* Update contracts to match SQL Ops definitons
This commit is contained in:
Karl Burtram
2018-06-11 16:32:46 -07:00
committed by GitHub
parent 372ca0cbe8
commit 7c1f78a678
12 changed files with 139 additions and 559 deletions

View File

@@ -18,6 +18,7 @@ using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.Hosting; using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.Management; using Microsoft.SqlTools.ServiceLayer.Management;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Microsoft.SqlTools.Utility; using Microsoft.SqlTools.Utility;
namespace Microsoft.SqlTools.ServiceLayer.Agent namespace Microsoft.SqlTools.ServiceLayer.Agent
@@ -149,7 +150,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
agentJobs.Add(JobUtilities.ConvertToAgentJobInfo(job)); agentJobs.Add(JobUtilities.ConvertToAgentJobInfo(job));
} }
} }
result.Succeeded = true; result.Success = true;
result.Jobs = agentJobs.ToArray(); result.Jobs = agentJobs.ToArray();
sqlConnection.Close(); sqlConnection.Close();
} }
@@ -198,7 +199,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
tlog.CloseReader(); tlog.CloseReader();
} }
result.Jobs = jobHistories.ToArray(); result.Jobs = jobHistories.ToArray();
result.Succeeded = true; result.Success = true;
connection.Disconnect(); connection.Disconnect();
await requestContext.SendResult(result); await requestContext.SendResult(result);
} }
@@ -213,11 +214,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
/// <summary> /// <summary>
/// Handle request to Run a Job /// Handle request to Run a Job
/// </summary> /// </summary>
internal async Task HandleJobActionRequest(AgentJobActionParams parameters, RequestContext<AgentJobActionResult> requestContext) internal async Task HandleJobActionRequest(AgentJobActionParams parameters, RequestContext<ResultStatus> requestContext)
{ {
await Task.Run(async () => await Task.Run(async () =>
{ {
var result = new AgentJobActionResult(); var result = new ResultStatus();
try try
{ {
ConnectionInfo connInfo; ConnectionInfo connInfo;
@@ -250,13 +251,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
default: default:
break; break;
} }
result.Succeeded = true; result.Success = true;
await requestContext.SendResult(result); await requestContext.SendResult(result);
} }
} }
catch (Exception e) catch (Exception e)
{ {
result.Succeeded = false; result.Success = false;
result.ErrorMessage = e.Message; result.ErrorMessage = e.Message;
await requestContext.SendResult(result); await requestContext.SendResult(result);
} }
@@ -285,7 +286,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
await requestContext.SendResult(new CreateAgentJobResult() await requestContext.SendResult(new CreateAgentJobResult()
{ {
Succeeded = result.Item1, Success = result.Item1,
ErrorMessage = result.Item2 ErrorMessage = result.Item2
}); });
} }
@@ -300,12 +301,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
await requestContext.SendResult(new UpdateAgentJobResult() await requestContext.SendResult(new UpdateAgentJobResult()
{ {
Succeeded = result.Item1, Success = result.Item1,
ErrorMessage = result.Item2 ErrorMessage = result.Item2
}); });
} }
internal async Task HandleDeleteAgentJobRequest(DeleteAgentJobParams parameters, RequestContext<DeleteAgentJobResult> requestContext) internal async Task HandleDeleteAgentJobRequest(DeleteAgentJobParams parameters, RequestContext<ResultStatus> requestContext)
{ {
var result = await ConfigureAgentJob( var result = await ConfigureAgentJob(
parameters.OwnerUri, parameters.OwnerUri,
@@ -313,9 +314,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
ConfigAction.Drop, ConfigAction.Drop,
ManagementUtils.asRunType(parameters.TaskExecutionMode)); ManagementUtils.asRunType(parameters.TaskExecutionMode));
await requestContext.SendResult(new DeleteAgentJobResult() await requestContext.SendResult(new ResultStatus()
{ {
Succeeded = result.Item1, Success = result.Item1,
ErrorMessage = result.Item2 ErrorMessage = result.Item2
}); });
} }
@@ -329,7 +330,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
await requestContext.SendResult(new CreateAgentJobStepResult() await requestContext.SendResult(new CreateAgentJobStepResult()
{ {
Succeeded = result.Item1, Success = result.Item1,
ErrorMessage = result.Item2 ErrorMessage = result.Item2
}); });
} }
@@ -340,9 +341,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
await requestContext.SendResult(result); await requestContext.SendResult(result);
} }
internal async Task HandleDeleteAgentJobStepRequest(DeleteAgentJobStepParams parameters, RequestContext<DeleteAgentJobStepResult> requestContext) internal async Task HandleDeleteAgentJobStepRequest(DeleteAgentJobStepParams parameters, RequestContext<ResultStatus> requestContext)
{ {
DeleteAgentJobStepResult result = new DeleteAgentJobStepResult(); ResultStatus result = new ResultStatus();
await requestContext.SendResult(result); await requestContext.SendResult(result);
} }
@@ -515,28 +516,37 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
/// <summary> /// <summary>
/// Handle request to delete an alert /// Handle request to delete an alert
/// </summary> /// </summary>
internal async Task HandleDeleteAgentAlertRequest(DeleteAgentAlertParams parameters, RequestContext<DeleteAgentAlertResult> requestContext) internal async Task HandleDeleteAgentAlertRequest(DeleteAgentAlertParams parameters, RequestContext<ResultStatus> requestContext)
{ {
await Task.Run(async () => await Task.Run(async () =>
{ {
var result = new DeleteAgentAlertResult(); var result = new ResultStatus();
ConnectionInfo connInfo; try
ConnectionServiceInstance.TryFindConnection(
parameters.OwnerUri,
out connInfo);
AgentAlertInfo alert = parameters.Alert;
if (connInfo != null && ValidateAgentAlertInfo(alert))
{ {
CDataContainer dataContainer = AdminService.CreateDataContainer(connInfo, databaseExists: true); ConnectionInfo connInfo;
STParameters param = new STParameters(dataContainer.Document); ConnectionServiceInstance.TryFindConnection(
param.SetParam("alert", alert.JobName); parameters.OwnerUri,
out connInfo);
using (AgentAlertActions agentAlert = new AgentAlertActions(dataContainer, alert)) AgentAlertInfo alert = parameters.Alert;
if (connInfo != null && ValidateAgentAlertInfo(alert))
{ {
agentAlert.Drop(); CDataContainer dataContainer = AdminService.CreateDataContainer(connInfo, databaseExists: true);
STParameters param = new STParameters(dataContainer.Document);
param.SetParam("alert", alert.JobName);
using (AgentAlertActions agentAlert = new AgentAlertActions(dataContainer, alert))
{
agentAlert.Drop();
result.Success = true;
}
} }
} }
catch (Exception ex)
{
result.Success = false;
result.ErrorMessage = ex.ToString();
}
await requestContext.SendResult(result); await requestContext.SendResult(result);
}); });
@@ -605,7 +615,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
await requestContext.SendResult(new CreateAgentProxyResult() await requestContext.SendResult(new CreateAgentProxyResult()
{ {
Succeeded = succeeded Success = succeeded
}); });
} }
@@ -619,11 +629,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
await requestContext.SendResult(new UpdateAgentProxyResult() await requestContext.SendResult(new UpdateAgentProxyResult()
{ {
Succeeded = succeeded Success = succeeded
}); });
} }
internal async Task HandleDeleteAgentProxyRequest(DeleteAgentProxyParams parameters, RequestContext<DeleteAgentProxyResult> requestContext) internal async Task HandleDeleteAgentProxyRequest(DeleteAgentProxyParams parameters, RequestContext<ResultStatus> requestContext)
{ {
bool succeeded = await ConfigureAgentProxy( bool succeeded = await ConfigureAgentProxy(
parameters.OwnerUri, parameters.OwnerUri,
@@ -631,9 +641,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
parameters.Proxy, parameters.Proxy,
ConfigAction.Drop); ConfigAction.Drop);
await requestContext.SendResult(new DeleteAgentProxyResult() await requestContext.SendResult(new ResultStatus()
{ {
Succeeded = succeeded Success = succeeded
}); });
} }

View File

@@ -45,11 +45,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
public DateTime LastResponseDate { get; set; } public DateTime LastResponseDate { get; set; }
public int MessageId { get; set; } public int MessageId { get; set; }
public string NotificationMessage { get; set; } public string NotificationMessage { get; set; }
public int OccurrenceCount { get; } public int OccurrenceCount { get; set; }
public string PerformanceCondition { get; set; } public string PerformanceCondition { get; set; }
public int Severity { get; set; } public int Severity { get; set; }
public string DatabaseName { get; set; } public string DatabaseName { get; set; }
public DateTime CountResetDate { get; } public DateTime CountResetDate { get; set; }
public string CategoryName { get; set; } public string CategoryName { get; set; }
public AlertType AlertType { get; set; } public AlertType AlertType { get; set; }
public string WmiEventNamespace { get; set; } public string WmiEventNamespace { get; set; }

View File

@@ -20,13 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent Job activity result /// SQL Agent Job activity result
/// </summary> /// </summary>
public class AgentAlertsResult public class AgentAlertsResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
public AgentAlertInfo[] Alerts { get; set; } public AgentAlertInfo[] Alerts { get; set; }
} }
@@ -56,11 +51,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent create Alert result /// SQL Agent create Alert result
/// </summary> /// </summary>
public class CreateAgentAlertResult public class CreateAgentAlertResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentAlertInfo Alert { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -76,39 +69,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
RequestType<CreateAgentAlertParams, CreateAgentAlertResult>.Create("agent/createalert"); RequestType<CreateAgentAlertParams, CreateAgentAlertResult>.Create("agent/createalert");
} }
/// <summary>
/// SQL Agent delete Alert params
/// </summary>
public class DeleteAgentAlertParams : GeneralRequestDetails
{
public string OwnerUri { get; set; }
public AgentAlertInfo Alert { get; set; }
}
/// <summary>
/// SQL Agent delete Alert result
/// </summary>
public class DeleteAgentAlertResult
{
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary>
/// SQL Agent delete Alert request type
/// </summary>
public class DeleteAgentAlertRequest
{
/// <summary>
/// Request definition
/// </summary>
public static readonly
RequestType<DeleteAgentAlertParams, DeleteAgentAlertResult> Type =
RequestType<DeleteAgentAlertParams, DeleteAgentAlertResult>.Create("agent/deletealert");
}
/// <summary> /// <summary>
/// SQL Agent update Alert params /// SQL Agent update Alert params
/// </summary> /// </summary>
@@ -116,17 +76,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
{ {
public string OwnerUri { get; set; } public string OwnerUri { get; set; }
public string OriginalAlertName { get; set; }
public AgentAlertInfo Alert { get; set; } public AgentAlertInfo Alert { get; set; }
} }
/// <summary> /// <summary>
/// SQL Agent update Alert result /// SQL Agent update Alert result
/// </summary> /// </summary>
public class UpdateAgentAlertResult public class UpdateAgentAlertResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentAlertInfo Alert { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -140,5 +100,28 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
public static readonly public static readonly
RequestType<UpdateAgentAlertParams, UpdateAgentAlertResult> Type = RequestType<UpdateAgentAlertParams, UpdateAgentAlertResult> Type =
RequestType<UpdateAgentAlertParams, UpdateAgentAlertResult>.Create("agent/updatealert"); RequestType<UpdateAgentAlertParams, UpdateAgentAlertResult>.Create("agent/updatealert");
}
/// <summary>
/// SQL Agent delete Alert params
/// </summary>
public class DeleteAgentAlertParams : GeneralRequestDetails
{
public string OwnerUri { get; set; }
public AgentAlertInfo Alert { get; set; }
} }
/// <summary>
/// SQL Agent delete Alert request type
/// </summary>
public class DeleteAgentAlertRequest
{
/// <summary>
/// Request definition
/// </summary>
public static readonly
RequestType<DeleteAgentAlertParams, ResultStatus> Type =
RequestType<DeleteAgentAlertParams, ResultStatus>.Create("agent/deletealert");
}
} }

View File

@@ -23,13 +23,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent Job activity result /// SQL Agent Job activity result
/// </summary> /// </summary>
public class AgentJobsResult public class AgentJobsResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
public AgentJobInfo[] Jobs { get; set; } public AgentJobInfo[] Jobs { get; set; }
} }
@@ -59,11 +54,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent create Job result /// SQL Agent create Job result
/// </summary> /// </summary>
public class CreateAgentJobResult public class CreateAgentJobResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentJobInfo Job { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -86,17 +79,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
{ {
public string OwnerUri { get; set; } public string OwnerUri { get; set; }
public string OriginalJobName { get; set; }
public AgentJobInfo Job { get; set; } public AgentJobInfo Job { get; set; }
} }
/// <summary> /// <summary>
/// SQL Agent update Job result /// SQL Agent update Job result
/// </summary> /// </summary>
public class UpdateAgentJobResult public class UpdateAgentJobResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -122,16 +114,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
public AgentJobInfo Job { get; set; } public AgentJobInfo Job { get; set; }
} }
/// <summary>
/// SQL Agent delete Job result
/// </summary>
public class DeleteAgentJobResult
{
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary> /// <summary>
/// SQL Agent delete Job request type /// SQL Agent delete Job request type
/// </summary> /// </summary>
@@ -141,8 +123,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// Request definition /// Request definition
/// </summary> /// </summary>
public static readonly public static readonly
RequestType<DeleteAgentJobParams, DeleteAgentJobResult> Type = RequestType<DeleteAgentJobParams, ResultStatus> Type =
RequestType<DeleteAgentJobParams, DeleteAgentJobResult>.Create("agent/deletejob"); RequestType<DeleteAgentJobParams, ResultStatus>.Create("agent/deletejob");
} }
/// <summary> /// <summary>
@@ -158,13 +140,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent Job history result /// SQL Agent Job history result
/// </summary> /// </summary>
public class AgentJobHistoryResult public class AgentJobHistoryResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
public AgentJobHistoryInfo[] Jobs { get; set; } public AgentJobHistoryInfo[] Jobs { get; set; }
} }
@@ -193,16 +170,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
public string Action { get; set; } public string Action { get; set; }
} }
/// <summary>
/// SQL Agent Job activity result
/// </summary>
public class AgentJobActionResult
{
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary> /// <summary>
/// SQL Agent Jobs request type /// SQL Agent Jobs request type
/// </summary> /// </summary>
@@ -212,7 +179,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// Request definition /// Request definition
/// </summary> /// </summary>
public static readonly public static readonly
RequestType<AgentJobActionParams, AgentJobActionResult> Type = RequestType<AgentJobActionParams, ResultStatus> Type =
RequestType<AgentJobActionParams, AgentJobActionResult>.Create("agent/jobaction"); RequestType<AgentJobActionParams, ResultStatus>.Create("agent/jobaction");
} }
} }

View File

@@ -20,13 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent Job Steps result /// SQL Agent Job Steps result
/// </summary> /// </summary>
public class AgentJobStepsResult public class AgentJobStepsResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
public AgentJobStepInfo[] Steps { get; set; } public AgentJobStepInfo[] Steps { get; set; }
} }
@@ -50,17 +45,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
{ {
public string OwnerUri { get; set; } public string OwnerUri { get; set; }
public string OriginalJobStepName { get; set; }
public AgentJobStepInfo Step { get; set; } public AgentJobStepInfo Step { get; set; }
} }
/// <summary> /// <summary>
/// SQL Agent create Step result /// SQL Agent create Step result
/// </summary> /// </summary>
public class CreateAgentJobStepResult public class CreateAgentJobStepResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentJobStepInfo Step { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -86,16 +81,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
public AgentJobStepInfo Step { get; set; } public AgentJobStepInfo Step { get; set; }
} }
/// <summary>
/// SQL Agent delete Step result
/// </summary>
public class DeleteAgentJobStepResult
{
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary> /// <summary>
/// SQL Agent delete Step request type /// SQL Agent delete Step request type
/// </summary> /// </summary>
@@ -105,8 +90,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// Request definition /// Request definition
/// </summary> /// </summary>
public static readonly public static readonly
RequestType<DeleteAgentJobStepParams, DeleteAgentJobStepResult> Type = RequestType<DeleteAgentJobStepParams, ResultStatus> Type =
RequestType<DeleteAgentJobStepParams, DeleteAgentJobStepResult>.Create("agent/deletejobstep"); RequestType<DeleteAgentJobStepParams, ResultStatus>.Create("agent/deletejobstep");
} }
/// <summary> /// <summary>
@@ -122,11 +107,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent update Step result /// SQL Agent update Step result
/// </summary> /// </summary>
public class UpdateAgentJobStepResult public class UpdateAgentJobStepResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentJobStepInfo Step { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>

View File

@@ -20,12 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent Operators request result /// SQL Agent Operators request result
/// </summary> /// </summary>
public class AgentOperatorsResult public class AgentOperatorsResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
public AgentOperatorInfo[] Operators { get; set; } public AgentOperatorInfo[] Operators { get; set; }
} }
@@ -55,11 +51,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent create Operator result /// SQL Agent create Operator result
/// </summary> /// </summary>
public class CreateAgentOperatorResult public class CreateAgentOperatorResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -88,11 +81,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent delete Operator result /// SQL Agent delete Operator result
/// </summary> /// </summary>
public class DeleteAgentOperatorResult public class DeleteAgentOperatorResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -121,11 +111,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent update Operator result /// SQL Agent update Operator result
/// </summary> /// </summary>
public class UpdateAgentOperatorResult public class UpdateAgentOperatorResult : ResultStatus
{ {
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>

View File

@@ -22,7 +22,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// </summary> /// </summary>
public class AgentProxiesResult public class AgentProxiesResult
{ {
public bool Succeeded { get; set; } public bool Success { get; set; }
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }
@@ -55,11 +55,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent create Proxy result /// SQL Agent create Proxy result
/// </summary> /// </summary>
public class CreateAgentProxyResult public class CreateAgentProxyResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentProxyInfo Proxy { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -75,39 +73,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
RequestType<CreateAgentProxyParams, CreateAgentProxyResult>.Create("agent/createproxy"); RequestType<CreateAgentProxyParams, CreateAgentProxyResult>.Create("agent/createproxy");
} }
/// <summary>
/// SQL Agent delete Proxy params
/// </summary>
public class DeleteAgentProxyParams : GeneralRequestDetails
{
public string OwnerUri { get; set; }
public AgentProxyInfo Proxy { get; set; }
}
/// <summary>
/// SQL Agent delete Proxy result
/// </summary>
public class DeleteAgentProxyResult
{
public bool Succeeded { get; set; }
public string ErrorMessage { get; set; }
}
/// <summary>
/// SQL Agent delete Proxy request type
/// </summary>
public class DeleteAgentProxyRequest
{
/// <summary>
/// Request definition
/// </summary>
public static readonly
RequestType<DeleteAgentProxyParams, DeleteAgentProxyResult> Type =
RequestType<DeleteAgentProxyParams, DeleteAgentProxyResult>.Create("agent/deleteproxy");
}
/// <summary> /// <summary>
/// SQL Agent update Proxy params /// SQL Agent update Proxy params
/// </summary> /// </summary>
@@ -123,11 +88,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
/// <summary> /// <summary>
/// SQL Agent update Proxy result /// SQL Agent update Proxy result
/// </summary> /// </summary>
public class UpdateAgentProxyResult public class UpdateAgentProxyResult : ResultStatus
{ {
public bool Succeeded { get; set; } public AgentProxyInfo Proxy { get; set; }
public string ErrorMessage { get; set; }
} }
/// <summary> /// <summary>
@@ -141,5 +104,28 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
public static readonly public static readonly
RequestType<UpdateAgentProxyParams, UpdateAgentProxyResult> Type = RequestType<UpdateAgentProxyParams, UpdateAgentProxyResult> Type =
RequestType<UpdateAgentProxyParams, UpdateAgentProxyResult>.Create("agent/updateproxy"); RequestType<UpdateAgentProxyParams, UpdateAgentProxyResult>.Create("agent/updateproxy");
}
/// <summary>
/// SQL Agent delete Proxy params
/// </summary>
public class DeleteAgentProxyParams : GeneralRequestDetails
{
public string OwnerUri { get; set; }
public AgentProxyInfo Proxy { get; set; }
} }
/// <summary>
/// SQL Agent delete Proxy request type
/// </summary>
public class DeleteAgentProxyRequest
{
/// <summary>
/// Request definition
/// </summary>
public static readonly
RequestType<DeleteAgentProxyParams, ResultStatus> Type =
RequestType<DeleteAgentProxyParams, ResultStatus>.Create("agent/deleteproxy");
}
} }

View File

@@ -23,37 +23,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
/// <summary> /// <summary>
/// Summary description for JobStepAdvancedLogging. /// Summary description for JobStepAdvancedLogging.
/// </summary> /// </summary>
internal sealed class JobStepAdvancedLogging : IJobStepPropertiesControl internal sealed class JobStepAdvancedLogging
{ {
private CDataContainer dataContainer = null; private CDataContainer dataContainer = null;
// private IMessageBoxProvider messageProvider = null;
// private System.Windows.Forms.Label fileLabel;
// private System.Windows.Forms.TextBox outputFile;
// private System.Windows.Forms.Button browse;
// private System.Windows.Forms.CheckBox appendOutput;
private bool userIsSysAdmin = false;
private bool canViewFileLog = false;
private bool canSetFileLog = false;
private JobStepData jobStepData; private JobStepData jobStepData;
// private CheckBox logToTable;
// private CheckBox appendToFile;
// private CheckBox appendToTable;
// private Button viewFileLog;
// private Button viewTableLog;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public JobStepAdvancedLogging() public JobStepAdvancedLogging()
{ {
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
// TODO: Add any initialization after the InitForm call
} }
public JobStepAdvancedLogging(CDataContainer dataContainer, JobStepData jobStepData) public JobStepAdvancedLogging(CDataContainer dataContainer, JobStepData jobStepData)
@@ -62,305 +40,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
this.jobStepData = jobStepData; this.jobStepData = jobStepData;
} }
/// <summary>
/// Clean up any resources being used.
/// </summary>
// protected override void Dispose(bool disposing)
// {
// if (disposing)
// {
// if (components != null)
// {
// components.Dispose();
// }
// }
// base.Dispose(disposing);
// }
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
// System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(JobStepAdvancedLogging));
// this.fileLabel = new System.Windows.Forms.Label();
// this.outputFile = new System.Windows.Forms.TextBox();
// this.browse = new System.Windows.Forms.Button();
// this.appendOutput = new System.Windows.Forms.CheckBox();
// this.logToTable = new System.Windows.Forms.CheckBox();
// this.appendToFile = new System.Windows.Forms.CheckBox();
// this.appendToTable = new System.Windows.Forms.CheckBox();
// this.viewFileLog = new System.Windows.Forms.Button();
// this.viewTableLog = new System.Windows.Forms.Button();
// this.SuspendLayout();
// this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
// this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
// //
// // fileLabel
// //
// resources.ApplyResources(this.fileLabel, "fileLabel");
// this.fileLabel.Name = "fileLabel";
// //
// // outputFile
// //
// resources.ApplyResources(this.outputFile, "outputFile");
// this.outputFile.Name = "outputFile";
// this.outputFile.TextChanged += new System.EventHandler(this.outputFile_TextChanged);
// //
// // browse
// //
// resources.ApplyResources(this.browse, "browse");
// this.browse.Name = "browse";
// this.browse.Click += new System.EventHandler(this.browse_Click);
// //
// // appendOutput
// //
// resources.ApplyResources(this.appendOutput, "appendOutput");
// this.appendOutput.Name = "appendOutput";
// //
// // logToTable
// //
// resources.ApplyResources(this.logToTable, "logToTable");
// this.logToTable.Name = "logToTable";
// this.logToTable.CheckedChanged += new System.EventHandler(this.logToTable_CheckedChanged);
// //
// // appendToFile
// //
// resources.ApplyResources(this.appendToFile, "appendToFile");
// this.appendToFile.Name = "appendToFile";
// //
// // appendToTable
// //
// resources.ApplyResources(this.appendToTable, "appendToTable");
// this.appendToTable.Name = "appendToTable";
// //
// // viewFileLog
// //
// resources.ApplyResources(this.viewFileLog, "viewFileLog");
// this.viewFileLog.Name = "viewFileLog";
// this.viewFileLog.Click += new System.EventHandler(this.viewFileLog_Click);
// //
// // viewTableLog
// //
// resources.ApplyResources(this.viewTableLog, "viewTableLog");
// this.viewTableLog.Name = "viewTableLog";
// this.viewTableLog.Click += new System.EventHandler(this.viewTableLog_Click);
// //
// // JobStepAdvancedLogging
// //
// this.Controls.Add(this.viewTableLog);
// this.Controls.Add(this.viewFileLog);
// this.Controls.Add(this.appendToTable);
// this.Controls.Add(this.appendToFile);
// this.Controls.Add(this.logToTable);
// this.Controls.Add(this.appendOutput);
// this.Controls.Add(this.browse);
// this.Controls.Add(this.outputFile);
// this.Controls.Add(this.fileLabel);
// this.Name = "JobStepAdvancedLogging";
// resources.ApplyResources(this, "$this");
// this.ResumeLayout(false);
// this.PerformLayout();
}
#endregion
#region IJobStepPropertiesControl implementation
void IJobStepPropertiesControl.Load(JobStepData data)
{
// this.outputFile.Text = data.OutputFileName;
// this.appendToFile.Checked = data.AppendToLogFile;
// this.appendOutput.Checked = data.AppendToStepHistory;
// this.logToTable.Checked = data.WriteLogToTable;
// this.logToTable.Enabled = data.CanLogToTable;
// this.appendToTable.Checked = data.AppendLogToTable;
this.userIsSysAdmin = (data.Parent.Parent.UserRole & UserRoles.SysAdmin) > 0;
this.canViewFileLog = this.userIsSysAdmin && data.Version.Major <= 8;
// must be sysadmin to set log in yukon
this.canSetFileLog = (data.Version.Major <= 8 || this.userIsSysAdmin);
if (this.canSetFileLog)
{
// Managed Instance doesn't allow setting this path.
//
if (this.dataContainer != null &&
this.dataContainer.Server != null &&
this.dataContainer.Server.DatabaseEngineEdition == DatabaseEngineEdition.SqlManagedInstance)
{
this.canSetFileLog = false;
}
}
UpdateControlStatus();
}
void IJobStepPropertiesControl.Save(JobStepData data, bool isSwitching)
{
// if (this.appendToFile.Checked && this.outputFile.Text.Trim().Length == 0)
// {
// throw new ApplicationException(SRError.MissingOutputLogFileName);
// }
// data.OutputFileName = this.outputFile.Text;
// data.AppendToLogFile = this.appendToFile.Checked;
// data.AppendToStepHistory = this.appendOutput.Checked;
// data.WriteLogToTable = this.logToTable.Checked;
// if (this.logToTable.Checked)
// {
// data.AppendLogToTable = this.appendToTable.Checked;
// }
// else
// {
// data.AppendLogToTable = false;
// }
}
#endregion
#region event handlers
/// <summary>
/// Called when the user clicks on the browse for file button. Will allow the
/// user to either enter a new file, or pick an existing one for logging on the server
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void browse_Click(object sender, System.EventArgs e)
{
// using (BrowseFolder browse = new BrowseFolder(this.dataContainer.Server.ConnectionContext,
// this.messageProvider))
// {
// browse.Font = this.Font;
// browse.BrowseForFiles = true;
// if (browse.ShowDialog() == DialogResult.OK)
// {
// this.outputFile.Text = browse.SelectedFullFileName;
// }
// }
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void outputFile_TextChanged(object sender, EventArgs e)
{
UpdateControlStatus();
}
/// <summary>
/// User wishes to view the file log
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void viewFileLog_Click(object sender, EventArgs e)
{
// Cursor originalCursor = Cursor.Current;
// try
// {
// Cursor.Current = Cursors.WaitCursor;
// try
// {
// string tempFileName = String.Empty;
// if (CheckFileExistsAndIsValid(this.outputFile.Text))
// {
// tempFileName = ReadLogToFile(this.outputFile.Text);
// }
// ViewLog(tempFileName);
// }
// catch (Exception ex)
// {
// messageProvider.ShowMessage(
// ex
// , SRError.SQLWorkbench
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxButtons.OK
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxSymbol.Error
// , this);
// }
// }
// finally
// {
// Cursor.Current = originalCursor;
// }
}
/// <summary>
/// user wishes to view the table log
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void logToTable_CheckedChanged(object sender, EventArgs e)
{
UpdateControlStatus();
}
private void viewTableLog_Click(object sender, EventArgs e)
{
// Cursor originalCursor = Cursor.Current;
// try
// {
// Cursor.Current = Cursors.WaitCursor;
// try
// {
// JobStep step = this.jobStepData.JobStep;
// String tempFileName = String.Empty;
// if (step != null)
// {
// tempFileName = ReadStepLogToFile(step);
// }
// // Note that ViewLog deletes the temp file after showing it.
// ViewLog(tempFileName);
// }
// catch (Exception ex)
// {
// messageProvider.ShowMessage(
// ex
// , SRError.SQLWorkbench
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxButtons.OK
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxSymbol.Error
// , this);
// }
// }
// finally
// {
// Cursor.Current = originalCursor;
// }
}
private void ViewLog(string tempFileName)
{
// if (tempFileName == null || tempFileName.Length == 0)
// {
// messageProvider.ShowMessage(
// SRError.LogNotYetCreated
// , SRError.SQLWorkbench
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxButtons.OK
// , Microsoft.NetEnterpriseServers.ExceptionMessageBoxSymbol.Information
// , this);
// }
// else
// {
// try
// {
// String notepadProcess = String.Format(CultureInfo.InvariantCulture
// , "{0}\\notepad.exe"
// , System.Environment.SystemDirectory);
// System.Diagnostics.Process.Start(notepadProcess, tempFileName);
// System.Threading.Thread.Sleep(1000);
// }
// finally
// {
// System.IO.File.Delete(tempFileName);
// }
// }
}
#endregion
#region internal helpers #region internal helpers
/// <summary> /// <summary>
@@ -496,11 +175,3 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
#endregion #endregion
} }
} }

View File

@@ -3,12 +3,11 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
namespace Microsoft.SqlTools.ServiceLayer.Utility namespace Microsoft.SqlTools.ServiceLayer.Utility
{ {
public class ReturnResult public class ResultStatus
{ {
public bool Succeeded { get; set; } public bool Success { get; set; }
public string ErrorMessage { get; set; } public string ErrorMessage { get; set; }
} }

View File

@@ -19,6 +19,7 @@ using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Profiler; using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts; using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common; using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq; using Moq;
using Xunit; using Xunit;
@@ -102,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{ {
var createContext = new Mock<RequestContext<CreateAgentAlertResult>>(); var createContext = new Mock<RequestContext<CreateAgentAlertResult>>();
var updateContext = new Mock<RequestContext<UpdateAgentAlertResult>>(); var updateContext = new Mock<RequestContext<UpdateAgentAlertResult>>();
var deleteContext = new Mock<RequestContext<DeleteAgentAlertResult>>(); var deleteContext = new Mock<RequestContext<ResultStatus>>();
var service = new AgentService(); var service = new AgentService();
var alert = new AgentAlertInfo() var alert = new AgentAlertInfo()

View File

@@ -9,6 +9,7 @@ using Microsoft.SqlTools.ServiceLayer.Agent;
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts; using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility; using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Test.Common; using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq; using Moq;
using Xunit; using Xunit;
@@ -26,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
{ {
var createContext = new Mock<RequestContext<CreateAgentProxyResult>>(); var createContext = new Mock<RequestContext<CreateAgentProxyResult>>();
var updateContext = new Mock<RequestContext<UpdateAgentProxyResult>>(); var updateContext = new Mock<RequestContext<UpdateAgentProxyResult>>();
var deleteContext = new Mock<RequestContext<DeleteAgentProxyResult>>(); var deleteContext = new Mock<RequestContext<ResultStatus>>();
var service = new AgentService(); var service = new AgentService();
var proxy = new AgentProxyInfo() var proxy = new AgentProxyInfo()

View File

@@ -3,22 +3,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information. // Licensed under the MIT license. See LICENSE file in the project root for full license information.
// //
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.XEvent;
using Microsoft.SqlTools.Hosting.Protocol; using Microsoft.SqlTools.Hosting.Protocol;
using Microsoft.SqlTools.ServiceLayer.Agent; using Microsoft.SqlTools.ServiceLayer.Agent;
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts; using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
using Microsoft.SqlTools.ServiceLayer.Connection; using Microsoft.SqlTools.ServiceLayer.Connection;
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility; using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
using Microsoft.SqlTools.ServiceLayer.Profiler;
using Microsoft.SqlTools.ServiceLayer.Profiler.Contracts;
using Microsoft.SqlTools.ServiceLayer.Test.Common; using Microsoft.SqlTools.ServiceLayer.Test.Common;
using Microsoft.SqlTools.ServiceLayer.Utility;
using Moq; using Moq;
using Xunit; using Xunit;
@@ -86,7 +78,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
JobName = "Agent history clean up: distribution" JobName = "Agent history clean up: distribution"
}; };
var requestContext = new Mock<RequestContext<AgentJobActionResult>>(); var requestContext = new Mock<RequestContext<ResultStatus>>();
AgentService service = new AgentService(); AgentService service = new AgentService();
await service.HandleJobActionRequest(requestParams, requestContext.Object); await service.HandleJobActionRequest(requestParams, requestContext.Object);
@@ -94,4 +86,4 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
} }
} }
} }
} }