Esempio n. 1
0
 private async void _objChatSignalRService_OnGroupMessageReceived(object sender, GroupMessageResponseViewModel e)
 {
     try
     {
         if (e.MessageId != 0)
         {
             var chatmessage = GroupRepository.CheckGroupChatMessage(e.MessageId, e.GroupId);
             if (chatmessage == null)
             {
                 GroupRepository.SaveGroupMessage(e, "ChatList");
                 var chatConversation = ChatConversationRepository.GetConversationbyGroupId(e.GroupId);
                 if (e.Attachments.Count > 0)
                 {
                     e.Message = (string.IsNullOrEmpty(e.Message)) ? e.Attachments[e.Attachments.Count - 1].Type : e.Message;
                 }
                 chatConversation = ChatConversationRepository.UpdateChatLastMessage(chatConversation.id, e.Message, e.SenderProfileName);
                 if (chatConversation != null)
                 {
                     Activity.RunOnUiThread(() =>
                     {
                         MessageReceived(chatConversation, "OldChat");
                     });
                 }
                 //else
                 //{
                 //    Activity.RunOnUiThread(() =>
                 //    {
                 //        //chatConversation = new ChatConversation();
                 //        //chatConversation.ChatId = e.ChatId;
                 //        //chatConversation.ContactId = e.ContactId;
                 //        //chatConversation.CreatedDate = e.MessageTime;
                 //        //chatConversation.
                 //        //MessageReceived(chatConversation, "NewChat");
                 //    });
                 //}
                 GroupMessageStatusViewModel _model = new GroupMessageStatusViewModel();
                 _model.GroupMessageId = e.MessageId;
                 await _objChatSignalRService.SendGroupMessageUpdate(e.SenderId.ToString(), _model, "ChatList");
             }
         }
     }
     catch (Java.Lang.Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
        private async void _objChatSignalRService_OnGroupMessageReceived(object sender, GroupMessageResponseViewModel e)
        {
            try
            {
                if (e.MessageId != 0)
                {
                    var chatmessage = GroupRepository.CheckGroupChatMessage(e.MessageId, e.GroupId);
                    if (chatmessage == null)
                    {
                        GroupRepository.SaveGroupMessage(e, "ChatList");
                        var chatConversationResponse = ChatConversationRepository.GetConversationbyGroupId(e.GroupId);
                        if (chatConversationResponse.success)
                        {
                            if (e.Attachments.Count > 0)
                            {
                                e.Message = (string.IsNullOrEmpty(e.Message)) ? e.Attachments[e.Attachments.Count - 1].Type : e.Message;
                            }
                            chatConversationResponse.chatConversation = ChatConversationRepository.UpdateChatLastMessage(chatConversationResponse.chatConversation.id, e.Message, e.SenderProfileName);
                            if (chatConversationResponse.chatConversation != null)
                            {
                                InvokeOnMainThread(() =>
                                {
                                    MessageReceived(chatConversationResponse.chatConversation, "OldChat");
                                });
                            }
                        }

                        GroupMessageStatusViewModel _model = new GroupMessageStatusViewModel();
                        _model.GroupMessageId = e.MessageId;
                        await _objChatSignalRService.SendGroupMessageUpdate(e.SenderId.ToString(), _model, "ChatList");
                    }
                }
            }
            catch (Exception ex)
            {
                //Crashes.TrackError(ex);
            }
        }
 private void _objChatSignalRService_OnGroupMessageReceived(object sender, GroupMessageResponseViewModel e)
 {
     try
     {
         if (e.MessageId != 0)
         {
             var chatmessage = GroupRepository.CheckGroupChatMessage(e.MessageId, e.GroupId);
             if (chatmessage == null)
             {
                 GroupRepository.SaveGroupMessage(e, "Private");
                 InvokeOnMainThread(() =>
                 {
                     LoadLocalLatestMessages();
                 });
                 UpdateGroupChatMessage(e.SenderId.ToString(), e, "Private");
             }
         }
     }
     catch (Exception ex)
     {
         //Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
     }
 }