示例#1
0
 public void Execute(CancellationToken token)
 {
     _attachment.Status = PropertyNames.Processing;
     using (var packager = new MailAttachmentPackager())
     {
         packager.UnPack(_attachment, token);
     }
     _attachment.Status = PropertyNames.IsProcessed;
 }
示例#2
0
        public void Execute(CancellationToken token)
        {
            using (var packager = new MailAttachmentPackager())
            {
                foreach (IProtectAttachment attachment in _attachments)
                {
                    if (token.IsCancellationRequested)
                        return;

					// it is not possible to process encrypted attachment
					if (attachment.HasPassword && string.IsNullOrEmpty(attachment.OpenPassword))
						continue;

                    packager.RePack(attachment, token);
                }
            }
        }
示例#3
0
		public void Execute(CancellationToken token)
		{
			if (token.IsCancellationRequested)
				return;

            Attachment.Status = PropertyNames.Processing;


            switch (Attachment.FileType)
            {
                case FileType.PDFDocument:
                    {
                        if (!string.IsNullOrEmpty(Attachment.OpenPassword))
                        {
                            Pdf.Security.Add(Attachment.FileName, Attachment.OpenPassword);
                            Attachment.Reload();
                            Attachment.ReEncrypt = false;
                        }
                        break;
                    }
                    case FileType.ZIP:
                    {
                        using (var packager = new MailAttachmentPackager())
                        {
                            packager.RePack(Attachment, token);
                        }
                        break;
                    }
                default:
                    {
                        if (EncryptionManager == null)
                            throw new Exception("Cannot reencrypt file as no encryption manager");

                        EncryptionManager.ReEncrypt(Attachment);
                        break;
                    }
            }

            Attachment.Status = PropertyNames.IsProcessed;
		}
示例#4
0
        // ReSharper disable once UnusedParameter.Local
        private void VerifyFilesAreOfType(IProtectAttachment attachment, FileType fileType)
        {
            using (var packager = new MailAttachmentPackager())
            {
                packager.UnPack(attachment, new CancellationToken());
            }


            var flattenedList = TestUtils.Flatten(attachment.Children, new List<FileType>() { FileType.Email });

            foreach (var item in flattenedList)
            {
                Assert.IsTrue(item.FileType == fileType);
            }
        }