mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Initial admin and DR services. (#329)
* Add initial services for admin, tasks, and DR * Fix up some of the contract interfaces * Make fields public to allow Json.Net to work * Fix a couple issues in backup contracts
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TaskServices.Contracts
|
||||
{
|
||||
|
||||
public class ListTasksParams
|
||||
{
|
||||
bool ListActiveTasksOnly { get; set; }
|
||||
}
|
||||
|
||||
public class ListTasksResponse
|
||||
{
|
||||
TaskInfo[] Tasks { get; set; }
|
||||
}
|
||||
|
||||
public class ListTasksRequest
|
||||
{
|
||||
public static readonly
|
||||
RequestType<ListTasksParams, ListTasksResponse> Type =
|
||||
RequestType<ListTasksParams, ListTasksResponse>.Create("tasks/listtasks");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TaskServices.Contracts
|
||||
{
|
||||
public enum TaskState
|
||||
{
|
||||
NotStarted = 0,
|
||||
Running = 1,
|
||||
Complete = 2
|
||||
}
|
||||
|
||||
public class TaskInfo
|
||||
{
|
||||
public int TaskId { get; set; }
|
||||
|
||||
public TaskState State { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Microsoft.SqlTools.Hosting.Protocol;
|
||||
using Microsoft.SqlTools.ServiceLayer.Hosting;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.TaskServices.Contracts;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TaskServices
|
||||
{
|
||||
public class TaskService
|
||||
{
|
||||
private static readonly Lazy<TaskService> instance = new Lazy<TaskService>(() => new TaskService());
|
||||
|
||||
/// <summary>
|
||||
/// Default, parameterless constructor.
|
||||
/// </summary>
|
||||
internal TaskService()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the singleton instance object
|
||||
/// </summary>
|
||||
public static TaskService Instance
|
||||
{
|
||||
get { return instance.Value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the service instance
|
||||
/// </summary>
|
||||
public void InitializeService(ServiceHost serviceHost, SqlToolsContext context)
|
||||
{
|
||||
serviceHost.SetRequestHandler(ListTasksRequest.Type, HandleListTasksRequest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a list tasks request
|
||||
/// </summary>
|
||||
internal static async Task HandleListTasksRequest(
|
||||
ListTasksParams listTasksParams,
|
||||
RequestContext<ListTasksResponse> requestContext)
|
||||
{
|
||||
await requestContext.SendResult(new ListTasksResponse());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user