Commit 057ed2dc by mahaisong

fix:GHHttpClient.csproj 已经封装完毕。

实现功能: 1.HttpWebRequest改为4.6.1的HttpClient用法。 2.HttpClient做成公用预热长连接,节省TCP握手。 3.对于个别Timer获取不到TOKEN的逻辑进行补充,做了多线程的阻塞和同步机制。 4.接口从JOBJECT 改为 DIC。类内部做了封装。 5.通过配置文件读取配置。开放Token校验函数。
parent 354efbc4
using System;
using System;
namespace GHHttpClient
{
public class Class1
{
}
}
using System;
using System;
namespace GHHttpClient
{
public class Class1
{
}
}
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net46;net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net46;net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks Condition="'$(LibraryFrameworks)'==''">net45;net46;net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="'$(LibraryFrameworks)'!=''">$(LibraryFrameworks)</TargetFrameworks>
</PropertyGroup>
</Project>
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyTitleAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyTitleAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
e94233612123dc19e4eb14d4c5fe3115252e5def
e94233612123dc19e4eb14d4c5fe3115252e5def
e94233612123dc19e4eb14d4c5fe3115252e5def
e94233612123dc19e4eb14d4c5fe3115252e5def
4957e125e53707b1f892b4bb9d9dae27b7dabc9d
4957e125e53707b1f892b4bb9d9dae27b7dabc9d
4957e125e53707b1f892b4bb9d9dae27b7dabc9d
4957e125e53707b1f892b4bb9d9dae27b7dabc9d
++ "b/14.java\350\275\254C#/TestC/Backup/obj/Debug/net45/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92(2).cs"
++ "b/14.java\350\275\254C#/TestC/Backup/obj/Debug/net45/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs"
++ "b/14.java\350\275\254C#/TestC/Backup/obj/Debug/net45/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1(2).cs"
++ "b/14.java\350\275\254C#/TestC/Backup/obj/Debug/net45/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs"
++ "b/14.java\350\275\254C#/TestC/Backup/obj/Debug/net45/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3(2).cs"
++ "b/14.java\350\275\254C#/TestC/Backup/obj/Debug/net45/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyTitleAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyTitleAttribute("GHHttpClient")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
e94233612123dc19e4eb14d4c5fe3115252e5def
e94233612123dc19e4eb14d4c5fe3115252e5def
e94233612123dc19e4eb14d4c5fe3115252e5def
e94233612123dc19e4eb14d4c5fe3115252e5def
f4f84d0f7b9be806e309cf4b836ae6730b568570
f4f84d0f7b9be806e309cf4b836ae6730b568570
f4f84d0f7b9be806e309cf4b836ae6730b568570
f4f84d0f7b9be806e309cf4b836ae6730b568570
{
{
"version": 1,
"dgSpecHash": "off1dTzfQ/RYdzCX7TirhXM9T/GdWzXalE7k/SchiFtyPRpcOcxvTH/IgtxFPkRA4OtfCcShTZ/I5Jq80npXAw==",
"success": true
}
\ No newline at end of file
{
{
"version": 1,
"dgSpecHash": "off1dTzfQ/RYdzCX7TirhXM9T/GdWzXalE7k/SchiFtyPRpcOcxvTH/IgtxFPkRA4OtfCcShTZ/I5Jq80npXAw==",
"success": true
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\admin\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.7.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\admin\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.7.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
{
{
"version": 3,
"targets": {
".NETFramework,Version=v4.5": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETFramework,Version=v4.5": []
},
"packageFolders": {
"C:\\Users\\admin\\.nuget\\packages\\": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\smallproject\\14.java转C#\\TestC\\GHHttpClient\\GHHttpClient.csproj",
"projectName": "GHHttpClient",
"projectPath": "D:\\smallproject\\14.java转C#\\TestC\\GHHttpClient\\GHHttpClient.csproj",
"packagesPath": "C:\\Users\\admin\\.nuget\\packages\\",
"outputPath": "D:\\smallproject\\14.java转C#\\TestC\\GHHttpClient\\obj\\",
"projectStyle": "PackageReference",
"crossTargeting": true,
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net45",
"net46",
"net461",
"netstandard2.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.cdn.azure.cn/v3/index.json": {},
"https://www.nuget.org/api/v2/": {}
},
"frameworks": {
"net45": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net45": {}
}
}
}
\ No newline at end of file
{
{
"version": 3,
"targets": {
".NETFramework,Version=v4.5": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETFramework,Version=v4.5": []
},
"packageFolders": {
"C:\\Users\\admin\\.nuget\\packages\\": {},
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "D:\\smallproject\\14.java转C#\\TestC\\GHHttpClient\\GHHttpClient.csproj",
"projectName": "GHHttpClient",
"projectPath": "D:\\smallproject\\14.java转C#\\TestC\\GHHttpClient\\GHHttpClient.csproj",
"packagesPath": "C:\\Users\\admin\\.nuget\\packages\\",
"outputPath": "D:\\smallproject\\14.java转C#\\TestC\\GHHttpClient\\obj\\",
"projectStyle": "PackageReference",
"crossTargeting": true,
"fallbackFolders": [
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
],
"configFilePaths": [
"C:\\Users\\admin\\AppData\\Roaming\\NuGet\\NuGet.Config",
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net45",
"net46",
"net461",
"netstandard2.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {},
"https://nuget.cdn.azure.cn/v3/index.json": {},
"https://www.nuget.org/api/v2/": {}
},
"frameworks": {
"net45": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"net45": {}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2B952B48-7EA9-4279-99B5-CA04872E7347}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GHHttpClient</RootNamespace>
<AssemblyName>GHHttpClient</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BouncyCastle.Crypto, Version=1.8.2.0, Culture=neutral, PublicKeyToken=0e99375e54769942">
<HintPath>..\packages\BouncyCastle.1.8.2\lib\BouncyCastle.Crypto.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="CryptoUtil.cs" />
<Compile Include="ESBFinder.cs" />
<Compile Include="ConnectionOptions.cs" />
<Compile Include="KV.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GHHttpClient
{
public class KV
{
public String key;
public String value;
public KV()
{
}
public KV(String k, String v)
{
this.key = k;
this.value = v;
}
//得到
public static String urlFormed(KV[] param)
{
StringBuilder payload = new StringBuilder();
KV[] arrayOfKV = param;
//得到KV对象数组的拼接结果,
foreach (var item in arrayOfKV)
{
KV pa = item;
// utf-8 编码默认情况
payload.Append(System.Net.WebUtility.UrlEncode(pa.key))
.Append(System.Net.WebUtility.UrlEncode(pa.value))
.Append("&");
}
payload= payload.Remove(payload.Length - 1,1);
return payload.ToString();
}
}
}
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("GHHttpClient")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GHHttpClient")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("2b952b48-7ea9-4279-99b5-ca04872e7347")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
This source diff could not be displayed because it is too large. You can view the blob instead.
++ "b/14.java\350\275\254C#/TestC/GHHttpClient/obj/Debug/GHHttpClient.csproj.CopyComplete"
c250934ce8c26a28501162917f10eaad0dd666ce
c250934ce8c26a28501162917f10eaad0dd666ce
D:\smallproject\14.java转C#\TestC\GHHttpClient\bin\Debug\GHHttpClient.dll
D:\smallproject\14.java转C#\TestC\GHHttpClient\bin\Debug\GHHttpClient.dll
D:\smallproject\14.java转C#\TestC\GHHttpClient\bin\Debug\GHHttpClient.pdb
D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\Debug\GHHttpClient.csprojAssemblyReference.cache
D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\Debug\GHHttpClient.csproj.CoreCompileInputs.cache
D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\Debug\GHHttpClient.dll
D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\Debug\GHHttpClient.pdb
D:\smallproject\14.java转C#\TestC\GHHttpClient\bin\Debug\BouncyCastle.Crypto.dll
D:\smallproject\14.java转C#\TestC\GHHttpClient\bin\Debug\Newtonsoft.Json.dll
D:\smallproject\14.java转C#\TestC\GHHttpClient\bin\Debug\Newtonsoft.Json.xml
D:\smallproject\14.java转C#\TestC\GHHttpClient\obj\Debug\GHHttpClient.csproj.CopyComplete
++ "b/14.java\350\275\254C#/TestC/GHHttpClient/obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs"
++ "b/14.java\350\275\254C#/TestC/GHHttpClient/obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs"
++ "b/14.java\350\275\254C#/TestC/GHHttpClient/obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs"
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BouncyCastle" version="1.8.2" targetFramework="net461" />
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net461" />
</packages>
\ No newline at end of file


......@@ -7,6 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestC", "TestC\TestC.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject1", "UnitTestProject1\UnitTestProject1.csproj", "{3BB91B9E-4694-4844-A734-5229CC7CF3AE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestHttpClientGH", "TestHttpClientGH\TestHttpClientGH.csproj", "{6EF04946-198E-4A57-9660-9EFD79C14F77}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GHHttpClient", "GHHttpClient\GHHttpClient.csproj", "{2B952B48-7EA9-4279-99B5-CA04872E7347}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -21,6 +25,14 @@ Global
{3BB91B9E-4694-4844-A734-5229CC7CF3AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3BB91B9E-4694-4844-A734-5229CC7CF3AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3BB91B9E-4694-4844-A734-5229CC7CF3AE}.Release|Any CPU.Build.0 = Release|Any CPU
{6EF04946-198E-4A57-9660-9EFD79C14F77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EF04946-198E-4A57-9660-9EFD79C14F77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EF04946-198E-4A57-9660-9EFD79C14F77}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EF04946-198E-4A57-9660-9EFD79C14F77}.Release|Any CPU.Build.0 = Release|Any CPU
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B952B48-7EA9-4279-99B5-CA04872E7347}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
using Newtonsoft.Json;
using Newtonsoft.Json;
......@@ -16,6 +16,43 @@ namespace TestC
public class ESBFinder
{
private static readonly String HEADER_TOKEN = "gh-sec-token";
//首先是默认属性的值。
//其次做成单例,timer构造函数时要启动。
//构造函数根据配置文件加载属性值
//其他调用只调用send即可。
//send 中判断过期时间 token是否有效,无效自动请求一次(请求时要加锁token的刷新)。
//使用TASK 不需要我定义异步函数(因为我没有需要await的计算),直接使用httppost的异步即可。
//public bool IsAuthorized
//{
// get { return isAccessTokenSet && !string.IsNullOrEmpty(AccessToken) && !string.IsNullOrEmpty(TokenType) && TokenExpiresTime > DateTime.Now.AddMinutes(10); }
//}
//全套从 System.Net.HttpWebRequest类库,升级为System.Net.Http类库、System.Net.Http类库、System.Net.Http.Headers类库
//参见;https://msdn.microsoft.com/zh-cn/library/system.net.http(v=vs.110).aspx
//参见;https://msdn.microsoft.com/zh-cn/library/system.net.http.headers(v=vs.110).aspx
//由于对.NET CORE 的多目标框架不熟,暂时先使用.NET 4.6.1撰写类库。
//收到数据错误,重发一次。
protected bool isAccessTokenSet = false;
private String appid;
private String secretMD5;
private String enpoint;
......@@ -23,14 +60,7 @@ namespace TestC
private long tokenValidity;
private Timer tokenTimer;
private long lastTokenTimestamp;
// try
//{
// ESBFinder.this.authAndGetToken();
//}
//catch (ESBFinderException e)
//{
// e.printStackTrace();
//}
#region HEXjavaC#写法
////java的方法内部封装的很原始,C#很方便。
......
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Taikor.Opensdk
{
/// <summary>
/// Taikor 用于返回的Token类
/// </summary>
public class TaikorGHToken
{
/// <summary>
/// Access Token,
/// </summary>
public string AccessToken { get; set; }
/// <summary>
/// 错误信息
/// </summary>
public string Error { get; set; }
/// <summary>
/// 过期时间
/// </summary>
public long ExpiresIn { get; set; }
/// <summary>
/// Http错误信息
/// </summary>
public string HttpErrorReason { get; set; }
/// <summary>
/// Http错误状态码
/// </summary>
public int HttpErrorStatusCode { get; set; }
/// <summary>
/// 是否错误
/// </summary>
public bool IsError { get; set; }
/// <summary>
/// 是否Http错误
/// </summary>
public bool IsHttpError { get; set; }
/// <summary>
/// Refresh Token
/// </summary>
public string RefreshToken { get; set; }
/// <summary>
/// Token Type
/// </summary>
public string TokenType { get; set; }
}
}
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -55,6 +55,7 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RSAKeyConvert.cs" />
<Compile Include="TaikorToken.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
......
2dc95b9ac18ba069502ac00f0465914a0420bd47
114fe3febf5ff50165bddc6e9c9ff3d01b4458aa
2dc95b9ac18ba069502ac00f0465914a0420bd47
114fe3febf5ff50165bddc6e9c9ff3d01b4458aa
using System;
using System;
namespace TestHttpClientGH
{
public class Class1
{
}
}
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
</Project>
++ "b/14.java\350\275\254C#/TestC/TestHttpClientGH/obj/Debug/netcoreapp2.1/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs"
++ "b/14.java\350\275\254C#/TestC/TestHttpClientGH/obj/Debug/netcoreapp2.1/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs"
++ "b/14.java\350\275\254C#/TestC/TestHttpClientGH/obj/Debug/netcoreapp2.1/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs"
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("TestHttpClientGH")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("TestHttpClientGH")]
[assembly: System.Reflection.AssemblyTitleAttribute("TestHttpClientGH")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
// 由 MSBuild WriteCodeFragment 类生成。
2bbc96b9274398b4eaeeca9b5f56f3fc06843fbc
2bbc96b9274398b4eaeeca9b5f56f3fc06843fbc
77ab26723aa84b8092e95a97b8f61e4a57168549
77ab26723aa84b8092e95a97b8f61e4a57168549
{
{
"version": 1,
"dgSpecHash": "ZQAP5/lj1nNO5fAIJ4jz/xn23dicAXoOOUypQxy55kyw6US8CqZwXoWa3jetuR8ZXCtuMMWJXBf2lk3uVyWvGQ==",
"success": true
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">D:\smallproject\14.java转C#\TestC\TestHttpClientGH\obj\project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\admin\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.7.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.props" Condition="Exists('$(NuGetPackageRoot)microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.props')" />
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('C:\Program Files\dotnet\sdk\NuGetFallbackFolder\netstandard.library\2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Import Project="$(NuGetPackageRoot)microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.targets" Condition="Exists('$(NuGetPackageRoot)microsoft.netcore.app\2.1.0\build\netcoreapp2.1\Microsoft.NETCore.App.targets')" />
</ImportGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="GH_ESBFinder" connectionString="enpoint=http://113.16.174.140:8024/finder;appid=Mys77mkOyevOXMx0;secret=f00f8f8ea15e5d314d4ccb419c2e176d;crt=ESBFinder_SDK.crt;" />
</connectionStrings>
</configuration>
\ No newline at end of file
using System;
using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;
using System.Threading;
namespace UnitTestProject1
{
/// <summary>
/// UnitTest2 的摘要说明
/// </summary>
[TestClass]
public class UnitTest2
{
public UnitTest2()
{
//
//TODO: 在此处添加构造函数逻辑
//
}
private TestContext testContextInstance;
/// <summary>
///获取或设置测试上下文,该上下文提供
///有关当前测试运行及其功能的信息。
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region 附加测试特性
//
// 编写测试时,可以使用以下附加特性:
//
// 在运行类中的第一个测试之前使用 ClassInitialize 运行代码
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// 在类中的所有测试都已运行之后使用 ClassCleanup 运行代码
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// 在运行每个测试之前,使用 TestInitialize 来运行代码
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// 在每个测试运行完之后,使用 TestCleanup 来运行代码
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion
[TestMethod]
public void TestMethod1()
{
String cmd = "mallintf.getProdAction";
//JObject parameters = new JObject();
//parameters["page"] = "1";
//parameters["size"] = "10";
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add("page", "1");
dic.Add("size", "10");
//GHHttpClient.ESBFinder.mulresetEvent.WaitOne();
/**
* 3:发起请求,获取返回
*/
GHHttpClient.ESBFinder.Instance.authAndGetToken();
String resp = GHHttpClient.ESBFinder.Instance.sendRequest(cmd, dic);
Parallel.For(1,10000 , x=>{
int k = x;
GHHttpClient.ESBFinder.Instance.authAndGetToken();
});
/**
* 2: 设定接口参数
*/
//String cmd = "moni.getStockAction";
//JObject parameters = new JObject();
//parameters["username"] = "00000";
//parameters["password"] = "11111";
//String cmd = "mallintf.getProdAction";
//JObject parameters = new JObject();
//parameters["page"] = "1";
//parameters["size"] = "10";
///**
// * 3:发起请求,获取返回
// */
//String resp = client.sendRequest(cmd, parameters);
Console.ReadLine();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
......@@ -53,14 +53,20 @@
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UnitTest2.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="ESBFinder_SDK.crt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GHHttpClient\GHHttpClient.csproj">
<Project>{2b952b48-7ea9-4279-99b5-ca04872e7347}</Project>
<Name>GHHttpClient</Name>
</ProjectReference>
<ProjectReference Include="..\TestC\TestC.csproj">
<Project>{303a6757-1dfd-4a85-9129-feb6441cee7e}</Project>
<Name>TestC</Name>
......
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="GH_ESBFinder" connectionString="enpoint=http://113.16.174.140:8024/finder;appid=Mys77mkOyevOXMx0;secret=f00f8f8ea15e5d314d4ccb419c2e176d;crt=ESBFinder_SDK.crt;" />
</connectionStrings>
</configuration>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment