Update package is not working
Saturday, April 20, 2019 at 12:53pmWhat is the recommended way to update a package to use the new filled document? Should I delete the package and create another one.
I'm trying to update a package but the document inside is never updated and stay the same as when first created.
Here is the creation and update:
var packageBuilder = CreatePackageBuilder(adhesionEnLigneEvent);
var packageId = new PackageId(adhesionEnLigneEvent.PackageId);
eslClient.ChangePackageStatusToDraft(packageId);
eslClient.UpdatePackage(packageId, packageBuilder.Build());
eslClient.SendPackage(packageId);
Here is the first creation :
var packageBuilder = CreatePackageBuilder(adhesionEnLigneEvent);
var packageId = eslClient.CreatePackage(packageBuilder.Build());
eslClient.SendPackage(packageId);
Code that creates de documents :
private static PackageBuilder CreatePackageBuilder(InfoAdhesionEnLigneEvent adhesionEnLigneEvent)
{
var fieldValidatorString = new FieldValidator
{
MaxLength = 100
};
var path = AppDomain.CurrentDomain.BaseDirectory;
var directory = Path.GetDirectoryName(path);
var fileInfo = new FileInfo(directory + "/OneSpan/AdhesionFormulaire_TextTags.pdf");
var pdfFileStream = System.IO.File.OpenRead(fileInfo.FullName);
var regimeAbbreviation = adhesionEnLigneEvent.InfoAdhesionEnLigne.Regime.Abbreviation;
var packageName = $"Adhésion {regimeAbbreviation} - {adhesionEnLigneEvent.Prenom} {adhesionEnLigneEvent.Nom}";
var signerId = adhesionEnLigneEvent.SignerId.ToString();
var documentBuilder = DocumentBuilder.NewDocumentNamed("Formulaire d'adhésion")
.FromStream(pdfFileStream, DocumentType.PDF)
.WithExtractionType(ExtractionType.ACROFIELDS)
.EnableExtraction()
.WithSignature(SignatureBuilder.SignatureFor(adhesionEnLigneEvent.Courriel)
.WithId(new SignatureId("Signature")).WithName("Signature")
.WithPositionExtracted())
.WithInjectedField(FieldBuilder.TextField().WithName("Nom")
.WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.Nom))
.WithInjectedField(FieldBuilder.TextField().WithName("Prenom")
.WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.Prenom))
.WithInjectedField(FieldBuilder.TextField().WithName("Nas")
.WithValue(adhesionEnLigneEvent.Nas.ToString()))
.WithInjectedField(FieldBuilder.TextField().WithName("AdresseLigne1")
.WithValue(adhesionEnLigneEvent.GetAdresseLigne1Format()))
.WithInjectedField(FieldBuilder.TextField().WithName("AdresseLigne2")
.WithValue(adhesionEnLigneEvent.GetAdresseLigne2Format()))
.WithInjectedField(FieldBuilder.TextField().WithName("NoEmploye")
.WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.NoEmploye))
.WithInjectedField(FieldBuilder.TextField().WithName("Sexe")
.WithValue(adhesionEnLigneEvent.GetSexeFormulaire()))
.WithInjectedField(FieldBuilder.Datepicker().WithName("DateNaissance")
.WithValue(adhesionEnLigneEvent.DateDeNaissance.GetValueOrDefault().ToString("yyyy-MM-dd")))
.WithInjectedField(FieldBuilder.SignatureDate().WithName("DateSignature")
.WithValue(DateTime.Now.ToString("yyyy-MM-dd")))
.WithInjectedField(FieldBuilder.Datepicker().WithName("DateEmploi")
.WithValue(adhesionEnLigneEvent.DateEmploi.GetValueOrDefault().ToString("yyyy-MM-dd")))
.WithInjectedField(FieldBuilder.Datepicker().WithName("DateAdhesion")
.WithValue(adhesionEnLigneEvent.DateAdhesion.GetValueOrDefault().ToString("yyyy-MM-dd")))
.WithInjectedField(FieldBuilder.TextField().WithName("NomConjoint").WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.NomConjoint))
.WithInjectedField(FieldBuilder.TextField().WithName("PrenomConjoint").WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.PrenomConjoint))
.WithInjectedField(FieldBuilder.TextArea().WithName("Commentaire").WithValidation(fieldValidatorString).WithValue(adhesionEnLigneEvent.Commentaire));
var indice = 1;
foreach (var adhesionEnLigneBeneficiaire in adhesionEnLigneEvent.beneficiaires)
{
var lienParente = LienParentes.List().ElementAt(adhesionEnLigneBeneficiaire.LienParente).Value;
documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("NomBeneficiaire" + indice).WithValidation(fieldValidatorString).WithValue(adhesionEnLigneBeneficiaire.Nom));
documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("PrenomBeneficiaire" + indice).WithValidation(fieldValidatorString).WithValue(adhesionEnLigneBeneficiaire.Prenom));
documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("LienParente" + indice).WithValidation(fieldValidatorString).WithValue(lienParente));
documentBuilder.WithInjectedField(FieldBuilder.TextField().WithName("Pourcentage" + indice).WithValidation(fieldValidatorString).WithValue((adhesionEnLigneBeneficiaire.Pourcentage / 100).ToString("P")));
indice++;
}
var document = documentBuilder.Build();
return PackageBuilder.NewPackageNamed(packageName)
.WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings()
.WithoutInPerson()
.WithoutLanguageDropDown()
.WithoutOptOut()
.WithoutDecline()
.WithHandOverLinkHref("http://www.google.ca")
.WithHandOverLinkText("click here")
.WithHandOverLinkTooltip("link tooltip")
.WithCeremonyLayoutSettings(CeremonyLayoutSettingsBuilder.NewCeremonyLayoutSettings()
.WithoutSessionBar()
.WithoutBreadCrumbs()
.WithoutGlobalConfirmButton()
.WithGlobalDownloadButton()
.WithLogoImageSource("https://mon.saiadnet.qc.ca/Content/images/logoSAI-gauche-img.jpg")))
.WithSigner(SignerBuilder.NewSignerWithEmail(adhesionEnLigneEvent.Courriel)
.WithFirstName(adhesionEnLigneEvent.Prenom)
.WithLastName(adhesionEnLigneEvent.Nom)
.WithCompany(regimeAbbreviation)
.WithCustomId(signerId)
.WithLanguage("fr"))
.WithDocument(document);
}
Reply to: Update package is not working
Monday, April 22, 2019 at 02:58pmReply to: Update package is not working
Tuesday, April 23, 2019 at 02:37pmReply to: Update package is not working
Wednesday, April 24, 2019 at 05:13am