Exemplo n.º 1
0
 public static void DoNotify(HistoryMessageInfo info)
 {
     if (OnNewMsgNotify != null)
     {
         OnNewMsgNotify(info);
     }
 }
Exemplo n.º 2
0
        private void ReceiveNewMsg(HistoryMessageInfo msgInfo)
        {
            var flag = true;
            foreach (var item in NotifyInfo)
            {
                if (item.Info.TargetId == msgInfo.TargetId)
                {
                    flag = false;
                    item.Count += 1;
                }
            }

            if (flag)
            {
                Application.Current.Dispatcher.Invoke(new Action(() =>
                {
                    var info = new ConversationMessageInfo()
                    {
                        TargetId = msgInfo.TargetId,
                        UnreadCount = 1,
                        SenderId = msgInfo.SenderId,
                        SendTime = msgInfo.SendTime,
                        Type = msgInfo.Type,
                        TargertName = msgInfo.TargetName,
                        AvatarIcon = SystemConfig.AvatarUrl + msgInfo.TargetId
                    };

                    var conversatinInfoViewModel = new NotifyInfo(info);
                    NotifyInfo.Insert(0, conversatinInfoViewModel);
                }));
            }

            TotalCount = NotifyInfo.Count;
        }
Exemplo n.º 3
0
        public static HistoryMessageInfo ParserReceiveToConversation(RcReceiveMsg info)
        {
            var data = new HistoryMessageInfo()
            {
                SenderId = info.m_SenderId,
                TargetId = info.m_TargetId,
                SendTime = info.m_SendTime,
                SenderAvatar = SystemConfig.AvatarUrl + info.m_SenderId,
                Content = ConversationContentParser(RcHelper.ParseMessageType(info.m_ClazzName), info.m_Message),
                IsMe = info.m_SenderId == UserContext.Current.Id,
                SenderName = _bussinessService.GetName(info.m_SenderId),
                Type = RcHelper.ParseMessageType(info.m_ClazzName)
            };

            return data;
        }
Exemplo n.º 4
0
 public RealAlarmViewModel(HistoryMessageInfo msgInfo)
 {
     Subscription.OnNotify(ReceiveNewMsg);
     ReceiveNewMsg(msgInfo);
 }
Exemplo n.º 5
0
        private void ReceiveNewMsg(HistoryMessageInfo o)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                this.FlashWindow(WindowFlash.FLASHW_TRAY | WindowFlash.FLASHW_TIMER);
            });

            if (this.Visibility == Visibility.Hidden)
            {
                if (!_hasNewNotify)
                {
                    _hasNewNotify = true;
                    _icoTimer.Start();

                    double screenWidth = Screen.PrimaryScreen.WorkingArea.Right;

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        if (!Application.Current.Windows.OfType<RealAlarm>().Any())
                        {
                            RealAlarm win = new RealAlarm();
                            win.Left = screenWidth - win.Width;
                            win.Top = Screen.PrimaryScreen.WorkingArea.Bottom - win.Height;
                            win.DataContext = new RealAlarmViewModel(o);
                        }
                    });

                    //_notifyIcon.ShowBalloonTip(2000, "新消息", o.TargetName + "发来了新的消息", ToolTipIcon.Info);
                }
                else
                {
                    // _notifyIcon.ShowBalloonTip(0);
                    // _notifyIcon.ShowBalloonTip(2000, "新消息", o.TargetName + "发来了新的消息", ToolTipIcon.Info);
                }

                //更新消息提示
            }
        }
Exemplo n.º 6
0
        public void PreSend(JObject msgJobj)
        {
            var thumImgPath = msgJobj["extra"].ToString();
            msgJobj["extra"] = _conversationInfo.Info.TargetId;
            string msgId;
            _businessCoreService.SendImageMsg(_conversationInfo.Info.TargetId, UserContext.Current.Id, msgJobj, _conversationInfo.Info.ConversationType, out msgId);

            if (string.IsNullOrEmpty(msgId)) return;
            var info = new HistoryMessageInfo()
            {
                Content = new ContentInfo()
                {
                    content = msgJobj["content"].ToString(),
                    MessageType = MessageTypeEnum.ImgMsg,
                    url = msgJobj["imageUri"].ToString(),
                    imageUri = msgJobj["imageUri"].ToString(),
                    thumImgPath = thumImgPath,
                    extra = _conversationInfo.Info.TargetId
                },
                ConversationId = _conversationInfo.Info.TargetId,
                SenderAvatar = SystemConfig.AvatarUrl + UserContext.Current.UserName,
                SenderName = UserContext.Current.Name,
                Type = MessageTypeEnum.ImgMsg,
                SendTime = DateTime.Now,
                MessageId = msgId,
                TargetId = _conversationInfo.Info.TargetId,
                SenderId = UserContext.Current.Id,
                IsMe = true
            };

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                HistoryMessage.Add(info);
            }));
        }
Exemplo n.º 7
0
        private void SendText(string text)
        {
            JObject jobj = new JObject();
            jobj["content"] = EncryptHelper.Encrypt(text);
            jobj["extra"] = "Bhikku_Test";
            _businessCoreService.SendMessage(_conversationInfo.Info.TargetId, UserContext.Current.Id, jobj, _conversationInfo.Info.ConversationType);

            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                var info = new HistoryMessageInfo()
                {
                    Content = new ContentInfo()
                    {
                        content = text,
                        MessageType = MessageTypeEnum.TxtMsg,
                        extra = _conversationInfo.Info.TargetId
                    },
                    SenderAvatar = SystemConfig.AvatarUrl + UserContext.Current.UserName,
                    SenderName = UserContext.Current.Name,
                    Type = MessageTypeEnum.TxtMsg,
                    SendTime = DateTime.Now,
                    TargetId = _conversationInfo.Info.TargetId,
                    SenderId = UserContext.Current.Id,
                    IsMe = true
                };

                HistoryMessage.Add(info);
            }));
        }
Exemplo n.º 8
0
        private void SendFiles(FileInfo fileInfo)
        {
            var b = new BackgroundWorker();
            b.DoWork += (o, args) =>
            {
                var response = UpLoadFile(fileInfo.Name, fileInfo.Extension, fileInfo.FullName, SystemConfig.FileUrl);
                args.Result = response;
            };

            //b.ProgressChanged += b_ProgressChanged;
            b.WorkerReportsProgress = true;
            b.RunWorkerCompleted += (o, args) =>
            {
                // var result = UpLoadFile(fileInfo.Name, fileInfo.Extension, fileInfo.FullName, SystemConfig.FileUrl);
                var result = (string) args.Result;
                JObject jobj = JObject.Parse(result);
                if ((bool)jobj["success"])
                {
                    JObject msgJobj = new JObject();
                    msgJobj["fileName"] = jobj["fileName"].ToString();
                    msgJobj["fileUrl"] = jobj["fileUrl"].ToString();
                    msgJobj["fileSize"] = jobj["fileSize"].ToString();

                    string msgId;

                    _businessCoreService.SendFileMessage(_conversationInfo.Info.TargetId, UserContext.Current.Id, msgJobj, _conversationInfo.Info.ConversationType, out msgId);

                    if (string.IsNullOrEmpty(msgId)) return;
                    var info = new HistoryMessageInfo()
                    {
                        Content = new ContentInfo()
                        {
                            MessageType = MessageTypeEnum.file,
                            FileName = jobj["fileName"].ToString(),
                            FileUrl = jobj["fileUrl"].ToString(),
                            FileSize = jobj["fileSize"].ToString()
                        },
                        ConversationId = _conversationInfo.Info.TargetId,
                        SenderAvatar = SystemConfig.AvatarUrl + UserContext.Current.UserName,
                        SenderName = UserContext.Current.Name,
                        Type = MessageTypeEnum.file,
                        SendTime = DateTime.Now,
                        MessageId = msgId,
                        TargetId = _conversationInfo.Info.TargetId,
                        SenderId = UserContext.Current.Id,
                        IsMe = true
                    };

                    Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        HistoryMessage.Add(info);
                    }));
                }
                else
                {

                }
            };
            b.RunWorkerAsync();
        }