Exemple #1
0
        internal void CSSyncMsgStatus(CSSyncMsgStatusPackage package)
        {
            TempCustomItem chatVM = this.Items.FirstOrDefault(t => t.ID == package.data.userId);

            if (chatVM != null)
            {
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    this.Items.Remove(chatVM);
                }));
            }
        }
Exemple #2
0
        /// <summary>
        /// 客服任务回包
        /// </summary>
        /// <param name="package"></param>
        internal void CSSyncMsgStatus(CSSyncMsgStatusPackage package)
        {
            int           csid   = package.from.ToInt();
            ChatViewModel chatVM = this.Items.FirstOrDefault(info => info.ID == package.data.userId);

            if (csid == SDKClient.SDKClient.Instance.property.CurrentAccount.userID)//发给我的
            {
                //没有条目
                if (chatVM == null)
                {
                    IChat chat = new UserModel()
                    {
                        ID = package.data.userId,

                        DisplayName = package.data.userName,
                        HeadImg     = package.data.photo
                    };
                    chat.HeadImg = package.data.photo ?? ImagePathHelper.DefaultUserHead;

                    ChatModel chatModel = AppData.Current.GetChatViewModel(chat);

                    chatModel.LastMsg = new MessageModel()
                    {
                        SendTime = package.time.Value,
                    };
                    chatVM = new ChatViewModel(chatModel);
                    if (package.code == 0)
                    {
                        chatVM.sessionType = 0;
                    }
                    else
                    {
                        chatVM.sessionType = 2;
                    }
                    App.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        this.Items.Add(chatVM);
                    }));
                }
                else
                {
                    if ((chatVM.Model as ChatModel).Chat.HeadImg.Equals(ImagePathHelper.DefaultUserHead))
                    {
                        App.Current.Dispatcher.Invoke(new Action(() =>
                        {
                            (chatVM.Model as ChatModel).Chat.HeadImg = package.data.photo ?? ImagePathHelper.DefaultUserHead;
                        }));
                    }

                    if (chatVM.Chat.LastMsg != null)
                    {
                        chatVM.Chat.LastMsg.SendTime = package.time.Value;
                    }
                    if (package.code == 0)
                    {
                        chatVM.sessionType = 0;
                    }
                    else
                    {
                        chatVM.sessionType = 2;
                    }
                }
            }
            //else//广播消息
            //{
            //    if (chatVM != null)
            //    {
            //        if (package.code == 0)
            //        {
            //            chatVM.AddMessageTip("当前用户正在和其他客服进行沟通中",isSetLastMsg:false);
            //            chatVM.sessionType = 2;
            //        }
            //    }
            //}
        }