Exemplo n.º 1
0
        public void CanAddTwoAttachmentRequirement()
        {
            AttachmentRequirement attachmentRequirement1 = AttachmentRequirementBuilder.NewAttachmentRequirementWithName("Driver's license")
                                                           .WithDescription("Please upload scanned driver's license.")
                                                           .IsRequiredAttachment()
                                                           .Build();
            AttachmentRequirement attachmentRequirement2 = AttachmentRequirementBuilder.NewAttachmentRequirementWithName("Medicare card")
                                                           .WithDescription("Please upload scanned medicare card.")
                                                           .IsRequiredAttachment()
                                                           .Build();

            Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                            .WithFirstName("Billy")
                            .WithLastName("Bob")
                            .WithAttachmentRequirement(attachmentRequirement1)
                            .WithAttachmentRequirement(attachmentRequirement2)
                            .Build();

            Assert.AreEqual(signer.Attachments.Count, 2);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Name, attachmentRequirement1.Name);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Description, attachmentRequirement1.Description);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Required, attachmentRequirement1.Required);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Status, attachmentRequirement1.Status);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Name, attachmentRequirement2.Name);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Description, attachmentRequirement2.Description);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Required, attachmentRequirement2.Required);
            Assert.AreEqual(signer.GetAttachmentRequirement("Medicare card").Status.ToString(), attachmentRequirement2.Status.ToString());
        }
Exemplo n.º 2
0
        private void AddUpdateAttachment(string internalName, string refTableName, string strTypeCode, HttpFileCollection fileCollection)
        {
            var    file          = fileCollection[0];
            string fileName      = Path.GetFileName(file.FileName);
            string fileExtension = Path.GetExtension(file.FileName);

            var att = new Attachment();

            att.InternalName    = internalName;
            att.RefTableName    = refTableName;
            att.RefTableID      = _refId.Value.ToString();
            att.RelativePath    = "//";
            att.Name            = fileName;
            att.Extension       = fileExtension;
            att.Length          = file.ContentLength;
            att.CreateTime      = DateTime.Now;
            att.ID              = Guid.NewGuid();
            att.TypeCode        = strTypeCode;
            att.CreatorID       = ClientCookie.UserCode;
            att.CreatorNameENUS = ClientCookie.UserNameENUS;
            att.CreatorNameZHCN = ClientCookie.UserNameZHCN;

            var ar = AttachmentRequirement.FirstOrDefault(
                e => e.RefTableName == refTableName && e.TypeCode == strTypeCode);

            if (ar != null)
            {
                att.RequirementId = ar.Id;
            }

            att.UpdateTime = DateTime.Now;
            att.IsDelete   = 0;
            Attachment.SaveSigleFile(att);
        }
Exemplo n.º 3
0
        public void VerifyResult()
        {
            example = new AttachmentRequirementExample(Props.GetInstance());
            example.Run();

            // Asserts the attachment requirements for each signer is set correctly.
            DocumentPackage retrievedPackage = example.RetrievedPackage;
            IDictionary <string, AttachmentRequirement> signer1Attachments = retrievedPackage.Signers[example.Email1].Attachments;
            IDictionary <string, AttachmentRequirement> signer2Attachments = retrievedPackage.Signers[example.Email2].Attachments;

            Assert.AreEqual(signer1Attachments.Count, 1);
            AttachmentRequirement signer1Att1 = signer1Attachments[example.NAME1];

            Assert.AreEqual(signer1Att1.Name, example.NAME1);
            Assert.AreEqual(signer1Att1.Description, example.DESCRIPTION1);
            Assert.AreEqual(signer1Att1.Required, true);
            Assert.AreEqual(signer1Att1.Status.ToString(), RequirementStatus.INCOMPLETE.ToString());

            Assert.AreEqual(signer2Attachments.Count, 2);
            AttachmentRequirement signer2Att1 = signer2Attachments[example.NAME2];
            AttachmentRequirement signer2Att2 = signer2Attachments[example.NAME3];

            Assert.AreEqual(signer2Att1.Name, example.NAME2);
            Assert.AreEqual(signer2Att1.Description, example.DESCRIPTION2);
            Assert.AreEqual(signer2Att1.Required, false);
            Assert.AreEqual(signer2Att1.Status.ToString(), RequirementStatus.INCOMPLETE.ToString());
            Assert.AreEqual(signer2Att2.Name, example.NAME3);
            Assert.AreEqual(signer2Att2.Description, example.DESCRIPTION3);
            Assert.AreEqual(signer2Att2.Required, true);
            Assert.AreEqual(signer2Att2.Status.ToString(), RequirementStatus.INCOMPLETE.ToString());

            // Upload attachment for signer1
            string signerAuthenticationToken          = example.EslClient.AuthenticationTokenService.CreateSignerAuthenticationToken(example.PackageId, example.SIGNER1ID);
            AuthenticationClient authenticationClient = new AuthenticationClient(Props.GetInstance().Get("webpage.url"));
            String sessionIdForSigner = authenticationClient.GetSessionIdForSignerAuthenticationToken(signerAuthenticationToken);

            client   = new RestClient("");
            template = new UrlTemplate(Props.GetInstance().Get("api.url"));

            Stream fileStream1 = File.OpenRead(new FileInfo(Directory.GetCurrentDirectory() + "/src/document.pdf").FullName);

            uploadAttachment(example.PackageId, signer1Att1.Id, "Test Attachment", fileStream1, sessionIdForSigner);

            // Reject signer1's attachment
            example.RejectAttachment();
            signer1Att1 = retrievedPackage.Signers[example.Email1].Attachments[example.NAME1];
            Assert.AreEqual(signer1Att1.Status.ToString(), RequirementStatus.REJECTED.ToString());
            Assert.AreEqual(signer1Att1.SenderComment, example.REJECTION_COMMENT);

            // Accept signer1's attachment
            example.AcceptAttachment();
            Assert.AreEqual(signer1Att1.Status.ToString(), RequirementStatus.COMPLETE.ToString());
            Assert.AreEqual(signer1Att1.SenderComment, "");

            // Download signer1's attachment
            byte[] downloadedAttachment = example.DownloadAttachment();
            System.IO.File.WriteAllBytes("/dev/null", downloadedAttachment);
        }
Exemplo n.º 4
0
        override public void Execute()
        {
            // Signer with 1 attachment requirement
            signer = SignerBuilder.NewSignerWithEmail(email1)
                     .WithFirstName("John")
                     .WithLastName("Smith")
                     .WithCustomId(SIGNER_ID)
                     .WithAttachmentRequirement(AttachmentRequirementBuilder.NewAttachmentRequirementWithName(NAME)
                                                .WithDescription(DESCRIPTION)
                                                .IsRequiredAttachment()
                                                .Build()).Build();

            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName)
                                                .DescribedAs("This is a package created using the eSignLive SDK")
                                                .WithSigner(signer)
                                                .WithDocument(DocumentBuilder.NewDocumentNamed("test document")
                                                              .FromStream(fileStream1, DocumentType.PDF)
                                                              .WithSignature(SignatureBuilder.SignatureFor(email1)
                                                                             .Build())
                                                              .Build())
                                                .Build();

            packageId = OssClient.CreateAndSendPackage(superDuperPackage);

            retrievedPackage = OssClient.GetPackage(packageId);
            signerAtt        = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME);

            byte [] attachmentForSignerFileContent = new StreamDocumentSource(attachmentInputStream).Content();
            signerAttachmentFileSize = attachmentForSignerFileContent.Length;
            OssClient.UploadAttachment(packageId, signerAtt.Id, ATTACHMENT_FILE_NAME,
                                       attachmentForSignerFileContent, SIGNER_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signerAtt        = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME);

            filesAfterUpload = signerAtt.Files;

            AttachmentFile attachmentFile = filesAfterUpload[0];

            // Download signer attachment
            DownloadedFile downloadedAttachment = ossClient.AttachmentRequirementService.DownloadAttachmentFile(packageId, signerAtt.Id, attachmentFile.Id);

            System.IO.File.WriteAllBytes(downloadedAttachment.Filename, downloadedAttachment.Contents);

            OssClient.DeleteAttachmentFile(packageId, signerAtt.Id, attachmentFile.Id, SIGNER_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signerAtt        = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME);

            filesAfterDelete = signerAtt.Files;

            downloadedAttachmentFile = new FileInfo(downloadedAttachment.Filename);
        }
        public void BuildWithSpecificValues()
        {
            string name        = "Driver's license";
            string description = "Please upload driver's license";
            bool   isRequired  = true;

            AttachmentRequirement attachmentRequirement = AttachmentRequirementBuilder.NewAttachmentRequirementWithName(name)
                                                          .WithDescription(description)
                                                          .IsRequiredAttachment()
                                                          .Build();

            Assert.AreEqual(name, attachmentRequirement.Name);
            Assert.AreEqual(description, attachmentRequirement.Description);
            Assert.AreEqual(isRequired, attachmentRequirement.Required);
        }
Exemplo n.º 6
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();

            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName)
                                                .DescribedAs("This is a package created using the eSignLive SDK")
                                                .WithSigner(signer1)
                                                .WithDocument(DocumentBuilder.NewDocumentNamed("test document")
                                                              .FromStream(fileStream1, DocumentType.PDF)
                                                              .WithSignature(SignatureBuilder.SignatureFor(email1)
                                                                             .Build())
                                                              .Build())
                                                .Build();

            packageId = OssClient.CreateAndSendPackage(superDuperPackage);

            retrievedPackage = OssClient.GetPackage(packageId);
            signer1Att1      = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME1);

            byte [] attachment1ForSigner1FileContent = new StreamDocumentSource(attachmentInputStream1).Content();
            OssClient.UploadAttachment(packageId, signer1Att1.Id, ATTACHMENT_FILE_NAME1,
                                       attachment1ForSigner1FileContent, SIGNER1_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signer1Att1      = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME1);

            filesAfterUpload = signer1Att1.Files;

            AttachmentFile attachmentFile = filesAfterUpload[0];

            OssClient.DeleteAttachmentFile(packageId, signer1Att1.Id, attachmentFile.Id, SIGNER1_ID);

            retrievedPackage = OssClient.GetPackage(packageId);
            signer1Att1      = retrievedPackage.GetSigner(email1).GetAttachmentRequirement(NAME1);

            filesAfterDelete = signer1Att1.Files;
        }
Exemplo n.º 7
0
        public void CanSetAndGetAttachmentRequirements()
        {
            AttachmentRequirement attachmentRequirement = AttachmentRequirementBuilder.NewAttachmentRequirementWithName("Driver's license")
                                                          .WithDescription("Please upload scanned driver's license.")
                                                          .IsRequiredAttachment()
                                                          .Build();

            Signer signer = SignerBuilder.NewSignerWithEmail("*****@*****.**")
                            .WithFirstName("Billy")
                            .WithLastName("Bob")
                            .WithAttachmentRequirement(attachmentRequirement)
                            .Build();

            Assert.AreEqual(signer.Attachments.Count, 1);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Name, attachmentRequirement.Name);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Description, attachmentRequirement.Description);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Required, attachmentRequirement.Required);
            Assert.AreEqual(signer.GetAttachmentRequirement("Driver's license").Status, attachmentRequirement.Status);
        }
Exemplo n.º 8
0
 private void AddAttachmentRequirement(AttachmentRequirement attachmentRequirement)
 {
     attachments.Add(attachmentRequirement.Name, attachmentRequirement);
 }
Exemplo n.º 9
0
 public SignerBuilder WithAttachmentRequirement(AttachmentRequirement attachmentRequirement)
 {
     AddAttachmentRequirement(attachmentRequirement);
     return(this);
 }
        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(PackageName)
                                                .DescribedAs("This is a package created using the eSignLive 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.GetSigner(email1).GetAttachmentRequirement(NAME1).Id;
            signer1       = retrievedPackage.GetSigner(email1);

            signer1Attachments = retrievedPackage.GetSigner(email1).Attachments;
            signer2Attachments = retrievedPackage.GetSigner(email2).Attachments;

            signer1Att1 = signer1Attachments[0];
            signer2Att1 = signer2Attachments[0];
            signer2Att2 = signer2Attachments[1];

            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, ATTACHMENT_FILE_NAME1, attachment1ForSigner1FileContent, SIGNER1_ID);
            eslClient.UploadAttachment(packageId, signer2Att1.Id, ATTACHMENT_FILE_NAME2,
                                       new StreamDocumentSource(attachmentInputStream2).Content(), SIGNER2_ID);
            eslClient.UploadAttachment(PackageId, signer2Att2.Id, ATTACHMENT_FILE_NAME3,
                                       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.GetSigner(email1).GetAttachmentRequirement(NAME1).Status;
            retrievedSigner1Att1RequirementSenderCommentAfterRejection = retrievedPackageAfterRejection.GetSigner(email1).GetAttachmentRequirement(NAME1).SenderComment;

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

            retrievedSigner1Att1RequirementStatusAfterAccepting        = retrievedPackageAfterAccepting.GetSigner(email1).GetAttachmentRequirement(NAME1).Status;
            retrievedSigner1Att1RequirementSenderCommentAfterAccepting = retrievedPackageAfterAccepting.GetSigner(email1).GetAttachmentRequirement(NAME1).SenderComment;

            // Download signer1's attachment
            DownloadedFile downloadedAttachment = eslClient.AttachmentRequirementService.DownloadAttachmentFile(packageId, attachment1Id);

            System.IO.File.WriteAllBytes(downloadedAttachment.Filename, downloadedAttachment.Contents);

            // Download all attachments for the package
            DownloadedFile downloadedAllAttachmentsForPackage = eslClient.AttachmentRequirementService.DownloadAllAttachmentFilesForPackage(packageId);

            System.IO.File.WriteAllBytes(DOWNLOADED_ALL_ATTACHMENTS_FOR_PACKAGE_ZIP, downloadedAllAttachmentsForPackage.Contents);

            // Download all attachments for the signer1 in the package
            DownloadedFile downloadedAllAttachmentsForSigner1InPackage = eslClient.AttachmentRequirementService.DownloadAllAttachmentFilesForSignerInPackage(retrievedPackage, signer1);

            System.IO.File.WriteAllBytes(DOWNLOADED_ALL_ATTACHMENTS_FOR_SIGNER1_IN_PACKAGE_ZIP, downloadedAllAttachmentsForSigner1InPackage.Contents);

            // Download all attachments for the signer2 in the package
            DownloadedFile downloadedAllAttachmentsForSigner2InPackage = eslClient.AttachmentRequirementService.DownloadAllAttachmentFilesForSignerInPackage(retrievedPackage, signer2);

            System.IO.File.WriteAllBytes(DOWNLOADED_ALL_ATTACHMENTS_FOR_SIGNER2_IN_PACKAGE_ZIP, downloadedAllAttachmentsForSigner2InPackage.Contents);

            downloadedAttachemnt1 = new FileInfo(downloadedAttachment.Filename);
        }
Exemplo n.º 11
0
        private void GenerateCover(string projectId, string refTableName)
        {
            string coverPath      = string.Empty;
            string coverName      = "Cover";
            string coverTempPath  = SiteFilePath.UploadFiles_DIRECTORY + "\\" + Guid.NewGuid() + ".xlsx";
            string coverExtention = Path.GetExtension(coverTempPath);

            switch (refTableName)
            {
            case "MajorLeaseChangePackage":
                coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.MajorLeaseChangeCove_Template;
                var majorLeaseChangePackage = MajorLeaseChangePackage.GetMajorPackageInfo(projectId);
                majorLeaseChangePackage.GenerateCoverEexcel(coverPath, coverTempPath);
                break;

            case "ReimagePackage":
                var rmgPackage = ReimagePackage.Get(projectId);
                if (rmgPackage == null)
                {
                    return;
                }
                if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == ReimagePackage.TableName && i.RefTableID.ToString() == rmgPackage.Id.ToString()))
                {
                    var reimageInfoEntity = ReimageInfo.GetReimageInfo(projectId);
                    //生成cover文件
                    coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_Reimage_Cover_Template;
                    var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == reimageInfoEntity.USCode);

                    File.Copy(coverPath, coverTempPath);
                    var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.ReimageCover);
                    var inputInfo           = new ExcelInputDTO
                    {
                        Region    = store.Region,
                        Province  = store.ProvinceENUS,
                        City      = store.CityENUS,
                        StoreName = store.NameENUS,
                        USCode    = reimageInfoEntity.USCode,
                        OpenDate  = store.OpenDate
                    };
                    excelOutputDirector.Input(inputInfo);

                    var coverItem = new Attachment();
                    coverItem.Name         = coverName + coverExtention;
                    coverItem.InternalName = Path.GetFileName(coverTempPath);
                    coverItem.RefTableName = ReimagePackage.TableName;
                    coverItem.RefTableID   = rmgPackage.Id.ToString();
                    coverItem.RelativePath = "//";
                    coverItem.Extension    = coverExtention;
                    coverItem.CreateTime   = DateTime.Now;

                    coverItem.TypeCode        = coverName;
                    coverItem.CreatorID       = ClientCookie.UserCode;
                    coverItem.RequirementId   = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.Reimage_Package && e.NameENUS == "Cover").Id;
                    coverItem.CreatorNameENUS = ClientCookie.UserNameENUS;
                    coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN;

                    using (FileStream stream = new FileStream(coverTempPath, FileMode.Open))
                    {
                        coverItem.Length = (int)stream.Length;
                    }
                    Attachment.SaveSigleFile(coverItem);
                }
                break;

            case "TempClosurePackage":
                var tempClosurePackage = TempClosurePackage.Get(projectId);
                if (tempClosurePackage == null)
                {
                    return;
                }
                if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == tempClosurePackage.TableName && i.RefTableID.ToString() == tempClosurePackage.Id.ToString()))
                {
                    var tempClosureInfoEntity = TempClosureInfo.Get(projectId);
                    //生成cover文件
                    coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_TempClosure_Cover_Template;
                    var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == tempClosureInfoEntity.USCode);

                    File.Copy(coverPath, coverTempPath);
                    var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.TempClosureCover);
                    var inputInfo           = new ExcelInputDTO
                    {
                        StoreNameEN     = store.NameENUS,
                        USCode          = tempClosureInfoEntity.USCode,
                        City            = store.CityENUS,
                        Market          = store.MarketENUS,
                        ActualCloseDate = tempClosureInfoEntity.ActualTempClosureDate.ToString("yyyy-MM-dd")
                    };
                    excelOutputDirector.Input(inputInfo);

                    var coverItem = new Attachment();
                    coverItem.Name         = coverName + coverExtention;
                    coverItem.InternalName = Path.GetFileName(coverTempPath);
                    coverItem.RefTableName = tempClosurePackage.TableName;
                    coverItem.RefTableID   = tempClosurePackage.Id.ToString();
                    coverItem.RelativePath = "//";
                    coverItem.Extension    = coverExtention;
                    coverItem.CreateTime   = DateTime.Now;

                    coverItem.TypeCode  = coverName;
                    coverItem.CreatorID = ClientCookie.UserCode;
                    //coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.TempClosure_ClosurePackage && e.NameENUS == "Cover").Id;
                    coverItem.CreatorNameENUS = ClientCookie.UserNameENUS;
                    coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN;

                    using (FileStream stream = new FileStream(coverTempPath, FileMode.Open))
                    {
                        coverItem.Length = (int)stream.Length;
                    }
                    Attachment.SaveSigleFile(coverItem);
                }
                break;

            case "ClosurePackage":
                var closurePackage = ClosurePackage.Get(projectId);
                if (closurePackage == null)
                {
                    return;
                }
                if (!Attachment.Any(i => i.TypeCode == "Cover" && i.RefTableName == ClosurePackage.TableName && i.RefTableID.ToString() == closurePackage.Id.ToString()))
                {
                    var closureInfoEntity = ClosureInfo.GetByProjectId(projectId);
                    //生成cover文件
                    coverPath = SiteFilePath.Template_DIRECTORY + "\\" + SiteFilePath.Store_Closure_Cover_Template;
                    var store = StoreBasicInfo.FirstOrDefault(e => e.StoreCode == closureInfoEntity.USCode);

                    File.Copy(coverPath, coverTempPath);
                    var excelOutputDirector = new ExcelDataInputDirector(new FileInfo(coverTempPath), ExcelDataInputType.ClosureCover);
                    var inputInfo           = new ExcelInputDTO
                    {
                        StoreNameEN     = store.NameENUS,
                        USCode          = closureInfoEntity.USCode,
                        City            = store.CityENUS,
                        Market          = store.MarketENUS,
                        ActualCloseDate = closureInfoEntity.ActualCloseDate.Value.ToString("yyyy-MM-dd")
                    };
                    excelOutputDirector.Input(inputInfo);

                    var coverItem = new Attachment();
                    coverItem.Name         = coverName + coverExtention;
                    coverItem.InternalName = Path.GetFileName(coverTempPath);
                    coverItem.RefTableName = ClosurePackage.TableName;
                    coverItem.RefTableID   = closurePackage.Id.ToString();
                    coverItem.RelativePath = "//";
                    coverItem.Extension    = coverExtention;
                    coverItem.CreateTime   = DateTime.Now;

                    coverItem.TypeCode  = coverName;
                    coverItem.CreatorID = ClientCookie.UserCode;
                    //coverItem.RequirementId = AttachmentRequirement.FirstOrDefault(e => e.FlowCode == FlowCode.TempClosure_ClosurePackage && e.NameENUS == "Cover").Id;
                    coverItem.CreatorNameENUS = ClientCookie.UserNameENUS;
                    coverItem.CreatorNameZHCN = ClientCookie.UserNameZHCN;

                    using (FileStream stream = new FileStream(coverTempPath, FileMode.Open))
                    {
                        coverItem.Length = (int)stream.Length;
                    }
                    Attachment.SaveSigleFile(coverItem);
                }
                break;
            }
        }
Exemplo n.º 12
0
        public IHttpActionResult Upload(string projectId, string refTableName, Guid?requirementId = null)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var refTableId = Attachment.GetRefTableId(refTableName, projectId);
                if (refTableId == Guid.Empty.ToString())
                {
                    var newId = Guid.NewGuid();
                    refTableId = newId.ToString();
                    switch (refTableName)
                    {
                    case "MajorLeaseChangePackage":
                    {
                        var entity = new MajorLeaseChangePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageSummary":
                    {
                        var entity = new ReimageSummary();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimageConsInfo":
                    {
                        var entity = new ReimageConsInfo();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ReimagePackage":
                    {
                        var entity = new ReimagePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "RebuildLegalReview":
                    {
                        var entity = new RebuildLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureLegalReview":
                    {
                        var entity = new ClosureLegalReview();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;

                    case "ClosureExecutiveSummary":
                    {
                        var entity = new ClosureExecutiveSummary();
                        entity.ProjectId      = projectId;
                        entity.Id             = newId;
                        entity.CreateTime     = DateTime.Now;
                        entity.CreatorAccount = ClientCookie.UserCode;
                        entity.IsHistory      = false;
                        entity.Add();
                    }
                    break;

                    case "ClosurePackage":
                    {
                        var entity = new ClosurePackage();
                        entity.ProjectId         = projectId;
                        entity.Id                = newId;
                        entity.CreateTime        = DateTime.Now;
                        entity.CreateUserAccount = ClientCookie.UserCode;
                        entity.IsHistory         = false;
                        entity.Add();
                    }
                    break;
                    }
                }
                var userRole = ProjectUsers.Get(ClientCookie.UserCode, projectId);
                var files    = HttpContext.Current.Request.Files;
                if (requirementId.HasValue)
                {
                    var attReq      = AttachmentRequirement.Get(requirementId.Value);
                    var projectInfo = ProjectInfo.Get(projectId, attReq.FlowCode);
                    var store       = StoreBasicInfo.GetStorInfo(projectInfo.USCode);
                    var attachNode  = NodeInfo.FirstOrDefault(n => n.FlowCode == attReq.FlowCode && n.Code == attReq.NodeCode);
                    if (attachNode != null)
                    {
                        ProjectInfo.FinishNode(projectId, attReq.FlowCode, attReq.NodeCode);
                    }
                    var    file          = files[0];
                    string fileName      = Path.GetFileName(file.FileName);
                    string fileExtension = Path.GetExtension(file.FileName);
                    var    current       = System.Web.HttpContext.Current;
                    string internalName  = Guid.NewGuid() + fileExtension;
                    string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                    file.SaveAs(absolutePath);

                    Attachment att = Attachment.Get(refTableId, requirementId.Value);

                    if (att == null)
                    {
                        att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = "";
                        Attachment.Add(att);
                    }
                    else
                    {
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        Attachment.Update(att);
                    }
                    //TempClosure上传SignAgreement
                    //if (requirementId.Value.Equals(new Guid("1E9B17AF-357A-4DC9-8A60-17766663FB75")))
                    //{
                    //    var url = "/TempClosure/Main#/ClosureMemo?projectId=" + projectId;
                    //    var actor = ProjectUsers.FirstOrDefault(pu => pu.ProjectId == projectId && pu.RoleCode == ProjectUserRoleCode.AssetActor);
                    //    var title = string.Concat(projectId, " ", store.NameZHCN, " ", store.NameENUS);
                    //    TaskWork.Finish(t => t.ReceiverAccount == ClientCookie.UserCode && t.RefID == projectId && t.Status == TaskWorkStatus.UnFinish && t.TypeCode == FlowCode.TempClosure_ClosurePackage);
                    //    //TaskWork.SendTask(projectId, title, projectInfo.USCode, url, actor, FlowCode.TempClosure, FlowCode.TempClosure_ClosureMemo, "Start");
                    //}
                }
                else
                {
                    List <Attachment> attachments = new List <Attachment>();
                    string            typeCode    = "";
                    if (refTableName == "RebuildLegalReview")
                    {
                        typeCode = "Contract";
                    }
                    for (int i = 0; i < files.Count; i++)
                    {
                        var    file          = files[i];
                        string fileName      = Path.GetFileName(file.FileName);
                        string fileExtension = Path.GetExtension(file.FileName);
                        var    current       = System.Web.HttpContext.Current;
                        string internalName  = Guid.NewGuid() + fileExtension;
                        string absolutePath  = current.Server.MapPath("~/") + "UploadFiles/" + internalName;

                        file.SaveAs(absolutePath);

                        Attachment att = new Attachment();
                        att.InternalName    = internalName;
                        att.RefTableName    = refTableName;
                        att.RefTableID      = refTableId;
                        att.RelativePath    = "//";
                        att.Name            = fileName;
                        att.Extension       = fileExtension;
                        att.Length          = file.ContentLength;
                        att.CreateTime      = DateTime.Now;
                        att.CreatorNameZHCN = ClientCookie.UserNameZHCN;
                        att.CreatorNameENUS = ClientCookie.UserNameENUS;
                        att.CreatorID       = ClientCookie.UserCode;
                        att.ID            = Guid.NewGuid();
                        att.RequirementId = requirementId;
                        att.TypeCode      = typeCode;
                        attachments.Add(att);
                    }
                    Attachment.Add(attachments.ToArray());
                }
                tranScope.Complete();
                return(Ok());
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// 压缩文件
        /// </summary>
        /// <param name="filesUrls">文件路径列表</param>
        /// <returns></returns>
        public static string ExeFiles(IEnumerable <Attachment> atts)
        {
            string fileName = DateTime.Now.ToString("yyMMddHHmmssff");

            var    current      = System.Web.HttpContext.Current;
            string tempFilePath = current.Server.MapPath("~/") + "Temp\\" + fileName + ".zip";

            //ZipFile实例化一个压缩文件保存路径的一个对象zip
            using (ZipFile zip = new ZipFile(tempFilePath, Encoding.Default))
            {
                //加密压缩
                //zip.Password = "******";
                //将要压缩的文件夹添加到zip对象中去(要压缩的文件夹路径和名称)
                //zip.AddDirectory(@"E:\\yangfeizai\\" + "12051214544443");
                //将要压缩的文件添加到zip对象中去,如果文件不存在抛错FileNotFoundExcept
                //zip.AddFile(@"E:\\yangfeizai\\12051214544443\\"+"Jayzai.xml");

                string        filePath      = string.Empty;
                string        innerFileName = string.Empty;
                List <string> attNames      = new List <string>();
                string        folder        = SiteFilePath.UploadFiles_DIRECTORY;
                foreach (var att in atts)
                {
                    if (att.InternalName == null || att.FileURL == "#")
                    {
                        continue;
                    }

                    if (att.Name == "LL Negotiation Record List")
                    {
                        folder = SiteFilePath.TEMP_DIRECTORY;
                    }
                    else
                    {
                        folder = SiteFilePath.UploadFiles_DIRECTORY;
                    }

                    if (att.InternalName.IndexOf(".") != -1)
                    {
                        filePath = folder + "\\" + att.InternalName;
                    }
                    else
                    {
                        filePath = folder + "\\" + att.InternalName + att.Extension;
                    }
                    using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        if (att.RequirementId.HasValue)
                        {
                            var ar = AttachmentRequirement.Get(att.RequirementId.Value);
                            innerFileName = ar != null ? ar.NameENUS : att.Name;
                        }
                        else
                        {
                            innerFileName = att.Name;
                        }


                        if (!attNames.Contains(innerFileName))
                        {
                            attNames.Add(innerFileName);
                            zip.AddEntry(innerFileName + att.Extension, fs);
                            zip.Save();
                        }
                    }
                }
            }
            string downLoadPath = "Temp/" + fileName + ".zip";

            return(tempFilePath);
        }
Exemplo n.º 14
0
		private void AddAttachmentRequirement (AttachmentRequirement attachmentRequirement)
		{
			attachments.Add(attachmentRequirement.Name, attachmentRequirement);
		}
Exemplo n.º 15
0
		public SignerBuilder WithAttachmentRequirement (AttachmentRequirement attachmentRequirement)
		{
			AddAttachmentRequirement(attachmentRequirement);
			return this;
		}