Exemplo n.º 1
0
    public static void createConstraints(FormField ff, ImportConstraintContainer icc)
    {
        GRASPEntities db = new GRASPEntities();

        ConstraintContainer cc = new ConstraintContainer();

        cc.pushed = 0;
        cc.cType = icc.cNumber.ToString();
        cc.maxRange = icc.maxRange;
        cc.minRange = icc.minRange;
        cc.value = icc.value;
        db.ConstraintContainer.Add(cc);
        db.SaveChanges();

        createconstraintAssociation(ff.id, cc.id);
    }
Exemplo n.º 2
0
    public void detectConstraints()
    {
        Debug.WriteLine(this.fieldType.ToString());
        if (this.fieldType == FormFieldType.REPEATABLES || this.fieldType == FormFieldType.REPEATABLES_BASIC)
        {
            foreach (ImportingElement repEl in this.repElements)
            {
                repEl.detectConstraints();
            }
        }

        if (bindReference != null)
        {
            string splitString = " and ";
            if (bindReference.constraint.Contains(" and "))
            {
                splitString = " and ";
                constraintPolicy = AND_POLICY;
            }
            if (bindReference.constraint.Contains(" or "))
            {
                splitString = " or ";
                constraintPolicy = OR_POLICY;
            }

            string[] constraintElements = bindReference.constraint.Split(new string[] { splitString }, StringSplitOptions.None);
            foreach (string constraint in constraintElements)
            {
                if (constraint != "" && !constraint.Contains("regex"))
                {
                    foreach (string t in bindSymbols)
                    {
                        if (constraint.Contains(t))
                        {
                            string[] splitted = constraint.Split(new string[] { t }, StringSplitOptions.None);
                            string constraintValue = splitted[1];
                            if ((constraintValue[0] == '\'' && constraintValue[constraintValue.Length - 1] == '\''))
                            {
                                constraintValue = constraintValue.Substring(1, constraintValue.Length - 1);
                            }

                            ImportConstraintContainer constCont = new ImportConstraintContainer();
                            constCont.value = constraintValue;

                            if (t == " = ")
                                constCont.cNumber = ConstraintNumber.EQUALS;
                            else if (t == " != ")
                                constCont.cNumber = ConstraintNumber.NOT_EQUALS;
                            else if (t == " > ")
                                constCont.cNumber = ConstraintNumber.GREATER_THAN;
                            else if (t == " < ")
                                constCont.cNumber = ConstraintNumber.LESS_THAN;
                            else if (t == " >= ")
                                constCont.cNumber = ConstraintNumber.GREATER_EQUALS_THAN;
                            else if (t == " <= ")
                                constCont.cNumber = ConstraintNumber.LESS_EQUALS_THAN;

                            this.constraints.Add(constCont);
                            break;
                        }
                    }
                }
            }
        }
    }