public async Task GroupCreate(GroupResponseViewModel message) { try { _proxy.Invoke("GroupCreate", message); } catch (Exception ex) { } }
public async Task GroupCreate(GroupResponseViewModel message) { try { _proxy.Invoke("GroupCreate", message); } catch (Exception ex) { Crashes.TrackError(ex); } }
public static void SaveGroupCreated(GroupResponseViewModel grp) { var db = new SQLiteConnection(CommonConstant.DBPath); try { var group = GetGroupByID(grp.GroupId); if (group == null) { group = new GroupModel(); group.GroupName = grp.Name; group.GroupDescription = grp.Description; group.GroupPictureUrl = grp.PictureUrl; group.InterestId = grp.InterestId; group.GroupId = grp.GroupId; group.MemberCount = grp.MemberCount; group.OwnerId = grp.UserId; group.Visibility = grp.Visibility; group.LastMessage = grp.Message; group.LastMessageDate = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(grp.MessageTime)); group.UserId = CommonHelper.GetUserId(); db.Insert(group); } else { group.GroupName = grp.Name; group.GroupDescription = grp.Description; group.GroupPictureUrl = grp.PictureUrl; group.InterestId = grp.InterestId; group.MemberCount = grp.MemberCount; group.OwnerId = grp.UserId; group.Visibility = grp.Visibility; group.LastMessage = grp.Message; group.LastMessageDate = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(grp.MessageTime)); group.UserId = CommonHelper.GetUserId(); db.Update(group); } db.Commit(); } catch (Exception ex) { Console.WriteLine(ex.Message, ex); } db.Close(); }
private void _objChatSignalRService_OnGetGroupCreateStatusRecieved(object sender, GroupResponseViewModel e) { try { if (e.GroupId != 0) { GroupRepository.SaveGroupCreated(e); ChatModel cm = new ChatModel(); cm.ChatId = e.ChatModel.ChatId; cm.GroupId = e.ChatModel.GroupId; cm.Message = e.ChatModel.Message; cm.LastActiveTime = e.ChatModel.LastActiveTime; ChatConversation chatConversation = ChatConversationRepository.SaveGroupConverstionNewFromServer(cm); if (chatConversation != null) { Activity.RunOnUiThread(() => { MessageReceived(chatConversation, "NewChat"); }); } } } catch (Java.Lang.Exception ex) { Crashes.TrackError(ex); } }
public static void SaveChatConversationFromServer(List <ChatModel> chats) { if (GlobalConstant.ChatInsertStart) { var db = new SQLiteConnection(CommonConstant.DBPath); //ChatConversation mdchatconversation = null; try { GlobalConstant.ChatInsertStart = false; foreach (var chat in chats) { if (chat.IsGroup == false) { var conversationResponce = GetConversationbyId(chat.ChatId, (long)chat.ContactId); if (conversationResponce.success) { if (conversationResponce.chatConversation == null) { conversationResponce.chatConversation = new ChatConversation(); conversationResponce.chatConversation.LastMessage = chat.Message; conversationResponce.chatConversation.ChatId = chat.ChatId; conversationResponce.chatConversation.ContactId = chat.ContactId; conversationResponce.chatConversation.LastMessageDate = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(chat.LastActiveTime)); conversationResponce.chatConversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference conversationResponce.chatConversation.UserId = CommonHelper.GetUserId(); //var contact = new Contact //{ // name = chat.ContactProfile.FirstName + chat.ContactProfile.LastName, // contactId = chat.ContactProfile.UserId, // contactPicUrl = chat.ContactProfile.ProfileImageUrl, // Aboutme = chat.ContactProfile.AboutMe, // city = chat.ContactProfile.City, // state = chat.ContactProfile.State, // email = chat.email, // screenName = chat.ContactProfile.FirstName + " " + chat.ContactProfile.LastName, // UserId = CommonHelper.GetUserId() //}; //ContactRepository.SaveorUpdateContact(contact); db.Insert(conversationResponce.chatConversation); } else { conversationResponce.chatConversation.LastMessage = chat.Message; conversationResponce.chatConversation.SenderName = chat.SenderName; conversationResponce.chatConversation.LastMessageDate = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(chat.LastActiveTime)); conversationResponce.chatConversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference conversationResponce.chatConversation.UserId = CommonHelper.GetUserId(); //var contact = new Contact //{ // name = chat.ContactProfile.FirstName + " " + chat.ContactProfile.LastName, // contactId = chat.ContactProfile.UserId, // contactPicUrl = chat.ContactProfile.ProfileImageUrl, // Aboutme = chat.ContactProfile.AboutMe, // city = chat.ContactProfile.City, // state = chat.ContactProfile.State, // email = chat.email, // screenName = chat.ContactProfile.FirstName + " " + chat.ContactProfile.LastName, // UserId = CommonHelper.GetUserId() //}; //ContactRepository.SaveorUpdateContact(contact); db.Update(conversationResponce.chatConversation); } } } else { var conversationResponce = GetConversationbyGroupId((long)chat.GroupId); if (conversationResponce.success) { if (conversationResponce.chatConversation == null) { conversationResponce.chatConversation = new ChatConversation(); conversationResponce.chatConversation.LastMessage = chat.Message; conversationResponce.chatConversation.SenderName = chat.SenderName; conversationResponce.chatConversation.ChatId = chat.ChatId; conversationResponce.chatConversation.GroupId = chat.GroupId; conversationResponce.chatConversation.IsGroup = chat.IsGroup; conversationResponce.chatConversation.LastMessageDate = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime((DateTime)chat.LastActiveTime)); conversationResponce.chatConversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference conversationResponce.chatConversation.UserId = CommonHelper.GetUserId(); var group = new GroupResponseViewModel { Name = chat.GroupDetails.GroupName, Description = chat.GroupDetails.GroupDescription, PictureUrl = chat.GroupDetails.GroupPictureUrl, InterestId = chat.GroupDetails.InterestId, GroupId = chat.GroupDetails.GroupId, MemberCount = chat.GroupDetails.MemberCount, // m = chat.GroupDetails.UserId, Visibility = chat.GroupDetails.Visibility, Message = chat.GroupDetails.LastMessage, MessageTime = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime((DateTime)chat.LastActiveTime)), UserId = chat.GroupDetails.UserId }; GroupRepository.SaveGroupCreated(group); db.Insert(conversationResponce.chatConversation); foreach (var member in chat.GroupMember) { GroupRepository.SaveorUpdateGroupMember(member, group.GroupId); } } else { conversationResponce.chatConversation.LastMessage = chat.Message; conversationResponce.chatConversation.SenderName = chat.SenderName; conversationResponce.chatConversation.LastMessageDate = TimeZone.CurrentTimeZone.ToLocalTime(Convert.ToDateTime(chat.LastActiveTime)); conversationResponce.chatConversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference conversationResponce.chatConversation.UserId = CommonHelper.GetUserId(); conversationResponce.chatConversation.GroupId = chat.GroupId; conversationResponce.chatConversation.IsGroup = chat.IsGroup; var group = new GroupResponseViewModel { Name = chat.GroupDetails.GroupName, Description = chat.GroupDetails.GroupDescription, PictureUrl = chat.GroupDetails.GroupPictureUrl, InterestId = chat.GroupDetails.InterestId, GroupId = chat.GroupDetails.GroupId, MemberCount = chat.GroupDetails.MemberCount, // m = chat.GroupDetails.UserId, Visibility = chat.GroupDetails.Visibility, Message = chat.Message, MessageTime = (DateTime)chat.LastActiveTime, UserId = chat.GroupDetails.UserId }; GroupRepository.SaveGroupCreated(group); db.Update(conversationResponce.chatConversation); } } } db.Commit(); } GlobalConstant.ChatInsertStart = true; } catch (Exception ex) { GlobalConstant.ChatInsertStart = true; Crashes.TrackError(ex); Console.WriteLine(ex.Message, ex); } db.Close(); } }
public static void SaveChatConversationFromServer(List <ChatModel> chats) { var db = new SQLiteConnection(CommonConstant.DBPath); ChatConversation mdchatconversation = null; try { foreach (var chat in chats) { if (chat.IsGroup == false) { mdchatconversation = GetConversationbyId(chat.ChatId, (long)chat.ContactId); if (mdchatconversation == null) { mdchatconversation = new ChatConversation(); mdchatconversation.LastMessage = chat.Message; mdchatconversation.ChatId = chat.ChatId; mdchatconversation.ContactId = chat.ContactId; mdchatconversation.LastMessageDate = chat.LastActiveTime; mdchatconversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference mdchatconversation.UserId = CommonHelper.GetUserId(); var contact = new Contact { name = chat.ContactProfile.FirstName + chat.ContactProfile.LastName, contactId = chat.ContactProfile.UserId, contactPicUrl = chat.ContactProfile.ProfileImageUrl, Aboutme = chat.ContactProfile.AboutMe, city = chat.ContactProfile.City, state = chat.ContactProfile.State, email = chat.email, screenName = chat.ContactProfile.FirstName + " " + chat.ContactProfile.LastName, UserId = CommonHelper.GetUserId() }; ContactRepository.SaveorUpdateContact(contact); db.Insert(mdchatconversation); } else { mdchatconversation.LastMessage = chat.Message; mdchatconversation.SenderName = chat.SenderName; mdchatconversation.LastMessageDate = chat.LastActiveTime; mdchatconversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference mdchatconversation.UserId = CommonHelper.GetUserId(); var contact = new Contact { name = chat.ContactProfile.FirstName + " " + chat.ContactProfile.LastName, contactId = chat.ContactProfile.UserId, contactPicUrl = chat.ContactProfile.ProfileImageUrl, Aboutme = chat.ContactProfile.AboutMe, city = chat.ContactProfile.City, state = chat.ContactProfile.State, email = chat.email, screenName = chat.ContactProfile.FirstName + " " + chat.ContactProfile.LastName, UserId = CommonHelper.GetUserId() }; ContactRepository.SaveorUpdateContact(contact); db.Update(mdchatconversation); } } else { mdchatconversation = GetConversationbyGroupId((long)chat.GroupId); if (mdchatconversation == null) { mdchatconversation = new ChatConversation(); mdchatconversation.LastMessage = chat.Message; mdchatconversation.SenderName = chat.SenderName; mdchatconversation.ChatId = chat.ChatId; mdchatconversation.GroupId = chat.GroupId; mdchatconversation.IsGroup = chat.IsGroup; mdchatconversation.LastMessageDate = chat.LastActiveTime; mdchatconversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference mdchatconversation.UserId = CommonHelper.GetUserId(); var group = new GroupResponseViewModel { Name = chat.GroupDetails.GroupName, Description = chat.GroupDetails.GroupDescription, PictureUrl = chat.GroupDetails.GroupPictureUrl, InterestId = chat.GroupDetails.InterestId, GroupId = chat.GroupDetails.GroupId, MemberCount = chat.GroupDetails.MemberCount, // m = chat.GroupDetails.UserId, Visibility = chat.GroupDetails.Visibility, Message = chat.GroupDetails.LastMessage, MessageTime = (DateTime)chat.LastActiveTime, UserId = chat.GroupDetails.UserId }; GroupRepository.SaveGroupCreated(group); db.Insert(mdchatconversation); foreach (var member in chat.GroupMember) { GroupRepository.SaveorUpdateGroupMember(member, group.GroupId); } } else { mdchatconversation.LastMessage = chat.Message; mdchatconversation.SenderName = chat.SenderName; mdchatconversation.LastMessageDate = chat.LastActiveTime; mdchatconversation.OwnerId = CommonHelper.GetUserId(); //set my owner id from preference mdchatconversation.UserId = CommonHelper.GetUserId(); mdchatconversation.GroupId = chat.GroupId; mdchatconversation.IsGroup = chat.IsGroup; var group = new GroupResponseViewModel { Name = chat.GroupDetails.GroupName, Description = chat.GroupDetails.GroupDescription, PictureUrl = chat.GroupDetails.GroupPictureUrl, InterestId = chat.GroupDetails.InterestId, GroupId = chat.GroupDetails.GroupId, MemberCount = chat.GroupDetails.MemberCount, // m = chat.GroupDetails.UserId, Visibility = chat.GroupDetails.Visibility, Message = chat.Message, MessageTime = (DateTime)chat.LastActiveTime, UserId = chat.GroupDetails.UserId }; GroupRepository.SaveGroupCreated(group); db.Update(mdchatconversation); } } db.Commit(); } } catch (Exception ex) { Console.WriteLine(ex.Message, ex); } db.Close(); }