senparc / neuchar Goto Github PK
View Code? Open in Web Editor NEWSenparc.NeuChar 跨平台信息交互标准
License: Apache License 2.0
Senparc.NeuChar 跨平台信息交互标准
License: Apache License 2.0
请问你们这个和php的微擎是不是类似的?
企业微信第三方应用开发,返回的数据没有包含MsgId,CreateTime 导致CancelExcute=True,微信推送过来的消息永远被标记为重复,相关事件不能触发!
跟踪调试输出的日志:
[[[系统日志]]]
[2021/03/25 12:14:16.2526]
[线程:6]
消息去重
lastMessage.MsgId=0,RequestMessage.MsgId=0
lastMessage.CreateTime=0001/1/1 0:00:00 +00:00,RequestMessage.CreateTime=0001/1/1 0:00:00 +00:00
lastMessage.MsgType=Event,RequestMessage.MsgType=Event
企业微信生成联系我二维码添加外部联系时候,如果多个微信同时扫码,100%会出现(反复测试)不推送消息的情况,原因是消息去重屏蔽了消息继续向下。MsgId,TimeStamp,MsgType,CreateTime这几维度不足以判断是否为重复消息,
接收消息推送
具体说明可以参考客服消息接收消息和事件 推送时会增加一个参数BusinessId,代表消息是从子商户的会话中过来的。 以发送文本消息为例:
JSON格式示例
{
"ToUserName": "toUser",
"FromUserName": "fromUser",
"CreateTime": 1482048670,
"MsgType": "text",
"Content": "this is a test",
"MsgId": 1234567890123456,
"BusinessId": 1
}
一些平台型的小程序需要为商户开通独立的客服,需要增加一个BusinessId参数
if (!handler.MatchSuccessed &&
((handler.CaseSensitive && handler.SelectMenuId == finalKeyword ||
(!handler.CaseSensitive && handler.SelectMenuId.ToUpper() == finalKeyword.ToUpper()))))
其中 handler.SelectMenuId未初始化则此步会导致服务器异常
开启实时同步通讯录,添加用户,回调三次;
第一次:
{"ChangeType":1,"NewUserID":null,"Name":null,"Department":"6","DepartmentIdList":[6],"Position":null,"Mobile":null,"Gender":0,"Email":null,"IsLeader":0,"Avatar":null,"Status":0,"Telephone":null,"EnglishName":null,"ExtAttr":null,"UserID":"1222","Event":17,"AgentID":0,"MsgType":7,"EventType":17,"EventName":"change_contact","MsgId":0,"Encrypt":null,"ToUserName":"ww4538e490b80c56b4","FromUserName":"sys","CreateTime":"2021-04-07T17:28:04+08:00"}
第二次:
{"ChangeType":1,"NewUserID":null,"Name":null,"Department":"6","DepartmentIdList":[6],"Position":null,"Mobile":null,"Gender":0,"Email":null,"IsLeader":0,"Avatar":null,"Status":0,"Telephone":null,"EnglishName":null,"ExtAttr":null,"UserID":"1222","Event":17,"AgentID":0,"MsgType":7,"EventType":17,"EventName":"change_contact","MsgId":0,"Encrypt":null,"ToUserName":"ww4538e490b80c56b4","FromUserName":"sys","CreateTime":"2021-04-07T17:28:04+08:00"}
第三次,
{"ChangeType":0,"Name":"111","Department":"6","DepartmentIdList":[6],"Position":null,"Mobile":"14100033111","Gender":1,"Email":null,"IsLeader":0,"Avatar":"https://rescdn.qqmail.com/node/wwmng/wwmng/style/images/independent/DefaultAvatar$73ba92b5.png\",\"Status\":4,\"Telephone\":null,\"EnglishName\":null,\"ExtAttr\":null,\"UserID\":\"1222\",\"Event\":17,\"AgentID\":0,\"MsgType\":7,\"EventType\":17,\"EventName\":\"change_contact\",\"MsgId\":0,\"Encrypt\":null,\"ToUserName\":\"ww4538e490b80c56b4\",\"FromUserName\":\"sys\",\"CreateTime\":\"2021-04-07T17:28:04+08:00\"}
在获取企业微信的审批接口OaDataOpenApi.GetApprovalData中,返回值【GetApprovalDataJsonResult】中为什么没有取得审批单提交时间【apply_time】呢?谢谢。
System.TypeInitializationException
HResult=0x80131534
Message=The type initializer for 'Senparc.NeuChar.MessageHandlers.MessageHandler3' threw an exception. Source=Senparc.NeuChar StackTrace: at Senparc.NeuChar.MessageHandlers.MessageHandler
3..ctor(Stream inputStream, Int32 maxRecordCount, Object postData)
at Senparc.Weixin.MP.MessageHandlers.MessageHandler`1..ctor(Stream inputStream, PostModel postModel, Int32 maxRecordCount, DeveloperInfo developerInfo)
at MYOL.WeChatGZH.Service.CustomMessageHandler..ctor(String appId, String appSecret, Stream inputStream, PostModel postModel, Int32 maxRecordCount) in D:\zzh\MYOL.WeChatGZH\MYOL.WeChatGZH\Service\CustomMessageHandler.cs:line 52
at MYOL.WeChatGZH.Controllers.WeixinController.Post(PostModel postModel) in D:\zzh\MYOL.WeChatGZH\MYOL.WeChatGZH\Controllers\WeixinController.cs:line 104
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d__12.MoveNext()
内部异常 1:
TypeInitializationException: The type initializer for 'Senparc.NeuChar.Register' threw an exception.
内部异常 2:
TypeInitializationException: The type initializer for 'Nested' threw an exception.
内部异常 3:
ArgumentNullException: Value cannot be null.
00:13:28.422 9 W - Senparc.Weixin.Exceptions.WeixinException: RequestMessage转换出错!可能是InfoType不存在!,XML:
1536250407
---> System.ArgumentException: 未找到属性设置方法。
在 System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
在 System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
在 Senparc.NeuChar.Helpers.EntityHelper.FillEntityWithXml[T](T entity, XDocument doc)
在 Senparc.Weixin.Open.RequestMessageFactory.GetRequestEntity(XDocument doc, PostModel postModel)
环境:Windows 2016 IIS 10
框架:.net core 3.0
nuget引用的版本:
Senparc.CO2NET Version="1.0.102"
Senparc.CO2NET.Cache.Redis Version="3.6.102"
Senparc.CO2NET.Cache.Redis.RedLock Version="2.2.4"
Senparc.NeuChar Version="1.0.102"
Senparc.NeuChar.App Version="0.6.102"
Senparc.Weixin.Cache.Redis Version="2.7.102"
Senparc.Weixin.Cache.Redis.RedLock Version="1.2.5"
Senparc.Weixin.TenPay Version="1.5.102"
均为发帖时最新版
经过多次反复实验,目前测试的结果是,在setup.cs中开启 Redis 缓存,并且自定义了 JSON 序列化的默认设置 JsonConvert.DefaultSettings (设置成任何内容都一样),向公众号发送消息时,就出现错误,异常信息被保存到了 SenparcTraceLog 的 log 文件中,内容如下:
[[[MessageHandlerware 过程发证异常]]]
[2019/11/11 09:50:36.7535]
[线程:44]
中间件类型:MpMessageHandlerMiddleware1 MessageHandler 类型:尚未生成 异常信息:System.ArgumentNullException: Value cannot be null. (Parameter 'value') at Newtonsoft.Json.Utilities.ValidationUtils.ArgumentNotNull(Object value, String parameterName) at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable
1 value)
at Senparc.NeuChar.Context.MessageContextJsonConverter3.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonConverter[] converters) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonConverter[] converters) at Senparc.NeuChar.Context.GlobalMessageContext
3.GetMessageContextAsync(String userName)
at Senparc.NeuChar.Context.GlobalMessageContext3.GetMessageContextAsync(String userName, Boolean createIfNotExists) at Senparc.NeuChar.Context.GlobalMessageContext
3.GetMessageContextAsync(TRequest requestMessage)
at Senparc.NeuChar.MessageHandlers.MessageHandler3.GetCurrentMessageContext() at Senparc.NeuChar.MessageHandlers.MessageHandler
3.CommonInitialize(XDocument postDataDocument, Int32 maxRecordCount, IEncryptPostModel postModel, Boolean onlyAllowEcryptMessage)
at Senparc.NeuChar.MessageHandlers.MessageHandler3..ctor(Stream inputStream, IEncryptPostModel postModel, Int32 maxRecordCount, Boolean onlyAllowEcryptMessage) at Senparc.Weixin.MP.MessageHandlers.MessageHandler
1..ctor(Stream inputStream, PostModel postModel, Int32 maxRecordCount, Boolean onlyAllowEcryptMessage, DeveloperInfo developerInfo)
at Senparc.NeuChar.Middlewares.MessageHandlerMiddleware`5.Invoke(HttpContext context)
开启
messageHandler.SaveResponseMessageLog();//记录 Response 日志(可选)
当发送过来的消息是加密的时候这里会报 NullReferenceException 。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.