Ejemplo n.º 1
0
 public async Task SendGroupMessageUpdate(string toUserId, GroupMessageStatusViewModel message, string activity)
 {
     try
     {
         _proxy.Invoke("UpdateGroupMessageStatus", toUserId, message, activity);
     }
     catch (Exception ex)
     { }
 }
Ejemplo n.º 2
0
 public async void UpdateGroupChatMessage(string contactid, GroupMessageResponseViewModel model, string privatemsg)
 {
     try
     {
         GroupMessageStatusViewModel _model = new GroupMessageStatusViewModel();
         _model.GroupMessageId = model.MessageId;
         await _objChatSignalRService.SendGroupMessageUpdate(contactid, _model, privatemsg);
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
        public static GroupMessageStatus UpdateGroupMessageStatus(GroupMessageStatusViewModel grpMessage)
        {
            var db = new SQLiteConnection(CommonConstant.DBPath);
            GroupMessageStatus grpMsg = null;

            try
            {
                if (grpMessage != null)
                {
                    grpMsg = getGroupMessageStatusbyidAndReceiver(grpMessage.GroupMessageId, grpMessage.ReceiverId);
                    if (grpMsg != null)
                    {
                        grpMsg.IsSend     = grpMessage.IsSend;
                        grpMsg.IsRead     = grpMessage.IsRead;
                        grpMsg.IsRecieved = grpMessage.IsRecieved;
                        grpMsg.UserId     = CommonHelper.GetUserId();
                        db.Update(grpMsg);
                    }
                    else
                    {
                        grpMsg = new GroupMessageStatus();
                        grpMsg.GroupMessageId = grpMessage.GroupMessageId;
                        grpMsg.IsSend         = grpMessage.IsSend;
                        grpMsg.IsRead         = grpMessage.IsRead;
                        grpMsg.IsRecieved     = grpMessage.IsRecieved;
                        grpMsg.ReceiverId     = grpMessage.ReceiverId;
                        grpMsg.UserId         = CommonHelper.GetUserId();
                        db.Insert(grpMsg);
                    }
                    db.Commit();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message, ex);
            }
            db.Close();
            return(grpMsg);
        }
        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_OnGetGroupMessageUpdateStatusRecieved(object sender, GroupMessageStatusViewModel e)
 {
     try
     {
         if (e.GroupMessageId != 0)
         {
             var savedMessages = GroupRepository.UpdateGroupMessageStatus(e);
             InvokeOnMainThread(() =>
             {
                 LoadLocalLatestMessages();
             });
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Ejemplo n.º 7
0
 private void _objChatSignalRService_OnGetGroupMessageUpdateStatusRecieved(object sender, GroupMessageStatusViewModel e)
 {
     try
     {
         if (e.GroupMessageId != 0)
         {
             var savedMessages = GroupRepository.UpdateGroupMessageStatus(e);
             Activity.RunOnUiThread(() =>
             {
                 LoadLocalChats();
             });
         }
     }
     catch (Java.Lang.Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }