From 58e4138a9f96b6197fd53357c6845b45f706656d Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Wed, 25 Sep 2024 17:07:41 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=20Sample=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Senparc.Weixin.Sample.Net8/Startup.cs | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/Startup.cs b/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/Startup.cs index 8b2ebcab7f..5cbb4eb9f1 100644 --- a/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/Startup.cs +++ b/Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/Startup.cs @@ -1,18 +1,12 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc.ViewFeatures; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; -using NuGet.Protocol; using Senparc.AI.Kernel; using Senparc.CO2NET; using Senparc.CO2NET.AspNet; using Senparc.CO2NET.Cache; using Senparc.CO2NET.Cache.Memcached; +using Senparc.CO2NET.Extensions; using Senparc.CO2NET.Helpers; using Senparc.CO2NET.Utilities; using Senparc.CO2NET.WebApi.WebApiEngines; @@ -38,8 +32,6 @@ using Senparc.Weixin.Work.MessageHandlers.Middleware; using Senparc.Weixin.WxOpen; using Senparc.Weixin.WxOpen.MessageHandlers.Middleware; -using System; -using System.IO; using System.Text; namespace Senparc.Weixin.Sample.Net8 @@ -291,7 +283,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, .RegisterTenpayV3(senparcWeixinSetting.Value, "【盛派网络小助手】公众号")//记录到同一个 SenparcWeixinSettingItem 对象中 /* 特别注意: * 在 services.AddSenparcWeixin() 代码中,已经自动为当前的 - * senparcWeixinSetting 对应的TenpayV3 配置进行了 Cert 证书配置, + * senparcWeixinSetting 对应的 TenpayV3 配置进行了 Cert 证书配置, * 如果此处注册的微信支付信息和默认 senparcWeixinSetting 信息不同, * 请在 ConfigureServices() 方法中使用 services.AddCertHttpClient() * 添加对应证书。 @@ -362,7 +354,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, using (StreamWriter sw = new StreamWriter(file, true)) { //这里存了整个对象,实际上只存RefreshToken也可以,有了RefreshToken就能刷新到最新的AccessToken - sw.Write(refreshResult.ToJson()); + sw.Write((refreshResult as object).ToJson()); sw.Flush(); } }, "【盛派网络】开放平台") @@ -497,7 +489,7 @@ private void ConfigTraceLog() }; } - + /// /// 判断当前配置是否满足使用 Redis(根据是否已经修改了默认配置字符串判断) /// @@ -509,9 +501,7 @@ private bool UseRedis(SenparcSetting senparcSetting, out string redisConfigurati var useRedis = !string.IsNullOrEmpty(redisConfigurationStr) && redisConfigurationStr != "#{Cache_Redis_Configuration}#"/*默认值,不启用*/; return useRedis; } - - /// /// 初步判断当前配置是否满足使用 Memcached(根据是否已经修改了默认配置字符串判断) /// @@ -523,7 +513,7 @@ private bool UseMemcached(SenparcSetting senparcSetting, out string memcachedCon var useMemcached = !string.IsNullOrEmpty(memcachedConfigurationStr) && memcachedConfigurationStr != "#{Cache_Memcached_Configuration}#"; return useMemcached; } - + } } From d8333fbe510ad812b334b34bdf82fee800a3afb5 Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Sun, 29 Sep 2024 20:48:44 +0800 Subject: [PATCH 2/5] =?UTF-8?q?[2024-09-29]=20v3.23.0=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=B9=B6=E5=90=8C=E6=84=8F=20BuildingKey=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E6=9E=84=E5=BB=BA=E4=B8=80=E8=87=B4=E7=9A=84=20AppKey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Senparc.WeixinTests/BaseTest.cs | 27 +--- .../MutipleCacheTestWapper.cs | 3 +- .../Senparc.WeixinTests.net8.csproj | 2 +- .../Senparc.Weixin.Open.Test/OpenBaseTest.cs | 3 +- .../Signer/SM3WithSM2SignerTests.cs | 3 +- .../CommonApis/CommonApiTest.Menu.cs | 117 +++++++++--------- .../CommonApis/CommonApiTest.cs | 22 +--- .../Senparc.Weixin.Work.Test.net8.csproj | 2 +- .../Containers/AccessTokenContainer.cs | 4 +- .../Containers/JsApiTicketContainer.cs | 23 +--- .../Containers/ProviderTokenContainer.cs | 28 ++--- .../Senparc.Weixin.Work.net8.csproj | 3 +- 12 files changed, 86 insertions(+), 151 deletions(-) diff --git a/src/Senparc.Weixin.MP/Senparc.WeixinTests/BaseTest.cs b/src/Senparc.Weixin.MP/Senparc.WeixinTests/BaseTest.cs index e57fadc4e8..247ec262a0 100644 --- a/src/Senparc.Weixin.MP/Senparc.WeixinTests/BaseTest.cs +++ b/src/Senparc.Weixin.MP/Senparc.WeixinTests/BaseTest.cs @@ -1,21 +1,13 @@ -#if NETCOREAPP2_0_OR_GREATER || NET6_0_OR_GREATER -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -#endif using Moq; using Senparc.CO2NET; -using Senparc.CO2NET.Cache; using Senparc.CO2NET.RegisterServices; using Senparc.Weixin; -using Senparc.Weixin.Cache; -using Senparc.Weixin.Cache.Memcached; -using Senparc.Weixin.Cache.Redis; using Senparc.Weixin.Entities; using Senparc.Weixin.RegisterServices; using System; -using System.Collections.Generic; using System.IO; using System.Text; @@ -40,9 +32,7 @@ public BaseTest() /// protected void RegisterStart() { -#if NETCOREAPP2_0_OR_GREATER || NET6_0_OR_GREATER Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);//支持 GB2312 -#endif //注册开始 RegisterService register; @@ -50,19 +40,12 @@ protected void RegisterStart() //注册 CON2ET 全局 var senparcSetting = new SenparcSetting() { IsDebug = true }; -#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER -#if NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER var mockEnv = new Mock(); -#else - var mockEnv = new Mock(); -#endif + mockEnv.Setup(z => z.ContentRootPath).Returns(() => UnitTestHelper.RootPath); register = Senparc.CO2NET.AspNet.RegisterServices.RegisterService.Start(mockEnv.Object, senparcSetting); RegisterServiceCollection(); -#else - register = RegisterService.Start(senparcSetting); -#endif //Func> func = () => //{ @@ -81,7 +64,6 @@ protected void RegisterStart() register.ChangeDefaultCacheNamespace("Senparc.Weixin Test Cache"); } -#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER /// /// 注册 IServiceCollection 和 MemoryCache /// @@ -124,7 +106,6 @@ public void RegisterServiceCollection() _serviceProvider = serviceCollection.BuildServiceProvider(); } -#endif /// /// 获取到达项目根目录的相对路径 @@ -132,11 +113,7 @@ public void RegisterServiceCollection() /// protected string GetParentRootRelativePath() { -#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER return @"..\..\..\"; -#else - return @"..\..\"; -#endif } } } diff --git a/src/Senparc.Weixin.MP/Senparc.WeixinTests/MutipleCacheTestWapper.cs b/src/Senparc.Weixin.MP/Senparc.WeixinTests/MutipleCacheTestWapper.cs index 4d7df7291c..094aa542a4 100644 --- a/src/Senparc.Weixin.MP/Senparc.WeixinTests/MutipleCacheTestWapper.cs +++ b/src/Senparc.Weixin.MP/Senparc.WeixinTests/MutipleCacheTestWapper.cs @@ -6,11 +6,10 @@ using Senparc.CO2NET; using Senparc.CO2NET.Cache; using Senparc.CO2NET.Cache.Memcached; -using Senparc.CO2NET.Cache.Redis; +using Senparc.CO2NET.Cache.CsRedis; using Senparc.Weixin; using Senparc.Weixin.Cache; using Senparc.Weixin.Cache.Memcached; -using Senparc.Weixin.Cache.Redis; namespace Senparc.WeixinTests { diff --git a/src/Senparc.Weixin.MP/Senparc.WeixinTests/Senparc.WeixinTests.net8.csproj b/src/Senparc.Weixin.MP/Senparc.WeixinTests/Senparc.WeixinTests.net8.csproj index bf795c118b..cd63245028 100644 --- a/src/Senparc.Weixin.MP/Senparc.WeixinTests/Senparc.WeixinTests.net8.csproj +++ b/src/Senparc.Weixin.MP/Senparc.WeixinTests/Senparc.WeixinTests.net8.csproj @@ -37,8 +37,8 @@ + - diff --git a/src/Senparc.Weixin.Open/Senparc.Weixin.Open.Test/OpenBaseTest.cs b/src/Senparc.Weixin.Open/Senparc.Weixin.Open.Test/OpenBaseTest.cs index c3035e3754..d05072ab8f 100644 --- a/src/Senparc.Weixin.Open/Senparc.Weixin.Open.Test/OpenBaseTest.cs +++ b/src/Senparc.Weixin.Open/Senparc.Weixin.Open.Test/OpenBaseTest.cs @@ -6,9 +6,8 @@ using System.Threading.Tasks; using System.Xml.Linq; using Senparc.CO2NET.Cache; -using Senparc.CO2NET.Cache.Redis; +using Senparc.CO2NET.Cache.CsRedis; using Senparc.Weixin.Cache; -using Senparc.Weixin.Cache.Redis; using Senparc.Weixin.Open.CommonAPIs; using Senparc.Weixin.Open.ComponentAPIs; using Senparc.Weixin.Open.Containers; diff --git a/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3.Test/TenPayHttpClient/Signer/SM3WithSM2SignerTests.cs b/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3.Test/TenPayHttpClient/Signer/SM3WithSM2SignerTests.cs index bc205b78b7..7153751273 100644 --- a/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3.Test/TenPayHttpClient/Signer/SM3WithSM2SignerTests.cs +++ b/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3.Test/TenPayHttpClient/Signer/SM3WithSM2SignerTests.cs @@ -15,10 +15,11 @@ public class SM3WithSM2SignerTests public void SignTest() { SM3WithSM2Signer sM3WithSM2Signer = new(); - var message = ""; + var message = "Senparc"; var privateKey = ""; var sign = sM3WithSM2Signer.Sign(message, privateKey); var exceptResult = "1ab21d8355cfa17f8e61194831e81a8f22bec8c728fefb747ed035eb5082aa2b"; + Assert.AreEqual(exceptResult, sign); } } diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.Menu.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.Menu.cs index cbf6e84bdd..3685306820 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.Menu.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.Menu.cs @@ -18,18 +18,13 @@ and limitations under the License. ----------------------------------------------------------------*/ #endregion Apache License Version 2.0 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using Senparc.NeuChar; using Senparc.Weixin.Exceptions; using Senparc.Weixin.Work.CommonAPIs; using Senparc.Weixin.Work.Containers; using Senparc.Weixin.Work.Entities.Menu; +using System.Threading.Tasks; namespace Senparc.Weixin.Work.Test.CommonApis { @@ -38,62 +33,62 @@ public partial class CommonApiTest private int _agentId = 7; [TestMethod] -public async Task CreateMenuTest() -{ - ButtonGroup bg = new ButtonGroup(); - - //单击 - bg.button.Add(new SingleClickButton() - { - name = "单击测试", - key = "OneClick", - type = MenuButtonType.click.ToString(),//默认已经设为此类型,这里只作为演示 - }); - - //二级菜单 - var subButton = new SubButton() - { - name = "二级菜单" - }; - subButton.sub_button.Add(new SingleClickButton() - { - key = "SubClickRoot_Text", - name = "返回文本" - }); - subButton.sub_button.Add(new SingleClickButton() - { - key = "SubClickRoot_News", - name = "返回图文" - }); - subButton.sub_button.Add(new SingleClickButton() - { - key = "SubClickRoot_Music", - name = "返回音乐" - }); - subButton.sub_button.Add(new SingleViewButton() - { - url = "https://weixin.senparc.com", - name = "Url跳转" - }); - subButton.sub_button.Add(new SinglePicPhotoOrAlbumButton() - { - key = "SubClickRoot_Pic_Photo_Or_Album", - name = "微信拍照" - }); - bg.button.Add(subButton); - - var workWeixinSetting = Config.SenparcWeixinSetting.WorkSetting; - var appKey = AccessTokenContainer.BuildingKey(workWeixinSetting); - int agentId; - if (!int.TryParse(workWeixinSetting.WeixinCorpAgentId, out agentId)) - { - throw new WeixinException("WeixinCorpAgentId 必须为整数!"); - } - var result = await CommonApi.CreateMenuAsync(appKey, agentId, bg); + public async Task CreateMenuTest() + { + ButtonGroup bg = new ButtonGroup(); + + //单击 + bg.button.Add(new SingleClickButton() + { + name = "单击测试", + key = "OneClick", + type = MenuButtonType.click.ToString(),//默认已经设为此类型,这里只作为演示 + }); + + //二级菜单 + var subButton = new SubButton() + { + name = "二级菜单" + }; + subButton.sub_button.Add(new SingleClickButton() + { + key = "SubClickRoot_Text", + name = "返回文本" + }); + subButton.sub_button.Add(new SingleClickButton() + { + key = "SubClickRoot_News", + name = "返回图文" + }); + subButton.sub_button.Add(new SingleClickButton() + { + key = "SubClickRoot_Music", + name = "返回音乐" + }); + subButton.sub_button.Add(new SingleViewButton() + { + url = "https://weixin.senparc.com", + name = "Url跳转" + }); + subButton.sub_button.Add(new SinglePicPhotoOrAlbumButton() + { + key = "SubClickRoot_Pic_Photo_Or_Album", + name = "微信拍照" + }); + bg.button.Add(subButton); + + var workWeixinSetting = Config.SenparcWeixinSetting.WorkSetting; + var appKey = AccessTokenContainer.BuildingKey(workWeixinSetting); + int agentId; + if (!int.TryParse(workWeixinSetting.WeixinCorpAgentId, out agentId)) + { + throw new WeixinException("WeixinCorpAgentId 必须为整数!"); + } + var result = await CommonApi.CreateMenuAsync(appKey, agentId, bg); - Assert.IsNotNull(result); - Assert.AreEqual("ok", result.errmsg); -} + Assert.IsNotNull(result); + Assert.AreEqual("ok", result.errmsg); + } [TestMethod] diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.cs index 273a5e8f79..325750f9eb 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/CommonApis/CommonApiTest.cs @@ -25,21 +25,18 @@ and limitations under the License. using System.Xml.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Senparc.Weixin.Cache; -using Senparc.Weixin.Cache.Redis; +using Senparc.Weixin.Cache.CsRedis; using Senparc.Weixin.Exceptions; using Senparc.Weixin.Work.CommonAPIs; using Senparc.Weixin.Work.Containers; -using Senparc.CO2NET.Cache.Redis; using Senparc.CO2NET.Cache; using Moq; using Senparc.CO2NET.RegisterServices; using Senparc.CO2NET; using Senparc.Weixin.Entities; using Senparc.WeixinTests; - -#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER using Microsoft.AspNetCore.Hosting; -#endif +using Senparc.CO2NET.Cache.CsRedis; namespace Senparc.Weixin.Work.Test.CommonApis @@ -57,20 +54,12 @@ protected dynamic AppConfig { if (_appConfig == null) { -#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER var filePath = "../../../Config/test.config"; -#else - var filePath = "../../Config/test.config"; -#endif if (File.Exists(filePath)) { -#if NETSTANDARD2_0_OR_GREATER || NETCOREAPP2_1_OR_GREATER || NET6_0_OR_GREATER var stream = new FileStream(filePath, FileMode.Open); var doc = XDocument.Load(stream); stream.Dispose(); -#else - var doc = XDocument.Load(filePath); -#endif _appConfig = new { @@ -108,12 +97,11 @@ public CommonApiTest() { if (_userRedis) { - var redisConfiguration = "localhost:6379,defaultDatabase=2"; - RedisManager.ConfigurationOption = redisConfiguration; + var redisConfiguration = "10.37.129.2:6379,defaultDatabase=2"; CacheStrategyFactory.RegisterObjectCacheStrategy(() => RedisObjectCacheStrategy.Instance);//Redis - Senparc.CO2NET.Cache.Redis.Register.UseKeyValueRedisNow();//键值对缓存策略(推荐) + Senparc.CO2NET.Cache.CsRedis.Register.UseKeyValueRedisNow();//键值对缓存策略(推荐) - Senparc.Weixin.Cache.Redis.Register.ActivityDomainCache();//进行领域缓存注册 + Senparc.Weixin.Cache.CsRedis.Register.ActivityDomainCache();//进行领域缓存注册 } diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/Senparc.Weixin.Work.Test.net8.csproj b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/Senparc.Weixin.Work.Test.net8.csproj index ab4c0d4160..90834f7767 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/Senparc.Weixin.Work.Test.net8.csproj +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work.Test/Senparc.Weixin.Work.Test.net8.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/AccessTokenContainer.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/AccessTokenContainer.cs index a6066fe673..2ab711fc96 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/AccessTokenContainer.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/AccessTokenContainer.cs @@ -156,9 +156,9 @@ public class AccessTokenContainer : BaseContainer /// corpId /// corpSecret /// 此接口无异步方法 - public static string BuildingKey(string corpId, string corpSecret) + public static string BuildingKey(string corpId, string corpSecret, bool isAgentConfig=false) { - return string.Format("{0}@{1}", corpId, corpSecret); + return $"{corpId}@{corpSecret}{(isAgentConfig?$"@@AgentConfig" :null)}"; } /// diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/JsApiTicketContainer.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/JsApiTicketContainer.cs index 6ec5c67dac..0cbb706be8 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/JsApiTicketContainer.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/JsApiTicketContainer.cs @@ -134,19 +134,6 @@ public class JsApiTicketContainer : BaseContainer { private const string UN_REGISTER_ALERT = "此AppId尚未注册,JsApiTicketContainer.Register完成注册(全局执行一次即可)!"; - /// - /// 注册应用凭证信息,此操作只是注册,不会马上获取Ticket,并将清空之前的Ticket, - /// - /// - /// - /// 标记JsApiTicket名称(如微信公众号名称),帮助管理员识别。当 name 不为 null 和 空值时,本次注册内容将会被记录到 Senparc.Weixin.Config.SenparcWeixinSetting.Items[name] 中,方便取用。 - /// 是否为“应用jsapi_ticket”,如果是某个特定应用,则输入 true(用于计算 agentConfig 的签名),否则为 false。参考: - /// 此接口无异步方法 - private static string BuildingKey(string corpId, string corpSecret, bool isAgentConfig) - { - return corpId + corpSecret + (isAgentConfig?"_AgentConfig":""); - } - #region 同步方法 /// @@ -176,7 +163,7 @@ public static void Register(string corpId, string corpSecret, string name = null /// public static string TryGetTicket(string appId, string appSecret, bool isAgentConfig, bool getNewTicket = false) { - if (!CheckRegistered(BuildingKey(appId, appSecret,isAgentConfig)) || getNewTicket) + if (!CheckRegistered(AccessTokenContainer.BuildingKey(appId, appSecret,isAgentConfig)) || getNewTicket) { Register(appId, appSecret); } @@ -203,7 +190,7 @@ public static string GetTicket(string appId, string appSecret, bool isAgentConfi /// public static JsApiTicketResult GetTicketResult(string appId, string appSecret, bool isAgentConfig, bool getNewTicket = false) { - var appKey = BuildingKey(appId, appSecret,isAgentConfig); + var appKey = AccessTokenContainer.BuildingKey(appId, appSecret,isAgentConfig); if (!CheckRegistered(appKey)) { throw new WeixinWorkException(UN_REGISTER_ALERT); @@ -253,7 +240,7 @@ public static async Task RegisterAsync(string corpId, string corpSecret, string foreach (var isAgentConfig in isAgentConfigArr) { //记录注册信息,RegisterFunc委托内的过程会在缓存丢失之后自动重试 - var appKey = BuildingKey(corpId, corpSecret, isAgentConfig); + var appKey = AccessTokenContainer.BuildingKey(corpId, corpSecret, isAgentConfig); RegisterFuncCollection[appKey] = async () => { //using (FlushCache.CreateInstance()) @@ -289,7 +276,7 @@ public static async Task RegisterAsync(string corpId, string corpSecret, string /// public static async Task TryGetTicketAsync(string appId, string appSecret, bool isAgentConfig, bool getNewTicket = false) { - if (!await CheckRegisteredAsync(BuildingKey(appId, appSecret,isAgentConfig)).ConfigureAwait(false) || getNewTicket) + if (!await CheckRegisteredAsync(AccessTokenContainer.BuildingKey(appId, appSecret,isAgentConfig)).ConfigureAwait(false) || getNewTicket) { await RegisterAsync(appId, appSecret).ConfigureAwait(false); } @@ -316,7 +303,7 @@ public static async Task GetTicketAsync(string appId, string appSecret, /// public static async Task GetTicketResultAsync(string appId, string appSecret, bool isAgentConfig, bool getNewTicket = false) { - var shortKey = BuildingKey(appId, appSecret, isAgentConfig); + var shortKey = AccessTokenContainer.BuildingKey(appId, appSecret, isAgentConfig); if (!await CheckRegisteredAsync(shortKey).ConfigureAwait(false)) { Senparc.Weixin.WeixinTrace.BaseExceptionLog(new Exception($"{UN_REGISTER_ALERT} AppId:{appId}")); diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/ProviderTokenContainer.cs b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/ProviderTokenContainer.cs index 1bcc7b2f03..928cc4e3b1 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/ProviderTokenContainer.cs +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Containers/ProviderTokenContainer.cs @@ -130,18 +130,6 @@ public class ProviderTokenContainer : BaseContainer { private const string UN_REGISTER_ALERT = "此CorpId尚未注册,ProviderTokenContainer.Register完成注册(全局执行一次即可)!"; - - /// - /// 获取全局唯一Key - /// - /// - /// - private static string BuildingKey(string corpId, string corpSecret) - { - return corpId + corpSecret; - } - - #region 同步方法 /// @@ -170,7 +158,7 @@ public static void Register(string corpId, string corpSecret, string name = null /// public static string TryGetToken(string corpId, string corpSecret, bool getNewToken = false) { - if (!CheckRegistered(BuildingKey(corpId, corpSecret)) || getNewToken) + if (!CheckRegistered(AccessTokenContainer.BuildingKey(corpId, corpSecret)) || getNewToken) { Register(corpId, corpSecret); } @@ -198,12 +186,12 @@ public static string GetToken(string corpId, string corpSecret, bool getNewToken /// public static ProviderTokenResult GetTokenResult(string corpId, string corpSecret, bool getNewToken = false) { - if (!CheckRegistered(BuildingKey(corpId, corpSecret))) + if (!CheckRegistered(AccessTokenContainer.BuildingKey(corpId, corpSecret))) { throw new WeixinWorkException(UN_REGISTER_ALERT); } - var providerTokenBag = TryGetItem(BuildingKey(corpId, corpSecret)); + var providerTokenBag = TryGetItem(AccessTokenContainer.BuildingKey(corpId, corpSecret)); lock (providerTokenBag.Lock) { if (getNewToken || providerTokenBag.ExpireTime <= SystemTime.Now) @@ -239,7 +227,7 @@ public static ProviderTokenResult GetTokenResult(string corpId, string corpSecre /// 标记AccessToken名称(如微信公众号名称),帮助管理员识别。当 name 不为 null 和 空值时,本次注册内容将会被记录到 Senparc.Weixin.Config.SenparcWeixinSetting.Items[name] 中,方便取用。 public static async Task RegisterAsync(string corpId, string corpSecret, string name = null) { - var shortKey = BuildingKey(corpId, corpSecret); + var shortKey = AccessTokenContainer.BuildingKey(corpId, corpSecret); RegisterFuncCollection[shortKey] = async () => { //using (FlushCache.CreateInstance()) @@ -252,7 +240,7 @@ public static async Task RegisterAsync(string corpId, string corpSecret, string ExpireTime = DateTimeOffset.MinValue, ProviderTokenResult = new ProviderTokenResult() }; - await UpdateAsync(BuildingKey(corpId, corpSecret), bag, null).ConfigureAwait(false); + await UpdateAsync(AccessTokenContainer.BuildingKey(corpId, corpSecret), bag, null).ConfigureAwait(false); return bag; //} }; @@ -274,7 +262,7 @@ public static async Task RegisterAsync(string corpId, string corpSecret, string /// public static async Task TryGetTokenAsync(string corpId, string corpSecret, bool getNewToken = false) { - if (!await CheckRegisteredAsync(BuildingKey(corpId, corpSecret)).ConfigureAwait(false) || getNewToken) + if (!await CheckRegisteredAsync(AccessTokenContainer.BuildingKey(corpId, corpSecret)).ConfigureAwait(false) || getNewToken) { await RegisterAsync(corpId, corpSecret).ConfigureAwait(false); } @@ -303,12 +291,12 @@ public static async Task GetTokenAsync(string corpId, string corpSecret, /// public static async Task GetTokenResultAsync(string corpId, string corpSecret, bool getNewToken = false) { - if (!await CheckRegisteredAsync(BuildingKey(corpId, corpSecret)).ConfigureAwait(false)) + if (!await CheckRegisteredAsync(AccessTokenContainer.BuildingKey(corpId, corpSecret)).ConfigureAwait(false)) { throw new WeixinWorkException(UN_REGISTER_ALERT); } - var providerTokenBag = await TryGetItemAsync(BuildingKey(corpId, corpSecret)).ConfigureAwait(false); + var providerTokenBag = await TryGetItemAsync(AccessTokenContainer.BuildingKey(corpId, corpSecret)).ConfigureAwait(false); //lock (providerTokenBag.Lock) { if (getNewToken || providerTokenBag.ExpireTime <= DateTimeOffset.Now) diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj index d29779cecd..8747b93eb8 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj @@ -2,7 +2,7 @@ net462;netstandard2.0;netstandard2.1 - 3.22.2 + 3.23.0 10.0 Senparc.Weixin.Work Senparc.Weixin.Work @@ -213,6 +213,7 @@ v3.20.0 模板卡片点击回调事件(PR #2997) [2024-08-06] v3.21.4 更新基础库,包括 Senparc.CO2NET 相关库、Senparc.AI [2024-08-12] v3.22.2 Work:增加获客链接管理接口 #3060 + [2024-09-29] v3.23.0 更新并同意 BuildingKey 方法,构建一致的 AppKey https://github.com/JeffreySu/WeiXinMPSDK False From 4ff4283a9462910d94f0d75229c43996ed246c2d Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Sun, 29 Sep 2024 22:52:51 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 3159690fe8..c63879ca9e 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,5 @@ yarn.lock /Samples/Work/Senparc.Weixin.Sample.Work/App_Data/WeChat_Work /Samples/All/net8-mvc/Senparc.Weixin.Sample.Net8/appsettings.Development.json /Samples/MP/Senparc.Weixin.Sample.MP.Simple/appsettings.Development.json +/src/Senparc.Weixin.MP/Senparc.Weixin.MP.Test/AdvancedAPIs/Media/*.jpg +/src/Senparc.Weixin.MP/Senparc.Weixin.MP.Test/*.jpg From d651536e9a81bf41c395f81ac8e181fbb4fa21e5 Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Sun, 29 Sep 2024 23:29:03 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Console=20Sample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ....Net8SampleForConsole.CommonService.csproj | 23 ++++++----- ...Senparc.Weixin.MP.Sample.Consoles.NET8.sln | 40 +++++++++---------- .../Program.cs | 18 +++++---- .../Senparc.Weixin.MP.Sample.Consoles.csproj | 37 +++++++++-------- 4 files changed, 63 insertions(+), 55 deletions(-) diff --git a/Samples/All/Senparc.Weixin.Sample.CommonService/Senparc.Weixin.Net8SampleForConsole.CommonService.csproj b/Samples/All/Senparc.Weixin.Sample.CommonService/Senparc.Weixin.Net8SampleForConsole.CommonService.csproj index ab77c96711..f1a02990e8 100644 --- a/Samples/All/Senparc.Weixin.Sample.CommonService/Senparc.Weixin.Net8SampleForConsole.CommonService.csproj +++ b/Samples/All/Senparc.Weixin.Sample.CommonService/Senparc.Weixin.Net8SampleForConsole.CommonService.csproj @@ -19,9 +19,10 @@ - + + - + @@ -30,15 +31,15 @@ - - - - - - - - - + + + + + + + + + diff --git a/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles.NET8.sln b/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles.NET8.sln index 53b5b5fcc6..b3bbc9d0c1 100644 --- a/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles.NET8.sln +++ b/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles.NET8.sln @@ -9,7 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{DCF86D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.MP.Sample.Consoles", "Senparc.Weixin.MP.Sample.Consoles\Senparc.Weixin.MP.Sample.Consoles.csproj", "{1E843726-DB24-464D-A6A9-5607B197D807}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Net8SampleForConsole.CommonService", "Y:\Senparc 项目\WeiXinMPSDK\Samples\All\Senparc.Weixin.Sample.CommonService\Senparc.Weixin.Net8SampleForConsole.CommonService.csproj", "{E646F86A-065D-4991-9E96-6E1346E904B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Net8SampleForConsole.CommonService", "..\Senparc.Weixin.Sample.CommonService\Senparc.Weixin.Net8SampleForConsole.CommonService.csproj", "{CF37F455-9DA8-401D-AE7F-E96CDC912984}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -42,31 +42,31 @@ Global {1E843726-DB24-464D-A6A9-5607B197D807}.Test|x64.Build.0 = Debug|Any CPU {1E843726-DB24-464D-A6A9-5607B197D807}.Test|x86.ActiveCfg = Debug|Any CPU {1E843726-DB24-464D-A6A9-5607B197D807}.Test|x86.Build.0 = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Debug|x64.ActiveCfg = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Debug|x64.Build.0 = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Debug|x86.ActiveCfg = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Debug|x86.Build.0 = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Release|Any CPU.Build.0 = Release|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Release|x64.ActiveCfg = Release|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Release|x64.Build.0 = Release|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Release|x86.ActiveCfg = Release|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Release|x86.Build.0 = Release|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Test|Any CPU.ActiveCfg = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Test|Any CPU.Build.0 = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Test|x64.ActiveCfg = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Test|x64.Build.0 = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Test|x86.ActiveCfg = Debug|Any CPU - {E646F86A-065D-4991-9E96-6E1346E904B1}.Test|x86.Build.0 = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Debug|x64.ActiveCfg = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Debug|x64.Build.0 = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Debug|x86.ActiveCfg = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Debug|x86.Build.0 = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Release|Any CPU.Build.0 = Release|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Release|x64.ActiveCfg = Release|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Release|x64.Build.0 = Release|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Release|x86.ActiveCfg = Release|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Release|x86.Build.0 = Release|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Test|Any CPU.ActiveCfg = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Test|Any CPU.Build.0 = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Test|x64.ActiveCfg = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Test|x64.Build.0 = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Test|x86.ActiveCfg = Debug|Any CPU + {CF37F455-9DA8-401D-AE7F-E96CDC912984}.Test|x86.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {1E843726-DB24-464D-A6A9-5607B197D807} = {35139CB3-610E-4922-98AD-08A5D12BFC35} - {E646F86A-065D-4991-9E96-6E1346E904B1} = {35139CB3-610E-4922-98AD-08A5D12BFC35} + {CF37F455-9DA8-401D-AE7F-E96CDC912984} = {35139CB3-610E-4922-98AD-08A5D12BFC35} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DC7AD3EC-AB37-497E-925B-DCD5129FE6D3} diff --git a/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Program.cs b/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Program.cs index fe0b443955..2012754229 100644 --- a/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Program.cs +++ b/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Program.cs @@ -50,11 +50,9 @@ and limitations under the License. var config = builder.Build(); Console.WriteLine("完成 ServiceCollection 和 ConfigurationBuilder 初始化"); -//更多绑定操作参见:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-2.2 -var senparcSetting = new SenparcSetting(); -var senparcWeixinSetting = new SenparcWeixinSetting(); -config.GetSection("SenparcSetting").Bind(senparcSetting); -config.GetSection("SenparcWeixinSetting").Bind(senparcWeixinSetting); +//更多绑定操作参见:https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0 +var senparcSetting = config.GetSection("SenparcSetting").Get(); +var senparcWeixinSetting = config.GetSection("SenparcWeixinSetting").Get< SenparcWeixinSetting>(); var services = new ServiceCollection(); services.AddMemoryCache();//使用本地缓存必须添加 @@ -76,8 +74,8 @@ and limitations under the License. //启用微信配置(必须) var registerService = app.UseSenparcWeixin( - null /* 不为 null 则覆盖 appsettings 中的 SenpacSetting 配置*/, - null /* 不为 null 则覆盖 appsettings 中的 SenpacWeixinSetting 配置*/, + senparcSetting /* 不为 null 则覆盖 appsettings 中的 SenpacSetting 配置*/, + senparcWeixinSetting /* 不为 null 则覆盖 appsettings 中的 SenpacWeixinSetting 配置*/, register => { /* CO2NET 全局配置 */ }, (register, weixinSetting) => { @@ -91,4 +89,8 @@ and limitations under the License. var weixinSetting = Senparc.Weixin.Config.SenparcWeixinSetting; -Console.WriteLine(weixinSetting.Items["【盛派网络小助手】公众号"].ToJson(true)); \ No newline at end of file +Console.WriteLine(weixinSetting.ToJson(true, new Newtonsoft.Json.JsonSerializerSettings() { ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore })); +Console.WriteLine(); +//Console.WriteLine(weixinSetting.Items["【盛派网络小助手】公众号"].ToJson(true)); + +Console.ReadLine(); \ No newline at end of file diff --git a/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Senparc.Weixin.MP.Sample.Consoles.csproj b/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Senparc.Weixin.MP.Sample.Consoles.csproj index be413c017c..25457ec402 100644 --- a/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Senparc.Weixin.MP.Sample.Consoles.csproj +++ b/Samples/All/console/Senparc.Weixin.MP.Sample.Consoles/Senparc.Weixin.MP.Sample.Consoles.csproj @@ -6,28 +6,33 @@ - - - - - - - - - - - - + - + + PreserveNewest + - - PreserveNewest - + + + + + + + + + + + + + + + + + From 714b8538db4074e9e8da6969af77373f776bc56f Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Sun, 29 Sep 2024 23:55:43 +0800 Subject: [PATCH 5/5] =?UTF-8?q?[2024-09-29]=20v6.20.0=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?WeixinRegister.UseSenparcWeixin()=20=E6=96=B9=E6=B3=95=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20Console=20=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E5=AE=8C=E6=88=90=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Senparc.WebSocket.net8.csproj | 2 +- .../Senparc.Weixin.All.csproj | 4 +- .../Senparc.Weixin.AspNet.net8.csproj | 2 +- .../Senparc.Weixin.Cache.CsRedis.net8.csproj | 2 +- .../Senparc.Weixin.Cache.Dapr.net8.csproj | 2 +- ...Senparc.Weixin.Cache.Memcached.net8.csproj | 2 +- .../Senparc.Weixin.Cache.Redis.net8.csproj | 2 +- .../Senparc.Weixin.MP.Middleware.net8.csproj | 2 +- ...Senparc.Weixin.MP.MvcExtension.net8.csproj | 2 +- .../Senparc.Weixin.MP.net8.csproj | 2 +- .../Senparc.Weixin.Open.net8.csproj | 4 +- .../Senparc.Weixin.TenPay.net8.csproj | 2 +- .../Senparc.Weixin.TenPayV3.net8.csproj | 2 +- ...Senparc.Weixin.Work.Middleware.net8.csproj | 2 +- .../Senparc.Weixin.Work.net8.csproj | 16 +- ...nparc.Weixin.WxOpen.Middleware.net8.csproj | 2 +- .../Senparc.Weixin.WxOpen.net8.csproj | 2 +- .../Senparc.Weixin/Senparc.Weixin.net8.csproj | 174 +++++++++--------- .../Senparc.Weixin/WeixinRegister.cs | 5 +- 19 files changed, 117 insertions(+), 114 deletions(-) diff --git a/src/Senparc.WebSocket/src/Senparc.WebSocket/Senparc.WebSocket/Senparc.WebSocket.net8.csproj b/src/Senparc.WebSocket/src/Senparc.WebSocket/Senparc.WebSocket/Senparc.WebSocket.net8.csproj index 1de4a632ce..f84e1e9b25 100644 --- a/src/Senparc.WebSocket/src/Senparc.WebSocket/Senparc.WebSocket/Senparc.WebSocket.net8.csproj +++ b/src/Senparc.WebSocket/src/Senparc.WebSocket/Senparc.WebSocket/Senparc.WebSocket.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1;netcoreapp3.1;net8.0 - 1.0.1 + 1.0.2 Senparc.WebSocket Senparc.WebSocket true diff --git a/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj b/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj index fa9b97eead..262aab9165 100644 --- a/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj +++ b/src/Senparc.Weixin.All/Senparc.Weixin.All.csproj @@ -3,7 +3,7 @@ net8.0 enable enable - 2024.9.10 + 2024.9.11 10.0 Senparc.Weixin.All Senparc.Weixin.All @@ -47,7 +47,7 @@ [2024-08-12] v2024.8.12 升级 Senparc.Weixin.Work [2024-09-02] v2024.9.2 WxOpen 支持小程序付费能力的用量告警事件 [2024-09-10] v2024.9.10 更新基础库,包括缓存、APM、CO2NET 核心模块等全面升级 - + https://github.com/JeffreySu/WeiXinMPSDK diff --git a/src/Senparc.Weixin.AspNet/Senparc.Weixin.AspNet.net8.csproj b/src/Senparc.Weixin.AspNet/Senparc.Weixin.AspNet.net8.csproj index 319ff4c680..7e2fba84b1 100644 --- a/src/Senparc.Weixin.AspNet/Senparc.Weixin.AspNet.net8.csproj +++ b/src/Senparc.Weixin.AspNet/Senparc.Weixin.AspNet.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 1.3.2 + 1.3.3 Senparc.Weixin.AspNet Senparc.Weixin.AspNet diff --git a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.CsRedis/Senparc.Weixin.Cache.CsRedis.net8.csproj b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.CsRedis/Senparc.Weixin.Cache.CsRedis.net8.csproj index 4dcd77116d..9765ec3b1f 100644 --- a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.CsRedis/Senparc.Weixin.Cache.CsRedis.net8.csproj +++ b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.CsRedis/Senparc.Weixin.Cache.CsRedis.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 1.0.1 + 1.0.2 Senparc.Weixin.Cache.CsRedis Senparc.Weixin.Cache.CsRedis true diff --git a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Dapr/Senparc.Weixin.Cache.Dapr.net8.csproj b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Dapr/Senparc.Weixin.Cache.Dapr.net8.csproj index c1776f6748..ea6a6f3933 100644 --- a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Dapr/Senparc.Weixin.Cache.Dapr.net8.csproj +++ b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Dapr/Senparc.Weixin.Cache.Dapr.net8.csproj @@ -1,7 +1,7 @@ net8.0 - 0.1.1-beta1 + 0.1.2-beta1 Senparc.Weixin.Cache.Dapr Senparc.Weixin.Cache.Dapr true diff --git a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Memcached/Senparc.Weixin.Cache.Memcached.net8.csproj b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Memcached/Senparc.Weixin.Cache.Memcached.net8.csproj index 7148d9dc45..dd91c5f61f 100644 --- a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Memcached/Senparc.Weixin.Cache.Memcached.net8.csproj +++ b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Memcached/Senparc.Weixin.Cache.Memcached.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 2.17.2 + 2.17.3 Senparc.Weixin.Cache.Memcached Senparc.Weixin.Cache.Memcached diff --git a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Redis/Senparc.Weixin.Cache.Redis.net8.csproj b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Redis/Senparc.Weixin.Cache.Redis.net8.csproj index 07b3a0ada6..91c3977de3 100644 --- a/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Redis/Senparc.Weixin.Cache.Redis.net8.csproj +++ b/src/Senparc.Weixin.Cache/Senparc.Weixin.Cache.Redis/Senparc.Weixin.Cache.Redis.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 2.19.2 + 2.19.3 Senparc.Weixin.Cache.Redis Senparc.Weixin.Cache.Redis true diff --git a/src/Senparc.Weixin.MP.Middleware/Senparc.Weixin.MP.Middleware.net8.csproj b/src/Senparc.Weixin.MP.Middleware/Senparc.Weixin.MP.Middleware.net8.csproj index 532865f33e..3257c3f971 100644 --- a/src/Senparc.Weixin.MP.Middleware/Senparc.Weixin.MP.Middleware.net8.csproj +++ b/src/Senparc.Weixin.MP.Middleware/Senparc.Weixin.MP.Middleware.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1;netcoreapp3.1;net8.0 - 1.3.2 + 1.3.3 Senparc.Weixin.MP.Middleware Senparc.Weixin.MP.Middleware true diff --git a/src/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension.net8.csproj b/src/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension.net8.csproj index c1ae64d419..c654dd8a4e 100644 --- a/src/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension.net8.csproj +++ b/src/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension/Senparc.Weixin.MP.MvcExtension.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1;netcoreapp3.1;net8.0 - 7.15.2 + 7.15.3 Senparc.Weixin.MP.MvcExtension Senparc.Weixin.MP.MvcExtension true diff --git a/src/Senparc.Weixin.MP/Senparc.Weixin.MP/Senparc.Weixin.MP.net8.csproj b/src/Senparc.Weixin.MP/Senparc.Weixin.MP/Senparc.Weixin.MP.net8.csproj index 6438994507..528b8855cd 100644 --- a/src/Senparc.Weixin.MP/Senparc.Weixin.MP/Senparc.Weixin.MP.net8.csproj +++ b/src/Senparc.Weixin.MP/Senparc.Weixin.MP/Senparc.Weixin.MP.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 16.22.2 + 16.22.3 Senparc.Weixin.MP Senparc.Weixin.MP true diff --git a/src/Senparc.Weixin.Open/Senparc.Weixin.Open/Senparc.Weixin.Open.net8.csproj b/src/Senparc.Weixin.Open/Senparc.Weixin.Open/Senparc.Weixin.Open.net8.csproj index 674007a98c..8176fb8d20 100644 --- a/src/Senparc.Weixin.Open/Senparc.Weixin.Open/Senparc.Weixin.Open.net8.csproj +++ b/src/Senparc.Weixin.Open/Senparc.Weixin.Open/Senparc.Weixin.Open.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 4.20.2 + 4.20.3 Senparc.Weixin.Open Senparc.Weixin.Open true @@ -226,7 +226,7 @@ [2024-08-06] v4.18.4 更新基础库,包括 Senparc.CO2NET 相关库、Senparc.AI [2024-08-11] v4.20.0.0 1、添加查询小程序是否已完成交易结算管理确认 2、添加第三方小程序订单页设置结果及审核结果事件通知 #3055 感谢 @mc7246 [2024-09-10] v4.20.2 icp verifytask 接口 data 不能为 null 的问题处理 #3067 感谢 @mojinxun - + https://github.com/JeffreySu/WeiXinMPSDK diff --git a/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay.net8.csproj b/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay.net8.csproj index 61150d75ff..b97e221fa6 100644 --- a/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay.net8.csproj +++ b/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay/Senparc.Weixin.TenPay.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 1.16.2 + 1.16.3 Senparc.Weixin.TenPay Senparc.Weixin.TenPay true diff --git a/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Senparc.Weixin.TenPayV3.net8.csproj b/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Senparc.Weixin.TenPayV3.net8.csproj index d187dfd424..df480b284e 100644 --- a/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Senparc.Weixin.TenPayV3.net8.csproj +++ b/src/Senparc.Weixin.TenPay/Senparc.Weixin.TenPayV3/Senparc.Weixin.TenPayV3.net8.csproj @@ -1,7 +1,7 @@ netstandard2.1 - 1.6.3 + 1.6.4 Senparc.Weixin.TenPayV3 Senparc.Weixin.TenPayV3 10.0 diff --git a/src/Senparc.Weixin.Work.Middleware/Senparc.Weixin.Work.Middleware.net8.csproj b/src/Senparc.Weixin.Work.Middleware/Senparc.Weixin.Work.Middleware.net8.csproj index 8cf0093249..9764507771 100644 --- a/src/Senparc.Weixin.Work.Middleware/Senparc.Weixin.Work.Middleware.net8.csproj +++ b/src/Senparc.Weixin.Work.Middleware/Senparc.Weixin.Work.Middleware.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1;netcoreapp3.1;net8.0 - 1.3.2 + 1.3.3 Senparc.Weixin.Work.Middleware Senparc.Weixin.Work.Middleware true diff --git a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj index 3c46ec4f6d..c65f89e3b8 100644 --- a/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj +++ b/src/Senparc.Weixin.Work/Senparc.Weixin.Work/Senparc.Weixin.Work.net8.csproj @@ -1,12 +1,12 @@ - - net462;netstandard2.0;netstandard2.1 - 3.23.0 - 10.0 - Senparc.Weixin.Work - Senparc.Weixin.Work - true - + + net462;netstandard2.0;netstandard2.1 + 3.23.1 + 10.0 + Senparc.Weixin.Work + Senparc.Weixin.Work + true + 微信 SDK - 企业微信 模块 Senparc.Weixin SDK 开源项目: diff --git a/src/Senparc.Weixin.WxOpen.Middleware/Senparc.Weixin.WxOpen.Middleware.net8.csproj b/src/Senparc.Weixin.WxOpen.Middleware/Senparc.Weixin.WxOpen.Middleware.net8.csproj index e5dd72a72b..876c7eae26 100644 --- a/src/Senparc.Weixin.WxOpen.Middleware/Senparc.Weixin.WxOpen.Middleware.net8.csproj +++ b/src/Senparc.Weixin.WxOpen.Middleware/Senparc.Weixin.WxOpen.Middleware.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1;netcoreapp3.1;net8.0 - 1.3.2 + 1.3.3 Senparc.Weixin.WxOpen.Middleware Senparc.Weixin.WxOpen.Middleware true diff --git a/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen.net8.csproj b/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen.net8.csproj index 0b8e56a277..e40f1324ec 100644 --- a/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen.net8.csproj +++ b/src/Senparc.Weixin.WxOpen/src/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen/Senparc.Weixin.WxOpen.net8.csproj @@ -1,7 +1,7 @@ net462;netstandard2.0;netstandard2.1 - 3.20.3 + 3.20.4 9.0 Senparc.Weixin.WxOpen Senparc.Weixin.WxOpen diff --git a/src/Senparc.Weixin/Senparc.Weixin/Senparc.Weixin.net8.csproj b/src/Senparc.Weixin/Senparc.Weixin/Senparc.Weixin.net8.csproj index dc91c2881e..2f867f1534 100644 --- a/src/Senparc.Weixin/Senparc.Weixin/Senparc.Weixin.net8.csproj +++ b/src/Senparc.Weixin/Senparc.Weixin/Senparc.Weixin.net8.csproj @@ -1,29 +1,30 @@ + - - net462;netstandard2.0;netstandard2.1 - - 6.19.2 - 10.0 - Senparc.Weixin - Senparc.Weixin - true - + + net462;netstandard2.0;netstandard2.1 + + 6.20.0 + 10.0 + Senparc.Weixin + Senparc.Weixin + true + 微信 SDK - Senparc.Weixin SDK 基础模块 Senparc.Weixin SDK 开源项目: https://github.com/JeffreySu/WeiXinMPSDK - Senparc Copyright © 2004~2024 - 微信,weixin,公众号,WeChat,Senparc,盛派,SDK,C#,JSSDK,微信支付,分布式,小程序,Cache,Redis - Jeffrey Su - Senparc - Apache-2.0 - https://github.com/JeffreySu/WeiXinMPSDK - Senparc.Weixin.dll - 微信 SDK for .NET / C# - https://github.com/JeffreySu/WeiXinMPSDK - icon.jpg - + Senparc Copyright © 2004~2024 + 微信,weixin,公众号,WeChat,Senparc,盛派,SDK,C#,JSSDK,微信支付,分布式,小程序,Cache,Redis + Jeffrey Su + Senparc + Apache-2.0 + https://github.com/JeffreySu/WeiXinMPSDK + Senparc.Weixin.dll + 微信 SDK for .NET / C# + https://github.com/JeffreySu/WeiXinMPSDK + icon.jpg + v1.0.0 重构代码,从原来的Senparc.Weixin.MP.dll中分离基类代码 @@ -338,71 +339,72 @@ v6.15.8.6 AddCertHttpClient.AddCertHttpClient() 方法添加对 certPath 为 null 的判断 v6.17.1 添加 app.UseSenparcWeixin() 扩展方法 [2024-08-06] v6.18.4 更新基础库,包括 Senparc.CO2NET 相关库、Senparc.AI + [2024-09-29] v6.20.0 更新WeixinRegister.UseSenparcWeixin() 方法,修复 Console 模式下无法完成自定义注册的问题 - https://github.com/JeffreySu/WeiXinMPSDK - - - ..\..\BuildOutPut - TRACE;RELEASE - - - ..\..\BuildOutPut - $(DefineConstants);RELEASE - ..\..\BuildOutPut\Senparc.Weixin.XML - true - pdbonly - prompt - MinimumRecommendedRules.ruleset - - - ..\..\BuildOutPut\ - ..\..\BuildOutPut\net462\Senparc.Weixin.xml - - - ..\..\BuildOutPut\ - ..\..\BuildOutPut\netstandard2.0\Senparc.Weixin.xml - - - ..\..\BuildOutPut\ - ..\..\BuildOutPut\netstandard2.1\Senparc.Weixin.xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + https://github.com/JeffreySu/WeiXinMPSDK + + + ..\..\BuildOutPut + TRACE;RELEASE + + + ..\..\BuildOutPut + $(DefineConstants);RELEASE + ..\..\BuildOutPut\Senparc.Weixin.XML + true + pdbonly + prompt + MinimumRecommendedRules.ruleset + + + ..\..\BuildOutPut\ + ..\..\BuildOutPut\net462\Senparc.Weixin.xml + + + ..\..\BuildOutPut\ + ..\..\BuildOutPut\netstandard2.0\Senparc.Weixin.xml + + + ..\..\BuildOutPut\ + ..\..\BuildOutPut\netstandard2.1\Senparc.Weixin.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Senparc.Weixin/Senparc.Weixin/WeixinRegister.cs b/src/Senparc.Weixin/Senparc.Weixin/WeixinRegister.cs index f19ba853d0..07d65f87f1 100644 --- a/src/Senparc.Weixin/Senparc.Weixin/WeixinRegister.cs +++ b/src/Senparc.Weixin/Senparc.Weixin/WeixinRegister.cs @@ -93,7 +93,7 @@ public static class WeixinRegister /// 微信全局设置参数,必填 /// 用于提供 SenparcSetting.Cache_Redis_Configuration 和 Cache_Memcached_Configuration 两个参数,如果不使用这两种分布式缓存可传入null /// - public static IRegisterService UseSenparcWeixin(this IRegisterService registerService, SenparcWeixinSetting senparcWeixinSetting, SenparcSetting senparcSetting = null) + public static IRegisterService UseSenparcWeixin(this IRegisterService registerService, SenparcWeixinSetting senparcWeixinSetting, SenparcSetting senparcSetting = null, Action weixinRegisterConfigure=null) { senparcWeixinSetting = senparcWeixinSetting ?? new SenparcWeixinSetting(); senparcSetting = (senparcSetting ?? CO2NET.Config.SenparcSetting) ?? new SenparcSetting(); @@ -177,6 +177,7 @@ public static IRegisterService UseSenparcWeixin(this IRegisterService registerSe /* 扩展缓存注册结束 */ /* 自动注册所有平台开始 */ + weixinRegisterConfigure?.Invoke(registerService, senparcWeixinSetting); return registerService; } @@ -209,7 +210,7 @@ public static IRegisterService UseSenparcWeixin(this IConfigurationRoot app, //注册 CO2NET 全局 var register = app.UseSenparcGlobal(senparcSetting, globalRegisterConfigure, autoScanExtensionCacheStrategies, extensionCacheStrategiesFunc); - return WeixinRegister.UseSenparcWeixin(register.registerService, senparcWeixinSetting, senparcSetting); + return WeixinRegister.UseSenparcWeixin(register.registerService, senparcWeixinSetting, senparcSetting, weixinRegisterConfigure); } #endif