Beispiel #1
0
        /// <summary>
        /// This method provides a way to use the console to query the user for all
        /// form elements.
        /// </summary>
        /// <param name="formObject">
        ///     When called externally it should be Form, but this method is called recursively
        /// </param>
        /// <param name="fieldInfoList">The list of FieldInfos with the user's response</param>
        public static void getUserInputFieldInfoList(Object formObject, IList fieldInfoList)
        {
            if (formObject is Form)
            {
                Form form = (Form)formObject;
                for (int i = 0; i < form.componentList.Length; i++)
                {
                    getUserInputFieldInfoList(form.componentList[i], fieldInfoList);
                }
            }
            else if (formObject is FieldInfoSingle)
            {
                FieldInfoSingle fieldInfoSingle = (FieldInfoSingle)formObject;

                String result = promptUser(
                    fieldInfoSingle,
                    fieldInfoSingle.validationRules,
                    fieldInfoSingle.value,
                    0,
                    0);

                if (result != null && result.Length > 0)
                {
                    fieldInfoSingle.value = result;
                }

                fieldInfoList.Add(fieldInfoSingle);
            }
            else if (formObject is FieldInfoChoice)
            {
                FieldInfoChoice fieldInfoChoice = (FieldInfoChoice)formObject;
                for (int i = 0; i < fieldInfoChoice.fieldInfoList.Length; i++)
                {
                    getUserInputFieldInfoList(fieldInfoChoice.fieldInfoList[i], fieldInfoList);
                }
            }
            else if (formObject is FieldInfoMultiFixed)
            {
                FieldInfoMultiFixed fieldInfoMultiFixed = (FieldInfoMultiFixed)formObject;
                for (int i = 0; i < fieldInfoMultiFixed.valueIdentifiers.Length; i++)
                {
                    String result = promptUser(
                        fieldInfoMultiFixed,
                        fieldInfoMultiFixed.validationRules[i],
                        fieldInfoMultiFixed.values[i],
                        i,
                        fieldInfoMultiFixed.valueIdentifiers.Length);

                    if (result != null && result.Length > 0)
                    {
                        fieldInfoMultiFixed.values[i] = result;
                    }
                }
                fieldInfoList.Add(fieldInfoMultiFixed);
            }
            else
            {
                // Should throw an error
            }
        }
Beispiel #2
0
 /// <summary>
 /// A form has the potential to have many recursive layers.  This method
 /// allows any type of form element to be passed into it, and it determines
 /// which type of element is present and traverses appropriately
 /// </summary>
 /// <param name="formObject">The form object to be processed</param>
 /// <param name="padding">String padding to make the final display pretty</param>
 public static void PrintFormObjectAsText(Object formObject, String padding)
 {
     if (formObject is Form)
     {
         Form form = (Form)formObject;
         System.Console.WriteLine(padding + "  +-" + form.GetType());
         if (form.conjunctionOp.Value == FormConjunctionOperator.AND)
         {
             System.Console.WriteLine(padding + "  +-conjunctionOperator = AND");
         }
         else
         {
             System.Console.WriteLine(padding + "  +-conjunctionOperator = OR");
         }
         System.Console.WriteLine(padding + "  +-components");
         for (int i = 0; i < form.componentList.Length; i++)
         {
             PrintFormObjectAsText(form.componentList[i], padding + "    ");
         }
     }
     else if (formObject is FieldInfoSingle)
     {
         FieldInfoSingle fieldInfoSingle = (FieldInfoSingle)formObject;
         System.Console.WriteLine(padding + "+-" + fieldInfoSingle.GetType() + ", displayName=" + fieldInfoSingle.displayName);
         System.Console.WriteLine(padding + "  +-FieldType=" + fieldInfoSingle.fieldType.Value.ToString());
     }
     else if (formObject is FieldInfoChoice)
     {
         FieldInfoChoice fieldInfoChoice = (FieldInfoChoice)formObject;
         System.Console.WriteLine(padding + "+-" + fieldInfoChoice.GetType());
         for (int i = 0; i < fieldInfoChoice.fieldInfoList.Length; i++)
         {
             PrintFormObjectAsText(fieldInfoChoice.fieldInfoList[i], padding + "  ");
         }
     }
     else if (formObject is FieldInfoMultiFixed)
     {
         FieldInfoMultiFixed fieldInfoMultiFixed = (FieldInfoMultiFixed)formObject;
         System.Console.WriteLine(padding + "+-" + fieldInfoMultiFixed.GetType() + ", displayName=" + fieldInfoMultiFixed.displayName);
         for (int i = 0; i < fieldInfoMultiFixed.fieldTypes.Length; i++)
         {
             System.Console.WriteLine(padding + "  +-FieldType=" + fieldInfoMultiFixed.fieldTypes[i].Value.ToString());
         }
     }
     else
     {
         System.Console.WriteLine(padding + "+-" + formObject.GetType());
     }
 }
Beispiel #3
0
 /// <summary>
 /// A form has the potential to have many recursive layers.  This method
 /// allows any type of form element to be passed into it, and it determines
 /// which type of element is present and traverses appropriately
 /// </summary>
 /// <param name="formObject">The form object to be processed</param>
 /// <param name="stringBuilder">The StringBuilder that holds all of the output as it is built</param>
 /// <param name="padding">String padding to make the final display pretty</param>
 public static void PrintFormObjectAsHtml(Object formObject, StringBuilder stringBuilder, String padding)
 {
     // If the object is a Form it is either the top-level form, and a subform.
     // Sub-forms are incredibly rare in the Yodlee system.
     if (formObject is Form)
     {
         // A form object itself can be surrounded by a table.  The border is
         // turned on in this instance to make it slightly easier to see the levels
         // in a multi-level form.
         stringBuilder.Append(padding + "<table border=\"1\">\n");
         Form form = (Form)formObject;
         for (int i = 0; i < form.componentList.Length; i++)
         {
             PrintFormObjectAsHtml(form.componentList[i], stringBuilder, padding + "  ");
         }
         stringBuilder.Append(padding + "</table>\n");
     }
     // FieldInfoSingle is the most common type of object in the Yodlee system.
     // It describes a single Name/Value pair that is presented to the user.
     else if (formObject is FieldInfoSingle)
     {
         FieldInfoSingle fieldInfoSingle = (FieldInfoSingle)formObject;
         stringBuilder.Append(padding + "<tr>\n");
         stringBuilder.Append(padding + "  <td>" + fieldInfoSingle.displayName + ":</td>\n");
         stringBuilder.Append(padding + "  <td>\n");
         if (fieldInfoSingle.fieldType != null)
         {
             PrintFieldInfoAsHtml(fieldInfoSingle.fieldType.GetType().ToString(),
                                  fieldInfoSingle.valueIdentifier,
                                  fieldInfoSingle.value,
                                  fieldInfoSingle.validValues,
                                  fieldInfoSingle.displayValidValues,
                                  stringBuilder,
                                  padding + "    ");
         }
         else
         {
             // This is rare condition.  In a completely developed and released
             // Form, FieldType will never be null.  In certain forms under-
             // development that may be deployed to a staging environment, it
             // is possible that this entry could be Null.  The proper behavior
             // is likely to throw an exception that is caught higher up and
             // the end user is told the Site is not valid.
             stringBuilder.Append(padding + "    FieldType is null.\n");
         }
         stringBuilder.Append(padding + "  </td>\n");
         stringBuilder.Append(padding + "</tr>\n");
     }
     // A FieldInfoChoice object contains multiple child FieldInfo objects.
     // The user only need to fill in a single one of these child objects.
     else if (formObject is FieldInfoChoice)
     {
         FieldInfoChoice fieldInfoChoice = (FieldInfoChoice)formObject;
         stringBuilder.Append(padding + "<tr><td colspan=\"2\">\n");
         stringBuilder.Append(padding + "  <table border=\"1\">\n");
         for (int i = 0; i < fieldInfoChoice.fieldInfoList.Length; i++)
         {
             if (i > 0)
             {
                 stringBuilder.Append(padding + "  <tr><td colspan=\"2\">or</td></tr>\n");
             }
             PrintFormObjectAsHtml(fieldInfoChoice.fieldInfoList[i], stringBuilder, padding + "  ");
         }
         stringBuilder.Append(padding + "  </table>\n");
         stringBuilder.Append(padding + "</td></tr>\n");
     }
     // FieldInfoMultiFixed is meant to query for a single value that is broken up
     // up over multiple HTML fields.  Common uses are phone number as three fields,
     // zipcode as two fields or SSN as three fields.
     else if (formObject is FieldInfoMultiFixed)
     {
         FieldInfoMultiFixed fieldInfoMultiFixed = (FieldInfoMultiFixed)formObject;
         stringBuilder.Append(padding + "<tr>\n");
         stringBuilder.Append(padding);
         stringBuilder.Append("  <td>");
         stringBuilder.Append(fieldInfoMultiFixed.displayName);
         stringBuilder.Append("</td>\n");
         stringBuilder.Append(padding + "  <td>\n");
         for (int i = 0; i < fieldInfoMultiFixed.valueIdentifiers.Length; i++)
         {
             PrintFieldInfoAsHtml(
                 fieldInfoMultiFixed.fieldTypes[i].Value.ToString(),
                 fieldInfoMultiFixed.valueIdentifiers[i],
                 fieldInfoMultiFixed.values[i],
                 fieldInfoMultiFixed.validValues[i],
                 fieldInfoMultiFixed.displayValidValues[i],
                 stringBuilder,
                 padding + "    "
                 );
         }
         stringBuilder.Append(padding + "  </td>\n");
         stringBuilder.Append(padding + "</tr>\n");
     }
     else
     {
         System.Console.WriteLine("Unknowng Form Type: {0}", formObject.GetType());
     }
 }