Skip to content

Commit 0501c41

Browse files
committed
Version 1.1.2
1 parent eb6d226 commit 0501c41

File tree

7 files changed

+50
-30
lines changed

7 files changed

+50
-30
lines changed

Client/CredentialWeb.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,15 @@ public class CredentialWeb : Credential
1515
/// URL address of the ressource
1616
/// </summary>
1717
public string Url { get; set; }
18+
19+
/// <summary>
20+
/// Username value
21+
/// </summary>
22+
public string Username { get; set; }
23+
24+
/// <summary>
25+
/// Password value
26+
/// </summary>
27+
public string Password { get; set; }
1828
}
1929
}

Engine/CommandCredentials.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,46 @@ public void SetCredentialFolder(string folderName)
3838
return;
3939
}
4040

41-
public void SetCredentialWeb(string url)
41+
public void SetCredentialWeb(string url, string userName, string password)
4242
{
4343
DataSource dataSource = new DataSource("Web", url);
44-
DataSourceSetting dataSourceSetting = new DataSourceSetting("Anonymous");
44+
DataSourceSetting dataSourceSetting;
45+
if (userName == null)
46+
dataSourceSetting = new DataSourceSetting("Anonymous");
47+
else
48+
dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
4549

4650
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
47-
51+
52+
4853
return;
4954
}
5055

5156
public void SetCredentialSQL(string sql, string userName, string password)
5257
{
5358
DataSource dataSource = new DataSource("SQL", sql);
59+
DataSourceSetting dataSourceSetting;
5460
if (userName == null)
55-
{
56-
DataSourceSetting dataSourceSetting = new DataSourceSetting("Windows");
57-
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
58-
}
61+
dataSourceSetting = new DataSourceSetting("Windows");
5962
else
60-
{
61-
var dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
62-
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
63-
}
63+
dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
64+
65+
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
6466

6567
return;
6668
}
6769

6870
public void SetCredentialOData(string url, string userName, string password)
6971
{
7072
DataSource dataSource = new DataSource("OData", url);
73+
DataSourceSetting dataSourceSetting;
7174
if (userName == null)
72-
{
73-
DataSourceSetting dataSourceSetting = new DataSourceSetting("Anonymous");
74-
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
75-
}
75+
dataSourceSetting = new DataSourceSetting("Anonymous");
7676
else
77-
{
78-
var dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
79-
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
80-
}
77+
dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password);
78+
79+
CredentialStore.SetCredential(dataSource, dataSourceSetting, null);
80+
8181

8282
return;
8383
}

PQNet/Program.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ static void Main(string[] args)
5858
if (!string.IsNullOrWhiteSpace(a.OutputFile))
5959
File.WriteAllText(a.OutputFile, "");
6060

61-
//ExecuteRequest request = LoadRequest(a);
6261
PowerQueryCommand powerQueryCommand = LoadCommand(a);
6362

6463
PowerQueryResponse powerQueryResponse = powerQueryService.Execute(powerQueryCommand);
@@ -122,8 +121,6 @@ private static PowerQueryCommand LoadCommand(Arguments a)
122121
case ExecuteOutputFlags.Csv:
123122
c.CsvFileName = a.OutputFile;
124123
break;
125-
//case ExecuteOutputFlags.DataTable:
126-
// break;
127124
case ExecuteOutputFlags.Html:
128125
c.HtmlFileName = a.OutputFile;
129126
break;
13.6 KB
Binary file not shown.

Samples/cmd/pqnet.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o html -f "%temp%\Adve
99
REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o json -f "%temp%\AdventureWorksSales.json"
1010
REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o xml -f "%temp%\AdventureWorksSales.xml"
1111
REM PQNet "..\MyFiles\MyReport.pbix" vChineseCalendar -s "Data Source=.\SQL2016;Initial Catalog=master;Integrated Security=True" -t tChineseCalendar -a dc
12+
REM PQNet "..\MyFiles\MyReport.xlsx" vChineseCalendar
1213
@echo on
13-
PQNet "#Hello World.pq"
14+
PQNet "..\MyFiles\MyReport.xlsx" vChineseCalendar
1415
@echo off
1516
if %ERRORLEVEL% EQU 0 (
1617
echo Success

Service/PowerQueryService.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,22 @@ public string MashupFromFile(string fileName)
2323
{
2424
try
2525
{
26-
string tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()) + ".pbix";
27-
File.Copy(fileName, tempFile);
28-
string mashup = Command.MashupFromFile(tempFile);
29-
File.Delete(tempFile);
26+
string mashup = null;
27+
28+
try
29+
{
30+
mashup = Command.MashupFromFile(fileName);
31+
}
32+
catch (Exception)
33+
{
34+
string tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()) + Path.GetExtension(fileName);
35+
File.Copy(fileName, tempFile);
36+
37+
mashup = Command.MashupFromFile(tempFile);
38+
39+
File.Delete(tempFile);
40+
}
41+
3042
return mashup;
3143
}
3244
catch (Exception ex)
@@ -189,11 +201,11 @@ public PowerQueryResponse Execute(PowerQueryCommand powerQueryCommand)
189201
else if(credential is CredentialFolder credentialFolder)
190202
commandCredentials.SetCredentialFolder(credentialFolder.Path);
191203
else if (credential is CredentialWeb credentialWeb)
192-
commandCredentials.SetCredentialWeb(credentialWeb.Url);
204+
commandCredentials.SetCredentialWeb(credentialWeb.Url, credentialWeb.Username, credentialWeb.Password);
193205
else if (credential is CredentialSQL credentialSQL)
194206
commandCredentials.SetCredentialSQL(credentialSQL.SQL, credentialSQL.Username, credentialSQL.Password);
195207
else if (credential is CredentialOData credentialOData)
196-
commandCredentials.SetCredentialOData(((CredentialOData)credential).Url, credentialOData.Username, credentialOData.Password);
208+
commandCredentials.SetCredentialOData(credentialOData.Url, credentialOData.Username, credentialOData.Password);
197209
else
198210
throw new NotImplementedException("This Credential kind is not supported for now.");
199211
}

Setup/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:sql="http://schemas.microsoft.com/wix/SqlExtension">
33
<?include $(sys.CURRENTDIR)\Config.wxi?>
4-
<Product Id="95f93336-b7a9-4a68-acf5-1492ec0c5d72" Name="PowerQueryNet" Language="1033" Version="1.1.1" Manufacturer="Guillaume Simard" UpgradeCode="115ef465-536f-4030-bd2d-44b0edb1bbe5">
4+
<Product Id="95f93336-b7a9-4a68-acf5-1492ec0c5d72" Name="PowerQueryNet" Language="1033" Version="1.1.2" Manufacturer="Guillaume Simard" UpgradeCode="115ef465-536f-4030-bd2d-44b0edb1bbe5">
55
<Package Id="5e1dc07c-131a-43d4-8a98-4d091537ac0f" InstallPrivileges="elevated" InstallerVersion="200" Platform ="x64" Compressed="yes" InstallScope="perMachine" Languages="1033" SummaryCodepage="1252" Description="[ProductName]" />
66
<Icon Id="PQNet.ico" SourceFile="Resources\PQNet.ico" />
77
<Property Id="ARPPRODUCTICON" Value="PQNet.ico" />

0 commit comments

Comments
 (0)