Skip to content

Commit

Permalink
Merge pull request #5 from JeffreySu/master
Browse files Browse the repository at this point in the history
tongbu
  • Loading branch information
cqwebwang committed Dec 18, 2018
2 parents 19eab45 + 2f0a860 commit eb371f4
Show file tree
Hide file tree
Showing 98 changed files with 384 additions and 883 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ packages/
/Samples/Senparc.Weixin.MP.Sample/Senparc.Weixin.MP.Sample/App_Data/NeuChar/NeuCharRoot.config
/Samples/Senparc.Weixin.MP.Sample.vs2017 - DPB
/Samples/Senparc.Weixin.MP.Sample/Senparc.Weixin.MP.Sample/App_Data/NeuChar/NeuCharRoot.bak.*
/Samples/Senparc.Weixin.MP.Sample.vs2017/Senparc.Weixin.MP.CoreSample/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ public ActionResult Index()
}
catch (Exception e)
{
WeixinTrace.SendCustomLog("Document发生appsecret错误!",e.ToString());
WeixinTrace.SendCustomLog("Document发生appsecret错误!", e.ToString());
var accessTokenBags = AccessTokenContainer.GetAllItems();

WeixinTrace.SendCustomLog("当前AccessToken信息", accessTokenBags.ToJson());

throw;
}

}

/// <summary>
Expand Down Expand Up @@ -102,9 +102,9 @@ public Task<ActionResult> CheckDownload(string guid, string version)
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public Task<FileResult> Download(string guid)
public Task<ActionResult> Download(string guid)
{
return Task.Factory.StartNew<FileResult>(() =>
var task = Task.Factory.StartNew<ActionResult>(() =>
{
var success = CheckCanDownload(guid);
if (!success)
Expand Down Expand Up @@ -139,13 +139,21 @@ public Task<FileResult> Download(string guid)
var filePath = configHelper.Download(codeRecord.Version, codeRecord.IsWebVersion);
var file = File(filePath, "application/octet-stream");
file.FileDownloadName = string.Format("Senparc.Weixin{0}-v{1}.rar",
codeRecord.IsWebVersion ? "-Web" : "",
codeRecord.Version);
return file;
}
});

if (task.IsFaulted)
{
return Task.Factory.StartNew<ActionResult>(() => Content(task.Exception.ToString()));
}
else
{
return task;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ namespace Senparc.Weixin.MP.CoreSample.Controllers
public class MediaController : Controller
{
public readonly string appId = Config.SenparcWeixinSetting.WeixinAppId;//与微信公众账号后台的AppId设置保持一致,区分大小写。
private readonly string appSecret = Config.SenparcWeixinSetting.WeixinAppSecret;//与微信公众账号后台的AppId设置保持一致,区分大小写。

public FileResult GetVoice(string mediaId)
{
var accessToken = Containers.AccessTokenContainer.TryGetAccessToken(appId, appSecret);

MemoryStream ms = new MemoryStream();
AdvancedAPIs.MediaApi.Get(accessToken, mediaId, ms);
AdvancedAPIs.MediaApi.Get(appId, mediaId, ms);
ms.Seek(0, SeekOrigin.Begin);
return File(ms, "audio/amr","voice.amr");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public ActionResult Post(PostModel postModel)
try
{
messageHandler.SaveRequestMessageLog();//记录 Request 日志(可选)

messageHandler.Execute();//执行微信处理过程(关键)

messageHandler.SaveResponseMessageLog();//记录 Response 日志(可选)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<!--<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>-->
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
</PropertyGroup>

<ItemGroup>
Expand All @@ -11,16 +12,16 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Senparc.CO2NET" Version="0.3.0.2" />
<PackageReference Include="Senparc.NeuChar.App" Version="0.1.0-preview4" />
<PackageReference Include="System.Drawing.Common" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.0" />
<PackageReference Include="Senparc.CO2NET" Version="0.4.1-preview3" />
<PackageReference Include="Senparc.NeuChar.App" Version="0.2.0-preview3" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
<PackageReference Include="ZXing.Net" Version="0.16.4" />
</ItemGroup>

<ItemGroup>
<!--<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />-->
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="2.1.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="2.2.0" />
</ItemGroup>

<ItemGroup>
Expand Down Expand Up @@ -78,5 +79,11 @@
<ProjectReference Include="..\..\Senparc.Weixin.MP.Sample\Senparc.Weixin.MP.Sample.CommonService\Senparc.Weixin.MP.CoreSample.CommonService.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="App_Data\Document\Config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties appsettings_1json__JSONSchema="http://json.schemastore.org/commands" /></VisualStudio></ProjectExtensions>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@
<p class="goto-neuchar"><a href="@domain/User/WeixinMenu" target="_blank">开始使用</a></p>

<p class="img-area">
<video controls="controls" style="margin-bottom:50px; width:100%">
<video controls="controls" style="margin-bottom: 50px;" width="60%">

<source src="http://pgddpklyx.bkt.clouddn.com/menuShow.wmv" type="video/x-ms-wmv">
<source src="http://pgddpklyx.bkt.clouddn.com/menuShow.mp4" type="video/mp4">
<source src="http://pgddpklyx.bkt.clouddn.com/menuShow.avi" type="video/avi">
<source src="https://file.senparc.com/menuShow.wmv" type="video/x-ms-wmv">
<source src="https://file.senparc.com/menuShow.mp4" type="video/mp4">
<source src="https://file.senparc.com/menuShow.avi" type="video/avi">
your browser does not support the video tag
</video>
@*<img class="neucharpic" src="~/images/neuchar_menu.png" />*@
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</environment>
<script src="~/Content/danktooltip/js/jquery.darktooltip.min.js"></script>
<script src="~/Scripts/global.js"></script>
<script src="~/Scripts/jquery.form.js"></script>
@RenderSection("HeaderContent", false)
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var timestamp = DateTime.Now.Ticks.ToString();
var echostr = DateTime.Now.Ticks.ToString();
var token = ViewData["Token"] as string;
var portString = Context.Request.Host.Port.HasValue ? $":{Context.Request.Host.Port.Value}" : null;
}
@section HeaderContent
{
Expand Down Expand Up @@ -152,9 +153,9 @@
function switchAsyncController() {
if ($('#UseAsyncController:checked').length > 0) {
$('#Url').val('@Url.Action("Index", "WeixinAsync", null, "http", Context.Request.Host.Host + ":" + Context.Request.Host.Port)');
$('#Url').val('@Url.Action("Index", "WeixinAsync", null, "http", Context.Request.Host.Host + portString)');
} else {
$('#Url').val('@Url.Action("Index", "Weixin", null, "http", Context.Request.Host.Host + ":" + Context.Request.Host.Port)');
$('#Url').val('@Url.Action("Index", "Weixin", null, "http", Context.Request.Host.Host + portString)');
}
}
Expand All @@ -178,7 +179,7 @@
</li>
<li>
<label class="control-label">URL:</label>
@Html.TextBox("Url", Url.Action("Index", "WeixinAsync", null, "http", Context.Request.Host.Host + ":" + Context.Request.Host.Port), new { @class = "control-input" })
@Html.TextBox("Url", Url.Action("Index", "WeixinAsync", null, "http", Context.Request.Host.Host + portString), new { @class = "control-input" })
</li>
<li>
<label class="checkbox">@Html.CheckBox("UseAsyncController", true)使用异步Controller</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<head>
<title>公众号jsapi支付测试网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script language="javascript" src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/lazyloadv3.js" type="text/javascript"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<style type="text/css">
body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<head>
<title>共享地址测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script language="javascript" src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/lazyloadv3.js" type="text/javascript"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<style type="text/css">
body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<head>
<title>公众号H5支付测试网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script language="javascript" src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/lazyloadv3.js" type="text/javascript"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<style>
body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<head>
<title>公众号H5支付成功!</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script language="javascript" src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/lazyloadv3.js" type="text/javascript"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<style>
body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
<head>
<title>公众号jsapi支付测试网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<script language="javascript" src="/Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script language="javascript" src="/Scripts/lazyloadv3.js" type="text/javascript"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
<style>
body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<meta name="viewport" content="width=device-width" />
<title>公众号JSSDK演示</title>
<!--jQuery非JS-SDK必须-->
<script src="~/Scripts/jquery-1.7.1.min.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<script src="@(this.Context.Request.Scheme)://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
wx.config({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,44 +32,44 @@
//以下不使用的参数可以删除,key 修改后将会失效

//公众号
"Token": "weixin",
"EncodingAESKey": "",
"WeixinAppId": "WeixinAppId",
"WeixinAppSecret": "WeixinAppSecret",
"Token": "#{Token}#",
"EncodingAESKey": "#{EncodingAESKey}#",
"WeixinAppId": "#{WeixinAppId}#",
"WeixinAppSecret": "#{WeixinAppSecret}#",
//小程序
"WxOpenAppId": "WxOpenAppId",
"WxOpenAppSecret": "WxOpenAppSecret",
"WxOpenToken": "WxOpenToken",
"WxOpenEncodingAESKey": "WxOpenEncodingAESKey",
"WxOpenAppId": "#{WxOpenAppId}#",
"WxOpenAppSecret": "#{WxOpenAppSecret}#",
"WxOpenToken": "#{WxOpenToken}#",
"WxOpenEncodingAESKey": "#{WxOpenEncodingAESKey}#",
//企业微信
"WeixinCorpId": "WeixinCorpId",
"WeixinCorpSecret": "WeixinCorpSecret",
"WeixinCorpId": "#{WeixinCorpId}#",
"WeixinCorpSecret": "#{WeixinCorpSecret}#",

//微信支付
//微信支付V2(旧版)
"WeixinPay_PartnerId": "WeixinPay_PartnerId",
"WeixinPay_Key": "WeixinPay_Key",
"WeixinPay_AppId": "WeixinPay_AppId",
"WeixinPay_AppKey": "WeixinPay_AppKey",
"WeixinPay_TenpayNotify": "WeixinPay_TenpayNotify",
"WeixinPay_PartnerId": "#{WeixinPay_PartnerId}#",
"WeixinPay_Key": "#{WeixinPay_Key}#",
"WeixinPay_AppId": "#{WeixinPay_AppId}#",
"WeixinPay_AppKey": "#{WeixinPay_AppKey}#",
"WeixinPay_TenpayNotify": "#{WeixinPay_TenpayNotify}#",
//微信支付V3(新版)
"TenPayV3_MchId": "TenPayV3_MchId",
"TenPayV3_Key": "TenPayV3_Key",
"TenPayV3_AppId": "TenPayV3_AppId",
"TenPayV3_AppSecret": "TenPayV3_AppId",
"TenPayV3_TenpayNotify": "http://YourDomainName/TenpayV3/PayNotifyUrl",
"TenPayV3_MchId": "#{TenPayV3_MchId}#",
"TenPayV3_Key": "#{TenPayV3_Key}#",
"TenPayV3_AppId": "#{TenPayV3_AppId}#",
"TenPayV3_AppSecret": "#{TenPayV3_AppSecret}#",
"TenPayV3_TenpayNotify": "#{TenPayV3_TenpayNotify}#", //http://YourDomainName/TenpayV3/PayNotifyUrl
//如果不设置TenPayV3_WxOpenTenpayNotify,默认在 TenPayV3_TenpayNotify 的值最后加上 "WxOpen"
"TenPayV3_WxOpenTenpayNotify": "http://YourDomainName/TenpayV3/PayNotifyUrlWxOpen",
"TenPayV3_WxOpenTenpayNotify": "#{TenPayV3_WxOpenTenpayNotify}#", //http://YourDomainName/TenpayV3/PayNotifyUrlWxOpen

//开放平台
"Component_Appid": "Component_Appid",
"Component_Secret": "Component_Secret",
"Component_Token": "Component_Token",
"Component_EncodingAESKey": "Component_EncodingAESKey",
"Component_Appid": "#{Component_Appid}#",
"Component_Secret": "#{Component_Secret}#",
"Component_Token": "#{Component_Token}#",
"Component_EncodingAESKey": "#{Component_EncodingAESKey}#",

//扩展及代理参数
"AgentUrl": "AgentUrl",
"AgentToken": "AgentToken",
"SenparcWechatAgentKey": "SenparcWechatAgentKey"
"AgentUrl": "#{AgentUrl}#",
"AgentToken": "#{AgentToken}#",
"SenparcWechatAgentKey": "#{SenparcWechatAgentKey}#"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Senparc.Weixin.MP.CoreSample.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: DDCF8036-5B8C-481A-9E53-82DEA7F41E80-->
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public partial class CustomMessageHandler : MessageHandler<CustomMessageContext>
*/


#if !DEBUG || NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1
#if !DEBUG || NETSTANDARD1_6 || NETSTANDARD2_0 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2
string agentUrl = "http://localhost:12222/App/Weixin/4";
string agentToken = "27C455F496044A87";
string wiweihiKey = "CNadjJuWzyX5bz5Gn+/XoyqiqMa5DjXQ";
Expand All @@ -72,13 +72,8 @@ public partial class CustomMessageHandler : MessageHandler<CustomMessageContext>
private string wiweihiKey = Config.SenparcWeixinSetting.SenparcWechatAgentKey;//WeiweihiKey专门用于对接www.Weiweihi.com平台,获取方式见:http://www.weiweihi.com/ApiDocuments/Item/25#51
#endif

#if NET45
private string appId = Config.SenparcWeixinSetting.WeixinAppId;
private string appSecret = Config.SenparcWeixinSetting.WeixinAppSecret;
#else
private string appId = "appId";
private string appSecret = "appSecret";
#endif

/// <summary>
/// 模板消息集合(Key:checkCode,Value:OpenId)
Expand Down Expand Up @@ -486,14 +481,14 @@ public override IResponseMessageBase OnVoiceRequest(RequestMessageVoice requestM
//设置音乐信息
responseMessage.Music.Title = "天籁之音";
responseMessage.Music.Description = "播放您上传的语音";
responseMessage.Music.MusicUrl = "http://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
responseMessage.Music.HQMusicUrl = "http://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
responseMessage.Music.MusicUrl = "https://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
responseMessage.Music.HQMusicUrl = "https://sdk.weixin.senparc.com/Media/GetVoice?mediaId=" + requestMessage.MediaId;
responseMessage.Music.ThumbMediaId = uploadResult.media_id;

//推送一条客服消息
try
{
CustomApi.SendText(appId, WeixinOpenId, "本次上传的音频MediaId:" + requestMessage.MediaId);
CustomApi.SendText(appId, OpenId, "本次上传的音频MediaId:" + requestMessage.MediaId);

}
catch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>1.0.0.0</Version>
<AssemblyName>Senparc.Weixin.MP.Sample.CommonService</AssemblyName>
<RootNamespace>Senparc.Weixin.MP.Sample.CommonService</RootNamespace>
Expand All @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Senparc.NeuChar" Version="0.4.4.4" />
<PackageReference Include="Senparc.NeuChar" Version="0.5.0-preview3" />
<PackageReference Include="System.Diagnostics.FileVersionInfo" Version="4.3.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
<Reference Include="Senparc.CO2NET, Version=0.3.0.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.CO2NET.0.3.0.2\lib\net45\Senparc.CO2NET.dll</HintPath>
</Reference>
<Reference Include="Senparc.CO2NET.APM, Version=0.1.3.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.CO2NET.APM.0.1.3.2\lib\net45\Senparc.CO2NET.APM.dll</HintPath>
<Reference Include="Senparc.CO2NET.APM, Version=0.1.3.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.CO2NET.APM.0.1.3.3\lib\net45\Senparc.CO2NET.APM.dll</HintPath>
</Reference>
<Reference Include="Senparc.CO2NET.Cache.Redis.RedLock, Version=1.1.0.3, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Senparc.CO2NET.Cache.Redis.RedLock.1.1.0.3\lib\net45\Senparc.CO2NET.Cache.Redis.RedLock.dll</HintPath>
Expand Down

0 comments on commit eb371f4

Please sign in to comment.