From fe6668386465268b243bfabf18d9acdfc65962ee Mon Sep 17 00:00:00 2001 From: JeffreySu Date: Wed, 18 Dec 2024 12:26:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20Sample=EF=BC=8C=E6=89=B9?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8F=91=E5=B8=83=E5=8D=95=E4=B8=AA=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E7=9A=84=20Sample?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .../MessageHandlers/CustomMessageHandler.cs | 3 +++ .../Views/Home/Index.cshtml | 2 +- Samples/MP/Senparc.Weixin.Sample.MP.sln | 2 +- .../Controllers/WeixinController.cs | 5 ++++- .../MessageHandlers/CustomMessageHandler.cs | 5 +++++ .../CustomMessageHandler_Events.cs | 1 + .../Senparc.Weixin.Sample.MP.net8.csproj | 1 - .../Views/Home/Index.cshtml | 2 +- .../GlobalUsing.cs | 5 +++++ .../Senparc.Weixin.Sample.TenPayV2/Program.cs | 4 +++- ...Senparc.Weixin.Sample.TenPayV2.net8.csproj | 1 - .../Senparc.Weixin.Sample.TenPayV3/Program.cs | 8 +++++++- ...Senparc.Weixin.Sample.TenPayV3.net8.csproj | 1 - .../Senparc.Weixin.Sample.Work/Program.cs | 5 +++++ .../Senparc.Weixin.Sample.Work.net8.csproj | 1 - .../Senparc.Weixin.Sample.WxOpen/Program.cs | 6 ++++++ .../Senparc.Weixin.Sample.WxOpen.net8.csproj | 1 - Samples/sample-publish.bat | 19 ++++++++++++------- 19 files changed, 55 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 743db65639..7c004b3406 100644 --- a/.gitignore +++ b/.gitignore @@ -67,4 +67,4 @@ yarn.lock /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 -/Samples/SamplePublish/TenPayV3/net8.0 +/Samples/SamplePublish/ diff --git a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/MessageHandlers/CustomMessageHandler.cs b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/MessageHandlers/CustomMessageHandler.cs index 0aa4894583..099c02c45c 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/MessageHandlers/CustomMessageHandler.cs +++ b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/MessageHandlers/CustomMessageHandler.cs @@ -20,6 +20,9 @@ using Senparc.Weixin.MP.Entities.Request; using Senparc.Weixin.MP.MessageContexts; using Senparc.Weixin.MP.MessageHandlers; +using System; +using System.IO; +using System.Threading.Tasks; namespace Senparc.Weixin.Sample.MP { diff --git a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Views/Home/Index.cshtml b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Views/Home/Index.cshtml index 574d1d243c..2a280dc817 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Views/Home/Index.cshtml +++ b/Samples/MP/Senparc.Weixin.Sample.MP.Simple/Views/Home/Index.cshtml @@ -382,7 +382,7 @@ var result = await Senparc.Weixin.MP.AdvancedAPIs.UserApi.GetAsync(accessToken); wx.ready(function () { var url = '@(Context.Request.Scheme)://sdk.weixin.senparc.com'; - var link = url + '@(Context.Request.PathAndQuery())'; + var link = url + '@(Context.Request.Path + Context.Request.QueryString)'; var imgUrl = url + '/images/v2/ewm_01.png'; //转发到朋友圈 diff --git a/Samples/MP/Senparc.Weixin.Sample.MP.sln b/Samples/MP/Senparc.Weixin.Sample.MP.sln index 1dd87c1ad8..f38b9da116 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP.sln +++ b/Samples/MP/Senparc.Weixin.Sample.MP.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.MP", "Senparc.Weixin.Sample.MP\Senparc.Weixin.Sample.MP.csproj", "{99EEB8CC-FE5E-4A1D-80C2-9A0C1FA757BD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.MP", "Senparc.Weixin.Sample.MP\Senparc.Weixin.Sample.MP.net8.csproj", "{99EEB8CC-FE5E-4A1D-80C2-9A0C1FA757BD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.MP.Simple", "Senparc.Weixin.Sample.MP.Simple\Senparc.Weixin.Sample.MP.Simple.csproj", "{4A5EF3E4-3466-49C6-8A16-85EA6BD781BF}" EndProject diff --git a/Samples/MP/Senparc.Weixin.Sample.MP/Controllers/WeixinController.cs b/Samples/MP/Senparc.Weixin.Sample.MP/Controllers/WeixinController.cs index 4d31b02d72..5a4dce18fd 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP/Controllers/WeixinController.cs +++ b/Samples/MP/Senparc.Weixin.Sample.MP/Controllers/WeixinController.cs @@ -34,7 +34,10 @@ namespace Senparc.Weixin.Sample.MP.Controllers using Senparc.Weixin.MP; using Senparc.Weixin.MP.Entities.Request; using Senparc.Weixin.MP.MvcExtension; - + using System; + using System.IO; + using System.Threading; + using System.Threading.Tasks; public partial class WeixinController : BaseController { diff --git a/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler.cs b/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler.cs index a21b365636..99c2516691 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler.cs +++ b/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler.cs @@ -25,6 +25,11 @@ using Senparc.Weixin.MP.Entities.Request; using Senparc.Weixin.MP.MessageContexts; using Senparc.Weixin.MP.MessageHandlers; +using System; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace Senparc.Weixin.Sample.MP { diff --git a/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler_Events.cs b/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler_Events.cs index ac9996591b..c1de9f7f34 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler_Events.cs +++ b/Samples/MP/Senparc.Weixin.Sample.MP/MessageHandlers/CustomMessageHandler_Events.cs @@ -16,6 +16,7 @@ using Senparc.Weixin.MP.AdvancedAPIs; using Senparc.Weixin.MP.Entities; using System.Diagnostics; +using System.Threading.Tasks; namespace Senparc.Weixin.Sample.MP diff --git a/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.net8.csproj b/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.net8.csproj index d12dd14a79..9b39fbd9dd 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.net8.csproj +++ b/Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.net8.csproj @@ -7,7 +7,6 @@ true - $(SolutionDir)\..\..\SamplePublish\MP diff --git a/Samples/MP/Senparc.Weixin.Sample.MP/Views/Home/Index.cshtml b/Samples/MP/Senparc.Weixin.Sample.MP/Views/Home/Index.cshtml index 574d1d243c..2a280dc817 100644 --- a/Samples/MP/Senparc.Weixin.Sample.MP/Views/Home/Index.cshtml +++ b/Samples/MP/Senparc.Weixin.Sample.MP/Views/Home/Index.cshtml @@ -382,7 +382,7 @@ var result = await Senparc.Weixin.MP.AdvancedAPIs.UserApi.GetAsync(accessToken); wx.ready(function () { var url = '@(Context.Request.Scheme)://sdk.weixin.senparc.com'; - var link = url + '@(Context.Request.PathAndQuery())'; + var link = url + '@(Context.Request.Path + Context.Request.QueryString)'; var imgUrl = url + '/images/v2/ewm_01.png'; //转发到朋友圈 diff --git a/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/GlobalUsing.cs b/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/GlobalUsing.cs index 57d31a91a3..16687ffe6a 100644 --- a/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/GlobalUsing.cs +++ b/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/GlobalUsing.cs @@ -7,3 +7,8 @@ global using Microsoft.Extensions.Options; global using Senparc.Weixin.Entities; global using Microsoft.Extensions.FileProviders; +global using Microsoft.AspNetCore.Builder; +global using Microsoft.AspNetCore.Http; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Hosting; +global using System.IO; \ No newline at end of file diff --git a/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Program.cs b/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Program.cs index 368ba19986..2c78a0e6ca 100644 --- a/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Program.cs +++ b/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Program.cs @@ -1,4 +1,6 @@ -var builder = WebApplication.CreateBuilder(args); +using Senparc.Weixin.RegisterServices; + +var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); diff --git a/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Senparc.Weixin.Sample.TenPayV2.net8.csproj b/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Senparc.Weixin.Sample.TenPayV2.net8.csproj index d9d010e2b5..ab134a3fa5 100644 --- a/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Senparc.Weixin.Sample.TenPayV2.net8.csproj +++ b/Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Senparc.Weixin.Sample.TenPayV2.net8.csproj @@ -7,7 +7,6 @@ true - $(SolutionDir)\..\SamplePublish\TenPayV2 diff --git a/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Program.cs b/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Program.cs index 8cf23ad5c6..6c5d3c2e5c 100644 --- a/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Program.cs +++ b/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Program.cs @@ -1,4 +1,10 @@ -var builder = WebApplication.CreateBuilder(args); +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System.IO; + +var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); diff --git a/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Senparc.Weixin.Sample.TenPayV3.net8.csproj b/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Senparc.Weixin.Sample.TenPayV3.net8.csproj index e7265ba466..36a830c608 100644 --- a/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Senparc.Weixin.Sample.TenPayV3.net8.csproj +++ b/Samples/TenPayV3/Senparc.Weixin.Sample.TenPayV3/Senparc.Weixin.Sample.TenPayV3.net8.csproj @@ -7,7 +7,6 @@ true - $(SolutionDir)\..\SamplePublish\TenPayV3 diff --git a/Samples/Work/Senparc.Weixin.Sample.Work/Program.cs b/Samples/Work/Senparc.Weixin.Sample.Work/Program.cs index 1ccce656db..9872a5140d 100644 --- a/Samples/Work/Senparc.Weixin.Sample.Work/Program.cs +++ b/Samples/Work/Senparc.Weixin.Sample.Work/Program.cs @@ -1,4 +1,9 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Senparc.Weixin.Work.Containers; +using System.IO; var builder = WebApplication.CreateBuilder(args); diff --git a/Samples/Work/Senparc.Weixin.Sample.Work/Senparc.Weixin.Sample.Work.net8.csproj b/Samples/Work/Senparc.Weixin.Sample.Work/Senparc.Weixin.Sample.Work.net8.csproj index 92fc3c25ea..c0d9dd1c4f 100644 --- a/Samples/Work/Senparc.Weixin.Sample.Work/Senparc.Weixin.Sample.Work.net8.csproj +++ b/Samples/Work/Senparc.Weixin.Sample.Work/Senparc.Weixin.Sample.Work.net8.csproj @@ -7,7 +7,6 @@ true - $(SolutionDir)\..\SamplePublish\Work diff --git a/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Program.cs b/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Program.cs index 30fef9f80a..44510f2862 100644 --- a/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Program.cs +++ b/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Program.cs @@ -1,3 +1,9 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System.IO; + var builder = WebApplication.CreateBuilder(args); // Add services to the container. diff --git a/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Senparc.Weixin.Sample.WxOpen.net8.csproj b/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Senparc.Weixin.Sample.WxOpen.net8.csproj index 0f788b5b74..9a140031c1 100644 --- a/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Senparc.Weixin.Sample.WxOpen.net8.csproj +++ b/Samples/WxOpen/Senparc.Weixin.Sample.WxOpen/Senparc.Weixin.Sample.WxOpen.net8.csproj @@ -7,7 +7,6 @@ true - $(SolutionDir)\..\SamplePublish\WxOpen diff --git a/Samples/sample-publish.bat b/Samples/sample-publish.bat index becd23c4ba..ff1bfc850a 100644 --- a/Samples/sample-publish.bat +++ b/Samples/sample-publish.bat @@ -1,15 +1,20 @@ @echo off setlocal -echo Publishing MP/Senparc.Weixin.Sample.MP... -dotnet publish MP/Senparc.Weixin.Sample.MP +echo Publishing MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.net8.csproj... +dotnet publish MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.net8.csproj -o ./SamplePublish/MP -set ProjectFolders=(TenPayV2, TenPayV3, WxOpen) +echo Publishing TenPayV2/Senparc.Weixin.Sample.TenPayV2/Senparc.Weixin.Sample.TenPayV2.net8.csproj... +dotnet publish TenPayV2/Senparc.Weixin.Sample.TenPayV2/Senparc.Weixin.Sample.TenPayV2.net8.csproj -o ./SamplePublish/TenPayV2 -for %%F in %ProjectFolders% do ( - echo Publishing %%F... - dotnet publish %%F -) +echo Publishing TenPayV3/Senparc.Weixin.Sample.TenPayV3/Senparc.Weixin.Sample.TenPayV3.net8.csproj... +dotnet publish TenPayV3/Senparc.Weixin.Sample.TenPayV3/Senparc.Weixin.Sample.TenPayV3.net8.csproj -o ./SamplePublish/TenPayV3 + +echo Publishing Work/Senparc.Weixin.Sample.Work/Senparc.Weixin.Sample.Work.net8.csproj... +dotnet publish Work/Senparc.Weixin.Sample.Work/Senparc.Weixin.Sample.Work.net8.csproj -o ./SamplePublish/Work + +echo Publishing WxOpen/Senparc.Weixin.Sample.WxOpen/Senparc.Weixin.Sample.WxOpen.net8.csproj... +dotnet publish WxOpen/Senparc.Weixin.Sample.WxOpen/Senparc.Weixin.Sample.WxOpen.net8.csproj -o ./SamplePublish/WxOpen echo All projects have been published. endlocal