コード例 #1
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));
        }
コード例 #2
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));
        }