Beispiel #1
0
        private void ShowRecord(int pageIndex, bool allowCache)
        {
            if (this.remotePersister == null) //还未完成构造
            {
                return;
            }

            if (pageIndex != int.MaxValue)
            {
                if (pageIndex + 1 > this.totalPageCount)
                {
                    pageIndex = this.totalPageCount - 1;
                }

                if (pageIndex < 0)
                {
                    pageIndex = 0;
                }
                if (this.currentPageIndex == pageIndex && allowCache)
                {
                    this.toolStripTextBox_pageIndex.Text = (pageIndex + 1).ToString();
                    return;
                }
            }

            this.Cursor = Cursors.WaitCursor;
            try
            {
                ChatRecordTimeScope timeScope = ChatRecordTimeScope.All;
                DateTime            now       = DateTime.Now;
                if (this.skinComboBox1.SelectedIndex == 0) //一周
                {
                    timeScope = ChatRecordTimeScope.RecentWeek;
                }
                else if (this.skinComboBox1.SelectedIndex == 1)//一月
                {
                    timeScope = ChatRecordTimeScope.RecentMonth;
                }
                else if (this.skinComboBox1.SelectedIndex == 2)//三月
                {
                    timeScope = ChatRecordTimeScope.Recent3Month;
                }
                else //全部
                {
                }


                ChatRecordPage page = null;
                if (this.isGroupChat)
                {
                    page = this.CurrentPersister.GetGroupNoticeRecordPage(timeScope, this.group.Arg1, this.pageSize, pageIndex);
                }
                else
                {
                    page = this.CurrentPersister.GetChatRecordPage(timeScope, my.Arg1, friend.Arg1, this.pageSize, pageIndex);
                }
                this.chatBox_history.Clear();

                if (page == null || page.Content.Count == 0)
                {
                    MessageBoxEx.Show("没有消息记录!");
                    return;
                }

                this.currentPageIndex = page.PageIndex;
                this.toolStripTextBox_pageIndex.Text = (this.currentPageIndex + 1).ToString();
                for (int i = 0; i < page.Content.Count; i++)
                {
                    ChatMessageRecord record    = page.Content[i];
                    byte[]            decrypted = record.Content;
                    if (this.skinRadioButton_Server.Checked)
                    {
                        if (GlobalResourceManager.Des3Encryption != null)
                        {
                            decrypted = GlobalResourceManager.Des3Encryption.Decrypt(decrypted);
                        }
                    }

                    // ChatBoxContent content = CompactPropertySerializer.Default.Deserialize<ChatBoxContent>(decrypted, 0);

                    ChatBoxContent content = null;
                    if (content == null)
                    {
                        content      = new ChatBoxContent();
                        content.Text = System.Text.Encoding.UTF8.GetString(decrypted);
                    }

                    if (this.isGroupChat)
                    {
                        if (record.SpeakerID == this.my.Arg1)
                        {
                            this.AppendChatBoxContent(record.OccureTime, string.Format("{0}({1})", this.my.Arg2, record.SpeakerID), content, Color.Green);
                        }
                        else
                        {
                            string name = this.userNameGetter.GetUserName(record.SpeakerID) ?? record.SpeakerID;
                            this.AppendChatBoxContent(record.OccureTime, string.Format("{0}({1})", name, record.SpeakerID), content, Color.Blue);
                        }
                    }
                    else
                    {
                        if (record.SpeakerID == this.my.Arg1)
                        {
                            this.AppendChatBoxContent(record.OccureTime, this.my.Arg2, content, Color.Green);
                        }
                        else
                        {
                            this.AppendChatBoxContent(record.OccureTime, this.friend.Arg2, content, Color.Blue);
                        }
                    }
                }

                this.chatBox_history.SelectionStart = 0;
                this.chatBox_history.ScrollToCaret();

                int pageCount = page.TotalCount / this.pageSize;
                if (page.TotalCount % this.pageSize > 0)
                {
                    ++pageCount;
                }
                this.totalPageCount = pageCount;
                this.toolStripLabel_totalCount.Text = string.Format("/ {0}页", this.totalPageCount);
                this.toolStripTextBox_pageIndex.Focus();
            }
            catch (Exception ee)
            {
                MessageBoxEx.Show(ee.Message);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
Beispiel #2
0
        public ChatRecordPage GetGroupChatRecordPage(ChatRecordTimeScope timeScope, string groupID, int pageSize, int pageIndex)
        {
            ChatRecordPage page = this.globalCache.GetGroupChatRecordPage(timeScope, groupID, pageSize, pageIndex);

            return(page);
        }