Esempio n. 1
0
        public List <ChatMessageProxy> Chat_GetLastChatMessages(int userID, int targetUserID, int lastMessageID, int messageCount)
        {
            if (!CheckClient())
            {
                return(null);
            }

            ChatMessageCollection messages = ChatBO.Instance.GetLastChatMessages(userID, targetUserID, lastMessageID, messageCount);

            List <ChatMessageProxy> result = new List <ChatMessageProxy>();

            foreach (ChatMessage m in messages)
            {
                result.Add(ProxyConverter.GetChatMessageProxy(m));
            }

            return(result);
        }
Esempio n. 2
0
        public List <ChatMessageProxy> Chat_AdminGetChatMessages(int userID, int targetUserID, int pageNumber, int pageSize)
        {
            if (!CheckClient())
            {
                return(null);
            }


            ChatMessageCollection messages = ChatBO.Instance.AdminGetChatMessages(userID, targetUserID, pageNumber, pageSize);

            List <ChatMessageProxy> result = new List <ChatMessageProxy>();

            foreach (ChatMessage m in messages)
            {
                result.Add(ProxyConverter.GetChatMessageProxy(m));
            }

            return(result);
        }
Esempio n. 3
0
        public APIResult Chat_SendMessage(int senderUserID, int recoverUserID, string contentWithoutEncode, string ip, bool getNewMessages, int lastMessageID, out List <ChatMessageProxy> chatMessages)
        {
            chatMessages = null;
            if (CheckClient())
            {
                APIResult result = new APIResult();
                using (ErrorScope es = new ErrorScope())
                {
                    try
                    {
                        ChatMessageCollection messages = ChatBO.Instance.Server_SendMessage(senderUserID, recoverUserID, contentWithoutEncode, ip, getNewMessages, lastMessageID);

                        chatMessages = new List <ChatMessageProxy>();
                        foreach (ChatMessage message in messages)
                        {
                            chatMessages.Add(ProxyConverter.GetChatMessageProxy(message));
                        }

                        bool hasError = false;
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            hasError = true;
                            result.AddError(error.TatgetName, error.Message);
                        });

                        result.IsSuccess = hasError == false;
                    }
                    catch (Exception ex)
                    {
                        result.ErrorCode = Consts.ExceptionCode;
                        result.AddError(ex.Message);
                        result.IsSuccess = false;
                    }
                }

                return(result);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        public List <ChatMessageProxy> Chat_GetChatMessages(int userID, int targetUserID, int pageNumber, int pageSize, bool processKeyword, bool updateIsReaded, out int totalCount)
        {
            totalCount = 0;
            if (!CheckClient())
            {
                return(null);
            }

            ChatMessageCollection messages = ChatBO.Instance.GetChatMessages(userID, targetUserID, pageNumber, pageSize, updateIsReaded);

            totalCount = messages.TotalRecords;

            List <ChatMessageProxy> result = new List <ChatMessageProxy>();

            foreach (ChatMessage m in messages)
            {
                result.Add(ProxyConverter.GetChatMessageProxy(m));
            }

            return(result);
        }