Change preview report type (#1418)

* change report type

* PR comments

* fix doc for report

* rename format to mimetype

* nitpicks

* edit comments

* default to plain text
This commit is contained in:
Aditya Bist
2022-03-08 14:07:30 -08:00
committed by GitHub
parent 40c5d48c5e
commit 3e5bf00cc5
2 changed files with 25 additions and 4 deletions

View File

@@ -7,6 +7,23 @@ using Microsoft.SqlTools.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
{
/// <summary>
/// The service request to generate preview report describing the changes.
/// </summary>
public class GeneratePreviewReportResult
{
/// <summary>
/// The report generated for publish preview
/// </summary>
public string Report;
/// <summary>
/// format (mimetype) of the string
/// </summary>
public string MimeType;
}
/// <summary>
/// The service request to generate preview report describing the changes.
/// </summary>
@@ -15,6 +32,6 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
/// <summary>
/// Request definition
/// </summary>
public static readonly RequestType<TableInfo, string> Type = RequestType<TableInfo, string>.Create("tabledesigner/generatepreviewreport");
public static readonly RequestType<TableInfo, GeneratePreviewReportResult> Type = RequestType<TableInfo, GeneratePreviewReportResult>.Create("tabledesigner/generatepreviewreport");
}
}

View File

@@ -161,13 +161,17 @@ namespace Microsoft.SqlTools.ServiceLayer.TableDesigner
});
}
private Task HandleGeneratePreviewReportRequest(TableInfo tableInfo, RequestContext<string> requestContext)
private Task HandleGeneratePreviewReportRequest(TableInfo tableInfo, RequestContext<GeneratePreviewReportResult> requestContext)
{
return this.HandleRequest<string>(requestContext, async () =>
return this.HandleRequest<GeneratePreviewReportResult>(requestContext, async () =>
{
var table = this.GetTableDesigner(tableInfo);
var report = table.GenerateReport();
await requestContext.SendResult(report);
var generatePreviewReportResult = new GeneratePreviewReportResult();
// TODO - set report type by caohai
generatePreviewReportResult.Report = report;
generatePreviewReportResult.MimeType = "text/plain";
await requestContext.SendResult(generatePreviewReportResult);
});
}