コード例 #1
0
        // Token: 0x06000D02 RID: 3330 RVA: 0x00036364 File Offset: 0x00034564
        private FileSetItem GetNewestItem(Folder folder, string fileSetId)
        {
            List <FileSetItem> allItems    = this.GetAllItems(folder, fileSetId);
            FileSetItem        fileSetItem = null;

            foreach (FileSetItem fileSetItem2 in allItems)
            {
                if (fileSetItem == null || fileSetItem2.Time > fileSetItem.Time)
                {
                    fileSetItem = fileSetItem2;
                }
            }
            if (fileSetItem != null)
            {
                this.tracer.TraceDebug((long)this.GetHashCode(), "Found {0} items for fileSetId='{1}'in folder '{2}'. Most recent item is {3} from {4}", new object[]
                {
                    allItems.Count,
                    fileSetId,
                    this.folderName,
                    fileSetItem.Id,
                    fileSetItem.Time
                });
            }
            return(fileSetItem);
        }
コード例 #2
0
        // Token: 0x06000CFE RID: 3326 RVA: 0x00035F6C File Offset: 0x0003416C
        public Stream GetSingleFile(FileSetItem fileSetItem, string fileName, MailboxSession mailboxSession)
        {
            MemoryStream memoryStream = null;

            try
            {
                using (Item item = Item.Bind(mailboxSession, fileSetItem.Id))
                {
                    foreach (AttachmentHandle handle in item.IAttachmentCollection)
                    {
                        using (IAttachment attachment = item.IAttachmentCollection.OpenIAttachment(handle))
                        {
                            if (string.Equals(fileName, attachment[AttachmentSchema.AttachLongFileName] as string, StringComparison.OrdinalIgnoreCase))
                            {
                                IStreamAttachment attachment2 = attachment as IStreamAttachment;
                                memoryStream = new MemoryStream();
                                this.ReadAttachmentIntoStreamAndValidateHash(attachment2, new NoCloseStream(memoryStream), new Action(MailboxFileStore.NeverAbort));
                                memoryStream.Seek(0L, SeekOrigin.Begin);
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                if (memoryStream != null)
                {
                    memoryStream.Dispose();
                    memoryStream = null;
                }
                throw;
            }
            return(memoryStream);
        }
コード例 #3
0
        // Token: 0x06000CFB RID: 3323 RVA: 0x00035C68 File Offset: 0x00033E68
        public List <string> Download(FileSetItem fileSetItem, MailboxSession mailboxSession, string tempFolderPath, bool ignoreDuplicateFiles, Action abortFileOperation)
        {
            bool   flag = false;
            string text = Path.Combine(tempFolderPath, this.folderName + Path.GetRandomFileName());

            Directory.CreateDirectory(text);
            List <string> list = new List <string>(100);
            List <string> result;

            try
            {
                this.tracer.TraceDebug <string, string, string>((long)this.GetHashCode(), "Downloading files for fileSetId='{0}' from mailbox folder '{1}' in filesystem folder {2}", fileSetItem.Name, this.folderName, text);
                Stopwatch stopwatch = Stopwatch.StartNew();
                using (Item item = Item.Bind(mailboxSession, fileSetItem.Id))
                {
                    foreach (AttachmentHandle attachmentHandle in item.IAttachmentCollection)
                    {
                        this.tracer.TraceDebug <int>((long)this.GetHashCode(), "Handling attachment id:'{0}'", attachmentHandle.AttachNumber);
                        using (IAttachment attachment = item.IAttachmentCollection.OpenIAttachment(attachmentHandle))
                        {
                            IStreamAttachment streamAttachment = attachment as IStreamAttachment;
                            if (streamAttachment != null)
                            {
                                string text2 = this.DownloadSingleFile(streamAttachment, text, ignoreDuplicateFiles, abortFileOperation);
                                if (text2 != null)
                                {
                                    this.tracer.TraceDebug <int, string>((long)this.GetHashCode(), "Successfully downloaded attachment '{0}' into file {1}", attachmentHandle.AttachNumber, text2);
                                    list.Add(text2);
                                }
                                else
                                {
                                    this.tracer.TraceError <int>((long)this.GetHashCode(), "Ignoring attachment '{0}' because could not download its content", attachmentHandle.AttachNumber);
                                }
                            }
                            else
                            {
                                this.tracer.TraceError <int>((long)this.GetHashCode(), "Ignoring attachment '{0}' because it is not stream attachment", attachmentHandle.AttachNumber);
                            }
                        }
                    }
                }
                stopwatch.Stop();
                this.tracer.TraceDebug <int, long>((long)this.GetHashCode(), "Downloaded '{0}' files. Downloaded elapsed time: {1}ms", list.Count, stopwatch.ElapsedMilliseconds);
                flag   = true;
                result = list;
            }
            finally
            {
                if (!flag || list == null || list.Count == 0)
                {
                    this.tracer.TraceDebug <string>((long)this.GetHashCode(), "Download failed and temporary folder '{0}' needs to be removed", text);
                    this.DeleteFolder(text);
                }
            }
            return(result);
        }
コード例 #4
0
 // Token: 0x06000CFA RID: 3322 RVA: 0x00035C4C File Offset: 0x00033E4C
 public List <string> Download(FileSetItem fileSetItem, MailboxSession mailboxSession)
 {
     return(this.Download(fileSetItem, mailboxSession, Path.GetTempPath(), false, new Action(MailboxFileStore.NeverAbort)));
 }