/// <summary> /// 方法说明:触角SDK聊天消息和SDK聊天消息转换 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> /// <returns></returns> private static T GetReceiveAntSdkNotificationBaseInfo <T>(MsSdkNotificationBase entity) where T : NotificationsBase, new() { var sdkreceivemsgtypeValue = (long)entity.MsgType; var antsdkreceivemsgType = (AntSdkMsgType)sdkreceivemsgtypeValue; var result = new T { MsgType = antsdkreceivemsgType, sessionId = entity.sessionId, chatIndex = entity.chatIndex, chatType = entity.chatType, os = entity.os, flag = entity.flag, status = entity.status, messageId = entity.messageId, sendUserId = entity.sendUserId, targetId = entity.targetId, sendTime = entity.sendTime, attr = entity.attr }; return(result); }
/// <summary> /// 方法说明:获取接收到的平台SDK聊天消息,转化为触角SDK聊天消息 /// </summary> /// <param name="entity">SDK聊天信息</param> /// <returns>触角SDK聊天信息</returns> internal static NotificationsBase GetReceiveAntSdkNotificationInfo(MsSdkNotificationBase entity) { try { var sdknotifacationreadObj = entity as MsUnReadNotifications; if (sdknotifacationreadObj != null) { var antsdknoteficationMsg = GetReceiveAntSdkNotificationBaseInfo <UnRead>(sdknotifacationreadObj); var notefacationList = new List <Notification_content>(); if (sdknotifacationreadObj.content?.Count > 0) { notefacationList.AddRange( sdknotifacationreadObj.content.Where(c => c != null).Select(n => new Notification_content { notificationId = n.notificationId, title = n.title, createTime = n.createTime, createBy = n.createBy, hasAttach = n.hasAttach })); } antsdknoteficationMsg.content = notefacationList; return(antsdknoteficationMsg); } var sdknotifacationaddObj = entity as MsAddNotification; if (sdknotifacationaddObj != null) { var antsdknotifacationMsg = GetReceiveAntSdkNotificationBaseInfo <Add>(sdknotifacationaddObj); antsdknotifacationMsg.content = new Notification_content { notificationId = sdknotifacationaddObj.content?.notificationId, title = sdknotifacationaddObj.content?.title, createTime = sdknotifacationaddObj.content?.createTime, createBy = sdknotifacationaddObj.content?.createBy, hasAttach = sdknotifacationaddObj.content?.hasAttach }; return(antsdknotifacationMsg); } var sdknotifacationstateObj = entity as MsModifyNotificationState; if (sdknotifacationstateObj != null) { var antsdknotificationstaMsg = GetReceiveAntSdkNotificationBaseInfo <State>(sdknotifacationstateObj); antsdknotificationstaMsg.content = new Id { notificationId = sdknotifacationstateObj.content?.notificationId }; return(antsdknotificationstaMsg); } var sdknotifacationdeleteObj = entity as MsDeleteNotification; if (sdknotifacationdeleteObj != null) { var antsdknotifacationdeleteMsg = GetReceiveAntSdkNotificationBaseInfo <Delete>(sdknotifacationdeleteObj); antsdknotifacationdeleteMsg.content = new Id { notificationId = sdknotifacationdeleteObj.content?.notificationId }; return(antsdknotifacationdeleteMsg); } //返回空 return(null); } catch (Exception ex) { LogHelper.WriteError( $"[AntSdkChatMsg.GetReceiveAntSdkChatInfo]:{Environment.NewLine}{ex.Message}{ex.StackTrace}"); return(null); } }