private void AddNewUsers()
 {
     userDetails = new List<User> ();
     newUserCount = 0;
     toBeGrabbed = newUsersToAdd.Count;
     LOLConnectClient service = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
     service.UserGetSpecificCompleted += Service_UserGetSpecificDone;
     service.UserGetSpecificAsync (AndroidData.CurrentUser.AccountID, newUsersToAdd [newUserCount], new Guid (AndroidData.ServiceAuthToken));
 }
Exemplo n.º 2
0
 private void createNewUsers()
 {
     newUsersToAdd = UnknownUser.unknownUsers.Count;
     if (newUsersToAdd == 0)
         end();
     counter = 0;
     LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
     service.UserGetSpecificCompleted += Service_UserGetSpecificDone;
     service.UserGetSpecificAsync(AndroidData.CurrentUser.AccountID, UnknownUser.unknownUsers [counter], new Guid(AndroidData.ServiceAuthToken));
 }
        private void Service_MessageGetConversationsCompleted(object sender, MessageGetConversationsCompletedEventArgs e)
        {
            LOLMessageClient service = (LOLMessageClient)sender;
            service.MessageGetConversationsCompleted -= Service_MessageGetConversationsCompleted;

            if (null == e.Error) {
                LOLMessageDelivery.Message[] result = e.Result.ToArray ();
                List<MessageDB> msgList = new List<MessageDB> ();
                UserDB contactUser = null;
                foreach (LOLMessageDelivery.Message eachMessage in result) {
                    if (eachMessage.Errors.Count > 0) {
                        #if DEBUG
                        System.Diagnostics.Debug.WriteLine ("Error retrieving message: {0}", StringUtils.CreateErrorMessageFromMessageGeneralErrors (eachMessage.Errors.ToArray ()));
                        #endif
                    } else {
                        contactUser = null;
                        #if DEBUG
                        System.Diagnostics.Debug.WriteLine ("**Message id received: {0}", eachMessage.MessageID);
                        #endif

                        MessageDB msgDB = MessageDB.ConvertFromMessage (eachMessage);
                        msgList.Add (msgDB);

                        #if DEBUG
                        System.Diagnostics.Debug.WriteLine ("Message in conversation received! {0}", msgDB);
                        #endif

                        contactUser = msgDB.FromAccountID == AndroidData.CurrentUser.AccountID ? UserDB.ConvertFromUser (AndroidData.CurrentUser) :
                            dbm.GetUserWithAccountID (msgDB.FromAccountGuid);

                        this.MessageItems [eachMessage.MessageID] = new MessageInfo (msgDB, contactUser);
                    }//end if else
                }//end foreach

                if (msgList.Count > 0)
                    dbm.InsertOrUpdateMessages (msgList);

                // Get message users
                Pair<Queue<Guid>, Queue<Guid>> stateObj = new Pair<Queue<Guid>, Queue<Guid>> (new Queue<Guid> (), new Queue<Guid> ());
                foreach (MessageInfo eachMessageInfo in this.MessageItems.Values.Where(s => s.Message.FromAccountID != AndroidData.CurrentUser.AccountID)) {
                    if (!dbm.CheckUserExists (eachMessageInfo.Message.FromAccountGuid)) {
                        stateObj.ItemA.Enqueue (eachMessageInfo.Message.MessageID);
                        stateObj.ItemB.Enqueue (eachMessageInfo.Message.FromAccountID);
                    }//end if
                }//end foreach

                if (stateObj.ItemA.Count > 0) {
                    LOLConnectClient userService = new LOLConnectClient (LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
                    userService.UserGetSpecificCompleted += Service_UserGetSpecificCompletedForSenders;
                    userService.UserGetSpecificAsync (AndroidData.CurrentUser.AccountID, stateObj.ItemB.Peek (), new Guid (AndroidData.ServiceAuthToken), stateObj);
                } else {
                    fromLocalOnly = true;
                    RunOnUiThread (delegate {
                        if (progress != null)
                            progress.Dismiss ();
                        GetRowsForMessages ();
                        CreatePreviewUI ();
                    });
                }//end if else
            } else {
            #if(DEBUG)
                System.Diagnostics.Debug.WriteLine ("Exception in MessageGetConversationsCompleted! {0}--{1}", e.Error.Message, e.Error.StackTrace);
            #endif
            }//end if else
        }
Exemplo n.º 4
0
        public void Service_MessageGetNewCompleted(object sender, MessageGetNewCompletedEventArgs e)
        {
            LOLMessageClient service = (LOLMessageClient)sender;
            service.MessageGetNewCompleted -= Service_MessageGetNewCompleted;

            if (null == e.Error)
            {
                Message[] result = e.Result.ToArray();

            #if(DEBUG)
                System.Diagnostics.Debug.WriteLine("Received {0} new messages!", result.Length);
            #endif

                List<Message> msgList = new List<Message>();
                Queue<Guid> userQ = new Queue<Guid>();
                foreach (Message eachMessage in result)
                {
                    if (eachMessage.Errors.Count > 0)
                    {
            #if(DEBUG)
                        System.Diagnostics.Debug.WriteLine("Error retrieving new messages: {0}",
                                          StringUtils.CreateErrorMessageFromMessageGeneralErrors(eachMessage.Errors));
            #endif
                    } else
                    {
                        msgList.Add(eachMessage);
                        if (!dbm.CheckUserExists(eachMessage.FromAccountID.ToString()))
                        {
                            userQ.Enqueue(eachMessage.FromAccountID);
                        }
                    }
                }
                // Insert the messages to the database

                List<MessageDB> msgListForDB = new List<MessageDB>();
                msgList.ForEach(s => msgListForDB.Add(MessageDB.ConvertFromMessage(s)));
                dbm.InsertOrUpdateMessages(msgListForDB);

                // Trigger the event only if the app is active.
            #if DEBUG
                System.Diagnostics.Debug.WriteLine("IsAppActive = {0}, msgList.Count = {1}", AndroidData.IsAppActive, msgList.Count);
            #endif
                if (AndroidData.IsAppActive == true && msgList.Count > 0)
                {
                    if (null != this.ReceivedMessages)
                    {
                        this.ReceivedMessages(this, new IncomingMessageEventArgs(msgList));
                    }//end if
                }//end if

                if (userQ.Count > 0)
                {
                    LOLConnectClient clientService = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
                    clientService.UserGetSpecificCompleted += Service_UserGetSpecificCompleted;
                    clientService.UserGetSpecificAsync(AndroidData.CurrentUser.AccountID, userQ.Peek(), new Guid(AndroidData.ServiceAuthToken), userQ);
                } else
                    this.isMsgInProgress = false;
            } else
            {
                this.isMsgInProgress = false;
            #if(DEBUG)
                System.Diagnostics.Debug.WriteLine("Exception receiving message! {0}--{1}",
                                  e.Error.Message, e.Error.StackTrace);
            #endif
            }//end if else
        }
Exemplo n.º 5
0
        private void getNewContacts(List<Guid>contactsToGet)
        {
            LOLConnectClient client = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
            Queue<Guid> userQ = new Queue<Guid>();
            foreach (Guid guid in contactsToGet)
                userQ.Enqueue(guid);
            client.UserGetSpecificAsync(AndroidData.CurrentUser.AccountID, userQ.Peek(), new Guid(AndroidData.ServiceAuthToken), userQ);
            client.UserGetSpecificCompleted += (object sender, UserGetSpecificCompletedEventArgs e) =>
            {
                if (null == e.Error)
                {
                    LOLAccountManagement.User result = e.Result;
                    if (result.Errors.Count > 0)
                    {
            #if DEBUG
                        System.Diagnostics.Debug.WriteLine("Error retrieving user: {0}", StringUtils.CreateErrorMessageFromGeneralErrors(result.Errors));
            #endif
                    } else
                    {
                        Queue<Guid> userQQ = (Queue<Guid>)e.UserState;

                        if (!dbm.CheckUserExists(userQQ.Dequeue().ToString()))
                        {
                            dbm.InsertOrUpdateUser(result);
                            if (result.HasProfileImage)
                                getContactImage(userQQ.Peek(), true);
                        }

                        if (userQQ.Count > 0)
                            client.UserGetSpecificAsync(AndroidData.CurrentUser.AccountID, userQQ.Peek(), new Guid(AndroidData.ServiceAuthToken), userQQ);
                    }
                }
            };
        }