Skip to content

Commit

Permalink
Merge branch 'Developer_BankPay' of https://github.com/JeffreySu/WeiX…
Browse files Browse the repository at this point in the history
…inMPSDK into Developer_BankPay
  • Loading branch information
JeffreySu committed Dec 8, 2017
2 parents 8a43290 + 58c91d8 commit a0dd698
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task<ActionResult> TemplateMessageTest(string checkcode)
remark = new TemplateDataItem("更详细信息,请到Senparc.Weixin SDK官方网站(http://sdk.weixin.senparc.com)查看!")
};

var result = await TemplateApi.SendTemplateMessageAsync(appId, openId, templateId, null, testData);
var result = await TemplateApi.SendTemplateMessageAsync(appId, openId, templateId, "pages/index/index", testData);
return Content("异步模板消息已经发送到【盛派网络小助手】公众号,请查看。此前的验证码已失效,如需继续测试,请重新获取验证码。");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,15 @@ public override async Task OnMessageReceiced(WebSocketHelper webSocketHandler, R

var data = new
{
keyword1 = new TemplateDataItem("ADD"),
keyword1 = new TemplateDataItem("来自小程序WebSocket的模板消息"),
keyword2 = new TemplateDataItem(DateTime.Now.ToString()),
keyword3 = new TemplateDataItem("Name"),
keyword4 = new TemplateDataItem("Number"),
keyword5 = new TemplateDataItem(100.ToString("C")),
keyword6 = new TemplateDataItem("400-9939-858"),
};



var tmResult = Senparc.Weixin.WxOpen.AdvancedAPIs.Template.TemplateApi.SendTemplateMessage(appId, openId, "Oc7R_U_23T8DtVgWn3d__-WkIctx_yDWTg8_4Mx8wgY", data, receivedMessage.FormId, null,
var tmResult = Senparc.Weixin.WxOpen.AdvancedAPIs.Template.TemplateApi.SendTemplateMessage(appId, openId, "Ap1S3tRvsB8BXsWkiILLz93nhe7S8IgAipZDfygy9Bg", data, receivedMessage.FormId, "pages/websocket/websocket", "websocket",
null);
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ public async Task<ActionResult> TemplateMessageTest(string checkcode)
remark = new TemplateDataItem("更详细信息,请到Senparc.Weixin SDK官方网站(http://sdk.weixin.senparc.com)查看!")
};

var result = await TemplateApi.SendTemplateMessageAsync(appId, openId, templateId, null, testData);
var miniProgram = new TempleteModel_MiniProgram()
{
appid = "wxfcb0a0031394a51c",//【盛派互动(BookHelper)】小程序
pagepath = "pages/index/index"
};

var result = await TemplateApi.SendTemplateMessageAsync(appId, openId, templateId, null, testData, miniProgram);
return Content("异步模板消息已经发送到【盛派网络小助手】公众号,请查看。此前的验证码已失效,如需继续测试,请重新获取验证码。");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public ActionResult TemplateTest(string sessionId, string formId)
Senparc.Weixin.WxOpen.AdvancedAPIs
.Template.TemplateApi
.SendTemplateMessage(
AppId, openId, data.TemplateId, data, formId);
AppId, openId, data.TemplateId, data, formId, "pages/index/index", "图书", "#fff00");

return Json(new { success = true, msg = "发送成功,请返回消息列表中的【服务通知】查看模板消息。\r\n点击模板消息还可重新回到小程序内。" });
}
Expand All @@ -255,7 +255,7 @@ public ActionResult DecryptPhoneNumber(string sessionId, string encryptedData, s
{
var phoneNumber = Senparc.Weixin.WxOpen.Helpers.EncryptHelper.DecryptPhoneNumber(sessionId, encryptedData,
iv);

//throw new WeixinException("解密PhoneNumber异常测试");//启用这一句,查看客户端返回的异常信息

return Json(new { success = true, phoneNumber = phoneNumber });
Expand All @@ -265,7 +265,7 @@ public ActionResult DecryptPhoneNumber(string sessionId, string encryptedData, s
return Json(new { success = false, msg = ex.Message });

}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
<Compile Include="ResponseMessageFactoryTest.cs" />
<Compile Include="TenPayV3\TenPayV3Test.cs" />
<Compile Include="CommonAPIs\ApiHandlerWapperTest.cs" />
<Compile Include="Utilities\Senparc.Weixin.Utilities.HttpUtility\GetTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config">
Expand Down Expand Up @@ -165,9 +166,7 @@
<Name>Senparc.WeixinTests</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Utilities\" />
</ItemGroup>
<ItemGroup />
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Senparc.Weixin.HttpUtility;
using Senparc.Weixin.MP.AdvancedAPIs;
using Senparc.Weixin.MP.Test.CommonAPIs;

namespace Senparc.Weixin.MP.Test.Utilities
{
[TestClass]
public class GetTests : CommonApiTest
{

[TestMethod]
public void DownloadToDirTest()
{
////下载图片
//var file = string.Format("qr-{0}.jpg", DateTime.Now.Ticks);
//using (FileStream fs = new FileStream(file, FileMode.OpenOrCreate))
//{
// Get.Download(url, fs);//下载
// fs.Flush();//直接保存,无需处理指针
//}

var fileName = @"E:\Senparc项目\WeiXinMPSDK\src\Senparc.Weixin.MP\Senparc.Weixin.MP.Test\qr.jpg";

//上传素材
var result = MediaApi.UploadTemporaryMedia(base._appId, UploadMediaFileType.image, fileName);
Console.WriteLine("MediaId:" + result.media_id);

//下载
var url = "http://sdk.weixin.senparc.com/images/v2/ewm_01.png";
var filePath = @"E:\Senparc项目\WeiXinMPSDK\src\Senparc.Weixin.MP\Senparc.Weixin.MP.Test\qr_" + DateTime.Now.ToString("HHmmss") + ".jpg";
var downloadResult = Senparc.Weixin.HttpUtility.Get.Download(url, filePath);
Console.WriteLine(downloadResult);
}


}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("14.8.8.*")]
[assembly: AssemblyVersion("14.8.9.*")]
//[assembly: AssemblyInformationalVersion("13.3.1-alpha")]
//[assembly: AssemblyFileVersion("0.4.2.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public void DownloadTest()
Get.Download(url, ms);//下载
ms.Seek(0, SeekOrigin.Begin);//将指针放到流的开始位置
string base64Img = Convert.ToBase64String(ms.ToArray());//输出图片base64编码
Console.WriteLine(base64Img);
}
}


[TestMethod]
public void GetJsonTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.8.0.*")]
[assembly: AssemblyVersion("2.8.1.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
创建标识:Senparc - 20170601
修改标识:Senparc - 20171201
修改描述:v1.7.3 修复ModifyDomainApi.ModifyDomain()方法判断问题
----------------------------------------------------------------*/

using Senparc.Weixin.CommonAPIs;
Expand Down Expand Up @@ -66,7 +69,7 @@ public class ModifyDomainApi

object data;

if (action == ModifyDomainAction.set)
if (action == ModifyDomainAction.get)
{
data = new
{
Expand Down Expand Up @@ -116,7 +119,7 @@ public class ModifyDomainApi

object data;

if (action == ModifyDomainAction.set)
if (action == ModifyDomainAction.get)
{
data = new
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.3.*")]
[assembly: AssemblyVersion("1.2.5.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net35;net40;net45;netstandard1.6;netstandard2.0</TargetFrameworks>
<Version>1.2.4</Version>
<Version>1.2.5</Version>
<AssemblyName>Senparc.Weixin.Work</AssemblyName>
<RootNamespace>Senparc.Weixin.Work</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down Expand Up @@ -53,6 +53,7 @@
v1.2.2 支持Senparc.Weixin v4.18.0,支持Ajax模拟请求
v1.2.3 GetDepartmentListResult.order改为long类型
v1.2.4 支持Senparc.Weixin v4.18.5 可自定义API域名
v1.2.5 支持Senparc.Weixin v4.18.6 修复自定义API域名问题
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
<SignAssembly>False</SignAssembly>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
修改描述:v1.2.1 修改模板消息URL
修改标识:Senparc - 20170707
修改描述:v14.5.1 完善异步方法async/await
修改描述:完善异步方法async/await
修改标识:Senparc - 20170707
修改描述:v1.7.4 完善模板消息发送参数
----------------------------------------------------------------*/

Expand Down Expand Up @@ -59,12 +62,13 @@ public static class TemplateApi
/// <param name="templateId"></param>
/// <param name="data"></param>
/// <param name="emphasisKeyword">模板需要放大的关键词,不填则默认无放大</param>
/// <param name="color">模板内容字体的颜色,不填默认黑色(非必填)</param>
/// <param name="timeOut">代理请求超时时间(毫秒)</param>
/// <param name="formId">表单提交场景下,为 submit 事件带上的 formId;支付场景下,为本次支付的 prepay_id</param>
/// <param name="page">点击模板查看详情跳转页面,不填则模板无跳转</param>
/// <param name="page">点击模板查看详情跳转页面,不填则模板无跳转(非必填)</param>
/// <returns></returns>
public static WxJsonResult SendTemplateMessage(string accessTokenOrAppId, string openId, string templateId,
object data, string formId, string page = null, string emphasisKeyword = null, int timeOut = Config.TIME_OUT)
object data, string formId, string page = null, string emphasisKeyword = null, string color = null, int timeOut = Config.TIME_OUT)
{
return ApiHandlerWapper.TryCommonApi(accessToken =>
{
Expand All @@ -73,8 +77,8 @@ public static class TemplateApi
{
touser = openId,
template_id = templateId,
// topcolor = topcolor,
//page = page,
color = color,
page = page,
form_id = formId,
data = data,
emphasis_keyword = emphasisKeyword,
Expand Down Expand Up @@ -119,6 +123,7 @@ public static class TemplateApi

#if !NET35 && !NET40
#region 异步方法

/// <summary>
/// 【异步方法】小程序模板消息接口
/// </summary>
Expand All @@ -127,11 +132,12 @@ public static class TemplateApi
/// <param name="templateId"></param>
/// <param name="data"></param>
/// <param name="emphasisKeyword">模板需要放大的关键词,不填则默认无放大</param>
/// <param name="color">模板内容字体的颜色,不填默认黑色(非必填)</param>
/// <param name="timeOut">代理请求超时时间(毫秒)</param>
/// <param name="formId">表单提交场景下,为 submit 事件带上的 formId;支付场景下,为本次支付的 prepay_id</param>
/// <param name="page">点击模板查看详情跳转页面,不填则模板无跳转</param>
/// <param name="page">点击模板查看详情跳转页面,不填则模板无跳转(非必填)</param>
/// <returns></returns>
public static async Task<WxJsonResult> SendTemplateMessageAsync(string accessTokenOrAppId, string openId, string templateId, object data, string formId, string page = null, string emphasisKeyword = null, int timeOut = Config.TIME_OUT)
public static async Task<WxJsonResult> SendTemplateMessageAsync(string accessTokenOrAppId, string openId, string templateId, object data, string formId, string page = null, string emphasisKeyword = null, string color = null, int timeOut = Config.TIME_OUT)
{
return await ApiHandlerWapper.TryCommonApiAsync(async accessToken =>
{
Expand All @@ -140,7 +146,7 @@ public static async Task<WxJsonResult> SendTemplateMessageAsync(string accessTok
{
touser = openId,
template_id = templateId,
// topcolor = topcolor,
color = color,
page = page,
form_id = formId,
data = data,
Expand All @@ -156,4 +162,3 @@ public static async Task<WxJsonResult> SendTemplateMessageAsync(string accessTok
#endif
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,15 @@ public class TempleteModel
public object data { get; set; }

/// <summary>
///
/// 模板需要放大的关键词,不填则默认无放大(非必填)
/// </summary>
public string emphasis_keyword { get; set; }

/// <summary>
/// 模板内容字体的颜色,不填默认黑色(非必填)
/// </summary>
public string color { get; set; }



public TempleteModel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.7.1.*")]
[assembly: AssemblyVersion("1.7.4.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net40;net45;netstandard1.6;netstandard2.0</TargetFrameworks>
<Version>1.7.2</Version>
<Version>1.7.4</Version>
<AssemblyName>Senparc.Weixin.WxOpen</AssemblyName>
<RootNamespace>Senparc.Weixin.WxOpen</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down Expand Up @@ -66,6 +66,8 @@
v1.7.0-beta1 提供.NET 4.0支持
v1.7.1 发布正式版;修复WxAppApi.GetWxaCodeUnlimit()方法参数错误的问题
v1.7.2 支持Senparc.Weixin v4.18.5 可自定义API域名
v1.7.3 修复ModifyDomainApi.ModifyDomain()方法判断问题
v1.7.4 完善模板消息发送参数
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Senparc.Weixin/Senparc.Weixin/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static string ApiMpHost
/// <summary>
/// 企业微信API的服务器地址(默认为:https://qyapi.weixin.qq.com)
/// </summary>
private static string _apiWorkHost = Config.ApiWorkHost + "";
private static string _apiWorkHost = "https://qyapi.weixin.qq.com";
/// <summary>
/// 企业微信API的服务器地址(默认为:https://qyapi.weixin.qq.com)
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.18.5.*")]
[assembly: AssemblyVersion("4.18.6.*")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net35;net40;net45;netstandard1.6;netstandard2.0;netcoreapp2.0</TargetFrameworks>
<Version>4.18.5</Version>
<Version>4.18.7</Version>
<AssemblyName>Senparc.Weixin</AssemblyName>
<RootNamespace>Senparc.Weixin</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down Expand Up @@ -207,6 +207,8 @@
v4.18.3 v4.18.2-beta发布正式版
v4.18.4 修正当.net core 2.0中对请求的流不支持Seek 时的判断
v4.18.5 添加Config.ApiMpHost属性,可以设置API域名
v4.18.6 重新设置企业微信默认域名
v4.18.7 调整HttpUtility.Get.Download(string url, string filePathName),改为输入完整文件路径+文件名
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
Expand Down

0 comments on commit a0dd698

Please sign in to comment.