Ejemplo n.º 1
0
        public void CannotGetAbstractDocumentTypes()
        {
            var type = DocumentTypeUtility.GetTypeBuilder(TypeAttributes.Abstract).CreateType();

            var typeService = GetTypeService(type);

            var documentTypes = typeService.DocumentTypes;

            Assert.IsFalse(documentTypes.Any());
        }
Ejemplo n.º 2
0
        public void CanGetDocumentTypes()
        {
            var type = DocumentTypeUtility.GetTypeBuilder().CreateType();

            var typeService = GetTypeService(type);

            var documentTypes = typeService.DocumentTypes;

            Assert.AreEqual(1, documentTypes.Count);
        }
Ejemplo n.º 3
0
        public void CanGetDocumentTypes()
        {
            var type = DocumentTypeUtility.GetTypeBuilder().CreateType();

            var typeServiceMock = GetTypeServiceMock(type);

            var typeResolver = new TypeResolver(typeServiceMock.Object);

            var documentTypes = typeResolver.DocumentTypes;

            Assert.AreEqual(1, documentTypes.Count);
        }
Ejemplo n.º 4
0
        public void CanGetDocumentForValidDocumentType()
        {
            var type = DocumentTypeUtility.GetTypeBuilder().CreateType();

            var contentMock = new Mock <IPublishedContent>();

            contentMock.Setup(m => m.Properties).Returns(new List <IPublishedProperty>());

            var service = new DocumentService(new Mock <IUmbracoHelperWrapper>().Object);

            var document = service.GetDocument(contentMock.Object, type);

            Assert.IsNotNull(document);
        }
Ejemplo n.º 5
0
        private void uploadAttachment(PackageId packageId, string attachmentId, string filename, Stream fileStream, string sessionId)
        {
            string path = template.UrlFor(UrlTemplate.ATTACHMENT_REQUIREMENT_PATH)
                          .Replace("{packageId}", packageId.Id)
                          .Replace("{attachmentId}", attachmentId)
                          .Build();

            byte[] fileBytes = new StreamDocumentSource(fileStream).Content();
            string fileName  = DocumentTypeUtility.NormalizeName(DocumentType.PDF, filename);
            string boundary  = GenerateBoundary();

            byte[] bytes = new byte[fileName.Length * sizeof(char)];
            System.Buffer.BlockCopy(fileName.ToCharArray(), 0, bytes, 0, bytes.Length);

            byte[] content = CreateMultipartContent(fileName, fileBytes, bytes, boundary);

            try {
                client.PostMultipartFile(path, content, boundary, sessionId, Converter.ToString(bytes));
            } catch (Exception e) {
                throw new EslException("Could not upload attachment for signer." + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 6
0
 public DocumentBuilder FromStream(Stream contentStream, DocumentType type)
 {
     documentSource = new StreamDocumentSource(contentStream);
     fileName       = DocumentTypeUtility.NormalizeName(type, name);
     return(this);
 }
Ejemplo n.º 7
0
        override public void Execute()
        {
            // Signer1 with 1 attachment requirement
            signer1 = SignerBuilder.NewSignerWithEmail(email1)
                      .WithFirstName("John")
                      .WithLastName("Smith")
                      .WithCustomId(SIGNER1_ID)
                      .WithAttachmentRequirement(AttachmentRequirementBuilder.NewAttachmentRequirementWithName(NAME1)
                                                 .WithDescription(DESCRIPTION1)
                                                 .IsRequiredAttachment()
                                                 .Build())
                      .Build();

            // Signer2 with 2 attachment requirements
            Signer signer2 = SignerBuilder.NewSignerWithEmail(email2)
                             .WithFirstName("Patty")
                             .WithLastName("Galant")
                             .WithCustomId(SIGNER2_ID)
                             .WithAttachmentRequirement(AttachmentRequirementBuilder.NewAttachmentRequirementWithName(NAME2)
                                                        .WithDescription(DESCRIPTION2)
                                                        .Build())
                             .WithAttachmentRequirement(AttachmentRequirementBuilder.NewAttachmentRequirementWithName(NAME3)
                                                        .WithDescription(DESCRIPTION3)
                                                        .IsRequiredAttachment()
                                                        .Build())
                             .Build();

            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("AttachmentRequirementExample: " + DateTime.Now)
                                                .DescribedAs("This is a package created using the e-SignLive SDK")
                                                .WithSigner(signer1)
                                                .WithSigner(signer2)
                                                .WithDocument(DocumentBuilder.NewDocumentNamed("test document")
                                                              .FromStream(fileStream1, DocumentType.PDF)
                                                              .WithSignature(SignatureBuilder.SignatureFor(email1)
                                                                             .Build())
                                                              .Build())
                                                .Build();

            packageId = eslClient.CreateAndSendPackage(superDuperPackage);

            retrievedPackage = eslClient.GetPackage(packageId);

            attachment1Id = retrievedPackage.Signers[email1].Attachments[NAME1].Id;
            signer1       = retrievedPackage.Signers[email1];

            signer1Attachments = retrievedPackage.Signers[email1].Attachments;
            signer2Attachments = retrievedPackage.Signers[email2].Attachments;

            signer1Att1 = signer1Attachments[NAME1];
            signer2Att1 = signer2Attachments[NAME2];
            signer2Att2 = signer2Attachments[NAME3];

            retrievedSigner1Att1RequirementStatus = signer1Att1.Status;
            retrievedSigner2Att1RequirementStatus = signer2Att1.Status;
            retrievedSigner2Att2RequirementStatus = signer2Att2.Status;

            // Upload attachment for signer1

            byte[] attachment1ForSigner1FileContent = new StreamDocumentSource(attachmentInputStream1).Content();
            attachment1ForSigner1FileSize = attachment1ForSigner1FileContent.Length;
            eslClient.UploadAttachment(packageId, signer1Att1.Id, DocumentTypeUtility.NormalizeName(DocumentType.PDF, "The attachment1 for signer1"), attachment1ForSigner1FileContent, SIGNER1_ID);
            eslClient.UploadAttachment(packageId, signer2Att1.Id, DocumentTypeUtility.NormalizeName(DocumentType.PDF, "The attachment1 for signer2"),
                                       new StreamDocumentSource(attachmentInputStream2).Content(), SIGNER2_ID);
            eslClient.UploadAttachment(PackageId, signer2Att2.Id, DocumentTypeUtility.NormalizeName(DocumentType.PDF, "The attachment2 for signer2"),
                                       new StreamDocumentSource(attachmentInputStream3).Content(), SIGNER2_ID);

            // Sender rejects Signer1's uploaded attachment
            eslClient.AttachmentRequirementService.RejectAttachment(packageId, signer1, NAME1, REJECTION_COMMENT);
            retrievedPackageAfterRejection = eslClient.GetPackage(packageId);
            retrievedSigner1Att1RequirementStatusAfterRejection        = retrievedPackageAfterRejection.Signers[email1].Attachments[NAME1].Status;
            retrievedSigner1Att1RequirementSenderCommentAfterRejection = retrievedPackageAfterRejection.Signers[email1].Attachments[NAME1].SenderComment;

            // Sender accepts Signer1's uploaded attachment
            eslClient.AttachmentRequirementService.AcceptAttachment(packageId, signer1, NAME1);
            retrievedPackageAfterAccepting = eslClient.GetPackage(packageId);

            retrievedSigner1Att1RequirementStatusAfterAccepting        = retrievedPackageAfterAccepting.Signers[email1].Attachments[NAME1].Status;
            retrievedSigner1Att1RequirementSenderCommentAfterAccepting = retrievedPackageAfterAccepting.Signers[email1].Attachments[NAME1].SenderComment;

            // Download signer1's attachment
            byte[] downloadedAttachment = eslClient.AttachmentRequirementService.DownloadAttachment(packageId, attachment1Id);
            System.IO.File.WriteAllBytes(DOWNLOADED_ATTACHMENT_PDF, downloadedAttachment);

            // Download all attachments for the package
            byte[] downloadedAllAttachmentsForPackage = eslClient.AttachmentRequirementService.DownloadAllAttachmentsForPackage(packageId);
            System.IO.File.WriteAllBytes(DOWNLOADED_ALL_ATTACHMENTS_FOR_PACKAGE_ZIP, downloadedAllAttachmentsForPackage);

            // Download all attachments for the signer1 in the package
            byte[] downloadedAllAttachmentsForSigner1InPackage = eslClient.AttachmentRequirementService.DownloadAllAttachmentsForSignerInPackage(retrievedPackage, signer1);
            System.IO.File.WriteAllBytes(DOWNLOADED_ALL_ATTACHMENTS_FOR_SIGNER1_IN_PACKAGE_ZIP, downloadedAllAttachmentsForSigner1InPackage);

            // Download all attachments for the signer2 in the package
            byte[] downloadedAllAttachmentsForSigner2InPackage = eslClient.AttachmentRequirementService.DownloadAllAttachmentsForSignerInPackage(retrievedPackage, signer2);
            System.IO.File.WriteAllBytes(DOWNLOADED_ALL_ATTACHMENTS_FOR_SIGNER2_IN_PACKAGE_ZIP, downloadedAllAttachmentsForSigner2InPackage);

            downloadedAttachemnt1 = new FileInfo(DOWNLOADED_ATTACHMENT_PDF);
            downloadedAllAttachmentsForPackageZip          = new ZipFile(DOWNLOADED_ALL_ATTACHMENTS_FOR_PACKAGE_ZIP);
            downloadedAllAttachmentsForSigner1InPackageZip = new ZipFile(DOWNLOADED_ALL_ATTACHMENTS_FOR_SIGNER1_IN_PACKAGE_ZIP);
            downloadedAllAttachmentsForSigner2InPackageZip = new ZipFile(DOWNLOADED_ALL_ATTACHMENTS_FOR_SIGNER2_IN_PACKAGE_ZIP);
        }