예제 #1
0
        /// <summary>
        /// Get all the messages in a folder
        /// </summary>
        /// <param name="folderId"></param>
        /// <param name="dataFormat"></param>
        /// <returns></returns>
        public async Task <GetUpdateResult <YouMailMessage[]> > GetMessagesAsync(int folderId, int imageSize, DataFormat dataFormat, int maxMessages = int.MaxValue)
        {
            try
            {
                AddPendingOp();
                GetUpdateResult <YouMailMessage[]> returnValue = null;
                if (await LoginWaitAsync())
                {
                    TraceLog(TraceLevelPriority.Normal, "Getting messages for folder: {0}", folderId);
                    var query = new YouMailMessageQuery(QueryType.GetMessages)
                    {
                        FolderId           = folderId,
                        DataFormat         = dataFormat,
                        MaxResults         = maxMessages,
                        Offset             = 0,
                        IncludePreview     = true,
                        IncludeContactInfo = true,
                        IncludeImageUrl    = true,
                        ImageSize          = imageSize,
                        PageLength         = s_PageLength,
                        Page = 1
                    };

                    returnValue = await ExecuteMessageQueryAsync(query);
                }
                return(returnValue);
            }
            finally
            {
                RemovePendingOp();
            }
        }
예제 #2
0
        /// <summary>
        /// Get the list of messages
        /// </summary>
        /// <param name="lastUpdated"></param>
        /// <param name="callback"></param>
        /// <param name="asyncState"></param>
        /// <returns></returns>
        public async Task <GetUpdateResult <YouMailHistory[]> > GetMessageHistoryAsync(DateTime lastUpdated, int imageSize)
        {
            GetUpdateResult <YouMailHistory[]> returnValue = null;

            try
            {
                AddPendingOp();
                if (await LoginWaitAsync())
                {
                    var query = new YouMailMessageQuery(QueryType.GetHistory)
                    {
                        MaxResults         = int.MaxValue,
                        Offset             = 0,
                        IncludeImageUrl    = true,
                        UpdatedFrom        = lastUpdated,
                        IncludeContactInfo = true,
                        ImageSize          = imageSize,
                        Page       = 1,
                        PageLength = s_PageLength
                    };

                    returnValue = await GetMessageHistoryFromQueryAsync(query);
                }
            }
            finally
            {
                RemovePendingOp();
            }

            return(returnValue);
        }
예제 #3
0
        /// <summary>
        /// Get the list of messages since we last checked
        /// </summary>
        /// <param name="lastUpdated"></param>
        /// <param name="dataFormat"></param>
        /// <returns></returns>
        public async Task <YouMailMessage[]> GetUpdatedMessagesSinceAsync(DateTime lastUpdated, int imageSize, DataFormat dataFormat)
        {
            YouMailMessage[] returnValue = null;
            try
            {
                AddPendingOp();
                if (await LoginWaitAsync())
                {
                    var query = new YouMailMessageQuery(QueryType.GetMessagesSince)
                    {
                        UpdatedFrom        = lastUpdated,
                        DataFormat         = dataFormat,
                        IncludePreview     = true,
                        IncludeImageUrl    = true,
                        IncludeContactInfo = true,
                        ImageSize          = imageSize,
                        Page       = 1,
                        PageLength = s_PageLength
                    };

                    List <YouMailMessage> list = new List <YouMailMessage>();
                    int count;

                    do
                    {
                        count = 0;
                        string post = query.GetQueryString();

                        TraceLog(TraceLevelPriority.Normal, "Getting MessageList: {0}", post);

                        using (var response = await YouMailApiAsync(YMST.c_messageBoxEntryQuery + post, null, HttpMethod.Get))
                        {
                            var messages = DeserializeObject <YouMailMessages>(response.GetResponseStream());

                            if (messages != null && messages.Messages != null)
                            {
                                count = messages.Messages.Length;
                                list.AddRange(messages.Messages);
                            }
                        }
                        query.Page++;
                    } while (count == query.PageLength);

                    returnValue = list.ToArray();
                }
            }
            finally
            {
                RemovePendingOp();
            }

            return(returnValue);
        }
예제 #4
0
        /// <summary>
        /// Get a specific message from the server
        /// </summary>
        /// <param name="item">The message we want to get</param>
        /// <param name="messageFormat">The format of the message to download</param>
        public async Task <YouMailMessage> GetMessageAsync(long item, int imageSize, DataFormat messageFormat)
        {
            try
            {
                AddPendingOp();
                YouMailMessage message = null;
                if (await(LoginWaitAsync()))
                {
                    var query = new YouMailMessageQuery(QueryType.GetMessage)
                    {
                        ImageSize          = imageSize,
                        DataFormat         = messageFormat,
                        IncludePreview     = true,
                        IncludeContactInfo = true,
                        IncludeImageUrl    = true,
                        IncludeExtraInfo   = true
                    };
                    query.AddItemId(item);

                    var results = await ExecuteMessageQueryAsync(query);

                    if (results != null && results.Data != null && results.Data.Length > 0)
                    {
                        message = results.Data[0];
                        if (!string.IsNullOrEmpty(message.Preview))
                        {
                            var uri = string.Format(YMST.c_messageBoxEntryDetails, item);
                            using (var response = await YouMailApiAsync(uri, null, HttpMethod.Get))
                            {
                                var resp = DeserializeObject <YouMailMessageResponse>(response.GetResponseStream());
                                if (resp != null)
                                {
                                    message.Transcription = resp.Message.Transcription;
                                }
                            }
                        }
                    }
                }
                return(message);
            }
            finally
            {
                RemovePendingOp();
            }
        }
예제 #5
0
        /// <summary>
        /// Get a specified call
        /// </summary>
        /// <param name="messageId">The message that we want to update</param>
        /// <returns></returns>
        public async Task <YouMailHistory> GetMessageHistoryAsync(long messageId, int imageSize)
        {
            YouMailHistory returnValue = null;

            try
            {
                AddPendingOp();
                if (await LoginWaitAsync())
                {
                    var query = new YouMailMessageQuery(QueryType.GetMessageHistory)
                    {
                        MaxResults         = int.MaxValue,
                        Offset             = 0,
                        IncludeImageUrl    = true,
                        IncludeContactInfo = true,
                        IncludeLocation    = true,
                        ImageSize          = imageSize,
                        Page       = 1,
                        PageLength = s_PageLength
                    };
                    query.AddItemId(messageId);

                    var result = await GetMessageHistoryFromQueryAsync(query);

                    if (result != null && result.Data != null && result.Data.Length > 0)
                    {
                        returnValue = result.Data[0];
                    }
                }
            }
            finally
            {
                RemovePendingOp();
            }

            return(returnValue);
        }
예제 #6
0
 public async Task <GetUpdateResult <YouMailMessage[]> > GetMessagesFromQueryAsync(YouMailMessageQuery query)
 {
     try
     {
         AddPendingOp();
         GetUpdateResult <YouMailMessage[]> returnValue = null;
         if (await LoginWaitAsync())
         {
             returnValue = await ExecuteMessageQueryAsync(query);
         }
         return(returnValue);
     }
     finally
     {
         RemovePendingOp();
     }
 }