mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-20 09:35:38 -05:00
added sub types for parameters (#340)
This commit is contained in:
@@ -300,7 +300,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.Nodes
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
Logger.Write(LogLevel.Error, $"Failed populating oe children error:{ex.Message} {ex.Source}");
|
||||
Logger.Write(LogLevel.Error, $"Failed populating oe children. error:{ex.Message} {ex.StackTrace}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -200,16 +200,19 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
||||
|
||||
private async Task<ConnectionCompleteParams> Connect(ConnectParams connectParams)
|
||||
{
|
||||
string connectionErrorMessage = string.Empty;
|
||||
try
|
||||
{
|
||||
// open connection based on request details
|
||||
ConnectionCompleteParams result = await connectionService.Connect(connectParams);
|
||||
if(result != null && !string.IsNullOrEmpty(result.ConnectionId))
|
||||
connectionErrorMessage = result != null ? result.Messages : string.Empty;
|
||||
if (result != null && !string.IsNullOrEmpty(result.ConnectionId))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Write(LogLevel.Warning, $"Connection Failed for OE. connection error: {connectionErrorMessage}");
|
||||
await serviceHost.SendEvent(ConnectionCompleteNotification.Type, result);
|
||||
return null;
|
||||
}
|
||||
@@ -217,6 +220,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Write(LogLevel.Warning, $"Connection Failed for OE. connection error:{connectionErrorMessage} error: {ex.Message}");
|
||||
// Send a connection failed error message in this case.
|
||||
ConnectionCompleteParams result = new ConnectionCompleteParams()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,12 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
return ParameterCustomeNodeHelper.GetCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
|
||||
public override string GetNodeSubType(object context)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.GetSubType(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +31,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
return ParameterCustomeNodeHelper.GetCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
public override string GetNodeSubType(object context)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.GetSubType(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +46,11 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
return ParameterCustomeNodeHelper.GetCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
public override string GetNodeSubType(object context)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.GetSubType(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,19 +61,39 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
{
|
||||
public override string GetNodeCustomName(object smoObject, SmoQueryContext smoContext)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.CalculateCustomLabel(smoObject, smoContext);
|
||||
return ParameterCustomeNodeHelper.GetCustomLabel(smoObject, smoContext);
|
||||
}
|
||||
public override string GetNodeSubType(object context)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.GetSubType(context);
|
||||
}
|
||||
}
|
||||
|
||||
static class ParameterCustomeNodeHelper
|
||||
{
|
||||
|
||||
internal static string CalculateCustomLabel(object context, SmoQueryContext smoContext)
|
||||
internal static string GetSubType(object context)
|
||||
{
|
||||
Parameter parameter = context as Parameter;
|
||||
if (parameter != null)
|
||||
{
|
||||
return ParameterCustomeNodeHelper.GetParameterCustomLabel(parameter);
|
||||
StoredProcedureParameter stordProcedureParameter = parameter as StoredProcedureParameter;
|
||||
if (stordProcedureParameter != null && stordProcedureParameter.IsOutputParameter)
|
||||
{
|
||||
return "Output";
|
||||
}
|
||||
return "Input";
|
||||
//TODO return parameters
|
||||
}
|
||||
return string.Empty;
|
||||
|
||||
}
|
||||
|
||||
internal static string GetCustomLabel(object context, SmoQueryContext smoContext)
|
||||
{
|
||||
Parameter parameter = context as Parameter;
|
||||
if (parameter != null)
|
||||
{
|
||||
return GetParameterCustomLabel(parameter);
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
Table table = smoObject as Table;
|
||||
if (table != null && table.IsSystemVersioned)
|
||||
{
|
||||
return $"{table.Name} ({SR.SystemVersioned_LabelPart})";
|
||||
return $"{table.Schema}.{table.Name} ({SR.SystemVersioned_LabelPart})";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
@@ -34,21 +34,10 @@ namespace Microsoft.SqlTools.ServiceLayer.ObjectExplorer.SmoModel
|
||||
Table table = smoObject as Table;
|
||||
if (table != null)
|
||||
{
|
||||
return $"{table.Name} ({SR.History_LabelPart})";
|
||||
return $"{table.Schema}.{table.Name} ({SR.History_LabelPart})";
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public override string GetNodeSubType(object context)
|
||||
{
|
||||
Table table = context as Table;
|
||||
|
||||
if (table != null)
|
||||
{
|
||||
return "History";
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user