Skip to content

Commit

Permalink
Merge pull request #2690 from JeffreySu/Developer
Browse files Browse the repository at this point in the history
Senparc.Weixin v6.15.4
  • Loading branch information
JeffreySu authored Jul 30, 2022
2 parents 7b301c8 + b3f7eb4 commit 59c0dfb
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Senparc.CO2NET.Extensions;
using Senparc.Weixin.Helpers;
using Senparc.Weixin.MP.OpenAPIs;
using Senparc.Weixin.MP.Test.CommonAPIs;
using Senparc.WeixinTests;
Expand Down Expand Up @@ -53,10 +54,7 @@ public void RidGetTest()

Thread.Sleep(1000);//时间太快rid还没有被记录

var regex = new Regex("rid:(?<rid>[^\"]+)");
var ridResult = regex.Match(ex.JsonResult.errmsg);
Assert.IsTrue(ridResult.Success);
var rid = ridResult.Groups["rid"].Value;
var rid = ex.GetRid();
Console.WriteLine("rid:" + rid);

var result = OpenApi.RidGet(appId, "62e56973-0c7be0b1-368b3439");
Expand Down
81 changes: 81 additions & 0 deletions src/Senparc.Weixin/Senparc.Weixin/Helpers/JsonResultHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#region Apache License Version 2.0
/*----------------------------------------------------------------
Copyright 2022 Jeffrey Su & Suzhou Senparc Network Technology Co.,Ltd.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the specific language governing permissions
and limitations under the License.
Detail: https://github.com/JeffreySu/WeiXinMPSDK/blob/master/license.md
----------------------------------------------------------------*/
#endregion Apache License Version 2.0

/*----------------------------------------------------------------
Copyright (C) 2022 Senparc
文件名:JsonResultHelper.cs
文件功能描述:JsonResult 帮助类
创建标识:Senparc - 20220731
----------------------------------------------------------------*/

using Senparc.Weixin.Entities;
using Senparc.Weixin.Exceptions;
using System.Text.RegularExpressions;

namespace Senparc.Weixin.Helpers
{
/// <summary>
/// JsonResult 帮助类
/// </summary>
public static class JsonResultHelper
{
/// <summary>
/// 获取错误信息中的 rid 信息
/// </summary>
/// <param name="errmsg">errmsg</param>
/// <returns></returns>
public static string GetRid(string errmsg)
{
var regex = new Regex("rid:(?<rid>[^\"]+)");
var ridResult = regex.Match(errmsg);
if (ridResult.Success)
{
return ridResult.Groups["rid"].Value;
}
else
{
return null;
}
}

/// <summary>
/// 获取错误信息中的 rid 信息
/// </summary>
/// <param name="wxJsonResult">WxJsonResult</param>
/// <returns></returns>
public static string GetRid(this WxJsonResult wxJsonResult)
{
return GetRid(wxJsonResult.errmsg);
}

/// <summary>
/// 获取错误信息中的 rid 信息
/// </summary>
/// <param name="ex">ErrorJsonResultException</param>
/// <returns></returns>
public static string GetRid(this ErrorJsonResultException ex)
{
return ex.JsonResult.GetRid();
}
}
}
6 changes: 5 additions & 1 deletion src/Senparc.Weixin/Senparc.Weixin/Senparc.Weixin.net6.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,11 @@
v6.15 最低 .NET Framework 版本升级至 4.6.2
v6.15.2 更新 ReturnCode 枚举,添加“半屏小程序管理”代码
v6.15.3 使用最新 CO2NET,处理微信服务器无法识别中文文件名的问题。
</PackageReleaseNotes>
v6.15.4
1、更新 TryCommonApiBase 异常抛出逻辑
2、添加 JsonResultHelper
3、更新 ReturnCode 枚举,OpenApi 中的错误代码
</PackageReleaseNotes>
<RepositoryUrl>https://github.com/JeffreySu/WeiXinMPSDK</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down

0 comments on commit 59c0dfb

Please sign in to comment.