mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
add table type to process and publish results (#1448)
* add table type to process and publish results * make generic property bag * review comments * remove unused code * edit comment
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
@@ -22,6 +23,11 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
/// format (mimetype) of the string
|
||||
/// </summary>
|
||||
public string MimeType;
|
||||
|
||||
/// <summary>
|
||||
/// Metadata about the table
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Metadata { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
|
||||
@@ -24,6 +25,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
public bool IsValid { get; set; }
|
||||
|
||||
public TableDesignerIssue[] Issues { get; set; }
|
||||
|
||||
public Dictionary<string, string> Metadata { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.SqlTools.Hosting.Protocol.Contracts;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
@@ -12,6 +13,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
public TableInfo NewTableInfo;
|
||||
public TableViewModel ViewModel;
|
||||
public TableDesignerView View;
|
||||
public Dictionary<string, string> Metadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Dac = Microsoft.Data.Tools.Sql.DesignServices.TableDesigner;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
{
|
||||
public static class TableDesignerMetadata
|
||||
{
|
||||
public static bool IsNode(this Dac.TableDesigner tableDesigner)
|
||||
{
|
||||
return tableDesigner.TableViewModel.IsNode;
|
||||
}
|
||||
|
||||
public static bool IsEdge(this Dac.TableDesigner tableDesigner)
|
||||
{
|
||||
return tableDesigner.TableViewModel.IsEdge;
|
||||
}
|
||||
|
||||
public static bool IsSystemVersioned(this Dac.TableDesigner tableDesigner)
|
||||
{
|
||||
return tableDesigner.TableViewModel.IsSystemVersioningEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -119,7 +119,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
ViewModel = this.GetTableViewModel(requestParams.TableInfo),
|
||||
IsValid = issues.Where(i => i.Severity == IssueSeverity.Error).Count() == 0,
|
||||
Issues = issues.ToArray(),
|
||||
View = refreshViewRequired ? this.GetDesignerViewInfo(requestParams.TableInfo) : null
|
||||
View = refreshViewRequired ? this.GetDesignerViewInfo(requestParams.TableInfo) : null,
|
||||
Metadata = this.GetMetadata(requestParams.TableInfo)
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -147,7 +148,8 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
{
|
||||
NewTableInfo = tableInfo,
|
||||
ViewModel = this.GetTableViewModel(tableInfo),
|
||||
View = GetDesignerViewInfo(tableInfo)
|
||||
View = GetDesignerViewInfo(tableInfo),
|
||||
Metadata = this.GetMetadata(tableInfo)
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -171,6 +173,7 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
var generatePreviewReportResult = new GeneratePreviewReportResult();
|
||||
generatePreviewReportResult.Report = report;
|
||||
generatePreviewReportResult.MimeType = "text/markdown";
|
||||
generatePreviewReportResult.Metadata = this.GetMetadata(tableInfo);
|
||||
await requestContext.SendResult(generatePreviewReportResult);
|
||||
});
|
||||
}
|
||||
@@ -1298,9 +1301,9 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
|
||||
private Dac.TableDesigner CreateTableDesigner(TableInfo tableInfo)
|
||||
{
|
||||
var connectinStringbuilder = new SqlConnectionStringBuilder(tableInfo.ConnectionString);
|
||||
connectinStringbuilder.InitialCatalog = tableInfo.Database;
|
||||
var connectionString = connectinStringbuilder.ToString();
|
||||
var connectionStringbuilder = new SqlConnectionStringBuilder(tableInfo.ConnectionString);
|
||||
connectionStringbuilder.InitialCatalog = tableInfo.Database;
|
||||
var connectionString = connectionStringbuilder.ToString();
|
||||
var tableDesigner = new Dac.TableDesigner(connectionString, tableInfo.AccessToken, tableInfo.Schema, tableInfo.Name, tableInfo.IsNewTable);
|
||||
this.idTableMap[tableInfo.Id] = tableDesigner;
|
||||
return tableDesigner;
|
||||
@@ -1319,6 +1322,18 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, string> GetMetadata(TableInfo tableInfo)
|
||||
{
|
||||
var tableDesigner = this.GetTableDesigner(tableInfo);
|
||||
var metadata = new Dictionary<string, string>()
|
||||
{
|
||||
{ "IsEdge", tableDesigner.IsEdge().ToString() },
|
||||
{ "IsNode", tableDesigner.IsNode().ToString() },
|
||||
{ "IsSystemVersioned", tableDesigner.IsSystemVersioned().ToString() }
|
||||
};
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the table designer Service
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user