Skip to content

Commit

Permalink
Merge pull request #2608 from JeffreySu/Developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
JeffreySu committed Apr 2, 2022
2 parents 40d4841 + b58d1ad commit 67f1d2f
Show file tree
Hide file tree
Showing 67 changed files with 1,883 additions and 225 deletions.
22 changes: 22 additions & 0 deletions Samples/All/net6-mvc/Senparc.Weixin.Sample.Net6.sln
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.Work"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.WxOpen", "..\..\WxOpen\Senparc.Weixin.Sample.WxOpen\Senparc.Weixin.Sample.WxOpen.csproj", "{5CDE163E-A083-418F-B70A-63F25A957666}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Senparc.Weixin.Sample.TenPayV2", "..\..\TenPayV2\Senparc.Weixin.Sample.TenPayV2\Senparc.Weixin.Sample.TenPayV2.csproj", "{94C58964-01E0-4AA0-AF98-5851208D9755}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{5cde163e-a083-418f-b70a-63f25a957666}*SharedItemsImports = 5
..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{81a078a9-97d1-446d-88ed-87f4bb484d91}*SharedItemsImports = 5
..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{94c58964-01e0-4aa0-af98-5851208d9755}*SharedItemsImports = 5
..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{9fe36012-8b32-488e-96ad-ba7cedaeeab8}*SharedItemsImports = 13
..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{defd229c-0482-4924-8746-73d21b9dab02}*SharedItemsImports = 5
EndGlobalSection
Expand Down Expand Up @@ -616,6 +619,24 @@ Global
{5CDE163E-A083-418F-B70A-63F25A957666}.Test|x64.Build.0 = Debug|Any CPU
{5CDE163E-A083-418F-B70A-63F25A957666}.Test|x86.ActiveCfg = Debug|Any CPU
{5CDE163E-A083-418F-B70A-63F25A957666}.Test|x86.Build.0 = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Debug|x64.ActiveCfg = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Debug|x64.Build.0 = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Debug|x86.ActiveCfg = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Debug|x86.Build.0 = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Release|Any CPU.Build.0 = Release|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Release|x64.ActiveCfg = Release|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Release|x64.Build.0 = Release|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Release|x86.ActiveCfg = Release|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Release|x86.Build.0 = Release|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Test|Any CPU.ActiveCfg = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Test|Any CPU.Build.0 = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Test|x64.ActiveCfg = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Test|x64.Build.0 = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Test|x86.ActiveCfg = Debug|Any CPU
{94C58964-01E0-4AA0-AF98-5851208D9755}.Test|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -657,6 +678,7 @@ Global
{9FE36012-8B32-488E-96AD-BA7CEDAEEAB8} = {34CFB1D8-6025-4E93-A67F-D94DD3B9198F}
{DEFD229C-0482-4924-8746-73D21B9DAB02} = {34CFB1D8-6025-4E93-A67F-D94DD3B9198F}
{5CDE163E-A083-418F-B70A-63F25A957666} = {34CFB1D8-6025-4E93-A67F-D94DD3B9198F}
{94C58964-01E0-4AA0-AF98-5851208D9755} = {34CFB1D8-6025-4E93-A67F-D94DD3B9198F}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC7AD3EC-AB37-497E-925B-DCD5129FE6D3}
Expand Down
28 changes: 28 additions & 0 deletions Samples/MP/Senparc.Weixin.Sample.MP.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

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}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{99eeb8cc-fe5e-4a1d-80c2-9a0c1fa757bd}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{99EEB8CC-FE5E-4A1D-80C2-9A0C1FA757BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{99EEB8CC-FE5E-4A1D-80C2-9A0C1FA757BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{99EEB8CC-FE5E-4A1D-80C2-9A0C1FA757BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{99EEB8CC-FE5E-4A1D-80C2-9A0C1FA757BD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {34AD62B8-CE7D-43AB-82FD-C46CBB2A6E76}
EndGlobalSection
EndGlobal
45 changes: 20 additions & 25 deletions Samples/MP/Senparc.Weixin.Sample.MP/Senparc.Weixin.Sample.MP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,8 @@
<!-- 此节点为 Sample 共享文件需要而添加,实际项目无需添加 -->
<GenerateEmbeddedFilesManifest Condition=" '$(Configuration)' != 'Release' ">true</GenerateEmbeddedFilesManifest>
</PropertyGroup>

<ItemGroup>
<Compile Remove="wwwroot\css\**" />
<Content Remove="wwwroot\css\**" />
<EmbeddedResource Remove="wwwroot\css\**" />
<None Remove="wwwroot\css\**" />
</ItemGroup>

<ItemGroup>
<None Remove="Views\Shared\_Layout.cshtml.css" />
</ItemGroup>

<ItemGroup>
<Content Include="Views\Shared\_Layout.cshtml.css" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Senparc.Weixin.AspNet\Senparc.Weixin.AspNet.net6.csproj" />
<ProjectReference Include="..\..\..\src\Senparc.Weixin.MP.Middleware\Senparc.Weixin.MP.Middleware.net6.csproj" />
<ProjectReference Include="..\..\..\src\Senparc.Weixin.MP.MvcExtension\Senparc.Weixin.MP.MvcExtension\Senparc.Weixin.MP.MvcExtension.net6.csproj" />
<ProjectReference Include="..\..\..\src\Senparc.Weixin.MP\Senparc.Weixin.MP\Senparc.Weixin.MP.net6.csproj" />
</ItemGroup>


<!-- 此节点为 Sample 共享文件需要而添加,实际项目无需添加 -->

<!-- 此节点为 Sample 共享文件需要而添加,实际项目无需添加 -->
<ItemGroup Condition=" '$(Configuration)' != 'Release' ">
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="6.0.0" />
Expand All @@ -45,4 +22,22 @@
<!-- 此节点为 Sample 共享文件需要而添加,实际项目无需添加 -->
<Import Project="..\..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems" Label="Shared" />


<!--引用 Nuget 包-->
<ItemGroup>
<PackageReference Include="Senparc.Weixin.AspNet" Version="0.7.6" />
<PackageReference Include="Senparc.Weixin.MP" Version="16.17.8" />
<PackageReference Include="Senparc.Weixin.MP.Middleware" Version="0.7.6" />
<PackageReference Include="Senparc.Weixin.MP.MVC" Version="7.11.6" />
</ItemGroup>

<!--直接引用源码-->
<!--<ItemGroup>
<ProjectReference Include="..\..\..\src\Senparc.Weixin.AspNet\Senparc.Weixin.AspNet.net6.csproj" />
<ProjectReference Include="..\..\..\src\Senparc.Weixin.MP.Middleware\Senparc.Weixin.MP.Middleware.net6.csproj" />
<ProjectReference Include="..\..\..\src\Senparc.Weixin.MP.MvcExtension\Senparc.Weixin.MP.MvcExtension\Senparc.Weixin.MP.MvcExtension.net6.csproj" />
<ProjectReference Include="..\..\..\src\Senparc.Weixin.MP\Senparc.Weixin.MP\Senparc.Weixin.MP.net6.csproj" />
</ItemGroup>-->


</Project>
10 changes: 7 additions & 3 deletions Samples/MP/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

当前 Sample 用于独立演示公众号的主要功能

正在快速更新中,非最终版,敬请期待!
打开 `Senparc.Weixin.Sample.MP.sln` 打开解决方案(使用 Nuget 包引用)。

## 打开项目
## 打开全量 Sample 项目

当前您仍然可以使用 [全量 Sample](../All/net6-mvc/) 解决方案打开,并单独运行 Senparc.Weixin.Sample.MP 项目。
当前您仍然可以使用 [全量 Sample](../All/net6-mvc/) 解决方案打开,并将 Senparc.Weixin.Sample.MP 项目设为启动项目。

## 引用源码调试

当前项目默认使用 Nuget 包引用,如果您想直接引用源码调试,可以打开 [全量 Sample](../All/net6-mvc/),并编辑当前项目 .csproj 文件,根据注释,删除 Nuget 包引用代码,并启用源码项目引用。
28 changes: 28 additions & 0 deletions Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

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.TenPayV2", "Senparc.Weixin.Sample.TenPayV2\Senparc.Weixin.Sample.TenPayV2.csproj", "{0FA694CF-308E-4763-AC3A-5799BFD20068}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
..\Shared\Senparc.Weixin.Sample.Shared\Senparc.Weixin.Sample.Shared.projitems*{0fa694cf-308e-4763-ac3a-5799bfd20068}*SharedItemsImports = 5
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0FA694CF-308E-4763-AC3A-5799BFD20068}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0FA694CF-308E-4763-AC3A-5799BFD20068}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0FA694CF-308E-4763-AC3A-5799BFD20068}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0FA694CF-308E-4763-AC3A-5799BFD20068}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {64CCB121-C5D5-4198-9F2C-949829F1828A}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "6.0.2",
"commands": [
"dotnet-ef"
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*----------------------------------------------------------------
Copyright (C) 2022 Senparc
文件名:BaseController.cs
文件功能描述:Controller基类
创建标识:Senparc - 20150312
----------------------------------------------------------------*/

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Senparc.Weixin.Entities;

namespace Senparc.Weixin.Sample.TenPayV2.Controllers
{
public class BaseController : Controller
{
protected string AppId
{
get
{
return Config.SenparcWeixinSetting.WeixinAppId;//与微信公众账号后台的AppId设置保持一致,区分大小写。
}
}

protected static ISenparcWeixinSettingForMP MpSetting
{
get
{
return Config.SenparcWeixinSetting.MpSetting;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.AspNetCore.Mvc;
using Senparc.Weixin.Sample.Models;
using System.Diagnostics;

namespace Senparc.Weixin.Sample.TenPayV2.Controllers
{
public class HomeController : BaseController
{
private readonly ILogger<HomeController> _logger;

public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}

public IActionResult Index()
{
return View();
}

[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
global using Senparc.NeuChar.MessageHandlers;
global using Senparc.Weixin.AspNet;
global using Senparc.Weixin.MP;
global using Senparc.Weixin.TenPay;
global using Senparc.Weixin.RegisterServices;
global using Senparc.Weixin.Sample.TenPayV2;
global using Microsoft.Extensions.Options;
global using Senparc.Weixin.Entities;
global using Microsoft.Extensions.FileProviders;
74 changes: 74 additions & 0 deletions Samples/TenPayV2/Senparc.Weixin.Sample.TenPayV2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();

#region 添加微信配置

//使用本地缓存必须添加
builder.Services.AddMemoryCache();

//Senparc.Weixin 注册(必须)
builder.Services.AddSenparcWeixinServices(builder.Configuration);

#endregion

var app = builder.Build();

#region 启用微信配置

var senparcWeixinSetting = app.Services.GetService<IOptions<SenparcWeixinSetting>>()!.Value;

//启用微信配置(必须)
var registerService = app.UseSenparcWeixin(app.Environment,
null /* 不为 null 则覆盖 appsettings 中的 SenpacSetting 配置*/,
null /* 不为 null 则覆盖 appsettings 中的 SenpacWeixinSetting 配置*/,
register => { /* CO2NET 全局配置 */ },
(register, weixinSetting) =>
{
//注册公众号信息(可以执行多次,注册多个公众号)
register.RegisterMpAccount(weixinSetting, "【盛派网络小助手】公众号");
//注册微信支付(可以执行多次,注册多个微信支付)
register.RegisterTenpayOld(weixinSetting, "【盛派网络小助手】微信支付(V2)");
});

#endregion

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

#region 此部分代码为 Sample 共享文件需要而添加,实际项目无需添加
#if DEBUG
//app.UseStaticFiles(new StaticFileOptions
//{
// FileProvider = new ManifestEmbeddedFileProvider(Assembly.GetExecutingAssembly(), "wwwroot"),
// RequestPath = new PathString("")
//});

app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), @"..", "..", "Shared", "Senparc.Weixin.Sample.Shared", "wwwroot")),
RequestPath = new PathString("")
});
#endif
#endregion


app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:17965",
"sslPort": 44365
}
},
"profiles": {
"Senparc.Weixin.Sample.MP": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7065;http://localhost:5065",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

0 comments on commit 67f1d2f

Please sign in to comment.