mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Agent/improvements (#779)
* job step type and error message details change * added newline for both environments * checked for inner exceptions * sorted imports * added ability to change job owner
This commit is contained in:
@@ -185,7 +185,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
if (connInfo != null)
|
if (connInfo != null)
|
||||||
{
|
{
|
||||||
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
CDataContainer dataContainer = CDataContainer.CreateDataContainer(connInfo, databaseExists: true);
|
||||||
var jobs = dataContainer.Server.JobServer.Jobs;
|
var jobServer = dataContainer.Server.JobServer;
|
||||||
|
var jobs = jobServer.Jobs;
|
||||||
Tuple<SqlConnectionInfo, DataTable, ServerConnection> tuple = CreateSqlConnection(connInfo, parameters.JobId);
|
Tuple<SqlConnectionInfo, DataTable, ServerConnection> tuple = CreateSqlConnection(connInfo, parameters.JobId);
|
||||||
SqlConnectionInfo sqlConnInfo = tuple.Item1;
|
SqlConnectionInfo sqlConnInfo = tuple.Item1;
|
||||||
DataTable dt = tuple.Item2;
|
DataTable dt = tuple.Item2;
|
||||||
@@ -211,7 +212,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
result.Schedules = jobSchedules.ToArray();
|
result.Schedules = jobSchedules.ToArray();
|
||||||
|
|
||||||
// Alerts
|
// Alerts
|
||||||
AlertCollection alerts = dataContainer.Server.JobServer.Alerts;
|
AlertCollection alerts = jobServer.Alerts;
|
||||||
var jobAlerts = new List<Alert>();
|
var jobAlerts = new List<Alert>();
|
||||||
foreach (Alert alert in alerts)
|
foreach (Alert alert in alerts)
|
||||||
{
|
{
|
||||||
@@ -241,7 +242,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
result.Success = true;
|
result.Success = true;
|
||||||
tlog.CloseReader();
|
tlog.CloseReader();
|
||||||
}
|
}
|
||||||
connection.Disconnect();
|
|
||||||
await requestContext.SendResult(result);
|
await requestContext.SendResult(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -428,6 +428,17 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var logins = dataContainer.Server.Logins;
|
||||||
|
result.Logins = new AgentJobLogin[logins.Count];
|
||||||
|
for (int i = 0; i < logins.Count; i++)
|
||||||
|
{
|
||||||
|
result.Logins[i] = new AgentJobLogin
|
||||||
|
{
|
||||||
|
Id = logins[i].ID,
|
||||||
|
Name = logins[i].Name
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
result.Success = true;
|
result.Success = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -61,7 +61,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
EmailLevel = job.EmailLevel,
|
EmailLevel = job.EmailLevel,
|
||||||
PageLevel = job.PageLevel,
|
PageLevel = job.PageLevel,
|
||||||
EventLogLevel = job.EventLogLevel,
|
EventLogLevel = job.EventLogLevel,
|
||||||
DeleteLevel = job.DeleteLevel
|
DeleteLevel = job.DeleteLevel,
|
||||||
|
Owner = job.Owner
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,6 +205,15 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SQL Agent Login
|
||||||
|
/// </summary>
|
||||||
|
public class AgentJobLogin
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// SQL Agent Job Defaults result
|
/// SQL Agent Job Defaults result
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -213,6 +222,8 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent.Contracts
|
|||||||
public string Owner { get; set; }
|
public string Owner { get; set; }
|
||||||
|
|
||||||
public AgentJobCategory[] Categories { get; set; }
|
public AgentJobCategory[] Categories { get; set; }
|
||||||
|
|
||||||
|
public AgentJobLogin[] Logins { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -218,5 +218,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Agent
|
|||||||
{
|
{
|
||||||
get { return (JobCompletionActionCondition)this.eventLogLevel; }
|
get { return (JobCompletionActionCondition)this.eventLogLevel; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Owner
|
||||||
|
{
|
||||||
|
get { return this.owner; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user