mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-15 17:23:32 -05:00
Merge branch 'main' into v-chrcan/issue392
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// 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;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.QueryExecution.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Parameters for the connection uri changed notification.
|
||||
/// </summary>
|
||||
public class ConnectionUriChangedParams
|
||||
{
|
||||
public string NewOwnerUri { get; set; }
|
||||
public string OriginalOwnerUri { get; set; }
|
||||
}
|
||||
public class ConnectionUriChangedNotification
|
||||
{
|
||||
public static readonly
|
||||
EventType<ConnectionUriChangedParams> Type =
|
||||
EventType<ConnectionUriChangedParams>.Create("query/connectionUriChanged");
|
||||
}
|
||||
}
|
||||
@@ -385,6 +385,20 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
Batches[saveParams.BatchIndex].SaveAs(saveParams, fileFactory, successHandler, failureHandler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the OwnerURI for the editor connection.
|
||||
/// </summary>
|
||||
public String ConnectionOwnerURI {
|
||||
get
|
||||
{
|
||||
return this.editorConnection.OwnerUri;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.editorConnection.OwnerUri = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Helpers
|
||||
|
||||
@@ -170,6 +170,7 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
serviceHost.SetRequestHandler(SubsetRequest.Type, HandleResultSubsetRequest);
|
||||
serviceHost.SetRequestHandler(QueryDisposeRequest.Type, HandleDisposeRequest);
|
||||
serviceHost.SetRequestHandler(QueryCancelRequest.Type, HandleCancelRequest);
|
||||
serviceHost.SetEventHandler(ConnectionUriChangedNotification.Type, HandleConnectionUriChangedNotification);
|
||||
serviceHost.SetRequestHandler(SaveResultsAsCsvRequest.Type, HandleSaveResultsAsCsvRequest);
|
||||
serviceHost.SetRequestHandler(SaveResultsAsExcelRequest.Type, HandleSaveResultsAsExcelRequest);
|
||||
serviceHost.SetRequestHandler(SaveResultsAsJsonRequest.Type, HandleSaveResultsAsJsonRequest);
|
||||
@@ -351,6 +352,33 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles a request to change the uri associated with an active query and connection info.
|
||||
/// </summary>
|
||||
internal Task HandleConnectionUriChangedNotification(ConnectionUriChangedParams changeUriParams,
|
||||
EventContext eventContext)
|
||||
{
|
||||
try {
|
||||
string OriginalOwnerUri = changeUriParams.OriginalOwnerUri;
|
||||
string NewOwnerUri = changeUriParams.NewOwnerUri;
|
||||
// Attempt to load the query
|
||||
Query query;
|
||||
if(!ActiveQueries.TryRemove(OriginalOwnerUri, out query)){
|
||||
throw new Exception("Uri: " + OriginalOwnerUri + " is not associated with an active query.");
|
||||
}
|
||||
ConnectionService.ReplaceUri(OriginalOwnerUri, NewOwnerUri);
|
||||
query.ConnectionOwnerURI = NewOwnerUri;
|
||||
ActiveQueries.TryAdd(NewOwnerUri, query);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(TraceEventType.Error, "Error encountered " + ex.ToString());
|
||||
return Task.FromException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles a request to get a subset of the results of this query
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user