/// <summary> /// 融云-消息路由 /// </summary> public dynamic TemplateRouteCallback(TemplateRouteInputDto inputDto) { var form = HttpContext.Current?.Request?.Form; var items = form.AllKeys.SelectMany(form.GetValues, (k, v) => new { key = k, value = v }); var fromUserId = items.FirstOrDefault(o => o.key.ToUpper() == "FROMUSERID")?.value; var toUserId = items.FirstOrDefault(o => o.key.ToUpper() == "TOUSERID")?.value; var objectName = items.FirstOrDefault(o => o.key.ToUpper() == "OBJECTNAME")?.value; var content = items.FirstOrDefault(o => o.key.ToUpper() == "CONTENT")?.value; var channelType = items.FirstOrDefault(o => o.key.ToUpper() == "CHANNELTYPE")?.value; var msgTimestamp = items.FirstOrDefault(o => o.key.ToUpper() == "MSGTIMESTAMP")?.value; var msgUID = items.FirstOrDefault(o => o.key.ToUpper() == "MSGUID")?.value; var sensitiveType = items.FirstOrDefault(o => o.key.ToUpper() == "SENSITIVETYPE")?.value; var source = items.FirstOrDefault(o => o.key.ToUpper() == "SOURCE")?.value; var groupUserIds = items.FirstOrDefault(o => o.key.ToUpper() == "GROUPUSERIDS")?.value; string appKey = ConfigurationManager.AppSettings["RongCloudAppKey"]; string appSecret = ConfigurationManager.AppSettings["RongCloudAppSecret"]; string signature = RongHttpClient.GetHash(appSecret + inputDto.Nonce + inputDto.SignTimestamp); if (signature.ToUpper() != inputDto.Signature.ToUpper()) { var massage = string.Format("[RouteCallback]:Error {0}==>{1},{2}", inputDto.Signature, signature, RongJsonUtil.ObjToJsonString(inputDto)); LoggerHelper.Error(massage); return(new { pass = "******" }); } var rongCloudContent = new RongCloudContent { Id = Guid.NewGuid().ToString(), CreateTime = DateTime.UtcNow.AddHours(8), FromUserId = fromUserId, ToUserId = toUserId,//此ID对应会议ID ObjectName = objectName, ChannelType = channelType, MsgTimeStamp = msgTimestamp, MsgUID = msgUID, SensitiveType = sensitiveType, Source = source, Audit = 0, Remark = RongJsonUtil.ObjToJsonString(items), }; if (objectName == "RC:TxtMsg" && !string.IsNullOrEmpty(content)) { var res = (ContentInputDto)RongJsonUtil.JsonStringToObj <ContentInputDto>(content); //var doctor = _rep.FirstOrDefault<WxUserModel>(s => s != null && s.IsDeleted != 1 && s.Id == toUserId); rongCloudContent.WxName = res?.User?.Name; rongCloudContent.WxPicture = res?.User?.Avatar; rongCloudContent.Content = res.Content; } else { rongCloudContent.Content = content; } rongCloudContent.GroupUserIds = groupUserIds; _rep.Insert <RongCloudContent>(rongCloudContent); _rep.SaveChanges(); return(new { pass = "******" }); }
public IHttpActionResult TemplateRouteCallback([FromUri] TemplateRouteInputDto inputDto) { var ret = _rongCloudService.TemplateRouteCallback(inputDto); return(Ok(ret)); }