Ejemplo n.º 1
0
        /// <summary>
        /// Update all the QR codes for a document.
        /// </summary>
        /// <param name="packageId">Package identifier of the DocumentPackage which contains the document with QR codes to update</param>
        /// <param name="documentId">Document identifier of the Document which contains the QR codes to update</param>
        /// <param name="qrCodeList">The list of QR codes (Field) to update for document</param>
        public void UpdateQRCodes(PackageId packageId, string documentId, IList <Field> qrCodeList)
        {
            IList <OneSpanSign.API.Field> fieldList = new List <OneSpanSign.API.Field>();

            foreach (OneSpanSign.Sdk.Field sdkField in qrCodeList)
            {
                OneSpanSign.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
                fieldList.Add(apiField);
            }

            apiClient.UpdateQRCodes(packageId.Id, documentId, fieldList);
        }
Ejemplo n.º 2
0
        internal Document ToSDKDocument()
        {
            if (apiDocument == null)
            {
                return(sdkDocument);
            }

            DocumentBuilder documentBuilder = DocumentBuilder.NewDocumentNamed(apiDocument.Name)
                                              .WithId(apiDocument.Id)
                                              .AtIndex(apiDocument.Index.Value)
                                              .WithDescription(apiDocument.Description)
                                              .WithData(apiDocument.Data);

            documentBuilder.WithExternal(new ExternalConverter(apiDocument.External).ToSDKExternal());
            foreach (string extractionType in apiDocument.ExtractionTypes)
            {
                documentBuilder.WithExtractionType((ExtractionType)Enum.Parse(typeof(ExtractionType), extractionType));
            }
            foreach (Approval apiApproval in apiDocument.Approvals)
            {
                documentBuilder.WithSignature(new SignatureConverter(apiApproval, apiPackage).ToSDKSignature());
            }

            foreach (OneSpanSign.API.Field apiField in apiDocument.Fields)
            {
                Field sdkField = new FieldConverter(apiField).ToSDKField();
                if (!FieldStyle.BOUND_QRCODE.getApiValue().Equals(apiField.Subtype))
                {
                    documentBuilder.WithInjectedField(sdkField);
                }
                else
                {
                    documentBuilder.WithQRCode(sdkField);
                }
            }

            Document document = documentBuilder.Build();

            if (apiDocument.Pages != null && apiDocument.Pages.Count > 0)
            {
                document.NumberOfPages = apiDocument.Pages.Count;
            }

            if (apiDocument.Tagged != null)
            {
                document.Tagged = apiDocument.Tagged;
            }

            return(document);
        }
Ejemplo n.º 3
0
 public void ModifyField(PackageId packageId, string documentId, SignatureId signatureId, Field sdkField)
 {
     OneSpanSign.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
     apiClient.ModifyField(packageId, documentId, signatureId, apiField);
 }
Ejemplo n.º 4
0
 public string AddField(PackageId packageId, string documentId, SignatureId signatureId, Field sdkField)
 {
     OneSpanSign.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
     return(apiClient.AddField(packageId, documentId, signatureId, apiField));
 }
Ejemplo n.º 5
0
        public Signature ToSDKSignature()
        {
            SignatureBuilder signatureBuilder = null;

            foreach (OneSpanSign.API.Role role in package.Roles)
            {
                if (role.Id.Equals(apiApproval.Role))
                {
                    if (isPlaceHolder(role))
                    {
                        signatureBuilder = SignatureBuilder.SignatureFor(new Placeholder(role.Id));
                    }
                    else if (isGroupRole(role))
                    {
                        signatureBuilder = SignatureBuilder.SignatureFor(new GroupId(role.Signers [0].Group.Id));
                    }
                    else
                    {
                        signatureBuilder = SignatureBuilder.SignatureFor(role.Signers [0].Email);
                    }
                }
            }

            if (apiApproval.Id != null)
            {
                signatureBuilder.WithId(new SignatureId(apiApproval.Id));
            }

            OneSpanSign.API.Field apiSignatureField = null;
            foreach (OneSpanSign.API.Field apiField in apiApproval.Fields)
            {
                if (FieldType.SIGNATURE.getApiValue().Equals(apiField.Type))
                {
                    apiSignatureField = apiField;
                }
                else
                {
                    Field field = new FieldConverter(apiField).ToSDKField();
                    signatureBuilder.WithField(field);
                }
            }

            if (apiSignatureField == null)
            {
                signatureBuilder.WithStyle(SignatureStyle.ACCEPTANCE);
                signatureBuilder.WithSize(0, 0);
            }
            else
            {
                signatureBuilder.WithStyle(new SignatureStyleConverter(apiSignatureField.Subtype).ToSDKSignatureStyle())
                .OnPage(apiSignatureField.Page.Value)
                .AtPosition(apiSignatureField.Left.Value, apiSignatureField.Top.Value)
                .WithSize(apiSignatureField.Width.Value, apiSignatureField.Height.Value);

                if (apiSignatureField.Extract.Value)
                {
                    signatureBuilder.WithPositionExtracted();
                }
                if (apiSignatureField.FontSize != null)
                {
                    signatureBuilder.WithFontSize(apiSignatureField.FontSize.Value);
                }
            }

            if (apiApproval.Optional)
            {
                signatureBuilder.MakeOptional();
            }

            if (apiApproval.Disabled)
            {
                signatureBuilder.Disabled();
            }

            if (apiApproval.EnforceCaptureSignature)
            {
                signatureBuilder.EnableEnforceCaptureSignature();
            }

            Signature signature = signatureBuilder.Build();

            if (null != apiApproval.Accepted)
            {
                signature.Accepted = apiApproval.Accepted;
            }

            return(signature);
        }
Ejemplo n.º 6
0
 /// <summary>
 ///  Modify the QR code in document.
 /// </summary>
 /// <param name="packageId">Package identifier of the DocumentPackage which contains the document with the QR code to modify.</param>
 /// <param name="documentId">Document identifier of the Document which contains the QR code to modify.</param>
 /// <param name="qrCodeField">The new QR code field</param>
 public void ModifyQRCode(PackageId packageId, string documentId, Field qrCodeField)
 {
     OneSpanSign.API.Field apiField = new FieldConverter(qrCodeField).ToAPIField();
     apiClient.ModifyQRCode(packageId.Id, documentId, apiField);
 }
Ejemplo n.º 7
0
 /// <summary>
 ///  Add a QR code field to the document.
 /// </summary>
 /// <returns>The field Id of the added QR code.</returns>
 /// <param name="packageId">Package identifier of the DocumentPackage which contains the document to add QR code to.</param>
 /// <param name="documentId">Document identifier of the Document to add QR code to.</param>
 /// <param name="qrCodeField">Qr code field.</param>
 public string AddQRCode(PackageId packageId, string documentId, Field qrCodeField)
 {
     OneSpanSign.API.Field apiField = new FieldConverter(qrCodeField).ToAPIField();
     return(apiClient.AddQRCode(packageId.Id, documentId, apiField));
 }