Пример #1
0
        // Gets a list of all the conversation IDs associated with this label.
        // One id per line.
        public async Task <List <MessageIdInfo> > GetLabelMessageListAsync(string labelName)
        {
            string labelsDir      = Path.Combine(AccountDir, _accountName, LabelsDir);
            string labelsFilePath = Path.Combine(labelsDir, EscapeLabelName(labelName) + ".csv");

            if (!_storage.DirectoryExists(labelsDir) || !_storage.FileExists(labelsFilePath))
            {
                return(null);
            }

            List <MessageIdInfo> messageIds = new List <MessageIdInfo>();

            using (var reader = new StreamReader(_storage.OpenFile(labelsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                string line = await reader.ReadLineAsync();

                while (line != null)
                {
                    string[]      parts = line.Split(',');
                    MessageIdInfo ids   = new MessageIdInfo()
                    {
                        Uid = parts[0], MessageId = parts[1], ThreadId = parts[2]
                    };
                    messageIds.Add(ids);
                    line = await reader.ReadLineAsync();
                }
            }

            return(messageIds);
        }
Пример #2
0
        // Gets a list of all the conversation IDs associated with this label.
        // One id per line.
        public async Task<List<MessageIdInfo>> GetLabelMessageListAsync(string labelName)
        {
            string labelsDir = Path.Combine(AccountDir, _accountName, LabelsDir);
            string labelsFilePath = Path.Combine(labelsDir, EscapeLabelName(labelName) + ".csv");

            if (!_storage.DirectoryExists(labelsDir) || !_storage.FileExists(labelsFilePath))
            {
                return null;
            }

            List<MessageIdInfo> messageIds = new List<MessageIdInfo>();

            using (var reader = new StreamReader(_storage.OpenFile(labelsFilePath, FileMode.Open, FileAccess.Read, FileShare.Read)))
            {
                string line = await reader.ReadLineAsync();
                while (line != null)
                {
                    string[] parts = line.Split(',');
                    MessageIdInfo ids = new MessageIdInfo() { Uid = parts[0], MessageId = parts[1], ThreadId = parts[2] };
                    messageIds.Add(ids);
                    line = await reader.ReadLineAsync();
                }
            }

            return messageIds;
        }