-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2690 from JeffreySu/Developer
Senparc.Weixin v6.15.4
- Loading branch information
Showing
3 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/Senparc.Weixin/Senparc.Weixin/Helpers/JsonResultHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters