mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-13 17:23:02 -05:00
Make sample work with current code (#707)
This commit is contained in:
@@ -14,7 +14,7 @@ using Microsoft.SqlTools.Hosting.Protocol.Channel;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
|
||||
namespace Microsoft.SqlTools.JsonRpc.Driver
|
||||
{
|
||||
/// <summary>
|
||||
@@ -59,6 +59,7 @@ namespace Microsoft.SqlTools.JsonRpc.Driver
|
||||
startTime = DateTime.Now;
|
||||
|
||||
// Launch the process
|
||||
this.protocolClient.Initialize();
|
||||
await this.protocolClient.Start();
|
||||
await Task.Delay(1000); // Wait for the service host to start
|
||||
|
||||
@@ -67,7 +68,7 @@ namespace Microsoft.SqlTools.JsonRpc.Driver
|
||||
// Setup events to queue for testing
|
||||
this.QueueEventsForType(ConnectionCompleteNotification.Type);
|
||||
this.QueueEventsForType(IntelliSenseReadyNotification.Type);
|
||||
this.QueueEventsForType(QueryExecuteCompleteEvent.Type);
|
||||
this.QueueEventsForType(QueryCompleteEvent.Type);
|
||||
this.QueueEventsForType(PublishDiagnosticsNotification.Type);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||
using Microsoft.SqlTools.JsonRpc.Utility;
|
||||
using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
|
||||
|
||||
namespace Microsoft.SqlTools.JsonRpc.ExecuteQuery
|
||||
{
|
||||
@@ -19,10 +20,11 @@ namespace Microsoft.SqlTools.JsonRpc.ExecuteQuery
|
||||
internal static void Main(string[] args)
|
||||
{
|
||||
// set SQLTOOLSSERVICE_EXE to location of SQL Tools Service executable
|
||||
Environment.SetEnvironmentVariable("SQLTOOLSSERVICE_EXE", @"Microsoft.SqlTools.ServiceLayer.exe");
|
||||
Environment.SetEnvironmentVariable("SQLTOOLSSERVICE_EXE", @"MicrosoftSqlToolsServiceLayer.exe");
|
||||
|
||||
// execute a query against localhost, master, with IntegratedAuth
|
||||
ExecuteQuery("SELECT * FROM sys.objects").Wait();
|
||||
|
||||
}
|
||||
|
||||
internal static async Task ExecuteQuery(string query)
|
||||
@@ -43,7 +45,7 @@ namespace Microsoft.SqlTools.JsonRpc.ExecuteQuery
|
||||
await testHelper.Connect(queryTempFile.FilePath, connectParams);
|
||||
|
||||
// execute the query
|
||||
QueryExecuteCompleteParams queryComplete =
|
||||
QueryCompleteParams queryComplete =
|
||||
await testHelper.RunQuery(queryTempFile.FilePath, query);
|
||||
|
||||
if (queryComplete.BatchSummaries != null && queryComplete.BatchSummaries.Length > 0)
|
||||
@@ -54,7 +56,7 @@ namespace Microsoft.SqlTools.JsonRpc.ExecuteQuery
|
||||
var resultSet = batch.ResultSetSummaries[0];
|
||||
|
||||
// retrive the results
|
||||
QueryExecuteSubsetResult querySubset = await testHelper.ExecuteSubset(
|
||||
SubsetResult querySubset = await testHelper.ExecuteSubset(
|
||||
queryTempFile.FilePath, batch.Id,
|
||||
resultSet.Id, 0, (int)resultSet.RowCount);
|
||||
|
||||
@@ -70,7 +72,7 @@ namespace Microsoft.SqlTools.JsonRpc.ExecuteQuery
|
||||
{
|
||||
for (int i = 0; i < resultSet.ColumnInfo.Length; ++i)
|
||||
{
|
||||
Console.Write(row.GetValue(i) + ", ");
|
||||
Console.Write(row[i].DisplayValue + ", ");
|
||||
}
|
||||
Console.Write(Environment.NewLine);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using Microsoft.SqlTools.ServiceLayer.LanguageServices.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.SqlContext;
|
||||
using Microsoft.SqlTools.ServiceLayer.Workspace.Contracts;
|
||||
using Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts.ExecuteRequests;
|
||||
|
||||
namespace Microsoft.SqlTools.JsonRpc.Utility
|
||||
{
|
||||
@@ -119,9 +120,9 @@ namespace Microsoft.SqlTools.JsonRpc.Utility
|
||||
/// <summary>
|
||||
/// Request the active SQL script is parsed for errors
|
||||
/// </summary>
|
||||
public async Task<QueryExecuteSubsetResult> RequestQueryExecuteSubset(QueryExecuteSubsetParams subsetParams)
|
||||
public async Task<SubsetResult> RequestQueryExecuteSubset(SubsetParams subsetParams)
|
||||
{
|
||||
return await Driver.SendRequest(QueryExecuteSubsetRequest.Type, subsetParams);
|
||||
return await Driver.SendRequest(SubsetRequest.Type, subsetParams);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -171,21 +172,21 @@ namespace Microsoft.SqlTools.JsonRpc.Utility
|
||||
/// <summary>
|
||||
/// Run a query using a given connection bound to a URI
|
||||
/// </summary>
|
||||
public async Task<QueryExecuteCompleteParams> RunQuery(string ownerUri, string query, int timeoutMilliseconds = 5000)
|
||||
public async Task<QueryCompleteParams> RunQuery(string ownerUri, string query, int timeoutMilliseconds = 5000)
|
||||
{
|
||||
// Write the query text to a backing file
|
||||
WriteToFile(ownerUri, query);
|
||||
|
||||
var queryParams = new QueryExecuteParams
|
||||
var queryParams = new ExecuteDocumentSelectionParams
|
||||
{
|
||||
OwnerUri = ownerUri,
|
||||
QuerySelection = null
|
||||
};
|
||||
|
||||
var result = await Driver.SendRequest(QueryExecuteRequest.Type, queryParams);
|
||||
if (result != null && string.IsNullOrEmpty(result.Messages))
|
||||
var result = await Driver.SendRequest(ExecuteDocumentSelectionRequest.Type, queryParams);
|
||||
if (result != null)
|
||||
{
|
||||
var eventResult = await Driver.WaitForEvent(QueryExecuteCompleteEvent.Type, timeoutMilliseconds);
|
||||
var eventResult = await Driver.WaitForEvent(QueryCompleteEvent.Type, timeoutMilliseconds);
|
||||
return eventResult;
|
||||
}
|
||||
else
|
||||
@@ -231,16 +232,16 @@ namespace Microsoft.SqlTools.JsonRpc.Utility
|
||||
/// <summary>
|
||||
/// Request a subset of results from a query
|
||||
/// </summary>
|
||||
public async Task<QueryExecuteSubsetResult> ExecuteSubset(string ownerUri, int batchIndex, int resultSetIndex, int rowStartIndex, int rowCount)
|
||||
public async Task<SubsetResult> ExecuteSubset(string ownerUri, int batchIndex, int resultSetIndex, int rowStartIndex, int rowCount)
|
||||
{
|
||||
var subsetParams = new QueryExecuteSubsetParams();
|
||||
var subsetParams = new SubsetParams();
|
||||
subsetParams.OwnerUri = ownerUri;
|
||||
subsetParams.BatchIndex = batchIndex;
|
||||
subsetParams.ResultSetIndex = resultSetIndex;
|
||||
subsetParams.RowsStartIndex = rowStartIndex;
|
||||
subsetParams.RowsCount = rowCount;
|
||||
|
||||
var result = await Driver.SendRequest(QueryExecuteSubsetRequest.Type, subsetParams);
|
||||
var result = await Driver.SendRequest(SubsetRequest.Type, subsetParams);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
16
docs/samples/jsonrpc/netcore/executequery/jsonrpc.csproj
Normal file
16
docs/samples/jsonrpc/netcore/executequery/jsonrpc.csproj
Normal file
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<!-- <PackageReference Include="Microsoft.SqlServer.Smo" Version="12.0.2000.8" /> -->
|
||||
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
|
||||
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" />
|
||||
<!-- <PackageReference Include="System.Data.SqlClient" Version="4.4.0-sqltools-24613-04" /> -->
|
||||
<PackageReference Include="Microsoft.SqlServer.Smo" Version="140.17279.0-xplat" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\..\src\Microsoft.SqlTools.ServiceLayer\Microsoft.SqlTools.ServiceLayer.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user