├── .gitattributes ├── .gitignore ├── Client ├── Client.csproj ├── Credential.cs ├── CredentialFile.cs ├── CredentialFolder.cs ├── CredentialOData.cs ├── CredentialSQL.cs ├── CredentialWeb.cs ├── Credentials.cs ├── ExecuteOutputFlags.cs ├── IPowerQueryService.cs ├── ObjectExtension.cs ├── Parameter.cs ├── Parameters.cs ├── PowerQueryCommand.cs ├── PowerQueryNet.Client.snk ├── PowerQueryResponse.cs ├── Properties │ └── AssemblyInfo.cs ├── Queries.cs ├── Query.cs └── SqlTableAction.cs ├── Engine ├── Command.cs ├── CommandCredentials.cs ├── Engine.csproj └── Properties │ └── AssemblyInfo.cs ├── LICENSE ├── PQNet ├── App.config ├── Arguments.cs ├── PQNet.csproj ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── WindowGrid.xaml └── WindowGrid.xaml.cs ├── PowerQueryNet.sln ├── README.md ├── Samples ├── PowerQueryApp │ ├── App.config │ ├── FormMain.Designer.cs │ ├── FormMain.cs │ ├── FormMain.resx │ ├── MyFiles │ │ ├── MyReport.pbix │ │ ├── MyReport.xlsx │ │ └── taPMTransactionInsert.xml │ ├── MyQueries │ │ ├── #Hello World.pq │ │ ├── #credentials.xml │ │ ├── AdventureWorksSales.pq │ │ ├── DateTable2018.pq │ │ ├── ListFiles.pq │ │ ├── TestXml.pq │ │ └── fnDateTable.pq │ ├── PowerQueryApp.csproj │ ├── PowerQueryApp.png │ ├── Program.cs │ ├── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings │ └── lib │ │ ├── Microsoft.WindowsAPICodePack.Shell.dll │ │ └── Microsoft.WindowsAPICodePack.dll ├── PowerQueryHelloWorld │ ├── App.config │ ├── FormMain.Designer.cs │ ├── FormMain.cs │ ├── FormMain.resx │ ├── PowerQueryHelloWorld.csproj │ ├── Program.cs │ └── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings ├── PowerQueryNet.Samples.sln ├── PowerQueryParameters │ ├── App.config │ ├── FormMain.Designer.cs │ ├── FormMain.cs │ ├── FormMain.resx │ ├── MyExcel │ │ ├── List1.xls │ │ ├── List1and2.xlsx │ │ └── List2.xlsx │ ├── MyQueries │ │ ├── #credentials.xml │ │ ├── List1.pq │ │ ├── List1and2.pq │ │ └── List2.pq │ ├── PowerQueryParameters.csproj │ ├── Program.cs │ └── Properties │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Resources.resx │ │ ├── Settings.Designer.cs │ │ └── Settings.settings └── cmd │ └── pqnet.cmd ├── Service ├── App.config ├── PowerQueryService.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings ├── Service.csproj └── WindowsService.cs ├── Setup.Actions ├── CustomAction.config ├── CustomAction.cs ├── Properties │ └── AssemblyInfo.cs ├── Setup.Actions.csproj └── app.manifest └── Setup ├── Config.wxi ├── Product.wxs ├── Resources ├── PQNet.ico ├── PQNetBanner.jpg ├── PQNetDialog.jpg ├── WiXNewFolderBtn.ico └── WiXUpFolderBtn.ico └── Setup.wixproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc 262 | /Microsoft Power Query SDK - Pre-Release or Evaluation Use Terms.rtf 263 | /Engine/lib/Microsoft.MashupEngine.dll 264 | /Engine/lib/Microsoft.Mashup.Tools.dll 265 | /Engine/lib/Microsoft.Mashup.OAuth.dll 266 | /Engine/lib/Microsoft.Data.Mashup.dll 267 | /Engine/lib/Microsoft.ApplicationInsights.dll 268 | /.doc 269 | -------------------------------------------------------------------------------- /Client/Client.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB} 8 | Library 9 | Properties 10 | PowerQueryNet.Client 11 | PowerQueryNet.Client 12 | v4.5.1 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 1.0.0.0 19 | 20 | 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | bin\Debug\PowerQueryNet.Client.xml 29 | 30 | 31 | pdbonly 32 | true 33 | bin\Release\ 34 | TRACE 35 | prompt 36 | 4 37 | 38 | 39 | false 40 | 41 | 42 | PowerQueryNet.Client.snk 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 87 | -------------------------------------------------------------------------------- /Client/Credential.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Runtime.Serialization; 7 | using System.Xml.Serialization; 8 | 9 | namespace PowerQueryNet.Client 10 | { 11 | /// 12 | /// Credential to access a ressource from the Power Query (M) formulas. 13 | /// 14 | [XmlInclude(typeof(CredentialFile))] 15 | [KnownType(typeof(CredentialFile))] 16 | [XmlInclude(typeof(CredentialFolder))] 17 | [KnownType(typeof(CredentialFolder))] 18 | [XmlInclude(typeof(CredentialWeb))] 19 | [KnownType(typeof(CredentialWeb))] 20 | [XmlInclude(typeof(CredentialSQL))] 21 | [KnownType(typeof(CredentialSQL))] 22 | [XmlInclude(typeof(CredentialOData))] 23 | [KnownType(typeof(CredentialOData))] 24 | public abstract class Credential 25 | { 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Client/CredentialFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Credential to access a file from the Power Query (M) formulas. 11 | /// 12 | public class CredentialFile : Credential 13 | { 14 | /// 15 | /// Full path of the file 16 | /// 17 | public string Path { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Client/CredentialFolder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Credential to access a folder from the Power Query (M) formulas. 11 | /// 12 | public class CredentialFolder : Credential 13 | { 14 | /// 15 | /// Full path of the folder 16 | /// 17 | public string Path { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Client/CredentialOData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Credential to access an OData resource from the Power Query (M) formulas. 11 | /// 12 | public class CredentialOData : Credential 13 | { 14 | /// 15 | /// URL address of the resource 16 | /// 17 | public string Url { get; set; } 18 | 19 | /// 20 | /// Username value 21 | /// 22 | public string Username { get; set; } 23 | 24 | /// 25 | /// Password value 26 | /// 27 | public string Password { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Client/CredentialSQL.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Credential to access a SQL ressource from the Power Query (M) formulas. 11 | /// 12 | public class CredentialSQL : Credential 13 | { 14 | /// 15 | /// SQL Server Name and database name. Format: serverName;databaseName 16 | /// 17 | public string SQL { get; set; } 18 | 19 | /// 20 | /// Username value 21 | /// 22 | public string Username { get; set; } 23 | 24 | /// 25 | /// Password value 26 | /// 27 | public string Password { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Client/CredentialWeb.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Credential to access a web ressource from the Power Query (M) formulas. 11 | /// 12 | public class CredentialWeb : Credential 13 | { 14 | /// 15 | /// URL address of the ressource 16 | /// 17 | public string Url { get; set; } 18 | 19 | /// 20 | /// Username value 21 | /// 22 | public string Username { get; set; } 23 | 24 | /// 25 | /// Password value 26 | /// 27 | public string Password { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Client/Credentials.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.Serialization; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Xml.Serialization; 9 | 10 | namespace PowerQueryNet.Client 11 | { 12 | /// 13 | /// Collection of instances of Credential to access one or many ressources from the Power Query (M) formulas. 14 | /// 15 | [XmlInclude(typeof(Credential))] 16 | [KnownType(typeof(Credential))] 17 | [XmlRootAttribute(Namespace = "", IsNullable = false, ElementName = "Credentials")] 18 | public class Credentials : IEnumerable, ICollection 19 | { 20 | private List credentialList; 21 | 22 | /// 23 | /// Initializes a new instance of the Credentials class. 24 | /// 25 | public Credentials() 26 | { 27 | credentialList = new List(); 28 | } 29 | 30 | /// 31 | /// Adds a Credential to the collection. 32 | /// 33 | /// 34 | public void Add(object credential) 35 | { 36 | if (credential is Credential) 37 | { 38 | credentialList.Add((Credential)credential); 39 | } 40 | } 41 | 42 | /// 43 | /// Removes all Credential from the collection. 44 | /// 45 | public void Clear() 46 | { 47 | credentialList = new List(); 48 | } 49 | 50 | /// 51 | /// Loads Credentials from an XML file. 52 | /// 53 | /// 54 | /// 55 | public static Credentials LoadFromFile(string path) 56 | { 57 | if (path == null) return null; 58 | string xml = System.IO.File.ReadAllText(path); 59 | Credentials credentials = xml.DeserializeXML(); 60 | return credentials; 61 | } 62 | 63 | /// 64 | /// Adds Credentials from an XML file. 65 | /// 66 | /// 67 | public void AddFromFile(string path) 68 | { 69 | if (path == null) return; 70 | string xml = System.IO.File.ReadAllText(path); 71 | Credentials credentials = xml.DeserializeXML(); 72 | credentialList.AddRange(credentials.ToArray()); 73 | } 74 | 75 | /// 76 | /// Saves Credentials to an XML file. 77 | /// 78 | /// 79 | public void SaveToFile(string path) 80 | { 81 | if (path == null) return; 82 | string xml = this.ToXML(); 83 | System.IO.File.WriteAllText(path, xml); 84 | } 85 | 86 | /// 87 | /// Removes the first occurence of a Credential from the collection. 88 | /// 89 | /// 90 | public void Remove(Credential credential) 91 | { 92 | credentialList.Remove(credential); 93 | } 94 | 95 | /// 96 | /// Gets a Credential by index. 97 | /// 98 | /// 99 | /// 100 | public Credential this[int index] 101 | { 102 | get { return credentialList[index]; } 103 | set { credentialList.Insert(index, value); } 104 | } 105 | 106 | /// 107 | /// Copies the elements of Credentials to a new array. 108 | /// 109 | /// 110 | public Credential[] ToArray() 111 | { 112 | return credentialList.ToArray(); 113 | } 114 | 115 | /// 116 | /// Returns an enumerator that iterates through the Credentials collection. 117 | /// 118 | /// 119 | public IEnumerator GetEnumerator() 120 | { 121 | return credentialList.GetEnumerator(); 122 | } 123 | 124 | /// 125 | /// Gets the number of Credential in the collection. 126 | /// 127 | public int Count 128 | { 129 | get 130 | { 131 | return credentialList.Count; 132 | } 133 | } 134 | 135 | /// 136 | /// Gets an object that can be used to synchronize access to the ICollection. 137 | /// 138 | public object SyncRoot 139 | { 140 | get 141 | { 142 | return this; 143 | } 144 | } 145 | 146 | /// 147 | /// Gets a value indicating whether access to the ICollection is synchronized (thread safe). 148 | /// 149 | public bool IsSynchronized 150 | { 151 | get 152 | { 153 | return false; 154 | } 155 | } 156 | 157 | /// 158 | /// NotImplemented yet. 159 | /// 160 | /// The one-dimensional array that is the destination of the elements copied from the current array. 161 | /// A 32-bit integer that represents the index in array at which copying begins. 162 | public void CopyTo(Array array, int index) 163 | { 164 | throw new NotImplementedException(); 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /Client/ExecuteOutputFlags.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Enumerates the different output formats allowed in the ExecutionResponse. 11 | /// 12 | [Flags] 13 | public enum ExecuteOutputFlags 14 | { 15 | 16 | /// 17 | /// Outputs result to comma-separated values (CSV) 18 | /// 19 | Csv = 1, 20 | 21 | /// 22 | /// Outputs result to DataTable 23 | /// 24 | DataTable = 2, 25 | 26 | /// 27 | /// Outputs result to HTML 28 | /// 29 | Html = 4, 30 | 31 | /// 32 | /// Outputs result to JSON 33 | /// 34 | Json = 8, 35 | 36 | /// 37 | /// Outputs result to a SQL Server Table 38 | /// 39 | Sql = 16, 40 | 41 | /// 42 | /// Outputs result to Xml 43 | /// 44 | Xml = 32 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Client/IPowerQueryService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.Linq; 5 | using System.ServiceModel; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PowerQueryNet.Client 10 | { 11 | /// 12 | /// Interface for PowerQueryService 13 | /// 14 | [ServiceContract(Namespace = "")] 15 | public interface IPowerQueryService 16 | { 17 | /// 18 | /// Execute the specified query. 19 | /// 20 | /// Inputs for the method 21 | /// 22 | [OperationContract] 23 | PowerQueryResponse Execute(PowerQueryCommand powerQueryCommand); 24 | 25 | /// 26 | /// Get the mashup (queries) from an Excel or Power BI file. 27 | /// 28 | /// Full path of the file 29 | /// 30 | [OperationContract] 31 | string MashupFromFile(string fileName); 32 | 33 | //[OperationContract] 34 | //void Stop(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Client/Parameter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Define a parameter in the Power Query (M) formulas. 11 | /// 12 | public class Parameter 13 | { 14 | /// 15 | /// Name of the parameter 16 | /// 17 | public string Name { get; set; } 18 | 19 | /// 20 | /// Value of the parameter 21 | /// 22 | public string Value { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Client/Parameters.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.Serialization; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Xml.Serialization; 9 | 10 | namespace PowerQueryNet.Client 11 | { 12 | /// 13 | /// Collection of instances of parameter in the Power Query (M) formulas. 14 | /// 15 | public class Parameters : IEnumerable, ICollection 16 | { 17 | private List parameterList; 18 | 19 | /// 20 | /// Initializes a new instance of the Parameters class. 21 | /// 22 | public Parameters() 23 | { 24 | parameterList = new List(); 25 | } 26 | 27 | /// 28 | /// Adds a Parameter to the collection. 29 | /// 30 | /// 31 | public void Add(object parameter) 32 | { 33 | if (parameter is Parameter) 34 | { 35 | parameterList.Add((Parameter)parameter); 36 | } 37 | } 38 | 39 | /// 40 | /// Removes all Parameter from the collection. 41 | /// 42 | public void Clear() 43 | { 44 | parameterList = new List(); 45 | } 46 | 47 | /// 48 | /// Removes the first occurence of a Parameter from the collection. 49 | /// 50 | /// 51 | public void Remove(Parameter parameter) 52 | { 53 | parameterList.Remove(parameter); 54 | } 55 | 56 | /// 57 | /// Gets a Parameter by index. 58 | /// 59 | /// 60 | /// 61 | public Parameter this[int index] 62 | { 63 | get { return parameterList[index]; } 64 | set { parameterList.Insert(index, value); } 65 | } 66 | 67 | /// 68 | /// Copies the elements of Parameters to a new array. 69 | /// 70 | /// 71 | public Parameter[] ToArray() 72 | { 73 | return parameterList.ToArray(); 74 | } 75 | 76 | /// 77 | /// Returns an enumerator that iterates through the Parameters collection. 78 | /// 79 | /// 80 | public IEnumerator GetEnumerator() 81 | { 82 | return parameterList.GetEnumerator(); 83 | } 84 | 85 | /// 86 | /// Gets the number of Parameter in the collection. 87 | /// 88 | public int Count 89 | { 90 | get 91 | { 92 | return parameterList.Count; 93 | } 94 | } 95 | 96 | /// 97 | /// Gets an object that can be used to synchronize access to the ICollection. 98 | /// 99 | public object SyncRoot 100 | { 101 | get 102 | { 103 | return this; 104 | } 105 | } 106 | 107 | /// 108 | /// Gets a value indicating whether access to the ICollection is synchronized (thread safe). 109 | /// 110 | public bool IsSynchronized 111 | { 112 | get 113 | { 114 | return false; 115 | } 116 | } 117 | 118 | /// 119 | /// NotImplemented yet. 120 | /// 121 | /// The one-dimensional array that is the destination of the elements copied from the current array. 122 | /// A 32-bit integer that represents the index in array at which copying begins. 123 | public void CopyTo(Array array, int index) 124 | { 125 | throw new NotImplementedException(); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Client/PowerQueryNet.Client.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Client/PowerQueryNet.Client.snk -------------------------------------------------------------------------------- /Client/PowerQueryResponse.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Data; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PowerQueryNet.Client 10 | { 11 | /// 12 | /// Response from the PowerQueryCommand.Execute method. 13 | /// 14 | public class PowerQueryResponse 15 | { 16 | 17 | /// 18 | /// Result returned as a System.Data.DataTable serialized in XML. 19 | /// 20 | private string DataTableXML { get; set; } = null; 21 | 22 | /// 23 | /// Result returned as a comma-separated values (CSV) 24 | /// 25 | public string Csv { get; set; } 26 | 27 | /// 28 | /// Result returned as a System.Data.DataTable. 29 | /// 30 | public DataTable DataTable { get; set; } = null; 31 | 32 | /// 33 | /// Path of the temporary file created from DataTableXML. 34 | /// 35 | public string DataTableFile { get; set; } 36 | 37 | /// 38 | /// Exception message when an error occured. 39 | /// 40 | public string ExceptionMessage { get; set; } 41 | 42 | /// 43 | /// Result returned as HTML 44 | /// 45 | public string Html { get; set; } 46 | 47 | /// 48 | /// Result returned as JSON 49 | /// 50 | public string Json { get; set; } 51 | 52 | /// 53 | /// Result returned as a readable XML. 54 | /// 55 | public string Xml { get; set; } = null; 56 | 57 | internal void LoadReturnValues(ExecuteOutputFlags executeOutputFlags) 58 | { 59 | if (DataTableFile != null) 60 | { 61 | DataTableXML = File.ReadAllText(DataTableFile); 62 | File.Delete(DataTableFile); 63 | DataTableFile = null; 64 | 65 | var dataTable = new DataTable(); 66 | StringReader sr = new StringReader(DataTableXML); 67 | dataTable.ReadXml(sr); 68 | 69 | if (executeOutputFlags.HasFlag(ExecuteOutputFlags.DataTable)) 70 | DataTable = dataTable; 71 | 72 | if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Csv)) 73 | Csv = dataTable.ToDelimitedFile(',', true); 74 | 75 | if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Html)) 76 | Html = dataTable.ToHTML(); 77 | 78 | if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Json)) 79 | Json = dataTable.ToContentJSON(); 80 | 81 | if (executeOutputFlags.HasFlag(ExecuteOutputFlags.Xml)) 82 | Xml = dataTable.ToContentXML(); 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Client/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle("PowerQueryNet.Client")] 7 | [assembly: AssemblyDescription("")] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("Guillaume Simard")] 10 | [assembly: AssemblyProduct("PowerQueryNet")] 11 | [assembly: AssemblyCopyright("Copyright © 2018")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | [assembly: ComVisible(true)] 16 | [assembly: Guid("4a24bc51-2e5c-43b5-bb49-902af66bb93c")] 17 | 18 | [assembly: AssemblyVersion("1.1.*")] 19 | [assembly: AssemblyInformationalVersion("1.0.0.0")] 20 | 21 | [assembly: AssemblyKeyName("")] 22 | [assembly: AssemblyKeyFile("PowerQueryNet.Client.snk")] 23 | [assembly: AssemblyDelaySign(false)] 24 | [assembly: CLSCompliant(true)] 25 | -------------------------------------------------------------------------------- /Client/Queries.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Runtime.Serialization; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Xml.Serialization; 10 | 11 | namespace PowerQueryNet.Client 12 | { 13 | /// 14 | /// Collection of instances of Query to execute Power Query (M) formulas. 15 | /// 16 | [XmlInclude(typeof(Query))] 17 | [KnownType(typeof(Query))] 18 | [XmlRootAttribute(Namespace = "", IsNullable = false, ElementName = "Queries")] 19 | public class Queries : IEnumerable, ICollection 20 | { 21 | private Dictionary queryDict; 22 | 23 | /// 24 | /// Initializes a new instance of the Queries class. 25 | /// 26 | public Queries() 27 | { 28 | queryDict = new Dictionary(); 29 | } 30 | 31 | /// 32 | /// Adds a Query to the collection. 33 | /// 34 | /// 35 | public void Add(object query) 36 | { 37 | if (query is Query) 38 | { 39 | queryDict.Add(((Query)query).Name, (Query)query); 40 | } 41 | } 42 | 43 | /// 44 | /// Adds a Query to the collection. 45 | /// 46 | /// 47 | /// 48 | public void Add(string name, string formula) 49 | { 50 | var query = new Query 51 | { 52 | Name = name, 53 | Formula = formula, 54 | }; 55 | queryDict.Add(name, query); 56 | } 57 | 58 | /// 59 | /// Adds Queries from a *.pq or *.m file. 60 | /// 61 | /// 62 | public void AddFromFile(string path) 63 | { 64 | if (path == null) return; 65 | Add(Query.LoadFromFile(path)); 66 | } 67 | 68 | /// 69 | /// Loads Queries from every *.pq or *.m file in a folder. 70 | /// 71 | /// 72 | /// 73 | /// 74 | public static Queries LoadFromFolder(string path, SearchOption searchOption = SearchOption.TopDirectoryOnly) 75 | { 76 | if (path == null) return null; 77 | var queries = new Queries(); 78 | var files = Directory.EnumerateFiles(path, "*.*", searchOption).Where(s => s.EndsWith(".pq") || s.EndsWith(".m")); 79 | foreach (string file in files) 80 | { 81 | queries.AddFromFile(file); 82 | } 83 | return queries; 84 | } 85 | 86 | /// 87 | /// Removes all Query from the collection. 88 | /// 89 | public void Clear() 90 | { 91 | queryDict = new Dictionary(); 92 | } 93 | 94 | /// 95 | /// Removes the first occurence of a Query from the collection. 96 | /// 97 | /// 98 | public void Remove(Query query) 99 | { 100 | queryDict.Remove(query.Name); 101 | } 102 | 103 | /// 104 | /// Gets a Query by name. 105 | /// 106 | /// 107 | /// 108 | public Query this[string key] 109 | { 110 | get 111 | { 112 | Query query = null; 113 | queryDict.TryGetValue(key, out query); 114 | return query; 115 | } 116 | set { queryDict[key] = value; } 117 | } 118 | 119 | /// 120 | /// Copies the elements of Queries to a new array. 121 | /// 122 | /// 123 | public Query[] ToArray() 124 | { 125 | return queryDict.Values.ToArray(); 126 | } 127 | 128 | /// 129 | /// Returns an enumerator that iterates through the Queries collection. 130 | /// 131 | /// 132 | public IEnumerator GetEnumerator() 133 | { 134 | return queryDict.Values.GetEnumerator(); 135 | } 136 | 137 | /// 138 | /// Gets the number of Query in the collection. 139 | /// 140 | public int Count 141 | { 142 | get 143 | { 144 | return queryDict.Count; 145 | } 146 | } 147 | 148 | /// 149 | /// Gets an object that can be used to synchronize access to the ICollection. 150 | /// 151 | public object SyncRoot 152 | { 153 | get 154 | { 155 | return this; 156 | } 157 | } 158 | 159 | /// 160 | /// Gets a value indicating whether access to the ICollection is synchronized (thread safe). 161 | /// 162 | public bool IsSynchronized 163 | { 164 | get 165 | { 166 | return false; 167 | } 168 | } 169 | 170 | /// 171 | /// Gets a Query by index. 172 | /// 173 | /// 174 | /// 175 | public Query this[int index] 176 | { 177 | get 178 | { 179 | Query q = queryDict.Values.ToArray()[index]; 180 | return q; 181 | } 182 | } 183 | 184 | /// 185 | /// NotImplemented yet. 186 | /// 187 | /// 188 | /// 189 | public void CopyTo(Array array, int index) 190 | { 191 | throw new NotImplementedException(); 192 | } 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /Client/Query.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Runtime.Serialization; 7 | using System.IO; 8 | 9 | namespace PowerQueryNet.Client 10 | { 11 | /// 12 | /// Represents a query to execute Power Query (M) formulas. 13 | /// 14 | [DataContract(Namespace = "")] 15 | public class Query 16 | { 17 | /// 18 | /// Initializes a new instance of the Query class. 19 | /// 20 | public Query() 21 | { 22 | Name = "Query1"; 23 | } 24 | 25 | /// 26 | /// Initializes a new instance of the Query class. 27 | /// 28 | /// 29 | /// 30 | public Query(string name, string formula) 31 | { 32 | Name = name; 33 | Formula = formula; 34 | } 35 | 36 | /// 37 | /// Name of the query. 38 | /// 39 | [DataMember] 40 | public string Name { get; set; } 41 | 42 | /// 43 | /// Power Query (M) expresion. 44 | /// 45 | [DataMember] 46 | public string Formula { get; set; } 47 | 48 | /// 49 | /// Loads Query from a *.pq or *.m file. 50 | /// 51 | /// Full path of the file 52 | /// 53 | public static Query LoadFromFile(string path) 54 | { 55 | var query = new Query() 56 | { 57 | Name = Path.GetFileNameWithoutExtension(path), 58 | Formula = File.ReadAllText(path), 59 | }; 60 | 61 | //if (query.Name.Contains(" ")) 62 | // query.Name = string.Format("#\"{0}\"", query.Name); 63 | 64 | return query; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Client/SqlTableAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace PowerQueryNet.Client 8 | { 9 | /// 10 | /// Enumerates the different actions available for output to SQL Table. 11 | /// 12 | public enum SqlTableAction 13 | { 14 | /// 15 | /// Undefined 16 | /// 17 | Undefined = 0, 18 | 19 | /// 20 | /// Create a new table and insert the rows 21 | /// 22 | Create = 1, 23 | 24 | /// 25 | /// Remove all existing rows from the table (Delete) and insert the new rows 26 | /// 27 | DeleteAndInsert = 2, 28 | 29 | /// 30 | /// Drop the existing table, create a new table and insert the rows 31 | /// 32 | DropAndCreate = 3, 33 | 34 | /// 35 | /// Insert the new rows to the existing table 36 | /// 37 | Insert = 4, 38 | 39 | /// 40 | /// Remove all existing rows from the table (Truncate) and insert the new rows 41 | /// 42 | TruncateAndInsert = 5 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Engine/Command.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Mashup; 2 | using Microsoft.Mashup.Engine.Interface; 3 | using Microsoft.Mashup.Tools; 4 | using PowerQueryNet.Client; 5 | using System; 6 | using System.Data; 7 | using System.IO; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | 11 | namespace PowerQueryNet.Engine 12 | { 13 | public class Command : IDisposable 14 | { 15 | public CredentialStore CredentialStore { get; set; } 16 | 17 | private QueryExecutor queryExecutor = new QueryExecutor(); 18 | 19 | public Command(CommandCredentials commandCredentials) 20 | { 21 | CredentialStore = commandCredentials.CredentialStore; 22 | } 23 | 24 | public DataTable Execute(string queryName, string mashup) 25 | { 26 | DataTable dataTable = null; 27 | MashupConnectionStringBuilder mcsb = GetMashupConnectionStringBuilder(mashup); 28 | 29 | mcsb.Location = queryName; 30 | 31 | queryExecutor.AllowNativeQuery = true; 32 | queryExecutor.FastCombine = true; 33 | 34 | Task task = null; 35 | 36 | //using (Task task = queryExecutor.CreateExecution(mcsb, CredentialStore, true)) 37 | //MashupConnection.SetProcessContainerDirectory(@"Z:\Desktop\PowerQuery\temp2", true); 38 | 39 | try 40 | { 41 | if (string.IsNullOrWhiteSpace(queryName)) 42 | throw new InvalidOperationException("QueryName must be specified."); 43 | 44 | task = queryExecutor.CreateExecution(mcsb, CredentialStore, true); 45 | 46 | if (task == null) 47 | throw new Exception("QueryExecutionResults is null."); 48 | 49 | task.RunSynchronously(); 50 | if (task.Result.Error != null) 51 | throw task.Result.Error; 52 | 53 | dataTable = task.Result.Table; 54 | dataTable.TableName = mcsb.Location; 55 | } 56 | finally 57 | { 58 | if (task != null) 59 | task.Dispose(); 60 | 61 | //queryExecutor.Cancel(); 62 | //MashupConnection.TryCleanup(); 63 | } 64 | 65 | return dataTable; 66 | } 67 | 68 | private static MashupConnectionStringBuilder GetMashupConnectionStringBuilder(string mashup) 69 | { 70 | IError error; 71 | MashupConnectionStringBuilder mcsb = Utilities.CreateMashupConnectionInfo(mashup, out error); 72 | if (mcsb == null) 73 | { 74 | if (error != null) 75 | throw new Exception(error.Message); 76 | else 77 | throw new Exception("CreateMashupConnectionInfo has failed."); 78 | } 79 | return mcsb; 80 | } 81 | 82 | public static string MashupFromFile(string fileName) 83 | { 84 | string fileExtension = Path.GetExtension(fileName); 85 | switch (fileExtension) 86 | { 87 | case ".xlsx": 88 | return Utilities.MashupFromXlsx(fileName); 89 | case ".pbix": 90 | case ".pbit": 91 | return Utilities.MashupFromPbix(fileName); 92 | default: 93 | return null; 94 | } 95 | } 96 | 97 | public static Queries MashupToQueries(string fileName) 98 | { 99 | throw new NotImplementedException(); 100 | } 101 | 102 | public void Dispose() 103 | { 104 | queryExecutor.Cancel(); 105 | queryExecutor = null; 106 | MashupConnection.TryCleanup(); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Engine/CommandCredentials.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Data.Mashup; 2 | using Microsoft.Mashup.Tools; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace PowerQueryNet.Engine 11 | { 12 | public class CommandCredentials 13 | { 14 | internal CredentialStore CredentialStore { get; set; } 15 | 16 | public CommandCredentials() 17 | { 18 | CredentialStore = new CredentialStore(); 19 | } 20 | 21 | public void SetCredentialFile(string fileName) 22 | { 23 | DataSource dataSource = new DataSource("File", fileName); 24 | DataSourceSetting dataSourceSetting = new DataSourceSetting("Windows"); 25 | 26 | CredentialStore.SetCredential(dataSource, dataSourceSetting, null); 27 | 28 | return; 29 | } 30 | 31 | public void SetCredentialFolder(string folderName) 32 | { 33 | DataSource dataSource = new DataSource("Folder", folderName); 34 | DataSourceSetting dataSourceSetting = new DataSourceSetting("Windows"); 35 | 36 | CredentialStore.SetCredential(dataSource, dataSourceSetting, null); 37 | 38 | return; 39 | } 40 | 41 | public void SetCredentialWeb(string url, string userName, string password) 42 | { 43 | DataSource dataSource = new DataSource("Web", url); 44 | DataSourceSetting dataSourceSetting; 45 | if (userName == null) 46 | dataSourceSetting = new DataSourceSetting("Anonymous"); 47 | else 48 | dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password); 49 | 50 | CredentialStore.SetCredential(dataSource, dataSourceSetting, null); 51 | 52 | 53 | return; 54 | } 55 | 56 | public void SetCredentialSQL(string sql, string userName, string password) 57 | { 58 | DataSource dataSource = new DataSource("SQL", sql); 59 | DataSourceSetting dataSourceSetting; 60 | if (userName == null) 61 | dataSourceSetting = new DataSourceSetting("Windows"); 62 | else 63 | dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password); 64 | 65 | CredentialStore.SetCredential(dataSource, dataSourceSetting, null); 66 | 67 | return; 68 | } 69 | 70 | public void SetCredentialOData(string url, string userName, string password) 71 | { 72 | DataSource dataSource = new DataSource("OData", url); 73 | DataSourceSetting dataSourceSetting; 74 | if (userName == null) 75 | dataSourceSetting = new DataSourceSetting("Anonymous"); 76 | else 77 | dataSourceSetting = DataSourceSetting.CreateUsernamePasswordCredential(userName, password); 78 | 79 | CredentialStore.SetCredential(dataSource, dataSourceSetting, null); 80 | 81 | 82 | return; 83 | } 84 | 85 | public bool LoadCredentials(string fileName) 86 | { 87 | try 88 | { 89 | using (FileStream fileStream = File.OpenRead(fileName)) 90 | CredentialStore.Load((Stream)fileStream); 91 | return true; 92 | } 93 | catch (Exception ex) 94 | { 95 | if (!Microsoft.Mashup.Common.SafeExceptions.IsSafeException(ex)) 96 | { 97 | throw; 98 | } 99 | else 100 | { 101 | return false; 102 | } 103 | } 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Engine/Engine.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {35C425A2-E884-4306-8285-3FD66A86B601} 8 | Library 9 | Properties 10 | PowerQueryNet.Engine 11 | PowerQueryNet.Engine 12 | v4.5.1 13 | 512 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | lib\Microsoft.MashupEngine.dll 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | lib\Microsoft.Mashup.Tools.dll 66 | 67 | 68 | lib\Microsoft.Data.Mashup.dll 69 | 70 | 71 | lib\Microsoft.Mashup.OAuth.dll 72 | 73 | 74 | 75 | 76 | lib\Microsoft.ApplicationInsights.dll 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | {4a24bc51-2e5c-43b5-bb49-902af66bb93c} 102 | Client 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /Engine/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle("PowerQueryNet.Engine")] 7 | [assembly: AssemblyDescription("")] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("Guillaume Simard")] 10 | [assembly: AssemblyProduct("PowerQueryNet")] 11 | [assembly: AssemblyCopyright("Copyright © 2018")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | [assembly: ComVisible(false)] 16 | [assembly: Guid("35c425a2-e884-4306-8285-3fd66a86b601")] 17 | 18 | [assembly: AssemblyVersion("1.1.*")] 19 | [assembly: AssemblyInformationalVersion("1.0.0.0")] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Guillaume Simard 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PQNet/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /PQNet/PQNet.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {91D3B517-685E-4806-A17F-5589CFF21E29} 8 | Exe 9 | PowerQueryNet.PQNet 10 | PQNet 11 | v4.5.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | WindowGrid.xaml 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | {5dcda550-a251-4c69-ae33-88d3bc1326fb} 63 | Client 64 | 65 | 66 | {24503a13-7d35-49d9-b071-a0173cd54276} 67 | Service 68 | 69 | 70 | 71 | 72 | MSBuild:Compile 73 | Designer 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /PQNet/Program.cs: -------------------------------------------------------------------------------- 1 | using PowerQueryNet.Client; 2 | using PowerQueryNet.Service; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows; 10 | 11 | namespace PowerQueryNet.PQNet 12 | { 13 | class Program 14 | { 15 | const string usage = @" 16 | PowerQueryNet Command Line Interface 17 | 18 | Usage: pqnet source [query name] [options] 19 | 20 | source (one of the following): 21 | ■ Power Query file (*.pq) to execute 22 | ■ Directory of the Power Query file(s) (*.pq) to load 23 | ■ Power BI file (*.pbix;*.pbit) 24 | ■ Excel file (*.xlsx;*.xlsm) 25 | 26 | query name: 27 | Name of the query to execute 28 | 29 | options: 30 | -c|--credentials ""file path"" Path to the credentials file. 31 | -o|--output {csv|json|html|xml} Output format of the resulting data. 32 | -f|--file ""file path"" Output result to the specified file path. 33 | -w|--window Output the result to a window. 34 | -s|--sql ""connection string"" Output result to the specified server. 35 | -t|--table ""table name"" Table name of the SQL or XML output. 36 | -a|--action {c|dc|di|i|ti} SQL action: 37 | c - create 38 | dc - drop/create 39 | di - delete/insert 40 | i - insert 41 | ti - truncate/insert 42 | "; 43 | 44 | private static PowerQueryService powerQueryService = new PowerQueryService(); 45 | 46 | [STAThread] 47 | static void Main(string[] args) 48 | { 49 | int exitCode = 0; 50 | try 51 | { 52 | if (args == null || args.Length == 0) 53 | Console.Write(usage); 54 | else 55 | { 56 | var a = new Arguments(args); 57 | 58 | if (!string.IsNullOrWhiteSpace(a.OutputFile)) 59 | File.WriteAllText(a.OutputFile, ""); 60 | 61 | PowerQueryCommand powerQueryCommand = LoadCommand(a); 62 | 63 | PowerQueryResponse powerQueryResponse = powerQueryService.Execute(powerQueryCommand); 64 | 65 | OutputResponse(a, powerQueryResponse); 66 | } 67 | exitCode = 0; 68 | } 69 | catch (Exception ex) 70 | { 71 | Console.WriteLine(ex.Message); 72 | exitCode = 1; 73 | } 74 | Environment.Exit(exitCode); 75 | } 76 | 77 | private static void OutputResponse(Arguments a, PowerQueryResponse powerQueryResponse) 78 | { 79 | if (powerQueryResponse.ExceptionMessage != null) 80 | throw new Exception($"{powerQueryResponse.ExceptionMessage}"); 81 | 82 | if (string.IsNullOrWhiteSpace(a.OutputFile)) 83 | { 84 | switch (a.OutputFlags) 85 | { 86 | case ExecuteOutputFlags.Csv: 87 | Console.WriteLine(powerQueryResponse.Csv); 88 | break; 89 | case ExecuteOutputFlags.Html: 90 | Console.WriteLine(powerQueryResponse.Html); 91 | break; 92 | case ExecuteOutputFlags.Json: 93 | Console.WriteLine(powerQueryResponse.Json); 94 | break; 95 | case ExecuteOutputFlags.Xml: 96 | Console.WriteLine(powerQueryResponse.Xml); 97 | break; 98 | default: 99 | break; 100 | } 101 | } 102 | 103 | if (powerQueryResponse.DataTable != null && a.OutputToWindow) 104 | new WindowGrid(powerQueryResponse.DataTable).ShowDialog(); 105 | } 106 | 107 | private static PowerQueryCommand LoadCommand(Arguments a) 108 | { 109 | var c = new PowerQueryCommand() 110 | { 111 | QueryName = a.QueryName, 112 | }; 113 | 114 | if (!string.IsNullOrWhiteSpace(a.CredentialsFile)) 115 | c.Credentials = Credentials.LoadFromFile(a.CredentialsFile); 116 | 117 | if (!string.IsNullOrWhiteSpace(a.OutputFile)) 118 | { 119 | switch (a.OutputFlags) 120 | { 121 | case ExecuteOutputFlags.Csv: 122 | c.CsvFileName = a.OutputFile; 123 | break; 124 | case ExecuteOutputFlags.Html: 125 | c.HtmlFileName = a.OutputFile; 126 | break; 127 | case ExecuteOutputFlags.Json: 128 | c.JsonFileName = a.OutputFile; 129 | break; 130 | case ExecuteOutputFlags.Xml: 131 | c.XmlFileName = a.OutputFile; 132 | break; 133 | default: 134 | break; 135 | } 136 | } 137 | 138 | if (!string.IsNullOrWhiteSpace(a.SqlConnectionString)) 139 | { 140 | c.SqlConnectionString = a.SqlConnectionString; 141 | c.SqlTableName = a.TableName; 142 | c.SqlTableAction = a.SqlTableAction; 143 | c.SqlDecimalPrecision = 18; 144 | c.SqlDecimalScale = 2; 145 | } 146 | 147 | if (string.IsNullOrWhiteSpace(a.SourceFileExtension)) 148 | c.Queries = Queries.LoadFromFolder(a.Source); 149 | 150 | if (a.SourceFileExtension == ".pq") 151 | c.Queries.AddFromFile(a.Source); 152 | 153 | if (a.SourceFileExtension == ".xlsx" 154 | || a.SourceFileExtension == ".xlsm" 155 | || a.SourceFileExtension == ".pbix" 156 | || a.SourceFileExtension == ".pbit" 157 | ) 158 | { 159 | c.Mashup = powerQueryService.MashupFromFile(a.Source); 160 | //req.Queries = powerQueryService.MashupToQueries(source); 161 | } 162 | 163 | c.ExecuteOutputFlags = a.OutputFlags.Value; 164 | 165 | if (a.OutputToWindow) 166 | c.ExecuteOutputFlags |= ExecuteOutputFlags.DataTable; 167 | 168 | return c; 169 | } 170 | } 171 | } 172 | -------------------------------------------------------------------------------- /PQNet/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerQueryNet.PQNet")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Guillaume Simard")] 12 | [assembly: AssemblyProduct("PowerQueryNet")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("91d3b517-685e-4806-a17f-5589cff21e29")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.*")] -------------------------------------------------------------------------------- /PQNet/WindowGrid.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /PQNet/WindowGrid.xaml.cs: -------------------------------------------------------------------------------- 1 | using PowerQueryNet.Client; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Data; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | using System.Windows.Data; 11 | using System.Windows.Documents; 12 | using System.Windows.Input; 13 | using System.Windows.Media; 14 | using System.Windows.Media.Imaging; 15 | using System.Windows.Shapes; 16 | 17 | namespace PowerQueryNet.PQNet 18 | { 19 | /// 20 | /// Interaction logic for WindowGrid.xaml 21 | /// 22 | public partial class WindowGrid : Window 23 | { 24 | public WindowGrid(DataTable dataTable) 25 | { 26 | InitializeComponent(); 27 | 28 | Title += " - " + dataTable.TableName; 29 | 30 | MyDataGrid.DataContext = dataTable.DefaultView; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /PowerQueryNet.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Service", "Service\Service.csproj", "{24503A13-7D35-49D9-B071-A0173CD54276}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{5DCDA550-A251-4C69-AE33-88D3BC1326FB}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Engine", "Engine\Engine.csproj", "{35C425A2-E884-4306-8285-3FD66A86B601}" 11 | EndProject 12 | Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "Setup\Setup.wixproj", "{17CC49B9-0954-42EF-95B9-895A9DC29BDE}" 13 | ProjectSection(ProjectDependencies) = postProject 14 | {24503A13-7D35-49D9-B071-A0173CD54276} = {24503A13-7D35-49D9-B071-A0173CD54276} 15 | {C4521615-F8A1-4021-90C4-A2B85EB09703} = {C4521615-F8A1-4021-90C4-A2B85EB09703} 16 | {91D3B517-685E-4806-A17F-5589CFF21E29} = {91D3B517-685E-4806-A17F-5589CFF21E29} 17 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB} = {5DCDA550-A251-4C69-AE33-88D3BC1326FB} 18 | {35C425A2-E884-4306-8285-3FD66A86B601} = {35C425A2-E884-4306-8285-3FD66A86B601} 19 | EndProjectSection 20 | EndProject 21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Setup.Actions", "Setup.Actions\Setup.Actions.csproj", "{C4521615-F8A1-4021-90C4-A2B85EB09703}" 22 | EndProject 23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PQNet", "PQNet\PQNet.csproj", "{91D3B517-685E-4806-A17F-5589CFF21E29}" 24 | EndProject 25 | Global 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Debug|x86 = Debug|x86 29 | Release|Any CPU = Release|Any CPU 30 | Release|x86 = Release|x86 31 | EndGlobalSection 32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 33 | {24503A13-7D35-49D9-B071-A0173CD54276}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {24503A13-7D35-49D9-B071-A0173CD54276}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {24503A13-7D35-49D9-B071-A0173CD54276}.Debug|x86.ActiveCfg = Debug|Any CPU 36 | {24503A13-7D35-49D9-B071-A0173CD54276}.Debug|x86.Build.0 = Debug|Any CPU 37 | {24503A13-7D35-49D9-B071-A0173CD54276}.Release|Any CPU.ActiveCfg = Release|Any CPU 38 | {24503A13-7D35-49D9-B071-A0173CD54276}.Release|Any CPU.Build.0 = Release|Any CPU 39 | {24503A13-7D35-49D9-B071-A0173CD54276}.Release|x86.ActiveCfg = Release|Any CPU 40 | {24503A13-7D35-49D9-B071-A0173CD54276}.Release|x86.Build.0 = Release|Any CPU 41 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 42 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Debug|Any CPU.Build.0 = Debug|Any CPU 43 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Debug|x86.ActiveCfg = Debug|Any CPU 44 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Debug|x86.Build.0 = Debug|Any CPU 45 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Release|Any CPU.ActiveCfg = Release|Any CPU 46 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Release|Any CPU.Build.0 = Release|Any CPU 47 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Release|x86.ActiveCfg = Release|Any CPU 48 | {5DCDA550-A251-4C69-AE33-88D3BC1326FB}.Release|x86.Build.0 = Release|Any CPU 49 | {35C425A2-E884-4306-8285-3FD66A86B601}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 50 | {35C425A2-E884-4306-8285-3FD66A86B601}.Debug|Any CPU.Build.0 = Debug|Any CPU 51 | {35C425A2-E884-4306-8285-3FD66A86B601}.Debug|x86.ActiveCfg = Debug|Any CPU 52 | {35C425A2-E884-4306-8285-3FD66A86B601}.Debug|x86.Build.0 = Debug|Any CPU 53 | {35C425A2-E884-4306-8285-3FD66A86B601}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 | {35C425A2-E884-4306-8285-3FD66A86B601}.Release|Any CPU.Build.0 = Release|Any CPU 55 | {35C425A2-E884-4306-8285-3FD66A86B601}.Release|x86.ActiveCfg = Release|Any CPU 56 | {35C425A2-E884-4306-8285-3FD66A86B601}.Release|x86.Build.0 = Release|Any CPU 57 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Debug|Any CPU.ActiveCfg = Debug|x86 58 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Debug|x86.ActiveCfg = Debug|x86 59 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Debug|x86.Build.0 = Debug|x86 60 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Release|Any CPU.ActiveCfg = Release|x86 61 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Release|Any CPU.Build.0 = Release|x86 62 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Release|x86.ActiveCfg = Release|x86 63 | {17CC49B9-0954-42EF-95B9-895A9DC29BDE}.Release|x86.Build.0 = Release|x86 64 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Debug|Any CPU.ActiveCfg = Debug|x86 65 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Debug|Any CPU.Build.0 = Debug|x86 66 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Debug|x86.ActiveCfg = Debug|x86 67 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Debug|x86.Build.0 = Debug|x86 68 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Release|Any CPU.ActiveCfg = Release|x86 69 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Release|Any CPU.Build.0 = Release|x86 70 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Release|x86.ActiveCfg = Release|x86 71 | {C4521615-F8A1-4021-90C4-A2B85EB09703}.Release|x86.Build.0 = Release|x86 72 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Debug|x86.ActiveCfg = Debug|Any CPU 75 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Debug|x86.Build.0 = Debug|Any CPU 76 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Release|Any CPU.ActiveCfg = Release|Any CPU 77 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Release|Any CPU.Build.0 = Release|Any CPU 78 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Release|x86.ActiveCfg = Release|Any CPU 79 | {91D3B517-685E-4806-A17F-5589CFF21E29}.Release|x86.Build.0 = Release|Any CPU 80 | EndGlobalSection 81 | GlobalSection(SolutionProperties) = preSolution 82 | HideSolutionNode = FALSE 83 | EndGlobalSection 84 | GlobalSection(ExtensibilityGlobals) = postSolution 85 | SolutionGuid = {674816A7-81B1-4F8B-974D-64B0E96AB025} 86 | EndGlobalSection 87 | EndGlobal 88 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PowerQueryNet 2 | Run Power Query M formula language from anywhere. 3 | 4 | ## About 5 | PowerQueryNet allows you to run M formulas commonly used in Power BI and Excel (aka Get & Transform) from the Command Prompt or any .NET application. 6 | 7 | ## Download 8 | 9 | Installer: [PowerQueryNet.msi](https://github.com/gsimardnet/PowerQueryNet/releases/latest/download/PowerQueryNet.msi) 10 | 11 | Dependency: [PowerQuerySdk.vsix 1.0.0.16](http://dakahn.gallery.vsassets.io/_apis/public/gallery/publisher/dakahn/extension/powerquerysdk/1.0.0.16/assetbyname/PowerQuerySdk.vsix) 12 | 13 | (Upon installation `PowerQuerySdk.vsix` must be in the same folder as `PowerQueryNet.msi`) 14 | 15 | Samples: [PowerQueryNet.Samples.zip](https://github.com/gsimardnet/PowerQueryNet/releases/download/v1.1.2/PowerQueryNet.Samples.zip) 16 | 17 | ## PQNet 18 | 19 | PQNet is a Command Line Interface (CLI) that comes with the installation of PowerQueryNet. 20 | 21 | ### Features 22 | 23 | Export the result of a query to several formats (CSV, JSON, HTML, XML) 24 | ```txt 25 | pqnet "#Hello World.pq" -o json 26 | ``` 27 | 28 | Export the result of a query to a SQL Server database 29 | ```txt 30 | pqnet "#Hello World.pq" -s "Data Source=.\SQL2016;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI" -t "dbo.HelloWorld" 31 | ``` 32 | 33 | Output the result of a Power BI query to file 34 | ```txt 35 | pqnet MyReport.pbix Query1 -o csv -f result.csv 36 | ``` 37 | 38 | ## Hello, World! - PQNet (CLI) 39 | 40 | 1. Create a new file with the following content: 41 | ```txt 42 | let Source = "Hello, World!" in Source 43 | ``` 44 | 2. Save the file as helloworld.pq 45 | 3. Run the following in the Command Prompt: 46 | ```txt 47 | pqnet helloworld.pq 48 | ``` 49 | 50 | ## Hello, World! - .NET (C#) 51 | 52 | 1. From your .NET project, add a reference to `PowerQueryNet.Client` 53 | 2. Run the following: 54 | ```txt 55 | var qry = new Query { Formula = "let hw = \"Hello World\" in hw" }; 56 | var pqc = new PowerQueryCommand() { ExecuteOutputFlags = ExecuteOutputFlags.Csv }; 57 | var result = pqc.Execute(qry); 58 | ``` 59 | ## Power Query App 60 | Run queries in a standalone application 61 | ![PowerQueryApp](Samples/PowerQueryApp/PowerQueryApp.png "Power Query App") 62 | 63 | ## Build requirements 64 | 65 | * Visual Studio 2015+ 66 | 67 | To build the Setup project, [WiX Toolset](http://wixtoolset.org/releases/) must be installed. 68 | 69 | ## Copyright 70 | 71 | Copyright 2019 72 | 73 | Licensed under the [MIT License](LICENSE) 74 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | MyQueries 15 | 16 | 17 | #credentials.xml 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/FormMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using PowerQueryNet.Client; 11 | using System.IO; 12 | using PowerQuery.Samples.Properties; 13 | using Microsoft.WindowsAPICodePack.Dialogs; 14 | 15 | namespace PowerQuery.Samples 16 | { 17 | public partial class FormMain : Form 18 | { 19 | private string queriesPath; 20 | private string credentialsPath; 21 | 22 | PowerQueryCommand powerQueryCommand; 23 | 24 | public FormMain() 25 | { 26 | InitializeComponent(); 27 | 28 | queriesPath = Path.Combine(Environment.CurrentDirectory, Settings.Default.DefaultQueriesPath); 29 | credentialsPath = Path.Combine(queriesPath, Settings.Default.DefaultCredentialsFile); 30 | 31 | LoadQueries(); 32 | } 33 | 34 | private void LoadQueries() 35 | { 36 | LabelStatus.Text = queriesPath; 37 | LabelCredential.Text = credentialsPath; 38 | TextBoxPQ.Text = ""; 39 | GridResult.DataSource = null; 40 | LoadPowerQueryCommand(); 41 | DisplayQueries(); 42 | } 43 | 44 | private void ButtonOpenFolder_Click(object sender, EventArgs e) 45 | { 46 | using (var dialog = new CommonOpenFileDialog()) 47 | { 48 | dialog.EnsurePathExists = true; 49 | dialog.EnsureFileExists = false; 50 | dialog.AllowNonFileSystemItems = false; 51 | dialog.DefaultFileName = "Select Folder"; 52 | 53 | dialog.Filters.Add(new CommonFileDialogFilter("Power Query Files", ".pq;.m")); 54 | dialog.Filters.Add(new CommonFileDialogFilter("Credentials Files", ".xml")); 55 | 56 | dialog.InitialDirectory = queriesPath; 57 | 58 | var commonFileDialogResult = dialog.ShowDialog(); 59 | 60 | if (commonFileDialogResult == CommonFileDialogResult.Ok && !string.IsNullOrWhiteSpace(dialog.FileName)) 61 | { 62 | queriesPath = Directory.Exists(dialog.FileName) ? dialog.FileName : Path.GetDirectoryName(dialog.FileName); 63 | credentialsPath = Path.Combine(queriesPath, Settings.Default.DefaultCredentialsFile); 64 | LoadQueries(); 65 | } 66 | } 67 | } 68 | 69 | private void LoadPowerQueryCommand() 70 | { 71 | if (!File.Exists(credentialsPath)) 72 | credentialsPath = null; 73 | powerQueryCommand = new PowerQueryCommand 74 | { 75 | Credentials = Credentials.LoadFromFile(credentialsPath), 76 | Queries = Queries.LoadFromFolder(queriesPath), 77 | }; 78 | } 79 | 80 | private void DisplayQueries() 81 | { 82 | var listPQ = new List(); 83 | 84 | foreach (Query q in powerQueryCommand.Queries) 85 | { 86 | listPQ.Add(q.Name); 87 | } 88 | ListBoxPQ.DataSource = listPQ; 89 | } 90 | 91 | private void ButtonExecute_Click(object sender, EventArgs e) 92 | { 93 | if (ListBoxPQ.SelectedItem == null) return; 94 | var queryName = ListBoxPQ.SelectedItem.ToString(); 95 | var result = powerQueryCommand.Execute(queryName); 96 | 97 | DisplayResult(result); 98 | } 99 | 100 | private void DisplayResult(PowerQueryResponse result) 101 | { 102 | if (result == null) 103 | { 104 | MessageBox.Show("Result is null.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); 105 | } 106 | else if (result.ExceptionMessage != null) 107 | { 108 | MessageBox.Show(result.ExceptionMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error); 109 | } 110 | else 111 | { 112 | GridResult.DataSource = result.DataTable; 113 | } 114 | } 115 | 116 | private void ListBoxPQ_SelectedIndexChanged(object sender, EventArgs e) 117 | { 118 | DisplayFormula(); 119 | } 120 | 121 | private void DisplayFormula() 122 | { 123 | if (ListBoxPQ.SelectedItem == null) return; 124 | var queryName = ListBoxPQ.SelectedItem.ToString(); 125 | TextBoxPQ.Text = powerQueryCommand.Queries[queryName].Formula; 126 | } 127 | 128 | private void FormMain_Activated(object sender, EventArgs e) 129 | { 130 | LoadPowerQueryCommand(); 131 | DisplayQueries(); 132 | DisplayFormula(); 133 | } 134 | 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyFiles/MyReport.pbix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryApp/MyFiles/MyReport.pbix -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyFiles/MyReport.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryApp/MyFiles/MyReport.xlsx -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyFiles/taPMTransactionInsert.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 1 7 | 00000000000000460 8 | ACETRAVE0001 9 | 1 10 | 6 11 | 400-6520-00 12 | 85.56 13 | 14 | 15 | 1 16 | 00000000000000460 17 | ACETRAVE0001 18 | 2 19 | 2 20 | Payable Amount 21 | 000-2100-00 22 | 85.56 23 | 24 | 25 | 26 | TEST 27 | 00000000000000460 28 | ACETRAVE0001 29 | 72230 30 | 1 31 | 85.56 32 | 2017-02-06 33 | 85.56 34 | 85.56 35 | 10195 36 | 0 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/#Hello World.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = Text.Proper("Hello, World!") 3 | in 4 | Source -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/#credentials.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | .\sql2016;AdventureWorks2012 4 | TestUser 5 | T3st!Passw0rd 6 | 7 | 8 | C:\Temp\PowerQueryNet\Samples\PowerQueryApp\MyQueries 9 | 10 | 11 | C:\Temp\PowerQueryNet\Samples\PowerQueryApp\MyFiles\taPMTransactionInsert.xml 12 | 13 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/AdventureWorksSales.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = Sql.Database(".\SQL2016" 3 | , "AdventureWorks2012" 4 | , [Query="SELECT TOP 10 * FROM Sales.SalesOrderHeader"]) 5 | in 6 | Source -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/DateTable2018.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = fnDateTable(#date(2018, 1, 1), #date(2019, 01, 01), null) 3 | in 4 | Source -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/ListFiles.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = "C:\Temp\PowerQueryNet\Samples\PowerQueryApp\MyQueries", 3 | Files = Folder.Contents(Source) 4 | in 5 | Files -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/TestXml.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = Xml.Tables(File.Contents("C:\Temp\PowerQueryNet\Samples\PowerQueryApp\MyFiles\taPMTransactionInsert.xml")), 3 | Table0 = Source{0}[Table], 4 | Table = Table0{1}[Table], 5 | #"Changed Type" = Table.TransformColumnTypes(Table,{{"BACHNUMB", type text}, {"VCHNUMWK", type text}, {"VENDORID", type text}, {"DOCNUMBR", Int64.Type}, {"DOCTYPE", Int64.Type}, {"DOCAMNT", type text}, {"DOCDATE", type date}, {"PRCHAMNT", type text}, {"CHRGAMNT", type text}, {"PORDNMBR", Int64.Type}, {"CREATEDIST", Int64.Type}}) 6 | in 7 | #"Changed Type" -------------------------------------------------------------------------------- /Samples/PowerQueryApp/MyQueries/fnDateTable.pq: -------------------------------------------------------------------------------- 1 | //Copyright: philbritton (https://gist.github.com/philbritton/9677152) 2 | let CreateDateTable = (StartDate as date, EndDate as date, optional Culture as nullable text) as table => 3 | let 4 | DayCount = Duration.Days(Duration.From(EndDate - StartDate)), 5 | Source = List.Dates(StartDate,DayCount,#duration(1,0,0,0)), 6 | TableFromList = Table.FromList(Source, Splitter.SplitByNothing()), 7 | ChangedType = Table.TransformColumnTypes(TableFromList,{{"Column1", type date}}), 8 | RenamedColumns = Table.RenameColumns(ChangedType,{{"Column1", "Date"}}), 9 | InsertYear = Table.AddColumn(RenamedColumns, "Year", each Date.Year([Date])), 10 | InsertQuarter = Table.AddColumn(InsertYear, "QuarterOfYear", each Date.QuarterOfYear([Date])), 11 | InsertMonth = Table.AddColumn(InsertQuarter, "MonthOfYear", each Date.Month([Date])), 12 | InsertDay = Table.AddColumn(InsertMonth, "DayOfMonth", each Date.Day([Date])), 13 | InsertDayInt = Table.AddColumn(InsertDay, "DateInt", each [Year] * 10000 + [MonthOfYear] * 100 + [DayOfMonth]), 14 | InsertMonthName = Table.AddColumn(InsertDayInt, "MonthName", each Date.ToText([Date], "MMMM", Culture), type text), 15 | InsertCalendarMonth = Table.AddColumn(InsertMonthName, "MonthInCalendar", each (try(Text.Range([MonthName],0,3)) otherwise [MonthName]) & " " & Number.ToText([Year])), 16 | InsertCalendarQtr = Table.AddColumn(InsertCalendarMonth, "QuarterInCalendar", each "Q" & Number.ToText([QuarterOfYear]) & " " & Number.ToText([Year])), 17 | InsertDayWeek = Table.AddColumn(InsertCalendarQtr, "DayInWeek", each Date.DayOfWeek([Date])), 18 | InsertDayName = Table.AddColumn(InsertDayWeek, "DayOfWeekName", each Date.ToText([Date], "dddd", Culture), type text), 19 | InsertWeekEnding = Table.AddColumn(InsertDayName, "WeekEnding", each Date.EndOfWeek([Date]), type date) 20 | in 21 | InsertWeekEnding 22 | in 23 | CreateDateTable -------------------------------------------------------------------------------- /Samples/PowerQueryApp/PowerQueryApp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CEEE2AF9-1C1A-48CB-A907-E5D6B15A0512} 8 | WinExe 9 | PowerQuery.Samples 10 | PowerQueryApp 11 | v4.5.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | False 37 | lib\Microsoft.WindowsAPICodePack.dll 38 | 39 | 40 | False 41 | lib\Microsoft.WindowsAPICodePack.Shell.dll 42 | 43 | 44 | False 45 | False 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | Form 62 | 63 | 64 | FormMain.cs 65 | 66 | 67 | 68 | 69 | FormMain.cs 70 | 71 | 72 | ResXFileCodeGenerator 73 | Resources.Designer.cs 74 | Designer 75 | 76 | 77 | True 78 | Resources.resx 79 | True 80 | 81 | 82 | 83 | Always 84 | 85 | 86 | Always 87 | 88 | 89 | Always 90 | 91 | 92 | Always 93 | 94 | 95 | Always 96 | 97 | 98 | Always 99 | 100 | 101 | SettingsSingleFileGenerator 102 | Settings.Designer.cs 103 | 104 | 105 | True 106 | Settings.settings 107 | True 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | Designer 119 | 120 | 121 | Always 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/PowerQueryApp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryApp/PowerQueryApp.png -------------------------------------------------------------------------------- /Samples/PowerQueryApp/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace PowerQuery.Samples 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | try 18 | { 19 | Application.EnableVisualStyles(); 20 | Application.SetCompatibleTextRenderingDefault(false); 21 | Application.Run(new FormMain()); 22 | } 23 | catch (Exception ex) 24 | { 25 | MessageBox.Show(ex.ToString()); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerQueryApp")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PowerQueryApp")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("ceee2af9-1c1a-48cb-a907-e5d6b15a0512")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQuery.Samples.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PowerQuery.Samples.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQuery.Samples.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("MyQueries")] 29 | public string DefaultQueriesPath { 30 | get { 31 | return ((string)(this["DefaultQueriesPath"])); 32 | } 33 | } 34 | 35 | [global::System.Configuration.ApplicationScopedSettingAttribute()] 36 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 37 | [global::System.Configuration.DefaultSettingValueAttribute("#credentials.xml")] 38 | public string DefaultCredentialsFile { 39 | get { 40 | return ((string)(this["DefaultCredentialsFile"])); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | MyQueries 7 | 8 | 9 | #credentials.xml 10 | 11 | 12 | -------------------------------------------------------------------------------- /Samples/PowerQueryApp/lib/Microsoft.WindowsAPICodePack.Shell.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryApp/lib/Microsoft.WindowsAPICodePack.Shell.dll -------------------------------------------------------------------------------- /Samples/PowerQueryApp/lib/Microsoft.WindowsAPICodePack.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryApp/lib/Microsoft.WindowsAPICodePack.dll -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/FormMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace PowerQuery.Samples 2 | { 3 | partial class FormMain 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.dgvResult = new System.Windows.Forms.DataGridView(); 32 | this.BtnHelloWorldString = new System.Windows.Forms.Button(); 33 | ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).BeginInit(); 34 | this.SuspendLayout(); 35 | // 36 | // dgvResult 37 | // 38 | this.dgvResult.AllowUserToAddRows = false; 39 | this.dgvResult.AllowUserToDeleteRows = false; 40 | this.dgvResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 41 | | System.Windows.Forms.AnchorStyles.Left) 42 | | System.Windows.Forms.AnchorStyles.Right))); 43 | this.dgvResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 44 | this.dgvResult.Location = new System.Drawing.Point(12, 41); 45 | this.dgvResult.Name = "dgvResult"; 46 | this.dgvResult.ReadOnly = true; 47 | this.dgvResult.Size = new System.Drawing.Size(493, 445); 48 | this.dgvResult.TabIndex = 100; 49 | // 50 | // BtnHelloWorldString 51 | // 52 | this.BtnHelloWorldString.Location = new System.Drawing.Point(12, 12); 53 | this.BtnHelloWorldString.Name = "BtnHelloWorldString"; 54 | this.BtnHelloWorldString.Size = new System.Drawing.Size(94, 23); 55 | this.BtnHelloWorldString.TabIndex = 0; 56 | this.BtnHelloWorldString.Text = "Hello World"; 57 | this.BtnHelloWorldString.UseVisualStyleBackColor = true; 58 | this.BtnHelloWorldString.Click += new System.EventHandler(this.BtnHelloWorldString_Click); 59 | // 60 | // FormMain 61 | // 62 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 63 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 64 | this.ClientSize = new System.Drawing.Size(517, 498); 65 | this.Controls.Add(this.BtnHelloWorldString); 66 | this.Controls.Add(this.dgvResult); 67 | this.MinimumSize = new System.Drawing.Size(533, 533); 68 | this.Name = "FormMain"; 69 | this.Text = "PowerQuery.Samples"; 70 | ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit(); 71 | this.ResumeLayout(false); 72 | 73 | } 74 | 75 | #endregion 76 | 77 | private System.Windows.Forms.DataGridView dgvResult; 78 | private System.Windows.Forms.Button BtnHelloWorldString; 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/FormMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using PowerQueryNet.Client; 11 | using System.IO; 12 | 13 | namespace PowerQuery.Samples 14 | { 15 | public partial class FormMain : Form 16 | { 17 | public FormMain() 18 | { 19 | InitializeComponent(); 20 | } 21 | 22 | private void BtnHelloWorldString_Click(object sender, EventArgs e) 23 | { 24 | var q = new Query { Formula = "let hw = \"Hello World\" in hw" }; 25 | var pq = new PowerQueryCommand(); 26 | var result = pq.Execute(q); 27 | DisplayResult(result); 28 | } 29 | 30 | private void DisplayResult(ExecuteResponse result) 31 | { 32 | if (result == null) 33 | { 34 | MessageBox.Show("Result is null.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); 35 | } 36 | else if (result.ExceptionMessage != null) 37 | { 38 | MessageBox.Show(result.ExceptionMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error); 39 | } 40 | else 41 | { 42 | dgvResult.DataSource = result.DataTable; 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/FormMain.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/PowerQueryHelloWorld.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {CC4C9419-35E4-4EFA-9393-A2FF01EDAEC6} 8 | WinExe 9 | PowerQuery.Samples 10 | PowerQueryHelloWorld 11 | v4.5.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | False 37 | False 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Form 54 | 55 | 56 | FormMain.cs 57 | 58 | 59 | 60 | 61 | FormMain.cs 62 | 63 | 64 | ResXFileCodeGenerator 65 | Resources.Designer.cs 66 | Designer 67 | 68 | 69 | True 70 | Resources.resx 71 | True 72 | 73 | 74 | SettingsSingleFileGenerator 75 | Settings.Designer.cs 76 | 77 | 78 | True 79 | Settings.settings 80 | True 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace PowerQuery.Samples 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new FormMain()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerQueryHelloWorld")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PowerQueryHelloWorld")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("cc4c9419-35e4-4efa-9393-a2ff01edaec6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQuery.Samples.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PowerQuery.Samples.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQuery.Samples.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Samples/PowerQueryHelloWorld/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Samples/PowerQueryNet.Samples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26730.16 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerQueryApp", "PowerQueryApp\PowerQueryApp.csproj", "{CEEE2AF9-1C1A-48CB-A907-E5D6B15A0512}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerQueryHelloWorld", "PowerQueryHelloWorld\PowerQueryHelloWorld.csproj", "{CC4C9419-35E4-4EFA-9393-A2FF01EDAEC6}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerQueryParameters", "PowerQueryParameters\PowerQueryParameters.csproj", "{97BDC87C-05E4-44D7-8A11-64422BAC0E11}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {CEEE2AF9-1C1A-48CB-A907-E5D6B15A0512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {CEEE2AF9-1C1A-48CB-A907-E5D6B15A0512}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {CEEE2AF9-1C1A-48CB-A907-E5D6B15A0512}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {CEEE2AF9-1C1A-48CB-A907-E5D6B15A0512}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {CC4C9419-35E4-4EFA-9393-A2FF01EDAEC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {CC4C9419-35E4-4EFA-9393-A2FF01EDAEC6}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {CC4C9419-35E4-4EFA-9393-A2FF01EDAEC6}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {CC4C9419-35E4-4EFA-9393-A2FF01EDAEC6}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {97BDC87C-05E4-44D7-8A11-64422BAC0E11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {97BDC87C-05E4-44D7-8A11-64422BAC0E11}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {97BDC87C-05E4-44D7-8A11-64422BAC0E11}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {97BDC87C-05E4-44D7-8A11-64422BAC0E11}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {2D312150-65E1-4259-95BD-7DE958E02FBB} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/FormMain.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace PowerQuery.Samples 2 | { 3 | partial class FormMain 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.dgvResult = new System.Windows.Forms.DataGridView(); 32 | this.BtnList2 = new System.Windows.Forms.Button(); 33 | this.BtnList1 = new System.Windows.Forms.Button(); 34 | this.BtnList1and2 = new System.Windows.Forms.Button(); 35 | ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).BeginInit(); 36 | this.SuspendLayout(); 37 | // 38 | // dgvResult 39 | // 40 | this.dgvResult.AllowUserToAddRows = false; 41 | this.dgvResult.AllowUserToDeleteRows = false; 42 | this.dgvResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 43 | | System.Windows.Forms.AnchorStyles.Left) 44 | | System.Windows.Forms.AnchorStyles.Right))); 45 | this.dgvResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 46 | this.dgvResult.Location = new System.Drawing.Point(12, 41); 47 | this.dgvResult.Name = "dgvResult"; 48 | this.dgvResult.ReadOnly = true; 49 | this.dgvResult.Size = new System.Drawing.Size(493, 445); 50 | this.dgvResult.TabIndex = 100; 51 | // 52 | // BtnList2 53 | // 54 | this.BtnList2.Location = new System.Drawing.Point(112, 12); 55 | this.BtnList2.Name = "BtnList2"; 56 | this.BtnList2.Size = new System.Drawing.Size(94, 23); 57 | this.BtnList2.TabIndex = 102; 58 | this.BtnList2.Text = "List2.pq"; 59 | this.BtnList2.UseVisualStyleBackColor = true; 60 | this.BtnList2.Click += new System.EventHandler(this.BtnList2_Click); 61 | // 62 | // BtnList1 63 | // 64 | this.BtnList1.Location = new System.Drawing.Point(12, 12); 65 | this.BtnList1.Name = "BtnList1"; 66 | this.BtnList1.Size = new System.Drawing.Size(94, 23); 67 | this.BtnList1.TabIndex = 101; 68 | this.BtnList1.Text = "List1.pq"; 69 | this.BtnList1.UseVisualStyleBackColor = true; 70 | this.BtnList1.Click += new System.EventHandler(this.BtnList1_Click); 71 | // 72 | // BtnList1and2 73 | // 74 | this.BtnList1and2.Location = new System.Drawing.Point(212, 12); 75 | this.BtnList1and2.Name = "BtnList1and2"; 76 | this.BtnList1and2.Size = new System.Drawing.Size(94, 23); 77 | this.BtnList1and2.TabIndex = 103; 78 | this.BtnList1and2.Text = "List1and2.pq"; 79 | this.BtnList1and2.UseVisualStyleBackColor = true; 80 | this.BtnList1and2.Click += new System.EventHandler(this.BtnList1and2_Click); 81 | // 82 | // FormMain 83 | // 84 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 85 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 86 | this.ClientSize = new System.Drawing.Size(517, 498); 87 | this.Controls.Add(this.BtnList2); 88 | this.Controls.Add(this.BtnList1); 89 | this.Controls.Add(this.BtnList1and2); 90 | this.Controls.Add(this.dgvResult); 91 | this.MinimumSize = new System.Drawing.Size(533, 533); 92 | this.Name = "FormMain"; 93 | this.Text = "PowerQuery.Samples"; 94 | ((System.ComponentModel.ISupportInitialize)(this.dgvResult)).EndInit(); 95 | this.ResumeLayout(false); 96 | 97 | } 98 | 99 | #endregion 100 | 101 | private System.Windows.Forms.DataGridView dgvResult; 102 | private System.Windows.Forms.Button BtnList2; 103 | private System.Windows.Forms.Button BtnList1; 104 | private System.Windows.Forms.Button BtnList1and2; 105 | } 106 | } 107 | 108 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/FormMain.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using PowerQueryNet.Client; 11 | using System.IO; 12 | 13 | namespace PowerQuery.Samples 14 | { 15 | public partial class FormMain : Form 16 | { 17 | private string myQueriesPath = Path.Combine(Environment.CurrentDirectory, @"MyQueries"); 18 | private string myExcelPath = Path.Combine(Environment.CurrentDirectory, @"MyExcel"); 19 | 20 | public FormMain() 21 | { 22 | InitializeComponent(); 23 | } 24 | 25 | private void BtnList1and2_Click(object sender, EventArgs e) 26 | { 27 | var pq = new PowerQueryCommand 28 | { 29 | Queries = Queries.LoadFromFolder(myQueriesPath), //Load every .pq file found in MyQueries folder 30 | }; 31 | 32 | //Add parameters to the queries 33 | pq.Queries.Add("List1Xls", string.Format("\"{0}\"", Path.Combine(myExcelPath, "List1.xls"))); 34 | pq.Queries.Add("List2Xlsx", string.Format("\"{0}\"", Path.Combine(myExcelPath, "List2.xlsx"))); 35 | 36 | //Add the required credentials 37 | pq.Credentials.Add(new CredentialFile { Path = Path.Combine(myExcelPath, "List1.xls") }); 38 | pq.Credentials.Add(new CredentialFile { Path = Path.Combine(myExcelPath, "List2.xlsx") }); 39 | 40 | //Execute List1and2 query. This query combines results from List1 and List2 queries 41 | var result = pq.Execute("List1and2"); 42 | 43 | DisplayResult(result); 44 | } 45 | 46 | private void BtnList1_Click(object sender, EventArgs e) 47 | { 48 | var pq = new PowerQueryCommand 49 | { 50 | Queries = Queries.LoadFromFolder(myQueriesPath), //Load every .pq file found in MyQueries folder 51 | }; 52 | 53 | //Add parameter to the query 54 | pq.Queries.Add("List1Xls", string.Format("\"{0}\"", Path.Combine(myExcelPath, "List1.xls"))); 55 | 56 | //Add the required credentials 57 | pq.Credentials.Add(new CredentialFile { Path = Path.Combine(myExcelPath, "List1.xls") }); 58 | 59 | var result = pq.Execute("List1"); 60 | 61 | DisplayResult(result); 62 | } 63 | 64 | private void BtnList2_Click(object sender, EventArgs e) 65 | { 66 | var pq = new PowerQueryCommand 67 | { 68 | Queries = Queries.LoadFromFolder(myQueriesPath), //Load every .pq file found in MyQueries folder 69 | }; 70 | 71 | //Add parameter to the query 72 | pq.Queries.Add("List2Xlsx", string.Format("\"{0}\"", Path.Combine(myExcelPath, "List2.xlsx"))); 73 | 74 | //Add the required credentials 75 | pq.Credentials.Add(new CredentialFile { Path = Path.Combine(myExcelPath, "List2.xlsx") }); 76 | 77 | var result = pq.Execute("List2"); 78 | 79 | DisplayResult(result); 80 | } 81 | 82 | private void DisplayResult(ExecuteResponse result) 83 | { 84 | if (result == null) 85 | { 86 | MessageBox.Show("Result is null.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); 87 | } 88 | else if (result.ExceptionMessage != null) 89 | { 90 | MessageBox.Show(result.ExceptionMessage, "", MessageBoxButtons.OK, MessageBoxIcon.Error); 91 | } 92 | else 93 | { 94 | dgvResult.DataSource = result.DataTable; 95 | } 96 | } 97 | 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/FormMain.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyExcel/List1.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryParameters/MyExcel/List1.xls -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyExcel/List1and2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryParameters/MyExcel/List1and2.xlsx -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyExcel/List2.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Samples/PowerQueryParameters/MyExcel/List2.xlsx -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyQueries/#credentials.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Z:\TMP\PowerQueryNet\MyExcel\List1.xls 4 | 5 | 6 | Z:\TMP\PowerQueryNet\MyExcel\List2.xlsx 7 | 8 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyQueries/List1.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = Excel.Workbook(File.Contents(List1Xls), null, true), 3 | Sheet2 = Source{[Name="Sheet1"]}[Data], 4 | #"Promoted Headers" = Table.PromoteHeaders(Sheet2, [PromoteAllScalars=true]), 5 | #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"ID", Int64.Type}, {"Name", type text}, {"Description", type text}}) 6 | in 7 | #"Changed Type" -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyQueries/List1and2.pq: -------------------------------------------------------------------------------- 1 | let 2 | List1and2 = Table.Combine({List1, List2}) 3 | in 4 | List1and2 -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/MyQueries/List2.pq: -------------------------------------------------------------------------------- 1 | let 2 | Source = Excel.Workbook(File.Contents(List2Xlsx), null, true), 3 | Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data], 4 | #"Changed Type" = Table.TransformColumnTypes(Table1_Table,{{"ID", Int64.Type}, {"Name", type text}, {"Description", type text}}) 5 | in 6 | #"Changed Type" -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/PowerQueryParameters.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {97BDC87C-05E4-44D7-8A11-64422BAC0E11} 8 | WinExe 9 | PowerQuery.Samples 10 | PowerQueryParameters 11 | v4.5.1 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | False 37 | False 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Form 54 | 55 | 56 | FormMain.cs 57 | 58 | 59 | 60 | 61 | FormMain.cs 62 | 63 | 64 | ResXFileCodeGenerator 65 | Resources.Designer.cs 66 | Designer 67 | 68 | 69 | True 70 | Resources.resx 71 | True 72 | 73 | 74 | Always 75 | 76 | 77 | Always 78 | 79 | 80 | Always 81 | 82 | 83 | Always 84 | 85 | 86 | Always 87 | 88 | 89 | Always 90 | 91 | 92 | SettingsSingleFileGenerator 93 | Settings.Designer.cs 94 | 95 | 96 | True 97 | Settings.settings 98 | True 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | Always 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace PowerQuery.Samples 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new FormMain()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerQueryParameters")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("PowerQueryParameters")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("97bdc87c-05e4-44d7-8a11-64422bac0e11")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQuery.Samples.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PowerQuery.Samples.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQuery.Samples.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Samples/PowerQueryParameters/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Samples/cmd/pqnet.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | cls 3 | cd "C:\Temp\PowerQueryNet\Samples\PowerQueryApp\MyQueries" 4 | C: 5 | REM PQNet "#Hello World.pq" 6 | REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" 7 | REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o csv -f "%temp%\AdventureWorksSales.csv" 8 | REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o html -f "%temp%\AdventureWorksSales.html" 9 | REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o json -f "%temp%\AdventureWorksSales.json" 10 | REM PQNet "AdventureWorksSales.pq" -c "#credentials.xml" -o xml -f "%temp%\AdventureWorksSales.xml" 11 | 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 13 | @echo on 14 | PQNet "..\MyFiles\MyReport.xlsx" vChineseCalendar 15 | @echo off 16 | if %ERRORLEVEL% EQU 0 ( 17 | echo Success 18 | ) else ( 19 | echo Exit Code is %errorlevel% 20 | ) -------------------------------------------------------------------------------- /Service/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Service/Program.cs: -------------------------------------------------------------------------------- 1 | using PowerQueryNet.Client; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Data; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Runtime.InteropServices; 10 | using System.ServiceModel; 11 | using System.ServiceProcess; 12 | using System.Text; 13 | using System.Threading; 14 | using System.Threading.Tasks; 15 | 16 | namespace PowerQueryNet.Service 17 | { 18 | class Program 19 | { 20 | [DllImport("kernel32.dll", SetLastError = true)] 21 | [return: MarshalAs(UnmanagedType.Bool)] 22 | static extern bool AllocConsole(); 23 | 24 | public static EventLog Log = new EventLog { Source = "PowerQueryNet" }; 25 | 26 | static void Main(string[] args) 27 | { 28 | if (args == null || args.Length == 0) 29 | { 30 | ServiceBase.Run(new WindowsService()); 31 | } 32 | else if (args.FirstOrDefault(x => x == "-ipc") != null) 33 | { 34 | try 35 | { 36 | PowerQueryService.Start(); 37 | var taskHandle = new ManualResetEvent(false); 38 | taskHandle.WaitOne(); 39 | } 40 | catch (Exception ex) 41 | { 42 | Log.WriteEntry(ex.ToString(), EventLogEntryType.Error); 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Service/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle("PowerQueryNet.Service")] 7 | [assembly: AssemblyDescription("")] 8 | [assembly: AssemblyConfiguration("")] 9 | [assembly: AssemblyCompany("Guillaume Simard")] 10 | [assembly: AssemblyProduct("PowerQueryNet")] 11 | [assembly: AssemblyCopyright("Copyright © 2018")] 12 | [assembly: AssemblyTrademark("")] 13 | [assembly: AssemblyCulture("")] 14 | 15 | [assembly: ComVisible(false)] 16 | [assembly: Guid("24503a13-7d35-49d9-b071-a0173cd54276")] 17 | 18 | [assembly: AssemblyVersion("1.1.*")] 19 | [assembly: AssemblyInformationalVersion("1.0.0.0")] -------------------------------------------------------------------------------- /Service/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQueryNet.Service.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("PowerQueryNet.Service.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Service/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /Service/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace PowerQueryNet.Service.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.3.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Service/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Service/Service.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {24503A13-7D35-49D9-B071-A0173CD54276} 8 | WinExe 9 | PowerQueryNet.Service 10 | PowerQueryNet.Service 11 | v4.5.1 12 | 512 13 | true 14 | SAK 15 | SAK 16 | SAK 17 | SAK 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | false 29 | 30 | 31 | AnyCPU 32 | pdbonly 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Component 61 | 62 | 63 | ResXFileCodeGenerator 64 | Resources.Designer.cs 65 | Designer 66 | 67 | 68 | True 69 | Resources.resx 70 | True 71 | 72 | 73 | SettingsSingleFileGenerator 74 | Settings.Designer.cs 75 | 76 | 77 | True 78 | Settings.settings 79 | True 80 | 81 | 82 | 83 | 84 | Designer 85 | 86 | 87 | 88 | 89 | {5dcda550-a251-4c69-ae33-88d3bc1326fb} 90 | Client 91 | 92 | 93 | {35c425a2-e884-4306-8285-3fd66a86b601} 94 | Engine 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Service/WindowsService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.Linq; 5 | using System.ServiceProcess; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace PowerQueryNet.Service 10 | { 11 | public class WindowsService : ServiceBase 12 | { 13 | protected override void OnStart(string[] args) 14 | { 15 | try 16 | { 17 | Program.Log.WriteEntry("PowerQueryNet.Service Start", EventLogEntryType.Information); 18 | PowerQueryService.Start(); 19 | } 20 | catch (Exception ex) 21 | { 22 | Program.Log.WriteEntry(ex.ToString(), EventLogEntryType.Error); 23 | this.Stop(); 24 | } 25 | } 26 | 27 | protected override void OnStop() 28 | { 29 | Program.Log.WriteEntry("PowerQueryNet.Service Stop", EventLogEntryType.Information); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Setup.Actions/CustomAction.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Setup.Actions/CustomAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | using Microsoft.Deployment.WindowsInstaller; 6 | using System.IO; 7 | using System.IO.Compression; 8 | using System.Windows.Forms; 9 | 10 | namespace Setup.Actions 11 | { 12 | public class CustomActions 13 | { 14 | [CustomAction] 15 | public static ActionResult ExtractDependencies(Session session) 16 | { 17 | session.Log("Begin ExtractDependencies"); 18 | 19 | string installPath = session.CustomActionData["installPath"]; 20 | string vsixPath = Path.Combine(session.CustomActionData["sourcePath"], "PowerQuerySdk.vsix"); 21 | 22 | if (!File.Exists(vsixPath)) 23 | { 24 | MessageBox.Show( 25 | string.Format( 26 | "The following file is required: {0}\n\nTo download, go to: {1}" 27 | , vsixPath 28 | , "http://dakahn.gallery.vsassets.io/_apis/public/gallery/publisher/dakahn/extension/powerquerysdk/1.0.0.16/assetbyname/PowerQuerySdk.vsix" 29 | ), "PowerQueryNet", MessageBoxButtons.OK, MessageBoxIcon.Error); 30 | return ActionResult.Failure; 31 | } 32 | 33 | try 34 | { 35 | using (ZipArchive zipArchive = ZipFile.OpenRead(vsixPath)) 36 | { 37 | var dependencies = from entry in zipArchive.Entries 38 | where Path.GetDirectoryName(entry.FullName) == "Dependencies" 39 | where !String.IsNullOrEmpty(entry.Name) 40 | select entry; 41 | 42 | foreach (ZipArchiveEntry zipArchiveEntry in dependencies) 43 | { 44 | zipArchiveEntry.ExtractToFile(Path.Combine(installPath, zipArchiveEntry.Name)); 45 | } 46 | } 47 | } 48 | catch (Exception ex) 49 | { 50 | MessageBox.Show("Error extracting dependencies. " + ex.Message, "PowerQueryNet", MessageBoxButtons.OK, MessageBoxIcon.Error); 51 | return ActionResult.Failure; 52 | } 53 | 54 | return ActionResult.Success; 55 | } 56 | 57 | [CustomAction] 58 | public static ActionResult RemoveDependencies(Session session) 59 | { 60 | try 61 | { 62 | string installPath = session.CustomActionData["installPath"]; 63 | 64 | DirectoryInfo di = new DirectoryInfo(installPath); 65 | foreach (var file in di.GetFiles()) 66 | { 67 | file.Delete(); 68 | } 69 | Directory.Delete(installPath); 70 | } 71 | catch (Exception ex) 72 | { 73 | MessageBox.Show("Error removing dependencies. " + ex.Message, "PowerQueryNet", MessageBoxButtons.OK, MessageBoxIcon.Error); 74 | return ActionResult.Success; 75 | } 76 | return ActionResult.Success; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Setup.Actions/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("PowerQueryNet.Setup.Actions")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyCompany("Guillaume Simard")] 11 | [assembly: AssemblyProduct("PowerQueryNet")] 12 | [assembly: AssemblyCopyright("Copyright © 2018")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("c4521615-f8a1-4021-90c4-a2b85eb09703")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.1.*")] -------------------------------------------------------------------------------- /Setup.Actions/Setup.Actions.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | x86 6 | 8.0.30703 7 | 2.0 8 | {C4521615-F8A1-4021-90C4-A2B85EB09703} 9 | Library 10 | Properties 11 | PowerQueryNet.Setup.Actions 12 | PowerQueryNet.Setup.Actions 13 | v4.5.1 14 | 512 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | app.manifest 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /Setup.Actions/app.manifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 40 | 47 | 48 | 49 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /Setup/Config.wxi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Setup/Resources/PQNet.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Setup/Resources/PQNet.ico -------------------------------------------------------------------------------- /Setup/Resources/PQNetBanner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Setup/Resources/PQNetBanner.jpg -------------------------------------------------------------------------------- /Setup/Resources/PQNetDialog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Setup/Resources/PQNetDialog.jpg -------------------------------------------------------------------------------- /Setup/Resources/WiXNewFolderBtn.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Setup/Resources/WiXNewFolderBtn.ico -------------------------------------------------------------------------------- /Setup/Resources/WiXUpFolderBtn.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gsimardnet/PowerQueryNet/b8cf85d06ece8563a457958a6af8612ae4ea6835/Setup/Resources/WiXUpFolderBtn.ico -------------------------------------------------------------------------------- /Setup/Setup.wixproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Debug 5 | x86 6 | 3.10 7 | {17cc49b9-0954-42ef-95b9-895a9dc29bde} 8 | 2.0 9 | PowerQueryNet 10 | Package 11 | $(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.targets 12 | $(MSBuildExtensionsPath)\Microsoft\WiX\v3.x\Wix.targets 13 | SAK 14 | SAK 15 | SAK 16 | SAK 17 | 18 | 19 | bin\$(Configuration)\ 20 | obj\$(Configuration)\ 21 | Debug; 22 | 23 | 24 | bin\$(Configuration)\ 25 | obj\$(Configuration)\ 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | $(WixExtDir)\WixUtilExtension.dll 46 | WixUtilExtension 47 | 48 | 49 | $(WixExtDir)\WixUIExtension.dll 50 | WixUIExtension 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | --------------------------------------------------------------------------------