├── .gitignore ├── Quandl_Excel.sln ├── README.md ├── Src ├── App.config ├── BLL.cs ├── CQLQuandl-Excel-en.dna ├── Class1.cs ├── Class2.cs ├── Form │ ├── Form1.Designer.cs │ ├── Form1.cs │ └── Form1.resx ├── Form1.cs ├── Form1.designer.cs ├── Form1.resx ├── Interface1.cs ├── Properties │ ├── AssemblyInfo.cs │ └── ExcelDna.Build.props ├── Quandl_Excel.csproj ├── Ribbon1.cs └── packages.config ├── excel.png └── packages ├── DynamicLanguageRuntime.1.2.2 ├── .signature.p7s ├── DynamicLanguageRuntime.1.2.2.nupkg ├── LICENSE ├── README.md └── lib │ ├── net45 │ ├── Microsoft.Dynamic.dll │ ├── Microsoft.Dynamic.xml │ ├── Microsoft.Scripting.Metadata.dll │ ├── Microsoft.Scripting.Metadata.xml │ ├── Microsoft.Scripting.dll │ └── Microsoft.Scripting.xml │ ├── netcoreapp2.0 │ ├── Microsoft.Dynamic.dll │ ├── Microsoft.Dynamic.xml │ ├── Microsoft.Scripting.Metadata.dll │ ├── Microsoft.Scripting.Metadata.xml │ ├── Microsoft.Scripting.dll │ └── Microsoft.Scripting.xml │ └── netcoreapp2.1 │ ├── Microsoft.Dynamic.dll │ ├── Microsoft.Dynamic.xml │ ├── Microsoft.Scripting.Metadata.dll │ ├── Microsoft.Scripting.Metadata.xml │ ├── Microsoft.Scripting.dll │ └── Microsoft.Scripting.xml ├── ExcelDna.AddIn.0.34.6 ├── .signature.p7s ├── ExcelDna.AddIn.0.34.6.nupkg ├── content │ ├── ExcelDna-Template.dna │ └── Properties │ │ └── ExcelDna.Build.props ├── readme.txt └── tools │ ├── ExcelDna.AddIn.Tasks.dll │ ├── ExcelDna.AddIn.targets │ ├── ExcelDna.Integration.dll │ ├── ExcelDna.xll │ ├── ExcelDna64.xll │ ├── ExcelDnaPack.exe │ ├── ExcelDnaPack.exe.config │ ├── install.ps1 │ └── uninstall.ps1 ├── ExcelDna.Integration.0.34.6 ├── .DS_Store ├── .signature.p7s ├── ExcelDna.Integration.0.34.6.nupkg ├── lib │ └── ExcelDna.Integration.dll └── tools │ └── install.ps1 ├── JSON.1.0.1 ├── .DS_Store ├── .signature.p7s ├── JSON.1.0.1.nupkg ├── LICENSE └── lib │ ├── .DS_Store │ ├── net35 │ ├── Json.Net35.dll │ └── Json.Net35.pdb │ ├── net40 │ ├── Json.dll │ └── Json.pdb │ ├── sl3 │ ├── Json.Silverlight.dll │ └── Json.Silverlight.pdb │ ├── sl4 │ ├── Json.Silverlight4.dll │ └── Json.Silverlight4.pdb │ └── wp │ ├── Json.WindowsPhone.dll │ └── Json.WindowsPhone.pdb ├── Microsoft.CSharp.4.5.0 ├── .signature.p7s ├── LICENSE.TXT ├── Microsoft.CSharp.4.5.0.nupkg ├── THIRD-PARTY-NOTICES.TXT ├── lib │ ├── MonoAndroid10 │ │ └── _._ │ ├── MonoTouch10 │ │ └── _._ │ ├── net45 │ │ └── _._ │ ├── netcore50 │ │ └── Microsoft.CSharp.dll │ ├── netcoreapp2.0 │ │ └── _._ │ ├── netstandard1.3 │ │ └── Microsoft.CSharp.dll │ ├── netstandard2.0 │ │ └── Microsoft.CSharp.dll │ ├── portable-net45+win8+wp8+wpa81 │ │ └── _._ │ ├── uap10.0.16299 │ │ └── _._ │ ├── win8 │ │ └── _._ │ ├── wp80 │ │ └── _._ │ ├── wpa81 │ │ └── _._ │ ├── xamarinios10 │ │ └── _._ │ ├── xamarinmac20 │ │ └── _._ │ ├── xamarintvos10 │ │ └── _._ │ └── xamarinwatchos10 │ │ └── _._ ├── ref │ ├── MonoAndroid10 │ │ └── _._ │ ├── MonoTouch10 │ │ └── _._ │ ├── net45 │ │ └── _._ │ ├── netcore50 │ │ ├── Microsoft.CSharp.dll │ │ ├── Microsoft.CSharp.xml │ │ ├── de │ │ │ └── Microsoft.CSharp.xml │ │ ├── es │ │ │ └── Microsoft.CSharp.xml │ │ ├── fr │ │ │ └── Microsoft.CSharp.xml │ │ ├── it │ │ │ └── Microsoft.CSharp.xml │ │ ├── ja │ │ │ └── Microsoft.CSharp.xml │ │ ├── ko │ │ │ └── Microsoft.CSharp.xml │ │ ├── ru │ │ │ └── Microsoft.CSharp.xml │ │ ├── zh-hans │ │ │ └── Microsoft.CSharp.xml │ │ └── zh-hant │ │ │ └── Microsoft.CSharp.xml │ ├── netcoreapp2.0 │ │ └── _._ │ ├── netstandard1.0 │ │ ├── Microsoft.CSharp.dll │ │ ├── Microsoft.CSharp.xml │ │ ├── de │ │ │ └── Microsoft.CSharp.xml │ │ ├── es │ │ │ └── Microsoft.CSharp.xml │ │ ├── fr │ │ │ └── Microsoft.CSharp.xml │ │ ├── it │ │ │ └── Microsoft.CSharp.xml │ │ ├── ja │ │ │ └── Microsoft.CSharp.xml │ │ ├── ko │ │ │ └── Microsoft.CSharp.xml │ │ ├── ru │ │ │ └── Microsoft.CSharp.xml │ │ ├── zh-hans │ │ │ └── Microsoft.CSharp.xml │ │ └── zh-hant │ │ │ └── Microsoft.CSharp.xml │ ├── netstandard2.0 │ │ ├── Microsoft.CSharp.dll │ │ └── Microsoft.CSharp.xml │ ├── portable-net45+win8+wp8+wpa81 │ │ └── _._ │ ├── uap10.0.16299 │ │ └── _._ │ ├── win8 │ │ └── _._ │ ├── wp80 │ │ └── _._ │ ├── wpa81 │ │ └── _._ │ ├── xamarinios10 │ │ └── _._ │ ├── xamarinmac20 │ │ └── _._ │ ├── xamarintvos10 │ │ └── _._ │ └── xamarinwatchos10 │ │ └── _._ ├── useSharedDesignerContext.txt └── version.txt └── Newtonsoft.Json.12.0.1 ├── .signature.p7s ├── LICENSE.md ├── Newtonsoft.Json.12.0.1.nupkg └── lib ├── net20 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── net35 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── net40 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── net45 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── netstandard1.0 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── netstandard1.3 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── netstandard2.0 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml ├── portable-net40+sl5+win8+wp8+wpa81 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml └── portable-net45+win8+wp8+wpa81 ├── Newtonsoft.Json.dll ├── Newtonsoft.Json.pdb └── Newtonsoft.Json.xml /.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 | # except build/, which is used as an MSBuild target. 157 | !**/packages/build/ 158 | # Uncomment if necessary however generally it will be regenerated when needed 159 | #!**/packages/repositories.config 160 | # NuGet v3's project.json files produces more ignoreable files 161 | *.nuget.props 162 | *.nuget.targets 163 | 164 | # Microsoft Azure Build Output 165 | csx/ 166 | *.build.csdef 167 | 168 | # Microsoft Azure Emulator 169 | ecf/ 170 | rcf/ 171 | 172 | # Windows Store app package directories and files 173 | AppPackages/ 174 | BundleArtifacts/ 175 | Package.StoreAssociation.xml 176 | _pkginfo.txt 177 | 178 | # Visual Studio cache files 179 | # files ending in .cache can be ignored 180 | *.[Cc]ache 181 | # but keep track of directories ending in .cache 182 | !*.[Cc]ache/ 183 | 184 | # Others 185 | ClientBin/ 186 | ~$* 187 | *~ 188 | *.dbmdl 189 | *.dbproj.schemaview 190 | *.jfm 191 | *.pfx 192 | *.publishsettings 193 | node_modules/ 194 | orleans.codegen.cs 195 | 196 | # Since there are multiple workflows, uncomment next line to ignore bower_components 197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 198 | #bower_components/ 199 | 200 | # RIA/Silverlight projects 201 | Generated_Code/ 202 | 203 | # Backup & report files from converting an old project file 204 | # to a newer Visual Studio version. Backup files are not needed, 205 | # because we have git ;-) 206 | _UpgradeReport_Files/ 207 | Backup*/ 208 | UpgradeLog*.XML 209 | UpgradeLog*.htm 210 | 211 | # SQL Server files 212 | *.mdf 213 | *.ldf 214 | 215 | # Business Intelligence projects 216 | *.rdl.data 217 | *.bim.layout 218 | *.bim_*.settings 219 | 220 | # Microsoft Fakes 221 | FakesAssemblies/ 222 | 223 | # GhostDoc plugin setting file 224 | *.GhostDoc.xml 225 | 226 | # Node.js Tools for Visual Studio 227 | .ntvs_analysis.dat 228 | 229 | # Visual Studio 6 build log 230 | *.plg 231 | 232 | # Visual Studio 6 workspace options file 233 | *.opt 234 | 235 | # Visual Studio LightSwitch build output 236 | **/*.HTMLClient/GeneratedArtifacts 237 | **/*.DesktopClient/GeneratedArtifacts 238 | **/*.DesktopClient/ModelManifest.xml 239 | **/*.Server/GeneratedArtifacts 240 | **/*.Server/ModelManifest.xml 241 | _Pvt_Extensions 242 | 243 | # Paket dependency manager 244 | .paket/paket.exe 245 | paket-files/ 246 | 247 | # FAKE - F# Make 248 | .fake/ 249 | 250 | # JetBrains Rider 251 | .idea/ 252 | *.sln.iml 253 | 254 | # CodeRush 255 | .cr/ 256 | 257 | # Python Tools for Visual Studio (PTVS) 258 | __pycache__/ 259 | *.pyc 260 | -------------------------------------------------------------------------------- /Quandl_Excel.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quandl_Excel", "ClassLibrary7\Quandl_Excel.csproj", "{E63F1976-99A2-419F-A205-CB1F9F493EF5}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7E26726B-BB96-4C08-97AA-86A3AB5931C5}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|.NET 2.0 = Debug|.NET 2.0 13 | Debug|Any CPU = Debug|Any CPU 14 | Debug|x86 = Debug|x86 15 | Release|.NET 2.0 = Release|.NET 2.0 16 | Release|Any CPU = Release|Any CPU 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Debug|.NET 2.0.ActiveCfg = Debug|Any CPU 21 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Debug|.NET 2.0.Build.0 = Debug|Any CPU 22 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Debug|x86.ActiveCfg = Debug|Any CPU 25 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Debug|x86.Build.0 = Debug|Any CPU 26 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Release|.NET 2.0.ActiveCfg = Release|Any CPU 27 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Release|.NET 2.0.Build.0 = Release|Any CPU 28 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Release|Any CPU.Build.0 = Release|Any CPU 30 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Release|x86.ActiveCfg = Release|Any CPU 31 | {E63F1976-99A2-419F-A205-CB1F9F493EF5}.Release|x86.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | GlobalSection(ExtensibilityGlobals) = postSolution 37 | SolutionGuid = {48B8F762-FA60-45CE-B035-001A90A1D529} 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /Src/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Src/BLL.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System.Data; 3 | using System.Text; 4 | using System.Net; 5 | using System.IO; 6 | using System.Security.Cryptography.X509Certificates; 7 | using System.Net.Security; 8 | using Newtonsoft.Json.Linq; 9 | using System.Configuration; 10 | 11 | namespace ExcelAddIn1 12 | { 13 | class BLL 14 | { 15 | 16 | public static DataTable GetDataTable(string dataset,string table,string limit, string offset) 17 | { 18 | ////创建Httphelper对象 19 | //HttpHelper http = new HttpHelper(); 20 | //ServicePointManager.ServerCertificateValidationCallback += (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => 21 | //{ 22 | // return true; 23 | //}; 24 | ////ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; 25 | ////创建Httphelper参数对象 26 | //HttpItem item = new HttpItem() 27 | //{ 28 | // Method = "POST", 29 | // URL = "https://e.morenodes.com:11108/v1/query",//URL 必需项 30 | // CerPath = "C:\\Cert\\read.data.thunderdb.io.pfx", // 31 | // Pwd = "covenantsql", 32 | // Postdata = "database = 053d0bb19637ffc7b4a94e3c79cc71b67a768813b09e4b67f1d6159902754a8b & query = "+ strSql + "limit 10000", 33 | // ContentType = "text" 34 | //}; 35 | ////请求的返回值对象 36 | //HttpResult result = http.GetHtml(item); 37 | //string html = result.Html; 38 | //DataTable dataTable1 = MyData.Class_mysql_conn.Get_DataTable(strSql, MyData.Class_mysql_conn.ConnStr,tableName); 39 | //var keystorefile = @"" + path + "\\read.data.thunderdb.io.pfx"; 40 | string strSql = "select * from quandl_" + dataset + " where quandlcode = '"+ table + "' limit " + limit + " offset " + offset; 41 | string certpath = ConfigurationManager.AppSettings["certpath"]; 42 | string keypasswd = ConfigurationManager.AppSettings["keypassword"]; 43 | string url = ConfigurationManager.AppSettings["url"]; 44 | string database = ConfigurationManager.AppSettings["database"]; 45 | var data = Encoding.UTF8.GetBytes("database=" + database + "&query=" + strSql); 46 | var request = (HttpWebRequest)WebRequest.Create(url); 47 | //X509Certificate2 支持读取.p12格式的证书 48 | var cer = new X509Certificate2(certpath, keypasswd); 49 | request.ClientCertificates.Add(cer); 50 | ServicePointManager.ServerCertificateValidationCallback += (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => 51 | { 52 | return true; 53 | }; 54 | //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; 55 | request.Method = "POST"; 56 | request.ContentType = "application/x-www-form-urlencoded"; 57 | request.ContentLength = data.Length; 58 | using (var stream = request.GetRequestStream()) 59 | { 60 | stream.Write(data, 0, data.Length); 61 | } 62 | var response = (HttpWebResponse)request.GetResponse(); 63 | var context = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd(); 64 | DataTable dt = GetObject(context); 65 | return dt; 66 | } 67 | 68 | public static DataTable ShowTables() 69 | { 70 | ////创建Httphelper对象 71 | //HttpHelper http = new HttpHelper(); 72 | //ServicePointManager.ServerCertificateValidationCallback += (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => 73 | //{ 74 | // return true; 75 | //}; 76 | ////ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; 77 | ////创建Httphelper参数对象 78 | //HttpItem item = new HttpItem() 79 | //{ 80 | // Method = "POST", 81 | // URL = "https://e.morenodes.com:11108/v1/query",//URL 必需项 82 | // CerPath = "C:\\Cert\\read.data.thunderdb.io.pfx", // 83 | // Pwd = "covenantsql", 84 | // Postdata = "database = 053d0bb19637ffc7b4a94e3c79cc71b67a768813b09e4b67f1d6159902754a8b & query = "+ strSql + "limit 10000", 85 | // ContentType = "text" 86 | //}; 87 | ////请求的返回值对象 88 | //HttpResult result = http.GetHtml(item); 89 | //string html = result.Html; 90 | //DataTable dataTable1 = MyData.Class_mysql_conn.Get_DataTable(strSql, MyData.Class_mysql_conn.ConnStr,tableName); 91 | //var keystorefile = @""+path+"\\read.data.thunderdb.io.pfx"; 92 | string certpath = ConfigurationManager.AppSettings["certpath"]; 93 | string keypasswd = ConfigurationManager.AppSettings["keypassword"]; 94 | string url = ConfigurationManager.AppSettings["url"]; 95 | string database = ConfigurationManager.AppSettings["database"]; 96 | var data = Encoding.UTF8.GetBytes("database=" + database + "&query=show tables"); 97 | var request = (HttpWebRequest)WebRequest.Create(url); 98 | //X509Certificate2 支持读取.p12格式的证书 99 | var cer = new X509Certificate2(certpath, keypasswd); 100 | request.ClientCertificates.Add(cer); 101 | ServicePointManager.ServerCertificateValidationCallback += (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => 102 | { 103 | return true; 104 | }; 105 | //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; 106 | request.Method = "POST"; 107 | request.ContentType = "application/x-www-form-urlencoded"; 108 | request.ContentLength = data.Length; 109 | using (var stream = request.GetRequestStream()) 110 | { 111 | stream.Write(data, 0, data.Length); 112 | } 113 | var response = (HttpWebResponse)request.GetResponse(); 114 | var context = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd(); 115 | DataTable dt = GetObject(context); 116 | return dt; 117 | } 118 | 119 | public static DataTable GetDataTableflex(string sql) 120 | { 121 | ////创建Httphelper对象 122 | //HttpHelper http = new HttpHelper(); 123 | //ServicePointManager.ServerCertificateValidationCallback += (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => 124 | //{ 125 | // return true; 126 | //}; 127 | ////ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; 128 | ////创建Httphelper参数对象 129 | //HttpItem item = new HttpItem() 130 | //{ 131 | // Method = "POST", 132 | // URL = "https://e.morenodes.com:11108/v1/query",//URL 必需项 133 | // CerPath = "C:\\Cert\\read.data.thunderdb.io.pfx", // 134 | // Pwd = "covenantsql", 135 | // Postdata = "database = 053d0bb19637ffc7b4a94e3c79cc71b67a768813b09e4b67f1d6159902754a8b & query = "+ strSql + "limit 10000", 136 | // ContentType = "text" 137 | //}; 138 | ////请求的返回值对象 139 | //HttpResult result = http.GetHtml(item); 140 | //string html = result.Html; 141 | //DataTable dataTable1 = MyData.Class_mysql_conn.Get_DataTable(strSql, MyData.Class_mysql_conn.ConnStr,tableName); 142 | //var keystorefile = @"" + path + "\\read.data.thunderdb.io.pfx"; 143 | string certpath = ConfigurationManager.AppSettings["certpath"]; 144 | string keypasswd = ConfigurationManager.AppSettings["keypassword"]; 145 | string url = ConfigurationManager.AppSettings["url"]; 146 | string database = ConfigurationManager.AppSettings["database"]; 147 | var data = Encoding.UTF8.GetBytes("database=" + database + "&query=" + sql); 148 | var request = (HttpWebRequest)WebRequest.Create(url); 149 | //X509Certificate2 支持读取.p12格式的证书 150 | var cer = new X509Certificate2(certpath, keypasswd); 151 | request.ClientCertificates.Add(cer); 152 | ServicePointManager.ServerCertificateValidationCallback += (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => 153 | { 154 | return true; 155 | }; 156 | //ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; 157 | request.Method = "POST"; 158 | request.ContentType = "application/x-www-form-urlencoded"; 159 | request.ContentLength = data.Length; 160 | using (var stream = request.GetRequestStream()) 161 | { 162 | stream.Write(data, 0, data.Length); 163 | } 164 | var response = (HttpWebResponse)request.GetResponse(); 165 | var context = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd(); 166 | DataTable dt = GetObject(context); 167 | return dt; 168 | } 169 | //} 170 | // 171 | /// 172 | /// Json 字符串 转换为 DataTable数据集合 173 | /// 174 | /// 175 | /// 176 | /// 177 | /// Json 字符串 转换为 DataTable数据集合 178 | /// 179 | /// 180 | /// 181 | 182 | 183 | //public static void getObject(string json) 184 | //{ 185 | // JObject obj = JsonConvert.DeserializeObject(json); 186 | // if ((bool)obj["success"]) 187 | // { 188 | // var data = obj["data"] as JObject; 189 | // DataTable dt = new DataTable(); 190 | // foreach (var col in data["columns"]) 191 | // { 192 | // dt.Columns.Add(col.ToString()); 193 | // } 194 | // JArray rows = data["rows"] as JArray; 195 | // foreach (JArray row in rows) 196 | // { 197 | // DataRow dr = dt.NewRow(); 198 | // for (var i = 0; i < row.Count; i++) 199 | // { 200 | // dr[i] = row[i].ToString(); 201 | // } 202 | // dt.Rows.Add(dr); 203 | // } 204 | // } 205 | //} 206 | //public static void GetObject(string json) 207 | //{ 208 | // JObject obj = JsonConvert.DeserializeObject(json); 209 | // if ((bool)obj["success"]) 210 | // { 211 | // var data = obj["data"] as JObject; 212 | // DataTable dt = new DataTable(); 213 | // foreach (var col in data["columns"]) 214 | // { 215 | // dt.Columns.Add(col.ToString()); 216 | // } 217 | // JArray rows = data["rows"] as JArray; 218 | // foreach (JArray row in rows) 219 | // { 220 | // DataRow dr = dt.NewRow(); 221 | // for (var i = 0; i < row.Count; i++) 222 | // { 223 | // dr[i] = row[i].ToString(); 224 | // } 225 | // dt.Rows.Add(dr); 226 | // } 227 | // } 228 | //} 229 | 230 | 231 | 232 | public static DataTable GetObject(string json) 233 | { 234 | JObject obj = JsonConvert.DeserializeObject(json); 235 | if ((bool)obj["success"]) 236 | { 237 | var data = obj["data"] as JObject; 238 | DataTable dt = new DataTable(); 239 | foreach (var col in data["columns"]) 240 | { 241 | dt.Columns.Add(col.ToString()); 242 | } 243 | JArray rows = data["rows"] as JArray; 244 | foreach (JArray row in rows) 245 | { 246 | DataRow dr = dt.NewRow(); 247 | for (var i = 0; i < row.Count; i++) 248 | { 249 | dr[i] = row[i].ToString(); 250 | } 251 | dt.Rows.Add(dr); 252 | } 253 | return dt; 254 | } 255 | return new DataTable(); 256 | } 257 | 258 | } 259 | } -------------------------------------------------------------------------------- /Src/CQLQuandl-Excel-en.dna: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 31 | 34 | 35 |