Skip to content

Commit 3adb74b

Browse files
committed
Version 1.1
1 parent c5494c5 commit 3adb74b

8 files changed

+174
-335
lines changed

Client/Client.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@
6464
<Compile Include="CredentialFile.cs" />
6565
<Compile Include="Credentials.cs" />
6666
<Compile Include="ExecuteOutputFlags.cs" />
67-
<Compile Include="ExecuteResponse.cs" />
67+
<Compile Include="PowerQueryResponse.cs" />
6868
<Compile Include="IPowerQueryService.cs" />
69-
<Compile Include="ExecuteRequest.cs" />
7069
<Compile Include="Queries.cs" />
7170
<Compile Include="Query.cs" />
7271
<Compile Include="ObjectExtension.cs" />

Client/ExecuteRequest.cs

Lines changed: 0 additions & 135 deletions
This file was deleted.

Client/IPowerQueryService.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ public interface IPowerQueryService
1717
/// <summary>
1818
/// Execute the specified query.
1919
/// </summary>
20-
/// <param name="executeRequest">Inputs for the method</param>
20+
/// <param name="powerQueryCommand">Inputs for the method</param>
2121
/// <returns></returns>
2222
[OperationContract]
23-
//ExecuteResponse Execute(string queryName, Queries queries, Credentials credentials);
24-
ExecuteResponse Execute(ExecuteRequest executeRequest);
23+
PowerQueryResponse Execute(PowerQueryCommand powerQueryCommand);
2524

2625
/// <summary>
2726
/// Get the mashup (queries) from an Excel or Power BI file.

Client/PowerQueryCommand.cs

Lines changed: 77 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,50 +73,87 @@ public string Mashup
7373
public Credentials Credentials { get; set; }
7474

7575
/// <summary>
76-
/// Collection of instances of Parameter in the Power Query (M) formulas.
76+
/// Name of the query to execute.
7777
/// </summary>
78-
//public Parameters Parameters { get; set; }
78+
public string QueryName { get; set; }
7979

8080
/// <summary>
81-
/// Execute the specified ExecuteRequest.
81+
/// Specifies the outputs that will be generated in memory after the execution of the query.
8282
/// </summary>
83-
/// <param name="executeRequest">ExecuteRequest to execute</param>
84-
/// <returns></returns>
85-
public ExecuteResponse Execute(ExecuteRequest executeRequest)
86-
{
87-
if (executeRequest.Credentials == null || executeRequest.Credentials.Count == 0)
88-
executeRequest.Credentials = this.Credentials;
83+
public ExecuteOutputFlags ExecuteOutputFlags { get; set; } = ExecuteOutputFlags.DataTable;
8984

90-
if (executeRequest.Mashup == null)
91-
executeRequest.Mashup = this.Mashup;
85+
/// <summary>
86+
/// Full path of the CSV file that will be generated after the execution of the query.
87+
/// </summary>
88+
public string CsvFileName { get; set; }
9289

93-
if (executeRequest.Queries == null || executeRequest.Queries.Count == 0)
94-
executeRequest.Queries = this.Queries;
90+
/// <summary>
91+
/// Full path of the HTML file that will be generated after the execution of the query.
92+
/// </summary>
93+
public string HtmlFileName { get; set; }
9594

96-
return ExecuteMethod("Execute", executeRequest);
97-
}
95+
/// <summary>
96+
/// Full path of the JSON file that will be generated after the execution of the query.
97+
/// </summary>
98+
public string JsonFileName { get; set; }
99+
100+
/// <summary>
101+
/// Full path of the XML file that will be generated after the execution of the query.
102+
/// </summary>
103+
public string XmlFileName { get; set; }
104+
105+
/// <summary>
106+
/// Connection string to the SQL Server and Database where the Table will be generated after the execution of the query.
107+
/// </summary>
108+
public string SqlConnectionString { get; set; }
109+
110+
/// <summary>
111+
/// For SQL decimal data type, the maximum total number of decimal digits to be stored.
112+
/// </summary>
113+
public int SqlDecimalPrecision { get; set; }
114+
115+
/// <summary>
116+
/// For SQL decimal data type, the number of decimal digits that are stored to the right of the decimal point.
117+
/// </summary>
118+
public int SqlDecimalScale { get; set; }
119+
120+
/// <summary>
121+
/// When SqlConnectionString is not null, name of the SQL Table that will be generated after the execution of the query. If this property is null, the default name will correspond to the QueryName.
122+
/// </summary>
123+
public string SqlTableName { get; set; }
124+
125+
/// <summary>
126+
/// Action taken when SqlConnectionString and SqlTableName are not null
127+
/// </summary>
128+
public SqlTableAction SqlTableAction { get; set; }
129+
130+
/// <summary>
131+
/// Path of the folder to create temporary files.
132+
/// </summary>
133+
public string TempPath { get; set; }
98134

99135
/// <summary>
100136
/// Execute the specified query.
101137
/// </summary>
102138
/// <param name="queryName">Name of the query to execute</param>
103139
/// <returns></returns>
104-
public ExecuteResponse Execute(string queryName)
140+
public PowerQueryResponse Execute(string queryName)
105141
{
106-
return ExecuteMethod("Execute", new ExecuteRequest { QueryName = queryName, Queries = this.Queries, Credentials = this.Credentials, Mashup = this.Mashup, ExecuteOutputFlags = ExecuteOutputFlags.DataTable });
142+
QueryName = queryName;
143+
return ExecuteMethod("Execute", this);
107144
}
108145

109146
/// <summary>
110147
/// Execute the specified query.
111148
/// </summary>
112149
/// <param name="query">Query object to execute</param>
113150
/// <returns></returns>
114-
public ExecuteResponse Execute(Query query)
151+
public PowerQueryResponse Execute(Query query)
115152
{
116153
if (Queries[query.Name] == null)
117154
Queries.Add(query);
118155

119-
return ExecuteMethod("Execute", new ExecuteRequest { QueryName = query.Name, Queries = this.Queries, Credentials = this.Credentials, Mashup = this.Mashup, ExecuteOutputFlags = ExecuteOutputFlags.DataTable });
156+
return ExecuteMethod("Execute", this);
120157
}
121158

122159
/// <summary>
@@ -126,10 +163,16 @@ public ExecuteResponse Execute(Query query)
126163
/// <param name="queries">Collection of instances of Query to execute Power Query (M) formulas.</param>
127164
/// <param name="credentials">Collection of instances of Credential to access one or many ressources from the Power Query (M) formulas.</param>
128165
/// <returns></returns>
129-
public static ExecuteResponse Execute(string queryName, Queries queries, Credentials credentials = null)
166+
public static PowerQueryResponse Execute(string queryName, Queries queries, Credentials credentials = null)
130167
{
131168
//return ExecuteMethod("Execute", queryName, queries.ToArray(), credentials);
132-
return ExecuteMethod("Execute", new ExecuteRequest { QueryName = queryName, Queries = queries, Credentials = credentials, ExecuteOutputFlags = ExecuteOutputFlags.DataTable });
169+
var c = new PowerQueryCommand()
170+
{
171+
QueryName = queryName,
172+
Queries = queries,
173+
Credentials = credentials,
174+
};
175+
return ExecuteMethod("Execute", c);
133176
}
134177

135178
/// <summary>
@@ -139,10 +182,16 @@ public static ExecuteResponse Execute(string queryName, Queries queries, Credent
139182
/// <param name="mashup">Mashup (queries) from which the query will be executed</param>
140183
/// <param name="credentials">Collection of instances of Credential to access one or many ressources from the Power Query (M) formulas.</param>
141184
/// <returns></returns>
142-
public static ExecuteResponse Execute(string queryName, string mashup, Credentials credentials = null)
185+
public static PowerQueryResponse Execute(string queryName, string mashup, Credentials credentials = null)
143186
{
144187
//return ExecuteMethod("Execute", queryName, queries.ToArray(), credentials);
145-
return ExecuteMethod("Execute", new ExecuteRequest { QueryName = queryName, Mashup = mashup, Credentials = credentials, ExecuteOutputFlags = ExecuteOutputFlags.DataTable });
188+
var c = new PowerQueryCommand()
189+
{
190+
QueryName = queryName,
191+
Mashup = mashup,
192+
Credentials = credentials,
193+
};
194+
return ExecuteMethod("Execute", c);
146195
}
147196

148197
/// <summary>
@@ -161,7 +210,6 @@ private static dynamic ExecuteMethod(string method, params object[] obj)
161210

162211
TimeSpan ipcTimeout;
163212
string ipcAddress;
164-
//using (var keyPQ = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\PowerQueryNet"))
165213
using (var keyPQ = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\PowerQueryNet"))
166214
{
167215
if (keyPQ == null)
@@ -185,10 +233,11 @@ private static dynamic ExecuteMethod(string method, params object[] obj)
185233

186234
if (method == "Execute")
187235
{
188-
var executeRequest = (ExecuteRequest)obj[0];
189-
executeRequest.TempPath = System.IO.Path.GetTempPath();
190-
var executeResponse = powerQueryService.Execute(executeRequest);
191-
executeResponse.LoadReturnValues(executeRequest.ExecuteOutputFlags);
236+
var powerQueryCommand = (PowerQueryCommand)obj[0];
237+
powerQueryCommand.TempPath = System.IO.Path.GetTempPath();
238+
var executeResponse = powerQueryService.Execute(powerQueryCommand);
239+
executeResponse.LoadReturnValues(powerQueryCommand.ExecuteOutputFlags);
240+
192241
return executeResponse;
193242
}
194243
else if (method == "MashupFromFile")

Client/ExecuteResponse.cs renamed to Client/PowerQueryResponse.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace PowerQueryNet.Client
1111
/// <summary>
1212
/// Response from the PowerQueryCommand.Execute method.
1313
/// </summary>
14-
public class ExecuteResponse
14+
public class PowerQueryResponse
1515
{
1616

1717
/// <summary>
@@ -66,19 +66,19 @@ internal void LoadReturnValues(ExecuteOutputFlags executeOutputFlags)
6666
StringReader sr = new StringReader(DataTableXML);
6767
dataTable.ReadXml(sr);
6868

69-
if (executeOutputFlags == ExecuteOutputFlags.DataTable)
69+
if (executeOutputFlags.HasFlag(ExecuteOutputFlags.DataTable))
7070
DataTable = dataTable;
7171

72-
if (executeOutputFlags == ExecuteOutputFlags.Csv)
72+
if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Csv))
7373
Csv = dataTable.ToDelimitedFile(',', true);
7474

75-
if (executeOutputFlags == ExecuteOutputFlags.Html)
75+
if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Html))
7676
Html = dataTable.ToHTML();
7777

78-
if (executeOutputFlags == ExecuteOutputFlags.Json)
78+
if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Json))
7979
Json = dataTable.ToContentJSON();
8080

81-
if (executeOutputFlags == ExecuteOutputFlags.Xml)
81+
if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Xml))
8282
Xml = dataTable.ToContentXML();
8383
}
8484
}

0 commit comments

Comments
 (0)