Exemplo n.º 1
0
        public Silanis.ESL.API.Field ToAPIField(Field field)
        {
            Silanis.ESL.API.Field result = new Silanis.ESL.API.Field();

            result.Name    = field.Name;
            result.Extract = field.Extract;
            result.Page    = field.Page;

            if (!field.Extract)
            {
                result.Left   = field.X;
                result.Top    = field.Y;
                result.Width  = field.Width;
                result.Height = field.Height;
            }

            if (field.TextAnchor != null)
            {
                result.ExtractAnchor = new TextAnchorConverter(field.TextAnchor).ToAPIExtractAnchor();
            }

            result.Value   = field.Value;
            result.Type    = Silanis.ESL.API.FieldType.INPUT;
            result.Subtype = GetFieldSubtype(field);
            result.Binding = field.Binding;

            if (field.Validator != null)
            {
                result.Validation = ConvertValidator(field.Validator);
            }

            return(result);
        }
Exemplo n.º 2
0
        private Silanis.ESL.API.Field ToField(Signature signature)
        {
            Silanis.ESL.API.Field result = new Silanis.ESL.API.Field();

            result.Page    = signature.Page;
            result.Name    = signature.Name;
            result.Extract = signature.Extract;

            if (!signature.Extract)
            {
                result.Top    = signature.Y;
                result.Left   = signature.X;
                result.Width  = signature.Width;
                result.Height = signature.Height;
            }

            if (signature.TextAnchor != null)
            {
                result.ExtractAnchor = new TextAnchorConverter(signature.TextAnchor).ToAPIExtractAnchor();
            }


            result.Type    = Silanis.ESL.API.FieldType.SIGNATURE;
            result.Subtype = GetSignatureSubtype(signature);

            return(result);
        }
Exemplo n.º 3
0
        private Silanis.ESL.API.Field ToField(Signature signature)
        {
            Silanis.ESL.API.Field result = new Silanis.ESL.API.Field();

            if (sdkSignature.Id != null)
            {
                result.Id = sdkSignature.Id.Id;
            }

            result.Page     = signature.Page;
            result.Name     = signature.Name;
            result.Extract  = signature.Extract;
            result.FontSize = signature.FontSize;

            if (!signature.Extract)
            {
                result.Top    = signature.Y;
                result.Left   = signature.X;
                result.Width  = signature.Width;
                result.Height = signature.Height;
            }

            if (signature.TextAnchor != null)
            {
                result.ExtractAnchor = new TextAnchorConverter(signature.TextAnchor).ToAPIExtractAnchor();
            }

            result.Type    = FieldType.SIGNATURE.getApiValue();
            result.Subtype = signature.Style.getApiValue();
            return(result);
        }
Exemplo n.º 4
0
        internal static SignatureBuilder NewSignatureFromAPIApproval(Silanis.ESL.API.Approval apiApproval, Silanis.ESL.API.Package package)
        {
            Silanis.ESL.API.Signer apiSigner = null;
            foreach (Silanis.ESL.API.Role role in package.Roles)
            {
                if (role.Id.Equals(apiApproval.Role))
                {
                    apiSigner = role.Signers [0];
                }
            }

            if (apiSigner == null)
            {
                return(null);
            }

            SignatureBuilder signatureBuilder = new SignatureBuilder(apiSigner.Email).WithName(apiApproval.Name);

            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
                {
                    FieldBuilder fieldBuilder = FieldBuilder.NewFieldFromAPIField(apiField);
                    signatureBuilder.WithField(fieldBuilder);
                }
            }

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

                if (apiSignatureField.Extract)
                {
                    signatureBuilder.EnableExtraction();
                }
            }

            return(signatureBuilder);
        }
Exemplo n.º 5
0
        private static FieldStyle GetFieldStyleFromAPIField(Silanis.ESL.API.Field field)
        {
            if (field.Binding == null)
            {
                switch (field.Subtype)
                {
                case Silanis.ESL.API.FieldSubtype.TEXTFIELD:
                    return(FieldStyle.UNBOUND_TEXT_FIELD);

                case Silanis.ESL.API.FieldSubtype.CHECKBOX:
                    return(FieldStyle.UNBOUND_CHECK_BOX);

                default:
                    throw new EslException("Unrecognized field style.");
                }
            }
            else
            {
                String binding = field.Binding;
                if (binding.Equals(FieldStyleUtility.BINDING_DATE))
                {
                    return(FieldStyle.BOUND_DATE);
                }
                else if (binding.Equals(FieldStyleUtility.BINDING_TITLE))
                {
                    return(FieldStyle.BOUND_TITLE);
                }
                else if (binding.Equals(FieldStyleUtility.BINDING_NAME))
                {
                    return(FieldStyle.BOUND_NAME);
                }
                else if (binding.Equals(FieldStyleUtility.BINDING_COMPANY))
                {
                    return(FieldStyle.BOUND_COMPANY);
                }
                else
                {
                    throw new EslException("Invalid field binding.");
                }
            }
        }
Exemplo n.º 6
0
        internal static FieldBuilder NewFieldFromAPIField(Silanis.ESL.API.Field apiField)
        {
            FieldBuilder fieldBuilder = new FieldBuilder()
                                        .OnPage(apiField.Page)
                                        .AtPosition(apiField.Left, apiField.Top)
                                        .WithSize(apiField.Width, apiField.Height)
                                        .WithStyle(GetFieldStyleFromAPIField(apiField))
                                        .WithName(apiField.Name);

            if (apiField.Id != null)
            {
                fieldBuilder.WithId(apiField.Id);
            }

            if (apiField.Extract)
            {
                fieldBuilder.WithPositionExtracted();
            }

            fieldBuilder.WithValue(apiField.Value);
            return(fieldBuilder);
        }
        public void ModifyQRCode(string packageId, string documentId, Silanis.ESL.API.Field apiField)
        {
            string path = template.UrlFor(UrlTemplate.QRCODE_ID_PATH)
                .Replace("{packageId}", packageId)
                .Replace("{documentId}", documentId)
                .Replace("{fieldId}", apiField.Id)
                .Build();

            string json = JsonConvert.SerializeObject(apiField, settings);

            try
            {
                restClient.Put(path, json);
            }
            catch (EslServerException e)
            {
                throw new EslServerException("Could not modify QR code in document." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not modify QR code in document." + " Exception: " + e.Message, e);
            }
        }
        public string AddQRCode(string packageId, string documentId, Silanis.ESL.API.Field apiField)
        {
            string path = template.UrlFor(UrlTemplate.QRCODE_PATH)
                .Replace("{packageId}", packageId)
                .Replace("{documentId}", documentId)
                .Build();

            string json = JsonConvert.SerializeObject(apiField, settings);

            try
            {
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Field result = JsonConvert.DeserializeObject<Silanis.ESL.API.Field>(response, settings);
                return result.Id;
            }
            catch (EslServerException e)
            {
                throw new EslServerException("Could not add QR code to document." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not add QR code to document." + " Exception: " + e.Message, e);
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
0
 /// <summary>
 ///  Get the QR code from document.
 /// </summary>
 /// <returns>The QR code field.</returns>
 /// <param name="packageId">Package identifier of the DocumentPackage which contains the document with the QR code to get.</param>
 /// <param name="documentId">Document identifier of the Document to get QR code from.</param>
 /// <param name="qrCodeFieldId">Field identifier of the QR code to get.</param>
 public Field GetQRCode(PackageId packageId, string documentId, string qrCodeFieldId)
 {
     Silanis.ESL.API.Field apiField = apiClient.GetQRCode(packageId.Id, documentId, qrCodeFieldId);
     return(new FieldConverter(apiField).ToSDKField());
 }
Exemplo n.º 11
0
        private Silanis.ESL.API.Field ToField(Signature signature) {
            Silanis.ESL.API.Field result = new Silanis.ESL.API.Field();

            result.Page = signature.Page;
            result.Name = signature.Name;
            result.Extract = signature.Extract;

            if (!signature.Extract)
            {
                result.Top = signature.Y;
                result.Left = signature.X;
                result.Width = signature.Width;
                result.Height = signature.Height;
            }

            if (signature.TextAnchor != null)
            {
                result.ExtractAnchor = new TextAnchorConverter(signature.TextAnchor).ToAPIExtractAnchor();
            }


            result.Type = Silanis.ESL.API.FieldType.SIGNATURE;
            result.Subtype = GetSignatureSubtype (signature);

            return result;
        }