private void MessageManager_MessageSendConfirmCompleted(object sender, MessageSendConfirmEventArgs e)
 {
     MessageDB message = e.Message;
     if (message.MessageConfirmed) {
         MessageInfo msgInfo = new MessageInfo (message, UserDB.ConvertFromUser (AndroidData.CurrentUser));
         if (conversationInfo.IsInConversation (msgInfo) && !conversationInfo.Messages.ContainsKey (message.MessageID)) {
             conversationInfo.Messages.Add (message.MessageID, msgInfo);
             if (!isConversation)
                 createUI (new List<MessageDB> (){msgInfo.Message}, new List<UserDB> (){msgInfo.MessageUser}, "", true);
             else
                 CreatePreviewUI ();
         }
     }
 }
Пример #2
0
 public bool IsConversationWith(MessageInfo otherMessage)
 {
     if (Message.MessageRecipientDBList.Count == otherMessage.Message.MessageRecipientDBList.Count) {
         bool toReturn = true;
         List<Guid> myUsers = GetAllUserAccountIDs ();
         List<Guid> otherUsers = otherMessage.GetAllUserAccountIDs ();
         for (int i = 0; i < myUsers.Count; ++i)
             toReturn &= myUsers [i].Equals (otherUsers [i]);
         return toReturn;
     } else
         return false;
 }
 private void MessageManager_MessageSendConfirmCompleted(object s, MessageSendConfirmEventArgs e)
 {
     MessageDB message = e.Message;
     if (message.MessageConfirmed) {
         MessageInfo msgInfo = new MessageInfo (message, UserDB.ConvertFromUser (AndroidData.CurrentUser));
         if (ConversationInfo.IsInConversation (msgInfo) && !(ConversationInfo.Messages.ContainsKey (message.MessageID)))
             ConversationInfo.Messages.Add (message.MessageID, msgInfo);
     }
 }
 private void CheckForSentMessage()
 {
     MessageDB latest = dbm.GetLatestSentMessage (AndroidData.CurrentUser.AccountID.ToString ());
     if (latest != null) {
         MessageInfo msgInfo = new MessageInfo (latest, UserDB.ConvertFromUser (AndroidData.CurrentUser));
         if (ConversationInfo.ConversationID.Equals (msgInfo.GetConversationID ())) {
             if (!ConversationInfo.Messages.ContainsKey (latest.MessageID)) {
                 ConversationInfo.Messages [latest.MessageID] = msgInfo;
                 // reload view
             }
         }
     }
 }
        private void AppDelegate_ReceivedMessages(object sender, IncomingMessageEventArgs e)
        {
            List<MessageInfo> messageItems = new List<MessageInfo> ();

            foreach (LOLMessageDelivery.Message eachMessage in e.Messages) {
                MessageDB msgDB = MessageDB.ConvertFromMessage (eachMessage);
                MessageInfo msgInfo = new MessageInfo (msgDB, msgDB.FromAccountID == AndroidData.CurrentUser.AccountID ?
                                                      UserDB.ConvertFromUser (AndroidData.CurrentUser) :
                                                      dbm.GetUserWithAccountID (msgDB.FromAccountGuid));
                if (msgInfo != null)
                    messageItems.Add (msgInfo);
            }//end foreach

            if (messageItems.Count > 0) {
                foreach (MessageInfo eachMessageInfo in messageItems) {
                    this.MessageItems [eachMessageInfo.Message.MessageID] = eachMessageInfo;
                }
                RunOnUiThread (delegate {
                    for (int i = 0; i < messageItems.Count; ++i) {
                        createUI (messageItems [i].Message, messageItems [i].MessageUser);
                    }
                });
            }//end if
        }
 public bool IsInConversation(MessageInfo messageInfo)
 {
     return this.ConversationID.Equals (messageInfo.GetConversationID ());
 }
 private void processMessages(MessageDB message)
 {
     List<MessageInfo> messageItems = new List<MessageInfo> ();
     MessageInfo msgInfo = new MessageInfo (message, message.FromAccountID == AndroidData.CurrentUser.AccountID ?
                                               UserDB.ConvertFromUser (AndroidData.CurrentUser) :
                                               dbm.GetUserWithAccountID (message.FromAccountGuid));
     if (msgInfo != null)
         messageItems.Add (msgInfo);
     if (messageItems.Count > 0) {
         foreach (MessageInfo eachMessageInfo in messageItems) {
             this.MessageItems [eachMessageInfo.Message.MessageID] = eachMessageInfo;
         }
     }//end if
 }
        private void LoadContactsAndMessages(bool fromLocalOnly)
        {
            this.MessageItems.Clear ();
            conversationItems.Clear ();
            contacts.Clear ();
            this.contacts = dbm.GetAllContactsForOwner (AndroidData.CurrentUser.AccountID.ToString ()).ToDictionary (s => s.ContactAccountID, s => s);
            List<MessageDB> message = new List<MessageDB> ();
            message = dbm.GetAllMessagesForOwner (AndroidData.CurrentUser.AccountID.ToString ());
            List<MessageDB> messages = new List<MessageDB> ();
            List<UserDB> users = new List<UserDB> ();

            foreach (MessageDB eachMessageDB in message) {
                ContactDB msgContact = null;
                UserDB contactUser = null;
                MessageInfo msgInfoItem = null;

                if (eachMessageDB.FromAccountID != AndroidData.CurrentUser.AccountID) {
                    if (this.contacts.TryGetValue (eachMessageDB.FromAccountID, out msgContact))
                        contactUser = UserDB.ConvertFromUser (msgContact.ContactUser);
                    else
                        contactUser = dbm.GetUserWithAccountID (eachMessageDB.FromAccountGuid);

                    msgInfoItem = new MessageInfo (eachMessageDB, contactUser);
                } else {
                    contactUser = UserDB.ConvertFromUser (AndroidData.CurrentUser);
                    msgInfoItem = new MessageInfo (eachMessageDB, contactUser);

                    if (!eachMessageDB.MessageConfirmed) {
                        ContentInfo contentInfo = dbm.GetContentInfoByMessageDBID (eachMessageDB.ID);
                        msgInfoItem.ContentInfo = contentInfo;
                    }
                }
                messages.Add (eachMessageDB);
                users.Add (contactUser);
                this.MessageItems [eachMessageDB.MessageID] = msgInfoItem;
                /*if (isConversation == false) {
                    RunOnUiThread (delegate {
                        createUI (messages, users);
                    });
                }*/
            }

            if (fromLocalOnly) {
                RunOnUiThread (delegate {
                    if (progress != null)
                        progress.Dismiss ();
                    GetRowsForMessages ();
                    CreatePreviewUI ();
                });
            } else {
                List<Guid> excludeMessageGuids = new List<Guid> ();
                excludeMessageGuids = this.MessageItems.Values.Where (s => s.Message.MessageStepDBList.Count (t => t.StepID == default(Guid)) == 0)
                    .Select (s => s.Message.MessageID).ToList ();

                LOLMessageClient service = new LOLMessageClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLMessageEndpoint);
            #if DEBUG
                System.Diagnostics.Debug.WriteLine ("**Will call MessageGetConversations with params: account id {0}, start date: new DateTime(1900, 1, 1), end date: new DateTime(2099, 1, 1), service auth token: {1}",
                                  AndroidData.CurrentUser.AccountID, new Guid (AndroidData.ServiceAuthToken));
            #endif
            #if DEBUG
                if (null == excludeMessageGuids) {

                    System.Diagnostics.Debug.WriteLine ("**Exclude message ids is NULL!");

                } else {
                    System.Diagnostics.Debug.WriteLine ("**Exclude message ids count: {0}", excludeMessageGuids.Count);

                    foreach (Guid eachMessageID in excludeMessageGuids) {
                        System.Diagnostics.Debug.WriteLine ("**Each message id to exclude: {0}", eachMessageID);
                    }//end foreach
                }//end if
                #endif

                service.MessageGetConversationsCompleted += Service_MessageGetConversationsCompleted;
                service.MessageGetConversationsAsync (AndroidData.CurrentUser.AccountID,
                                                     new DateTime (1900, 1, 1),
                                                     new DateTime (2099, 1, 1), 50,
                                                     excludeMessageGuids,
                                                     new Guid (AndroidData.ServiceAuthToken));
            }//end if else
        }
        private void AppDelegate_ReceivedConversationMessages(object sender, IncomingMessageEventArgs e)
        {
            foreach (LOLMessageDelivery.Message eachMessage in e.Messages) {
                MessageDB msgDB = MessageDB.ConvertFromMessage (eachMessage);
                MessageInfo msgInfo = new MessageInfo (msgDB, msgDB.FromAccountID == AndroidData.CurrentUser.AccountID ? UserDB.ConvertFromUser (AndroidData.CurrentUser) :
                                                        dbm.GetUserWithAccountID (msgDB.FromAccountGuid));

                if (conversationInfo.ConversationID.Equals (msgInfo.GetConversationID ()))
                    conversationInfo.Messages [msgInfo.Message.MessageID] = msgInfo;
                commonConversation (conversationInfo.ConversationID);
            }
        }