public void DefinitionIsFieldColonValueInQuotes()
        {
            var condition = new FieldCondition("beep", "a_1_b");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("a_1_b:'beep'"));
        }
        public void FieldIncludesRangeQuery()
        {
            var condition = new FieldCondition(new Range(33, 123, false, true), "testfield");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("testfield:{33,123]"));
        }
        public void InvalidXmlCharactersAreStrippedFromValue(string value, string expected)
        {
            var condition = new FieldCondition(value, "noop");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo(expected));
        }
        public void ValuesAreEncodedIfRequired(string value, string expected)
        {
            var condition = new FieldCondition(value, "zurb");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo(expected));
        }
        private OneSpanSign.Sdk.ConditionalField CreateTypicalSDKConditionalField()
        {
            OneSpanSign.Sdk.ConditionalField sdkField = new OneSpanSign.Sdk.ConditionalField();
            sdkField.Extract = false;
            sdkField.Height  = 100.0;
            sdkField.X       = 10.0;
            sdkField.Id      = "3";
            sdkField.Name    = "Field Name";
            sdkField.Page    = 1;
            sdkField.Y       = 101.0;
            sdkField.Style   = FieldStyle.BOUND_DATE;
            sdkField.Value   = "field value";
            sdkField.Width   = 102.0;

            FieldCondition condition = new FieldCondition();

            condition.Id        = "ConditionId";
            condition.Condition = "document['DocumentId'].field['fieldId2'].value == 'X'";
            condition.Action    = "document['DocumentId'].field['fieldId1'].disabled = true";
            List <FieldCondition> conditions = new List <FieldCondition> ();

            conditions.Add(condition);
            sdkField.Conditions = conditions;

            return(sdkField);
        }
Example #6
0
        public void DefinitionIsFieldColonValueInQuotes()
        {
            var condition = new FieldCondition("beep", "a_1_b");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("a_1_b:'beep'"));
        }
            public FieldCondition WhenInternalName(string fieldName)
            {
                var condition = new FieldCondition(this, fieldName, FieldName.NameType.Internal);

                Conditions.Add(condition);
                return(condition);
            }
            public FieldCondition When(string fieldDisplayName)
            {
                var condition = new FieldCondition(this, fieldDisplayName, FieldName.NameType.Display);

                Conditions.Add(condition);
                return(condition);
            }
Example #9
0
        public void ValuesAreEncodedIfRequired(string value, string expected)
        {
            var condition = new FieldCondition(value, "zurb");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo(expected));
        }
            private static string CamlForCondition(FieldCondition fieldCondition, IEnumerable <FieldDetails> allFields)
            {
                var condition = ConditionFrom(fieldCondition.ConditionType);

                string fieldInternalName;

                if (fieldCondition.Field.Type == FieldName.NameType.Internal)
                {
                    fieldInternalName = fieldCondition.Field.Name;
                }
                else
                {
                    try
                    {
                        fieldInternalName = allFields.Single(f => f.Title.Equals(fieldCondition.Field.Name)).InternalName;
                    }
                    catch (InvalidOperationException)
                    {
                        throw new DisplayNameNotUniqueException(fieldCondition.Field.Name);
                    }
                }

                var fieldRef = string.Format(baseFieldRef, fieldInternalName);

                var fieldValue = string.Empty;

                if (!condition.Equals("IsNull") && !condition.Equals("IsNotNull"))
                {
                    var type = allFields.Single(f => f.InternalName.Equals(fieldInternalName)).Type;
                    fieldValue = string.Format(baseFieldValue,
                                               type, Process(fieldCondition.ConditionValue, type));
                }

                return(string.Format("<{0}>{1}{2}</{0}>", condition, fieldRef, fieldValue));
            }
Example #11
0
        public FieldCondition InsertFieldCondition(FieldCondition fieldCondition, bool ignoreFieldCondtionRules = false)
        {
            fieldCondition.Id = Guid.NewGuid();

            string sql = "INSERT INTO UFfieldconditions(id, field, enabled, actiontype, logictype) VALUES(@id, @field, @enabled, @actiontype, @logictype);";

            sqlHelper.ExecuteNonQuery(sql,
                                      sqlHelper.CreateParameter("@id", fieldCondition.Id),
                                      sqlHelper.CreateParameter("@field", fieldCondition.Field),
                                      sqlHelper.CreateParameter("@enabled", fieldCondition.Enabled),
                                      sqlHelper.CreateParameter("@actiontype", fieldCondition.ActionType),
                                      sqlHelper.CreateParameter("@logictype", fieldCondition.LogicType));

            if (fieldCondition.Rules != null)
            {
                List <FieldConditionRule> _rules = new List <FieldConditionRule>();
                foreach (FieldConditionRule fcr in fieldCondition.Rules)
                {
                    fcr.FieldCondition = fieldCondition.Id;

                    if (!ignoreFieldCondtionRules)
                    {
                        _rules.Add(storage.InsertFieldConditionRule(fcr));
                    }
                    else
                    {
                        _rules.Add(fcr);
                    }
                }

                fieldCondition.Rules = _rules;
            }
            return(fieldCondition);
        }
Example #12
0
        public void FieldIncludesRangeQuery()
        {
            var condition = new FieldCondition(new Range(33, 123, false, true), "testfield");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo("testfield:{33,123]"));
        }
Example #13
0
        public FieldCondition UpdateFieldCondition(FieldCondition fieldCondition)
        {
            string sql = "UPDATE UFfieldconditions set  enabled = @enabled, actiontype = @actiontype, logictype = @logictype WHERE field = @field";

            sqlHelper.ExecuteNonQuery(sql,
                                      sqlHelper.CreateParameter("@field", fieldCondition.Field),
                                      sqlHelper.CreateParameter("@enabled", fieldCondition.Enabled),
                                      sqlHelper.CreateParameter("@actiontype", fieldCondition.ActionType),
                                      sqlHelper.CreateParameter("@logictype", fieldCondition.LogicType));

            fieldCondition.Id = sqlHelper.ExecuteScalar <Guid>("Select Id from UFfieldconditions where field = @field",
                                                               sqlHelper.CreateParameter("@field", fieldCondition.Field));

            storage.DeleteFieldConditionRules(fieldCondition);
            if (fieldCondition.Rules != null)
            {
                List <FieldConditionRule> _rules = new List <FieldConditionRule>();
                foreach (FieldConditionRule fcr in fieldCondition.Rules)
                {
                    fcr.FieldCondition = fieldCondition.Id;

                    _rules.Add(storage.InsertFieldConditionRule(fcr));
                }

                fieldCondition.Rules = _rules;
            }
            return(fieldCondition);
        }
Example #14
0
        public void InvalidXmlCharactersAreStrippedFromValue(string value, string expected)
        {
            var condition = new FieldCondition(value, "noop");
            var definition = condition.Definition;

            Assert.That(definition, Is.EqualTo(expected));
        }
Example #15
0
        public static bool CanConditionalDisplay(FieldCondition condition, object fieldValue)
        {
            if (fieldValue == null)
            {
                return(false);
            }

            switch (condition.Operator)
            {
            case Operators.Equals:
                if (condition.Value.ToString() != fieldValue.ToString())
                {
                    return(false);
                }
                break;

            case Operators.NotEquals:
                if (condition.Value.ToString() == fieldValue.ToString())
                {
                    return(false);
                }
                break;
            }

            return(true);
        }
        public void Build_ExpresstionWithCustomMethod_WithParameters_Test()
        {
            var dic     = new Dictionary <string, object>();
            var con     = new FieldCondition("A", CompareOperation.Equals, "NewID()");
            var express = new DataTableExpressionRender().BuildCondition(con, dic);

            Assert.IsTrue(express.Contains("NewID()"));
        }
Example #17
0
 private void AddFieldCondition(string showingFieldName, FieldCondition condition)
 {
     if (!fieldConditions.ContainsKey(showingFieldName))
     {
         fieldConditions.Add(showingFieldName, new List <FieldCondition>());
     }
     fieldConditions[showingFieldName].Add(condition);
 }
Example #18
0
        public FieldCondition Build()
        {
            FieldCondition fieldCondition = new FieldCondition();

            fieldCondition.Id        = this.id;
            fieldCondition.Condition = this.condition;
            fieldCondition.Action    = this.action;
            return(fieldCondition);
        }
Example #19
0
        public override void Execute()
        {
            FieldCondition condition = new FieldCondition();

            condition.Id        = "ConditionId";
            condition.Condition = "document['DocumentId'].field['fieldId2'].value == 'X'";
            condition.Action    = "document['DocumentId'].field['fieldId1'].disabled = false";

            DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(packageName)
                                                .DescribedAs("Description")
                                                .WithSigner(SignerBuilder.NewSignerWithEmail(email1)
                                                            .WithFirstName("Patty")
                                                            .WithLastName("Galant"))
                                                .WithDocument(DocumentBuilder.NewDocumentNamed("Document")
                                                              .WithId(documentId)
                                                              .FromStream(fileStream1, DocumentType.PDF)
                                                              .WithSignature(SignatureBuilder.SignatureFor(email1)
                                                                             .WithId(signatureId)
                                                                             .OnPage(0)
                                                                             .AtPosition(400, 100)
                                                                             .WithField(FieldBuilder.TextField()
                                                                                        .WithId(fieldId1)
                                                                                        .OnPage(0)
                                                                                        .AtPosition(0, 0))
                                                                             .WithField(FieldBuilder.CheckBox()
                                                                                        .WithId(fieldId2)
                                                                                        .OnPage(0)
                                                                                        .AtPosition(0, 0))))
                                                .WithCondition(condition)
                                                .Build();

            packageId        = eslClient.CreatePackageOneStep(superDuperPackage);
            retrievedPackage = eslClient.GetPackage(packageId);

            FieldCondition newCondition = new FieldCondition();

            newCondition.Id        = "ConditionId";
            newCondition.Condition = "document['DocumentId'].field['fieldId2'].value == 'X'";
            newCondition.Action    = "document['DocumentId'].field['fieldId1'].disabled = true";
            List <FieldCondition> conditions = new List <FieldCondition> ();

            conditions.Add(newCondition);

            ConditionalField conditionalField = new ConditionalField();

            conditionalField.Id         = fieldId2;
            conditionalField.Conditions = conditions;
            conditionalField.Style      = FieldStyle.UNBOUND_CHECK_BOX;

            eslClient.ApprovalService.ModifyConditionalField(packageId, documentId, signatureId, conditionalField);
            RetrievedPackageWithUpdatedConditions = eslClient.GetPackage(packageId);

            conditions.Clear();
            conditionalField.Conditions = conditions;
            eslClient.ApprovalService.ModifyConditionalField(packageId, documentId, signatureId, conditionalField);
            RetrievedPackageWithoutConditions = eslClient.GetPackage(packageId);
        }
        public bool DeleteFieldConditionRules(FieldCondition fieldCondition)
        {
            string sql = "DELETE FROM UFfieldconditionrules where fieldcondition = @fieldcondition";

            sqlHelper.ExecuteNonQuery(sql,
                                      sqlHelper.CreateParameter("@fieldcondition", fieldCondition.Id));

            return(true);
        }
Example #21
0
        public FieldCondition InsertFieldCondition(Field field, bool enabled, FieldConditionActionType actionType, FieldConditionLogicType logicType)
        {
            FieldCondition fc = new FieldCondition();

            fc.Field      = field.Id;
            fc.Enabled    = enabled;
            fc.ActionType = actionType;
            fc.LogicType  = logicType;
            return(InsertFieldCondition(fc));
        }
Example #22
0
        public void Add_2FieldsInConditionGroup_CheckValue()
        {
            var expected = new FieldCondition(new Field("F1"), RelationalOperators.Equal, new Field("F2"));

            _conditionGroup.Add(new Field("F1"), RelationalOperators.Equal, new Field("F2"));

            var actual = ((IFieldCondition)_conditionGroup.Conditions[0]);

            Assert.AreEqual(expected.Value.GetType(), actual.Value.GetType());
        }
Example #23
0
        public void Add_1FieldCondition_CheckValue()
        {
            var expected = new FieldCondition(new Field("F1"), RelationalOperators.Equal, 123);

            _conditionGroup.Add(new Field("F1"), RelationalOperators.Equal, 123);

            var actual = (IFieldCondition)_conditionGroup.Conditions[0];

            Assert.AreEqual(expected.Value, actual.Value);
        }
        public void FieldCondition_GreaterThan()
        {
            string         conditionString = @"\18\>>19";
            FieldCondition fieldCondition  = FieldCondition.Parse(conditionString);

            Assert.AreEqual("18>", fieldCondition.Field);
            Assert.AreEqual(">", fieldCondition.Operation);
            Assert.AreEqual("19", fieldCondition.Value);
            Assert.IsFalse(fieldCondition.FieldIndex.HasValue);
            Assert.IsFalse(fieldCondition.IsFieldByIndex);
        }
        public void FieldCondition_Contains()
        {
            string         conditionString = @"f\*o\=o*=b\=a\*r";
            FieldCondition fieldCondition  = FieldCondition.Parse(conditionString);

            Assert.AreEqual("f*o=o", fieldCondition.Field);
            Assert.AreEqual("*=", fieldCondition.Operation);
            Assert.AreEqual("b=a*r", fieldCondition.Value);
            Assert.IsFalse(fieldCondition.FieldIndex.HasValue);
            Assert.IsFalse(fieldCondition.IsFieldByIndex);
        }
        public void FieldConditionParse_FieldNotByIndex()
        {
            string         conditionString = @"365=bar";
            FieldCondition fieldCondition  = FieldCondition.Parse(conditionString);

            Assert.AreEqual("365", fieldCondition.Field);
            Assert.AreEqual("=", fieldCondition.Operation);
            Assert.AreEqual("bar", fieldCondition.Value);
            Assert.IsFalse(fieldCondition.FieldIndex.HasValue);
            Assert.IsFalse(fieldCondition.IsFieldByIndex);
        }
        public void FieldCondition_EscapedChars()
        {
            string         conditionString = @"\foo\=bar\\\&\|\\=b\ar\=foo\\\|\&";
            FieldCondition fieldCondition  = FieldCondition.Parse(conditionString);

            Assert.AreEqual(@"foo=bar\&|\", fieldCondition.Field);
            Assert.AreEqual("=", fieldCondition.Operation);
            Assert.AreEqual(@"bar=foo\|&", fieldCondition.Value);
            Assert.IsFalse(fieldCondition.FieldIndex.HasValue);
            Assert.IsFalse(fieldCondition.IsFieldByIndex);
        }
        public void FieldCondition_NotEqual()
        {
            string         conditionString = @"\!foo!=ba\=r";
            FieldCondition fieldCondition  = FieldCondition.Parse(conditionString);

            Assert.AreEqual("!foo", fieldCondition.Field);
            Assert.AreEqual("!=", fieldCondition.Operation);
            Assert.AreEqual("ba=r", fieldCondition.Value);
            Assert.IsFalse(fieldCondition.FieldIndex.HasValue);
            Assert.IsFalse(fieldCondition.IsFieldByIndex);
        }
        private Silanis.ESL.SDK.FieldCondition CreateTypicalSDKFieldCondition()
        {
            FieldCondition sdkFieldCondition = new FieldCondition();

            sdkFieldCondition.Id        = "ConditionId";
            sdkFieldCondition.Condition = "document['DocumentId'].field['fieldId2'].value == 'X'";
            sdkFieldCondition.Action    = "document['DocumentId'].field['fieldId1'].enabled = false";


            return(sdkFieldCondition);
        }
Example #30
0
        public bool DeleteFieldCondition(FieldCondition fieldCondition)
        {
            storage.DeleteFieldConditionRules(fieldCondition);

            string sql = "DELETE FROM UFfieldconditions where id = @id";

            sqlHelper.ExecuteNonQuery(sql,
                                      sqlHelper.CreateParameter("@id", fieldCondition.Id));

            return(true);
        }
Example #31
0
        public void Add_2FieldConditions_CheckValueItem2()
        {
            var expected = new FieldCondition(new Field("F2"), RelationalOperators.GreaterThan, 0);

            _conditionGroup.Add(new Field("F1"), RelationalOperators.Equal, 123)
            .Add(new Field("F2"), RelationalOperators.GreaterThan, 0);

            var actual = (IFieldCondition)(_conditionGroup.Conditions[1]);

            Assert.AreEqual(expected.Operator, actual.Operator);
        }
        private OneSpanSign.Sdk.FieldCondition CreateTypicalSDKFieldCondition()
        {
            FieldCondition sdkFieldCondition = new FieldCondition();

            sdkFieldCondition.Id        = "ConditionId";
            sdkFieldCondition.Condition = "document['DocumentId'].field['fieldId2'].value == 'X'";
            sdkFieldCondition.Action    = "document['DocumentId'].field['fieldId1'].disabled = true";


            return(sdkFieldCondition);
        }
Example #33
0
        public void Add_1ConditionGroup_CheckValue()
        {
            var expected   = new FieldCondition(new Field("F1"), RelationalOperators.Equal, 123);
            var groupToAdd = new ConditionGroup(new [] { expected });

            _conditionGroup.Add(groupToAdd);

            var actual = (IFieldCondition)((IConditionGroup)_conditionGroup.Conditions[0]).Conditions[0];

            Assert.AreEqual(expected.Value, actual.Value);
        }
        public void FieldCondition_GreaterThanOrEqual()
        {
            string         conditionString = @"\>\=foo>=99";
            FieldCondition fieldCondition  = FieldCondition.Parse(conditionString);

            Assert.AreEqual(">=foo", fieldCondition.Field);
            Assert.AreEqual(">=", fieldCondition.Operation);
            Assert.AreEqual("99", fieldCondition.Value);
            Assert.IsFalse(fieldCondition.FieldIndex.HasValue);
            Assert.IsFalse(fieldCondition.IsFieldByIndex);
        }