예제 #1
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);
            documentBuilder.WithExternal(new ExternalConverter(apiDocument.External).ToSDKExternal());
            foreach (Approval apiApproval in apiDocument.Approvals)
            {
                documentBuilder.WithSignature(new SignatureConverter(apiApproval, apiPackage).ToSDKSignature());
            }

            foreach (Silanis.ESL.API.Field apiField in apiDocument.Fields)
            {
                Field sdkField = new FieldConverter(apiField).ToSDKField();
                if (apiField.Subtype != FieldSubtype.QRCODE)
                {
                    documentBuilder.WithInjectedField(sdkField);
                }
                else
                {
                    documentBuilder.WithQRCode(sdkField);
                }
            }

            return documentBuilder.Build();
        }
예제 #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);

            documentBuilder.WithExternal(new ExternalConverter(apiDocument.External).ToSDKExternal());
            foreach (Approval apiApproval in apiDocument.Approvals)
            {
                documentBuilder.WithSignature(new SignatureConverter(apiApproval, apiPackage).ToSDKSignature());
            }

            foreach (Silanis.ESL.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);
                }
            }

            return(documentBuilder.Build());
        }
예제 #3
0
 public void ConvertAPIToAPI()
 {
     apiField1 = CreateTypicalAPIField();
     converter = new FieldConverter(apiField1);
     apiField2 = converter.ToAPIField();
     Assert.IsNotNull(apiField2);
     Assert.AreEqual(apiField2, apiField1);
 }
예제 #4
0
 public void ConvertSDKToSDK()
 {
     sdkField1 = CreateTypicalSDKField();
     converter = new FieldConverter(sdkField1);
     sdkField2 = converter.ToSDKField();
     Assert.IsNotNull(sdkField2);
     Assert.AreEqual(sdkField2, sdkField1);
 }
예제 #5
0
        public Signature ToSDKSignature() {

            SignatureBuilder signatureBuilder = null;
            foreach ( Silanis.ESL.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));
            }

            Silanis.ESL.API.Field apiSignatureField = null;
            foreach ( Silanis.ESL.API.Field apiField in apiApproval.Fields ) {
                if ( apiField.Type == Silanis.ESL.API.FieldType.SIGNATURE ) {
                    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();
                }                   
            }
            
            return signatureBuilder.Build();
        }
예제 #6
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 <Silanis.ESL.API.Field> fieldList = new List <Silanis.ESL.API.Field>();

            foreach (Silanis.ESL.SDK.Field sdkField in qrCodeList)
            {
                Silanis.ESL.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
                fieldList.Add(apiField);
            }

            apiClient.UpdateQRCodes(packageId.Id, documentId, fieldList);
        }
예제 #7
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 (Silanis.ESL.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);
        }
예제 #8
0
        public Signature ToSDKSignature()
        {
            SignatureBuilder signatureBuilder = null;

            foreach (Silanis.ESL.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));
            }

            Silanis.ESL.API.Field apiSignatureField = null;
            foreach (Silanis.ESL.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();
                }
            }

            Signature signature = signatureBuilder.Build();

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

            return(signature);
        }
예제 #9
0
 public void ModifyField(PackageId packageId, string documentId, SignatureId signatureId, Field sdkField)
 {
     Silanis.ESL.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
     apiClient.ModifyField(packageId, documentId, signatureId, apiField);
 }
예제 #10
0
 public string AddField(PackageId packageId, string documentId, SignatureId signatureId, Field sdkField)
 {
     Silanis.ESL.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
     return(apiClient.AddField(packageId, documentId, signatureId, apiField));
 }
예제 #11
0
 public void ConvertNullAPIToAPI()
 {
     apiField1 = null;
     converter = new FieldConverter(apiField1);
     Assert.IsNull(converter.ToAPIField());
 }
예제 #12
0
 public void ConvertNullSDKToSDK()
 {
     sdkField1 = null;
     converter = new FieldConverter(sdkField1);
     Assert.IsNull(converter.ToSDKField());
 }
예제 #13
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)
 {
     Silanis.ESL.API.Field apiField = new FieldConverter(qrCodeField).ToAPIField();
     apiClient.ModifyQRCode(packageId.Id, documentId, apiField);
 }
예제 #14
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)
 {
     Silanis.ESL.API.Field apiField = new FieldConverter(qrCodeField).ToAPIField();
     return(apiClient.AddQRCode(packageId.Id, documentId, apiField));
 }
예제 #15
0
 public string AddField(PackageId packageId, string documentId, SignatureId signatureId, Field sdkField)
 {
     Silanis.ESL.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
     return apiClient.AddField(packageId, documentId, signatureId, apiField);
 }
예제 #16
0
 public void ModifyField(PackageId packageId, string documentId, SignatureId signatureId, Field sdkField)
 {
     Silanis.ESL.API.Field apiField = new FieldConverter(sdkField).ToAPIField();
     apiClient.ModifyField(packageId, documentId, signatureId, apiField);
 }