Exemplo n.º 1
0
 public void HandleMassMsgReceipt(AntSdkChatMsg.ChatBase massMsgReceipt)
 {
     this.SendingAnimationVisible    = Visibility.Collapsed;
     this.SendFailureImageVisibility = Visibility.Collapsed;
     //this.SendTime = massMsgReceipt.sendTime;
     this.SendTime = DataConverter.FormatTimeByTimeStamp(massMsgReceipt.sendTime);//从消息来的为时间戳
     //this._sendTimeStamp = massMsgReceipt.sendTime;
     _waitingTimer.Stop();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 收到群发消息回执时刷新界面
        /// </summary>
        public void RefreshMassMsg(AntSdkChatMsg.ChatBase massMsgReceipt)
        {
            MassMsgViewModel controlVm = MassMsgControlList.FirstOrDefault(c => c.MessageId == massMsgReceipt.messageId);

            if (controlVm == null)
            {
                return;
            }
            controlVm.HandleMassMsgReceipt(massMsgReceipt);
        }
Exemplo n.º 3
0
 public static IList <AntSdkChatMsg.ChatBase> ConvertToChatMsgModel(DataTable dt)
 {
     try
     {
         var chatmsgList = new List <AntSdkChatMsg.ChatBase>();
         foreach (DataRow dr in dt.Rows)
         {
             var mtype = AntSdkMsgType.UnDefineMsg;
             if (dt.Columns.Contains("MTP"))
             {
                 long mp;
                 if (long.TryParse(dr["MTP"].ToString(), out mp))
                 {
                     mtype = (AntSdkMsgType)mp;
                 }
             }
             var chatMsg = new AntSdkChatMsg.ChatBase
             {
                 MsgType       = mtype,
                 chatIndex     = dt.Columns.Contains("CHATINDEX") ? dr["CHATINDEX"].ToString() : string.Empty,
                 sourceContent = dt.Columns.Contains("CONTENT") ? dr["CONTENT"].ToString() : string.Empty,
                 messageId     = dt.Columns.Contains("MESSAGEID") ? dr["MESSAGEID"].ToString() : string.Empty,
                 sendTime      = dt.Columns.Contains("SENDTIME") ? dr["SENDTIME"].ToString() : string.Empty,
                 sendUserId    = dt.Columns.Contains("SENDUSERID") ? dr["SENDUSERID"].ToString() : string.Empty,
                 sessionId     = dt.Columns.Contains("SESSIONID") ? dr["SESSIONID"].ToString() : string.Empty,
                 targetId      = dt.Columns.Contains("TARGETID") ? dr["TARGETID"].ToString() : string.Empty,
                 SENDORRECEIVE =
                     dt.Columns.Contains("SENDORRECEIVE") ? dr["SENDORRECEIVE"].ToString() : string.Empty,
                 sendsucessorfail =
                     dt.Columns.Contains("SENDSUCESSORFAIL")
                         ? int.Parse(dr["SENDSUCESSORFAIL"].ToString())
                         : 0,
                 flag             = dt.Columns.Contains("FLAG") ? int.Parse(dr["FLAG"].ToString()) : 0,
                 readtime         = dt.Columns.Contains("READTIME") ? dr["READTIME"].ToString() : string.Empty,
                 uploadOrDownPath =
                     dt.Columns.Contains("UPLOADORDOWNPATH")
                         ? dr["UPLOADORDOWNPATH"].ToString()
                         : string.Empty,
                 voiceread = dt.Columns.Contains("VOICEREAD") ? dr["VOICEREAD"].ToString() : string.Empty
             };
             var antsdkchatMsg = AntSdkChatMsg.GetAntSdkSpecificChatMsg(chatMsg);
             if (antsdkchatMsg != null)
             {
                 chatmsgList.Add(antsdkchatMsg);
             }
         }
         return(chatmsgList);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError($"[AntSdkSqliteHelper_ConvertToChatMsgModel]:{ex.Message}");
         return(null);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 刷新群发助手
 /// </summary>
 /// <param name="massMsgReceipt"></param>
 public void RefreshMassAssistantSession(AntSdkChatMsg.ChatBase massMsgReceipt)
 {
     if (string.IsNullOrEmpty(massMsgReceipt.chatIndex))//新发消息
     {
         this.LastMessage            = massMsgReceipt.sourceContent;
         this.LastMsgTimeStamp       = DataConverter.ConvertDateTimeInt(DateTime.Now).ToString() + "000";
         this.ImageSendingVisibility = Visibility.Visible;
     }
     else //回执
     {
         this.LastChatIndex          = massMsgReceipt.chatIndex;
         this.LastMsgTimeStamp       = massMsgReceipt.sendTime;
         this.ImageSendingVisibility = Visibility.Collapsed;
     }
     this.LastTime = DataConverter.FormatTimeByTimeStamp(LastMsgTimeStamp);//从消息来的为时间戳
 }
Exemplo n.º 5
0
        /// <summary>
        /// 方法说明:获取上一条消息
        /// </summary>
        /// <param name="chatIndex">消息索引</param>
        /// <param name="sessionId"></param>
        /// <returns></returns>
        public AntSdkChatMsg.ChatBase GetBeforeRecordByChatIndex(string chatIndex, string sessionId)
        {
            var selectStr =
                $"select  * from t_chat_message  where chatIndex<>'{chatIndex}' and sendtime<>'' and sendtime not null  and sessionId='{sessionId}' order by rowid desc limit 0,1";

            AntSdkChatMsg.ChatBase chatMsg = null;
            using (
                SQLiteConnection conn =
                    new SQLiteConnection(AntSdkSqliteHelper.ConnStr(AntSdkService.AntSdkConfigInfo.AntSdkCompanyCode,
                                                                    AntSdkService.AntSdkLoginOutput.userId)))
            {
                var dataReader = AntSdkSqliteHelper.ExecuteReader(conn, selectStr);
                if (dataReader == null)
                {
                    return(null);
                }
                if (dataReader.Read())
                {
                    chatMsg = new AntSdkChatMsg.ChatBase
                    {
                        MsgType          = (AntSdkMsgType)long.Parse(dataReader.GetValue(0).ToString()),
                        chatIndex        = dataReader.GetValue(1).ToString(),
                        sourceContent    = dataReader.GetValue(2).ToString(),
                        messageId        = dataReader.GetValue(3).ToString(),
                        sendTime         = dataReader.GetValue(4).ToString(),
                        sendUserId       = dataReader.GetValue(5).ToString(),
                        sessionId        = dataReader.GetValue(6).ToString(),
                        targetId         = dataReader.GetValue(7).ToString(),
                        SENDORRECEIVE    = dataReader.GetValue(8).ToString(),
                        sendsucessorfail = int.Parse(dataReader.GetValue(9).ToString()),
                        flag             = int.Parse(dataReader.GetValue(10).ToString()),
                        readtime         = dataReader.GetValue(11).ToString(),
                        uploadOrDownPath = dataReader.GetValue(12).ToString(),
                    };
                    dataReader.Close();
                }
            }
            if (chatMsg == null)
            {
                return(null);
            }
            //处理返回
            return(AntSdkChatMsg.GetAntSdkSpecificChatMsg(chatMsg));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 方法说明:根据投票或活动ID获取一条消息
        /// </summary>
        /// <param name="voteOrActivityId">投票或活动ID</param>
        /// <param name="sessionId"></param>
        /// <param name="msgType">消息类型码</param>
        /// <param name="companyCode"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public AntSdkChatMsg.ChatBase GetGroupMsgByVoteOrActivityId(string voteOrActivityId, string sessionId, string msgType, string companyCode, string userId)
        {
            var selectStr =
                $"select  * from t_chat_message_group  where MTP='" + msgType + "' AND SESSIONID='" + sessionId + "' AND SPARE1='" + voteOrActivityId + "'";

            AntSdkChatMsg.ChatBase chatMsg = null;
            using (
                SQLiteConnection conn =
                    new SQLiteConnection(AntSdkSqliteHelper.ConnStr(AntSdkService.AntSdkConfigInfo.AntSdkCompanyCode,
                                                                    AntSdkService.AntSdkLoginOutput.userId)))
            {
                var dataReader = AntSdkSqliteHelper.ExecuteReader(conn, selectStr);
                if (dataReader == null)
                {
                    return(null);
                }
                if (dataReader.Read())
                {
                    chatMsg = new AntSdkChatMsg.ChatBase
                    {
                        MsgType          = (AntSdkMsgType)long.Parse(dataReader.GetValue(0).ToString()),
                        chatIndex        = dataReader.GetValue(1).ToString(),
                        sourceContent    = dataReader.GetValue(2).ToString(),
                        messageId        = dataReader.GetValue(3).ToString(),
                        sendTime         = dataReader.GetValue(4).ToString(),
                        sendUserId       = dataReader.GetValue(5).ToString(),
                        sessionId        = dataReader.GetValue(6).ToString(),
                        targetId         = dataReader.GetValue(7).ToString(),
                        SENDORRECEIVE    = dataReader.GetValue(8).ToString(),
                        sendsucessorfail = int.Parse(dataReader.GetValue(9).ToString()),
                        //flag = int.Parse(dataReader.GetValue(10).ToString()),
                        //readtime = dataReader.GetValue(11).ToString(),
                        //uploadOrDownPath = dataReader.GetValue(12).ToString()
                    };
                    dataReader.Close();
                }
            }
            if (chatMsg == null)
            {
                return(null);
            }
            //处理返回
            return(AntSdkChatMsg.GetAntSdkSpecificChatMsg(chatMsg));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 格式化最后一条消息(会话列表中显示内容)
        /// </summary>
        public static string FormatLastMessageContent(AntSdkMsgType msgType, AntSdkChatMsg.ChatBase chatMsg, bool isGroupMsg, string startName = null)
        {
            var message = string.Empty;

            if (!isGroupMsg && chatMsg.flag == ((int)AntSdkBurnFlag.IsBurn)) //点对点聊天的阅后即焚消息(群聊的正常显示)
            {
                message = "无痕消息";
                if (!chatMsg.sessionId.StartsWith("G"))
                {
                    message = "[阅后即焚消息]";
                }
            }
            else if (msgType == AntSdkMsgType.ChatMsgAt)
            {
                var atMsg = chatMsg as AntSdkChatMsg.At;
                if (atMsg != null)
                {
                    message = FormatAtMsg(atMsg, startName);
                }
            }
            else
            {
                bool isIncludeAtMsg = false;
                switch (msgType)
                {
                case AntSdkMsgType.ChatMsgText:
                case AntSdkMsgType.Revocation:
                    message = chatMsg.sourceContent;
                    break;

                case AntSdkMsgType.ChatMsgPicture:
                    message = "[图片]";
                    break;

                case AntSdkMsgType.ChatMsgFile:
                    message = "[文件]";
                    break;

                case AntSdkMsgType.ChatMsgVideo:
                    message = "[视频]";
                    break;

                case AntSdkMsgType.PointAudioVideo:
                    message = "音频";
                    break;

                case AntSdkMsgType.ChatMsgAudio:
                    message = "[语音]";
                    break;

                case AntSdkMsgType.CreateVote:
                    message = "[投票]";
                    break;

                case AntSdkMsgType.CreateActivity:
                    message = "[活动]";
                    break;

                case AntSdkMsgType.ChatMsgMixMessage:
                    try
                    {
                        List <MixMessageObjDto> obj = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(chatMsg.sourceContent.ToString());
                        var strSB = new StringBuilder();
                        if (obj.Any())
                        {
                            foreach (var mixImageText in obj)
                            {
                                if (mixImageText.type == "1001")
                                {
                                    strSB.Append(mixImageText.content);
                                }
                                else if (mixImageText.type == "1002")
                                {
                                    strSB.Append("[图片]");
                                }
                                else if (mixImageText.type == "1008")
                                {
                                    if (mixImageText.content == null)
                                    {
                                        break;
                                    }
                                    try
                                    {
                                        var atMessage = JsonConvert.DeserializeObject <List <ATMessage> >(mixImageText.content.ToString());
                                        if (atMessage == null || atMessage.Count <= 0 ||
                                            string.IsNullOrEmpty(atMessage[0].names[0]))
                                        {
                                            continue;
                                        }
                                        isIncludeAtMsg = true;
                                        strSB.Append("@");
                                        strSB.Append(atMessage[0].names[0]);
                                    }
                                    catch (Exception ex)
                                    {
                                        message = "[混合消息]";
                                        LogHelper.WriteError("-------------------------------列表解析混合消息内容异常:chatMsg.os:----" + chatMsg.os + "----chatMsg.sourceContent:" + chatMsg.sourceContent + "mixImageText.content:" + mixImageText.content + ex.Message);
                                    }
                                }
                            }
                            message = strSB.ToString();
                        }
                        else
                        {
                            message = "[混合消息]";
                        }
                    }
                    catch (Exception ex)
                    {
                        message = "[混合消息]";
                        LogHelper.WriteError("-------------------------------列表解析混合消息内容异常:chatMsg.os:----" + chatMsg.os + "----chatMsg.sourceContent:" + chatMsg.sourceContent + ex.Message);
                    }
                    break;
                }
                if (!string.IsNullOrEmpty(startName))
                {
                    message = isIncludeAtMsg ? "[~!@]" + startName + ":" + message : startName + ":" + message;
                }
            }
            //返回信息
            return(message);
        }