Ejemplo n.º 1
0
 public void ConvertAPIToAPI()
 {
     apiField1 = CreateTypicalAPIField();
     converter = new FieldConverter(apiField1);
     apiField2 = converter.ToAPIField();
     Assert.IsNotNull(apiField2);
     Assert.AreEqual(apiField2, apiField1);
 }
Ejemplo n.º 2
0
 public void ConvertAPIToAPI()
 {
     apiField1 = CreateTypicalAPIField();
     converter = new FieldConverter(apiField1);
     apiField2 = converter.ToAPIField();
     Assert.IsNotNull(apiField2);
     Assert.AreEqual(apiField2, apiField1);
 }
Ejemplo n.º 3
0
     public Document AddField(Field value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("Argument cannot be null");
     }
     
     _fields.Add(value);
     return this;
 }
Ejemplo n.º 4
0
        public Silanis.ESL.API.Field ToAPIField()
        {
            if (sdkField == null)
            {
                return(apiField);
            }

            Silanis.ESL.API.Field result = new Silanis.ESL.API.Field();

            result.Name     = sdkField.Name;
            result.Extract  = sdkField.Extract;
            result.Page     = sdkField.Page;
            result.Id       = sdkField.Id;
            result.FontSize = sdkField.FontSize;

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

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

            result.Value = sdkField.Value;

            if (sdkField.Style == FieldStyle.BOUND_QRCODE)
            {
                result.Type = new FieldTypeConverter(FieldType.IMAGE).ToAPIFieldType();
            }
            else
            {
                result.Type = new FieldTypeConverter(FieldType.INPUT).ToAPIFieldType();
            }

            result.Subtype = new FieldStyleAndSubTypeConverter(sdkField.Style).ToAPIFieldSubtype();
            result.Binding = sdkField.Binding;

            if (sdkField.Validator != null)
            {
                result.Validation = new FieldValidatorConverter(sdkField.Validator).ToAPIFieldValidation();
            }

            return(result);
        }
Ejemplo n.º 5
0
        public void ConvertSDKToAPI()
        {
            sdkField1 = CreateTypicalSDKField();
            apiField1 = new FieldConverter(sdkField1).ToAPIField();

            Assert.IsNotNull(apiField1);
            Assert.AreEqual(sdkField1.Value, apiField1.Value);
            Assert.AreEqual(sdkField1.X, apiField1.Left);
            Assert.AreEqual(sdkField1.Y, apiField1.Top);
            Assert.AreEqual(sdkField1.Width, apiField1.Width);
            Assert.AreEqual(sdkField1.Height, apiField1.Height);
            Assert.AreEqual(sdkField1.Id, apiField1.Id);
            Assert.AreEqual(sdkField1.Name, apiField1.Name);
            Assert.AreEqual(sdkField1.Page, apiField1.Page);
        }
Ejemplo n.º 6
0
        public Silanis.ESL.API.Field ToAPIField()
        {
            if (sdkField == null)
            {
                return apiField;
            }

            Silanis.ESL.API.Field result = new Silanis.ESL.API.Field();

            result.Name = sdkField.Name;
            result.Extract = sdkField.Extract;
            result.Page = sdkField.Page;
            result.Id = sdkField.Id;

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

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

            result.Value = sdkField.Value;

            if (sdkField.Style == FieldStyle.BOUND_QRCODE)
            {
                result.Type = Silanis.ESL.API.FieldType.IMAGE;
            }
            else
            {
                result.Type = Silanis.ESL.API.FieldType.INPUT;
            }

            result.Subtype = new FieldStyleAndSubTypeConverter(sdkField.Style).ToAPIFieldSubtype();
            result.Binding = sdkField.Binding;

            if ( sdkField.Validator != null ) {
                result.Validation = new FieldValidatorConverter(sdkField.Validator).ToAPIFieldValidation();
            }

            return result;
        }
Ejemplo n.º 7
0
        public void ConvertAPIToSDK()
        {
            apiField1 = CreateTypicalAPIField();
            sdkField1 = new FieldConverter(apiField1).ToSDKField();

            Assert.IsNotNull(sdkField1);
            Assert.AreEqual(sdkField1.Validator, new FieldValidatorConverter(apiField1.Validation).ToSDKFieldValidator());
            Assert.AreEqual(sdkField1.Id, apiField1.Id);
            Assert.AreEqual(sdkField1.Name, apiField1.Name);
            Assert.AreEqual(sdkField1.Page, apiField1.Page);
            Assert.AreEqual(sdkField1.Style, new FieldStyleAndSubTypeConverter(apiField1.Subtype, apiField1.Binding).ToSDKFieldStyle());
            Assert.AreEqual(sdkField1.TextAnchor, new TextAnchorConverter(apiField1.ExtractAnchor).ToSDKTextAnchor());
            Assert.AreEqual(sdkField1.Value, apiField1.Value);
            Assert.AreEqual(sdkField1.X, apiField1.Left);
            Assert.AreEqual(sdkField1.Y, apiField1.Top);
            Assert.AreEqual(sdkField1.Width, apiField1.Width);
            Assert.AreEqual(sdkField1.Height, apiField1.Height);
        }
Ejemplo n.º 8
0
        private Silanis.ESL.API.Field CreateTypicalAPIField()
        {
            Silanis.ESL.API.Field apiField = new Silanis.ESL.API.Field();

            apiField.Extract = false;
            apiField.Height  = 100.0;
            apiField.Left    = 10.0;
            apiField.Id      = "3";
            apiField.Name    = "Field Name";
            apiField.Page    = 1;
            apiField.Subtype = FieldStyle.UNBOUND_TEXT_FIELD.getApiValue();
            apiField.Top     = 101.0;
            apiField.Type    = "INPUT";
            apiField.Value   = "field value";
            apiField.Width   = 102.0;

            return(apiField);
        }
Ejemplo n.º 9
0
        public void ConvertAPIToSDK()
        {
            apiField1 = CreateTypicalAPIField();
            sdkField1 = new FieldConverter(apiField1).ToSDKField();

            Assert.IsNotNull(sdkField1);
            Assert.AreEqual(sdkField1.Validator, new FieldValidatorConverter(apiField1.Validation).ToSDKFieldValidator());
            Assert.AreEqual(sdkField1.Id, apiField1.Id);
            Assert.AreEqual(sdkField1.Name, apiField1.Name);
            Assert.AreEqual(sdkField1.Page, apiField1.Page);
            Assert.AreEqual(sdkField1.Style, new FieldStyleAndSubTypeConverter(apiField1.Subtype, apiField1.Binding).ToSDKFieldStyle());
            Assert.AreEqual(sdkField1.TextAnchor, new TextAnchorConverter(apiField1.ExtractAnchor).ToSDKTextAnchor());
            Assert.AreEqual(sdkField1.Value, apiField1.Value);
            Assert.AreEqual(sdkField1.X, apiField1.Left);
            Assert.AreEqual(sdkField1.Y, apiField1.Top);
            Assert.AreEqual(sdkField1.Width, apiField1.Width);
            Assert.AreEqual(sdkField1.Height, apiField1.Height);
        }
Ejemplo n.º 10
0
        public Silanis.ESL.API.Field GetField(PackageId packageId, string documentId, SignatureId signatureId, string fieldId)
        {
            string path = template.UrlFor(UrlTemplate.FIELD_ID_PATH)
                          .Replace("{packageId}", packageId.Id)
                          .Replace("{documentId}", documentId)
                          .Replace("{approvalId}", signatureId.Id)
                          .Replace("{fieldId}", fieldId)
                          .Build();

            try {
                string response = restClient.Get(path);
                Silanis.ESL.API.Field apiField = JsonConvert.DeserializeObject <Silanis.ESL.API.Field> (response, jsonSettings);
                return(apiField);
            }
            catch (EslServerException e) {
                throw new EslServerException("Could not get field from signature.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Could not get field from signature.\t" + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 11
0
        public void ModifyField(PackageId packageId, string documentId, SignatureId signatureId, Silanis.ESL.API.Field field)
        {
            string path = template.UrlFor(UrlTemplate.FIELD_ID_PATH)
                          .Replace("{packageId}", packageId.Id)
                          .Replace("{documentId}", documentId)
                          .Replace("{approvalId}", signatureId.Id)
                          .Replace("{fieldId}", field.Id)
                          .Build();

            try {
                string json = JsonConvert.SerializeObject(field, jsonSettings);
                restClient.Put(path, json);
            }
            catch (EslServerException e) {
                throw new EslServerException("Could not modify field from signature.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Could not modify field from signature.\t" + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 12
0
        private Silanis.ESL.API.Field CreateTypicalAPIField()
        {
            Silanis.ESL.API.Field apiField = new Silanis.ESL.API.Field();

            apiField.Extract = false;
            apiField.Height = 100.0;
            apiField.Left = 10.0;
            apiField.Id = "3";
            apiField.Name = "Field Name";
            apiField.Page = 1;
            apiField.Subtype = FieldSubtype.TEXTFIELD;
            apiField.Top = 101.0;
            apiField.Type = FieldType.INPUT;
            apiField.Value = "field value";
            apiField.Width = 102.0;

            return apiField;
        }
Ejemplo n.º 13
0
 public void ConvertNullAPIToAPI()
 {
     apiField1 = null;
     converter = new FieldConverter(apiField1);
     Assert.IsNull(converter.ToAPIField());
 }
Ejemplo n.º 14
0
 public FieldConverter(Silanis.ESL.API.Field apiField)
 {
     this.apiField = apiField;
 }
Ejemplo n.º 15
0
 public FieldConverter(Silanis.ESL.API.Field apiField)
 {
     this.apiField = apiField;
 }
Ejemplo n.º 16
0
        internal static SignatureBuilder NewSignatureFromAPIApproval(Silanis.ESL.API.Approval apiApproval, Silanis.ESL.API.Package package)
        {
            SignatureBuilder signatureBuilder = null;

            Silanis.ESL.API.Signer apiSigner = null;
            foreach (Silanis.ESL.API.Role role in package.Roles)
            {
                if (role.Id.Equals(apiApproval.Role))
                {
                    if (!isPlaceHolder(role))
                    {
                        apiSigner = role.Signers [0];
                    }
                }
            }
            if (apiSigner != null)
            {
                if (apiSigner.Group == null)
                {
                    signatureBuilder = new SignatureBuilder(apiSigner.Email);
                }
                else
                {
                    signatureBuilder = new SignatureBuilder(new GroupId(apiSigner.Group.Id));
                }
            }
            else
            {
                signatureBuilder = new SignatureBuilder("");
            }
            signatureBuilder.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);
        }
Ejemplo n.º 17
0
 public Field GetField(PackageId packageId, string documentId, SignatureId signatureId, string fieldId)
 {
     Silanis.ESL.API.Field apiField = apiClient.GetField(packageId, documentId, signatureId, fieldId);
     return(new FieldConverter(apiField).ToSDKField());
 }
Ejemplo n.º 18
0
		public SignatureBuilder WithField (Field field)
		{
			fields.Add (field);
			return this;
		}
Ejemplo n.º 19
0
        public void ConvertSDKToAPI()
        {
            sdkField1 = CreateTypicalSDKField();
            apiField1 = new FieldConverter(sdkField1).ToAPIField();

            Assert.IsNotNull(apiField1);
            Assert.AreEqual(sdkField1.Value, apiField1.Value);
            Assert.AreEqual(sdkField1.X, apiField1.Left);
            Assert.AreEqual(sdkField1.Y, apiField1.Top);
            Assert.AreEqual(sdkField1.Width, apiField1.Width);
            Assert.AreEqual(sdkField1.Height, apiField1.Height);
            Assert.AreEqual(sdkField1.Id, apiField1.Id);
            Assert.AreEqual(sdkField1.Name, apiField1.Name);
            Assert.AreEqual(sdkField1.Page, apiField1.Page);
        }
Ejemplo n.º 20
0
 public void ConvertNullAPIToAPI()
 {
     apiField1 = null;
     converter = new FieldConverter(apiField1);
     Assert.IsNull(converter.ToAPIField());
 }