// // 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 { /// /// Parameters for the save results request /// public class SaveResultsRequestParams { /// /// The path of the file to save results in /// public string FilePath { get; set; } /// /// Index of the batch to get the results from /// public int BatchIndex { get; set; } /// /// Index of the result set to get the results from /// public int ResultSetIndex { get; set; } /// /// URI for the editor that called save results /// public string OwnerUri { get; set; } /// /// Start index of the selected rows (inclusive) /// public int? RowStartIndex { get; set; } /// /// End index of the selected rows (inclusive) /// public int? RowEndIndex { get; set; } /// /// Start index of the selected columns (inclusive) /// /// public int? ColumnStartIndex { get; set; } /// /// End index of the selected columns (inclusive) /// /// public int? ColumnEndIndex { get; set; } /// /// Check if request is a subset of result set or whole result set /// /// internal bool IsSaveSelection { get { return ColumnStartIndex.HasValue && ColumnEndIndex.HasValue && RowStartIndex.HasValue && RowEndIndex.HasValue; } } } /// /// Parameters to save results as CSV /// public class SaveResultsAsCsvRequestParams: SaveResultsRequestParams { /// /// Include headers of columns in CSV /// public bool IncludeHeaders { get; set; } /// /// Delimiter for separating data items in CSV /// public string Delimiter { get; set; } /// /// either CR, CRLF or LF to seperate rows in CSV /// public string LineSeperator { get; set; } /// /// Text identifier for alphanumeric columns in CSV /// public string TextIdentifier { get; set; } /// /// Encoding of the CSV file /// public string Encoding { get; set; } /// /// Maximum number of characters to store /// public int MaxCharsToStore { get; set; } } /// /// Parameters to save results as Excel /// public class SaveResultsAsExcelRequestParams : SaveResultsRequestParams { /// /// Include headers of columns in Excel /// public bool IncludeHeaders { get; set; } } /// /// Parameters to save results as JSON /// public class SaveResultsAsJsonRequestParams: SaveResultsRequestParams { //TODO: define config for save as JSON } /// /// Parameters to save results as XML /// public class SaveResultsAsXmlRequestParams: SaveResultsRequestParams { /// /// Formatting of the XML file /// public bool Formatted { get; set; } /// /// Encoding of the XML file /// public string Encoding { get; set; } } /// /// Parameters for the save results result /// public class SaveResultRequestResult { /// /// Error messages for saving to file. /// public string Messages { get; set; } } /// /// Request type to save results as CSV /// public class SaveResultsAsCsvRequest { public static readonly RequestType Type = RequestType.Create("query/saveCsv"); } /// /// Request type to save results as Excel /// public class SaveResultsAsExcelRequest { public static readonly RequestType Type = RequestType.Create("query/saveExcel"); } /// /// Request type to save results as JSON /// public class SaveResultsAsJsonRequest { public static readonly RequestType Type = RequestType.Create("query/saveJson"); } /// /// Request type to save results as XML /// public class SaveResultsAsXmlRequest { public static readonly RequestType Type = RequestType.Create("query/saveXml"); } }