Skip to content

Commit

Permalink
Merge pull request #3077 from JeffreySu/Developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
JeffreySu authored Oct 2, 2024
2 parents eb86ec8 + 4855e62 commit b4b9f39
Show file tree
Hide file tree
Showing 46 changed files with 209 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,19 @@ and limitations under the License.
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Senparc.CO2NET;
using Senparc.CO2NET.Extensions;
using Senparc.Weixin;
using Senparc.Weixin.Entities;
using Senparc.Weixin.MP;
using Senparc.Weixin.RegisterServices;


var builder = new ConfigurationBuilder();
builder.AddJsonFile("appsettings.json", false, false);
var environment = Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? "Production";

builder.AddJsonFile("appsettings.json", false, true);
builder.AddJsonFile($"appsettings.{environment}.json", false, true);
Console.WriteLine("完成 appsettings.json 添加");

var config = builder.Build();
Expand Down
2 changes: 1 addition & 1 deletion Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8.sln
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Work.Test.ne
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.MP.Test.net8", "..\..\..\src\Senparc.Weixin.MP\Senparc.Weixin.MP.Test\Senparc.Weixin.MP.Test.net8.csproj", "{B1165EE3-2DBB-474B-AFCA-ECAB096DAAAC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.WeixinTests.net8", "..\..\..\src\Senparc.Weixin.MP\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj", "{A514FE17-476F-4D10-B28E-A7597CB93F9A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.WeixinTests.net8", "..\..\..\src\Senparc.Weixin\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj", "{A514FE17-476F-4D10-B28E-A7597CB93F9A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AspNet", "AspNet", "{6DDD51DD-6029-4F4B-994A-4CD3231BC5B7}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1;netcoreapp3.1;net8.0</TargetFrameworks>
<Version>1.0.2</Version>
<Version>1.0.3</Version>
<AssemblyName>Senparc.WebSocket</AssemblyName>
<RootNamespace>Senparc.WebSocket</RootNamespace>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
Expand All @@ -22,34 +22,35 @@
<PackageProjectUrl>https://github.com/JeffreySu/WeiXinMPSDK</PackageProjectUrl>
<PackageIcon>icon.jpg</PackageIcon>
<PackageReleaseNotes>
v0.1.1 完成MessageHandler、WebSocketHandler等基础架构,完成基本消息通讯
v0.1.1 完成MessageHandler、WebSocketHandler等基础架构,完成基本消息通讯

v0.1.3 优化WebSocket通讯机制
v0.1.3 优化WebSocket通讯机制

v0.2.0 支持 .NET Core
v0.2.0 支持 .NET Core

v0.3.0 支持 .NET Core 2.0
v0.3.1
1、提供WebSocketHandler.IsReusable返回值(true)
2、升级Newtonsoft.Json版本至10.0.1
v0.3.2 注册WebSocketMessageHandler,自定义对象的实例化方法,用以支持Spring等框架的注入
v0.3.3 常规优化
v0.4.0 停止对 .net core 1.1 生成的独立版本
v0.3.0 支持 .NET Core 2.0
v0.3.1
1、提供WebSocketHandler.IsReusable返回值(true)
2、升级Newtonsoft.Json版本至10.0.1
v0.3.2 注册WebSocketMessageHandler,自定义对象的实例化方法,用以支持Spring等框架的注入
v0.3.3 常规优化
v0.4.0 停止对 .net core 1.1 生成的独立版本

v0.5.0-rc1 支持 .NET Core 2.1.0
v0.5.0-rc1 支持 .NET Core 2.1.0

v0.5.5 发布支持 .net core 2.1 的正式版
v0.6.0 支持最新基础库,使用 .NETStandard2.0 统一支持 .NET Core,放弃对 .NET Core 1.x 的单独适配
v0.7.3 全局使用 .ConfigureAwait(false) 应对异步锁死问题
v0.8.0
1、支持 .NET Core SignalR
2、提供 Register 注册方法
3、优化 WebSocketMesssageHandler
v0.8.1 引用最新版本 CO2NET
v0.8.2 引用最新版本 CO2NET
v0.8.3 提供带符号的 nuget 包(.snupkg)
v0.9.0 使用最新版本 Senparc.Weixin,支持 .NET Core 3.0
</PackageReleaseNotes>
v0.5.5 发布支持 .net core 2.1 的正式版
v0.6.0 支持最新基础库,使用 .NETStandard2.0 统一支持 .NET Core,放弃对 .NET Core 1.x 的单独适配
v0.7.3 全局使用 .ConfigureAwait(false) 应对异步锁死问题
v0.8.0
1、支持 .NET Core SignalR
2、提供 Register 注册方法
3、优化 WebSocketMesssageHandler
v0.8.1 引用最新版本 CO2NET
v0.8.2 引用最新版本 CO2NET
v0.8.3 提供带符号的 nuget 包(.snupkg)
v0.9.0 使用最新版本 Senparc.Weixin,支持 .NET Core 3.0
v1.0.3 清理引用项目
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down Expand Up @@ -102,13 +103,13 @@
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'net462' ">
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<!--<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />-->
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
<PackageReference Include="System.Threading.Thread" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />
<!--<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="2.2.1" />-->
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Senparc.Weixin.MP\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.Weixin\Senparc.Weixin.net8.csproj" />
<ProjectReference Include="..\Senparc.Weixin.Cache.Redis\Senparc.Weixin.Cache.Redis.net8.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<ProjectReference Include="..\..\Senparc.Weixin.TenPay\Senparc.Weixin.TenPay\Senparc.Weixin.TenPay.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.Weixin\Senparc.Weixin.net8.csproj" />
<ProjectReference Include="..\Senparc.Weixin.MP\Senparc.Weixin.MP.net8.csproj" />
<ProjectReference Include="..\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
33 changes: 0 additions & 33 deletions src/Senparc.Weixin.MP/Senparc.WeixinTests/app.config

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<ItemGroup>
<ProjectReference Include="..\..\Senparc.Weixin.MP\Senparc.Weixin.MP\Senparc.Weixin.MP.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin.MP\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.Weixin\Senparc.Weixin.net8.csproj" />
<ProjectReference Include="..\Senparc.Weixin.Open\Senparc.Weixin.Open.net8.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Senparc.Weixin.MP\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.Weixin\Senparc.Weixin.net8.csproj" />
<ProjectReference Include="..\Senparc.Weixin.TenPay\Senparc.Weixin.TenPay.net8.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Senparc.Weixin.TenPay.V3;
using System;
using System.Collections.Generic;
using System.Text;

namespace Senparc.Weixin.TenPay.Test.vs2017.V3
{
Expand Down Expand Up @@ -35,7 +33,7 @@ public void GetXmlValuesTest()
public void GetXmlValuesTest1()
{
var data = new TenPayV3UnifiedorderRequestData("", "", "test", "test123123", 1, "", "", TenPayV3Type.JSAPI, "", "", "1111");
TenPayV3.Unifiedorder(data);
Senparc.Weixin.TenPay.V3.TenPayV3.Unifiedorder(data);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Senparc.Weixin.MP\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\..\Senparc.Weixin\Senparc.WeixinTests\Senparc.WeixinTests.net8.csproj" />
<ProjectReference Include="..\Senparc.Weixin.TenPayV3\Senparc.Weixin.TenPayV3.net8.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@ and limitations under the License.
----------------------------------------------------------------*/
#endregion Apache License Version 2.0

using System;
using System.Text;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Senparc.Weixin.Exceptions;
using Senparc.Weixin.Work.AdvancedAPIs;
using Senparc.Weixin.Work.AdvancedAPIs.App;
using Senparc.Weixin.Work.AdvancedAPIs.MailList;
using Senparc.Weixin.Work.CommonAPIs;
using Senparc.Weixin.Work.Containers;
using Senparc.Weixin.Work.Test.CommonApis;
using System;
using System.Threading.Tasks;

namespace Senparc.Weixin.Work.Test.AdvancedAPIs
{
Expand All @@ -39,77 +34,59 @@ namespace Senparc.Weixin.Work.Test.AdvancedAPIs
[TestClass]
public partial class AppTest : CommonApiTest
{
const int AGENT_ID = 1000009;

[TestMethod]
public void GetAppInfoTest()
{
{
//使用AppKey测试
//常规AccessToken测试
var appKey = AccessTokenContainer.BuildingKey(_corpId, base._corpSecret);
var result = AppApi.GetAppInfo(appKey, 2);
var result = AppApi.GetAppInfo(appKey, AGENT_ID);

Assert.IsNotNull(result.agentid);
Assert.AreEqual(result.agentid, "2");
Assert.AreEqual(result.agentid, AGENT_ID.ToString());
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(result));
}

{
//常规AccessToken测试
var accessToken = AccessTokenContainer.GetToken(_corpId, base._corpSecret);
var result = AppApi.GetAppInfo(accessToken, 2);
var result = AppApi.GetAppInfo(accessToken, AGENT_ID);

Assert.IsNotNull(result.agentid);
Assert.AreEqual(result.agentid, "2");
Assert.AreEqual(result.agentid, AGENT_ID.ToString());
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(result));
}
}

[TestMethod]
public void GetAppInfoAsyncTest()
public async Task GetAppInfoAsyncTest()
{
var finishedCount = 0;

{
Task.Factory.StartNew(async () =>
{
//使用AppKey测试
//常规AccessToken测试
var appKey = AccessTokenContainer.BuildingKey(_corpId, base._corpSecret);
var result = await AppApi.GetAppInfoAsync(appKey, 2);
Assert.IsNotNull(result.agentid);
Assert.AreEqual(result.agentid, "2");
Console.WriteLine("1.Ticket:" + SystemTime.Now.Ticks);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(result));
finishedCount++;
});
//使用AppKey测试
//常规AccessToken测试
var appKey = AccessTokenContainer.BuildingKey(_corpId, base._corpSecret);
var result = await AppApi.GetAppInfoAsync(appKey, AGENT_ID);

while (finishedCount < 1)
{
Assert.IsNotNull(result.agentid);
Assert.AreEqual(result.agentid, AGENT_ID.ToString());

}
Console.WriteLine("1.Ticket:" + SystemTime.Now.Ticks);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(result));
}

{
Task.Factory.StartNew(async () =>
{
//常规AccessToken测试
var accessToken = AccessTokenContainer.GetToken(_corpId, base._corpSecret);
var result = await AppApi.GetAppInfoAsync(accessToken, 2);
Assert.IsNotNull(result.agentid);
Assert.AreEqual(result.agentid, "2");
Console.WriteLine("2.Ticket:" + SystemTime.Now.Ticks);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(result));
finishedCount++;
});
//常规AccessToken测试
var accessToken = AccessTokenContainer.GetToken(_corpId, base._corpSecret);
var result = await AppApi.GetAppInfoAsync(accessToken, AGENT_ID);

while (finishedCount < 2)
{
Assert.IsNotNull(result.agentid);
Assert.AreEqual(result.agentid, AGENT_ID.ToString());

}
Console.WriteLine("2.Ticket:" + SystemTime.Now.Ticks);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(result));
}
}

Expand All @@ -120,15 +97,15 @@ public void SetAppTest()

SetAppPostData date = new SetAppPostData()
{
agentid = "2",//"100" + SystemTime.Now.ToString("yyMMddHHMM"),
agentid = AGENT_ID.ToString(),//"100" + SystemTime.Now.ToString("yyMMddHHMM"),
report_location_flag = "1",
//logo_mediaid = "1muvdK7W8cjLfNqj0hWP89-CEhZNOVsktCE1JHSTSNpzTf7cGOXyDin_ozluwNZqi",
name = "单元测试添加" + SystemTime.Now.ToString("yyMMddHHMM"),
description = "test",
redirect_domain = "https://sdk.weixin.senparc.com",
name = "微信 SDK 单元测试添加" + SystemTime.Now.ToString("yyyyMMdd HH:mm"),
description = "微信 SDK 单元测试",
redirect_domain = "sdk.weixin.senparc.com",
//isreportenter = 0,
isreportuser = 1,
home_url = "weixin.senparc.com"
home_url = "https://weixin.senparc.com",
};

var result = AppApi.SetApp(accessToken, date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text;
using System.Threading.Tasks;
using Senparc.Weixin.Work.Test.CommonApis;
using Senparc.Weixin.Work.Containers;

namespace Senparc.Weixin.Work.AdvancedAPIs.Tests
{
Expand All @@ -15,8 +16,8 @@ public class MailListApiTests : CommonApiTest
[TestMethod()]
public void GetDepartmentMemberInfoTest()
{
var appKeyOrAccessToken = "";
var result = MailListApi.GetDepartmentMemberInfo(appKeyOrAccessToken, 1, 1/*, Int32.MaxValue*/);
var appKey = AccessTokenContainer.BuildingKey(_corpId, _corpSecret);
var result = MailListApi.GetDepartmentMemberInfo(appKey, 1, 1/*, Int32.MaxValue*/);
Assert.IsNotNull(result);
}
}
Expand Down
Loading

0 comments on commit b4b9f39

Please sign in to comment.