mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
Update Agent contracts to match SQL Ops definitons (#633)
* WIP 2 * Update contracts to match SQL Ops definitons
This commit is contained in:
@@ -18,6 +18,7 @@ using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.Management;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
@@ -149,7 +150,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
agentJobs.Add(JobUtilities.ConvertToAgentJobInfo(job));
|
||||
}
|
||||
}
|
||||
result.Succeeded = true;
|
||||
result.Success = true;
|
||||
result.Jobs = agentJobs.ToArray();
|
||||
sqlConnection.Close();
|
||||
}
|
||||
@@ -198,7 +199,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
tlog.CloseReader();
|
||||
}
|
||||
result.Jobs = jobHistories.ToArray();
|
||||
result.Succeeded = true;
|
||||
result.Success = true;
|
||||
connection.Disconnect();
|
||||
await requestContext.SendResult(result);
|
||||
}
|
||||
@@ -213,11 +214,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
/// <summary>
|
||||
/// Handle request to Run a Job
|
||||
/// </summary>
|
||||
internal async Task HandleJobActionRequest(AgentJobActionParams parameters, RequestContext<AgentJobActionResult> requestContext)
|
||||
internal async Task HandleJobActionRequest(AgentJobActionParams parameters, RequestContext<ResultStatus> requestContext)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var result = new AgentJobActionResult();
|
||||
var result = new ResultStatus();
|
||||
try
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
@@ -250,13 +251,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
default:
|
||||
break;
|
||||
}
|
||||
result.Succeeded = true;
|
||||
result.Success = true;
|
||||
await requestContext.SendResult(result);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
result.Succeeded = false;
|
||||
result.Success = false;
|
||||
result.ErrorMessage = e.Message;
|
||||
await requestContext.SendResult(result);
|
||||
}
|
||||
@@ -285,7 +286,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
await requestContext.SendResult(new CreateAgentJobResult()
|
||||
{
|
||||
Succeeded = result.Item1,
|
||||
Success = result.Item1,
|
||||
ErrorMessage = result.Item2
|
||||
});
|
||||
}
|
||||
@@ -300,12 +301,12 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
await requestContext.SendResult(new UpdateAgentJobResult()
|
||||
{
|
||||
Succeeded = result.Item1,
|
||||
Success = result.Item1,
|
||||
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(
|
||||
parameters.OwnerUri,
|
||||
@@ -313,9 +314,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
ConfigAction.Drop,
|
||||
ManagementUtils.asRunType(parameters.TaskExecutionMode));
|
||||
|
||||
await requestContext.SendResult(new DeleteAgentJobResult()
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
{
|
||||
Succeeded = result.Item1,
|
||||
Success = result.Item1,
|
||||
ErrorMessage = result.Item2
|
||||
});
|
||||
}
|
||||
@@ -329,7 +330,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
await requestContext.SendResult(new CreateAgentJobStepResult()
|
||||
{
|
||||
Succeeded = result.Item1,
|
||||
Success = result.Item1,
|
||||
ErrorMessage = result.Item2
|
||||
});
|
||||
}
|
||||
@@ -340,9 +341,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -515,11 +516,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
/// <summary>
|
||||
/// Handle request to delete an alert
|
||||
/// </summary>
|
||||
internal async Task HandleDeleteAgentAlertRequest(DeleteAgentAlertParams parameters, RequestContext<DeleteAgentAlertResult> requestContext)
|
||||
internal async Task HandleDeleteAgentAlertRequest(DeleteAgentAlertParams parameters, RequestContext<ResultStatus> requestContext)
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var result = new DeleteAgentAlertResult();
|
||||
var result = new ResultStatus();
|
||||
try
|
||||
{
|
||||
ConnectionInfo connInfo;
|
||||
ConnectionServiceInstance.TryFindConnection(
|
||||
parameters.OwnerUri,
|
||||
@@ -535,8 +538,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
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);
|
||||
});
|
||||
@@ -605,7 +615,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
await requestContext.SendResult(new CreateAgentProxyResult()
|
||||
{
|
||||
Succeeded = succeeded
|
||||
Success = succeeded
|
||||
});
|
||||
}
|
||||
|
||||
@@ -619,11 +629,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
|
||||
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(
|
||||
parameters.OwnerUri,
|
||||
@@ -631,9 +641,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
parameters.Proxy,
|
||||
ConfigAction.Drop);
|
||||
|
||||
await requestContext.SendResult(new DeleteAgentProxyResult()
|
||||
await requestContext.SendResult(new ResultStatus()
|
||||
{
|
||||
Succeeded = succeeded
|
||||
Success = succeeded
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
public DateTime LastResponseDate { get; set; }
|
||||
public int MessageId { get; set; }
|
||||
public string NotificationMessage { get; set; }
|
||||
public int OccurrenceCount { get; }
|
||||
public int OccurrenceCount { get; set; }
|
||||
public string PerformanceCondition { get; set; }
|
||||
public int Severity { get; set; }
|
||||
public string DatabaseName { get; set; }
|
||||
public DateTime CountResetDate { get; }
|
||||
public DateTime CountResetDate { get; set; }
|
||||
public string CategoryName { get; set; }
|
||||
public AlertType AlertType { get; set; }
|
||||
public string WmiEventNamespace { get; set; }
|
||||
|
||||
@@ -20,13 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent Job activity result
|
||||
/// </summary>
|
||||
public class AgentAlertsResult
|
||||
public class AgentAlertsResult : ResultStatus
|
||||
{
|
||||
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public AgentAlertInfo[] Alerts { get; set; }
|
||||
}
|
||||
|
||||
@@ -56,11 +51,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent create Alert result
|
||||
/// </summary>
|
||||
public class CreateAgentAlertResult
|
||||
public class CreateAgentAlertResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentAlertInfo Alert { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,39 +69,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
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>
|
||||
/// SQL Agent update Alert params
|
||||
/// </summary>
|
||||
@@ -116,17 +76,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
public string OriginalAlertName { get; set; }
|
||||
|
||||
public AgentAlertInfo Alert { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent update Alert result
|
||||
/// </summary>
|
||||
public class UpdateAgentAlertResult
|
||||
public class UpdateAgentAlertResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentAlertInfo Alert { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -141,4 +101,27 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
RequestType<UpdateAgentAlertParams, UpdateAgentAlertResult> Type =
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent Job activity result
|
||||
/// </summary>
|
||||
public class AgentJobsResult
|
||||
public class AgentJobsResult : ResultStatus
|
||||
{
|
||||
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public AgentJobInfo[] Jobs { get; set; }
|
||||
}
|
||||
|
||||
@@ -59,11 +54,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent create Job result
|
||||
/// </summary>
|
||||
public class CreateAgentJobResult
|
||||
public class CreateAgentJobResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentJobInfo Job { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,17 +79,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
public string OriginalJobName { get; set; }
|
||||
|
||||
public AgentJobInfo Job { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent update Job result
|
||||
/// </summary>
|
||||
public class UpdateAgentJobResult
|
||||
public class UpdateAgentJobResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,16 +114,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
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>
|
||||
/// SQL Agent delete Job request type
|
||||
/// </summary>
|
||||
@@ -141,8 +123,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<DeleteAgentJobParams, DeleteAgentJobResult> Type =
|
||||
RequestType<DeleteAgentJobParams, DeleteAgentJobResult>.Create("agent/deletejob");
|
||||
RequestType<DeleteAgentJobParams, ResultStatus> Type =
|
||||
RequestType<DeleteAgentJobParams, ResultStatus>.Create("agent/deletejob");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -158,13 +140,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent Job history result
|
||||
/// </summary>
|
||||
public class AgentJobHistoryResult
|
||||
public class AgentJobHistoryResult : ResultStatus
|
||||
{
|
||||
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public AgentJobHistoryInfo[] Jobs { get; set; }
|
||||
}
|
||||
|
||||
@@ -193,16 +170,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
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>
|
||||
/// SQL Agent Jobs request type
|
||||
/// </summary>
|
||||
@@ -212,7 +179,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<AgentJobActionParams, AgentJobActionResult> Type =
|
||||
RequestType<AgentJobActionParams, AgentJobActionResult>.Create("agent/jobaction");
|
||||
RequestType<AgentJobActionParams, ResultStatus> Type =
|
||||
RequestType<AgentJobActionParams, ResultStatus>.Create("agent/jobaction");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,13 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent Job Steps result
|
||||
/// </summary>
|
||||
public class AgentJobStepsResult
|
||||
public class AgentJobStepsResult : ResultStatus
|
||||
{
|
||||
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public AgentJobStepInfo[] Steps { get; set; }
|
||||
}
|
||||
|
||||
@@ -50,17 +45,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
{
|
||||
public string OwnerUri { get; set; }
|
||||
|
||||
public string OriginalJobStepName { get; set; }
|
||||
|
||||
public AgentJobStepInfo Step { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SQL Agent create Step result
|
||||
/// </summary>
|
||||
public class CreateAgentJobStepResult
|
||||
public class CreateAgentJobStepResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentJobStepInfo Step { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,16 +81,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
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>
|
||||
/// SQL Agent delete Step request type
|
||||
/// </summary>
|
||||
@@ -105,8 +90,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// Request definition
|
||||
/// </summary>
|
||||
public static readonly
|
||||
RequestType<DeleteAgentJobStepParams, DeleteAgentJobStepResult> Type =
|
||||
RequestType<DeleteAgentJobStepParams, DeleteAgentJobStepResult>.Create("agent/deletejobstep");
|
||||
RequestType<DeleteAgentJobStepParams, ResultStatus> Type =
|
||||
RequestType<DeleteAgentJobStepParams, ResultStatus>.Create("agent/deletejobstep");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -122,11 +107,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent update Step result
|
||||
/// </summary>
|
||||
public class UpdateAgentJobStepResult
|
||||
public class UpdateAgentJobStepResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentJobStepInfo Step { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -20,12 +20,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent Operators request result
|
||||
/// </summary>
|
||||
public class AgentOperatorsResult
|
||||
public class AgentOperatorsResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public AgentOperatorInfo[] Operators { get; set; }
|
||||
}
|
||||
|
||||
@@ -55,11 +51,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent create Operator result
|
||||
/// </summary>
|
||||
public class CreateAgentOperatorResult
|
||||
public class CreateAgentOperatorResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -88,11 +81,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent delete Operator result
|
||||
/// </summary>
|
||||
public class DeleteAgentOperatorResult
|
||||
public class DeleteAgentOperatorResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,11 +111,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent update Operator result
|
||||
/// </summary>
|
||||
public class UpdateAgentOperatorResult
|
||||
public class UpdateAgentOperatorResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// </summary>
|
||||
public class AgentProxiesResult
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
public bool Success { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
@@ -55,11 +55,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent create Proxy result
|
||||
/// </summary>
|
||||
public class CreateAgentProxyResult
|
||||
public class CreateAgentProxyResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentProxyInfo Proxy { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -75,39 +73,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
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>
|
||||
/// SQL Agent update Proxy params
|
||||
/// </summary>
|
||||
@@ -123,11 +88,9 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
/// <summary>
|
||||
/// SQL Agent update Proxy result
|
||||
/// </summary>
|
||||
public class UpdateAgentProxyResult
|
||||
public class UpdateAgentProxyResult : ResultStatus
|
||||
{
|
||||
public bool Succeeded { get; set; }
|
||||
|
||||
public string ErrorMessage { get; set; }
|
||||
public AgentProxyInfo Proxy { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,4 +105,27 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
||||
RequestType<UpdateAgentProxyParams, UpdateAgentProxyResult> Type =
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,37 +23,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
/// <summary>
|
||||
/// Summary description for JobStepAdvancedLogging.
|
||||
/// </summary>
|
||||
internal sealed class JobStepAdvancedLogging : IJobStepPropertiesControl
|
||||
internal sealed class JobStepAdvancedLogging
|
||||
{
|
||||
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 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()
|
||||
{
|
||||
// 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)
|
||||
@@ -62,305 +40,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
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
|
||||
/// <summary>
|
||||
@@ -496,11 +175,3 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
|
||||
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; }
|
||||
}
|
||||
@@ -19,6 +19,7 @@ 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.Utility;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
@@ -102,7 +103,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
|
||||
{
|
||||
var createContext = new Mock<RequestContext<CreateAgentAlertResult>>();
|
||||
var updateContext = new Mock<RequestContext<UpdateAgentAlertResult>>();
|
||||
var deleteContext = new Mock<RequestContext<DeleteAgentAlertResult>>();
|
||||
var deleteContext = new Mock<RequestContext<ResultStatus>>();
|
||||
|
||||
var service = new AgentService();
|
||||
var alert = new AgentAlertInfo()
|
||||
|
||||
@@ -9,6 +9,7 @@ using Microsoft.SqlTools.ServiceLayer.Agent;
|
||||
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.IntegrationTests.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Test.Common;
|
||||
using Microsoft.SqlTools.ServiceLayer.Utility;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
@@ -26,7 +27,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
|
||||
{
|
||||
var createContext = new Mock<RequestContext<CreateAgentProxyResult>>();
|
||||
var updateContext = new Mock<RequestContext<UpdateAgentProxyResult>>();
|
||||
var deleteContext = new Mock<RequestContext<DeleteAgentProxyResult>>();
|
||||
var deleteContext = new Mock<RequestContext<ResultStatus>>();
|
||||
|
||||
var service = new AgentService();
|
||||
var proxy = new AgentProxyInfo()
|
||||
|
||||
@@ -3,22 +3,14 @@
|
||||
// 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 Microsoft.SqlServer.Management.Smo;
|
||||
using Microsoft.SqlServer.Management.XEvent;
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Agent;
|
||||
using Microsoft.SqlTools.ServiceLayer.Agent.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection;
|
||||
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.Utility;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
|
||||
@@ -86,7 +78,7 @@ namespace Microsoft.SqlTools.ServiceLayer.IntegrationTests.Agent
|
||||
JobName = "Agent history clean up: distribution"
|
||||
};
|
||||
|
||||
var requestContext = new Mock<RequestContext<AgentJobActionResult>>();
|
||||
var requestContext = new Mock<RequestContext<ResultStatus>>();
|
||||
|
||||
AgentService service = new AgentService();
|
||||
await service.HandleJobActionRequest(requestParams, requestContext.Object);
|
||||
|
||||
Reference in New Issue
Block a user