}//END SaveItem class

        // =====================================================================================
        /// <summary>
        /// This class deletes items from the FormField table.
        /// </summary>
        /// <param name="Form">EvForm: a form object</param>
        /// <returns>EvEventCodes: an event code for deleting items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method to retrieve a list of formfield objects based on the form's Guid
        ///
        /// 2. Loop through the formfield list and execute the method for deleting the formfield items.
        ///
        /// 3. Return an event code for deleting items.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes DeleteFields(EdRecord Form)
        {
            this.LogMethod("DeleteFields");
            this.LogValue("Guid: " + Form.Guid);
            //
            // Define the local variables.
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Retrieve the TestReport items
            //
            List <EdRecordField> Items = this._DalFormFields.GetFieldList(Form.Guid);

            //
            // Iterate through the items deleting them
            //
            for (int Count = 0; Count < Items.Count; Count++)
            {
                EdRecordField FormItem = (EdRecordField)Items [Count];
                iReturn = _DalFormFields.DeleteItem(FormItem);
                if (iReturn < EvEventCodes.Ok)
                {
                    this.LogClass(this._DalFormFields.Log);
                    return(iReturn);
                }
            }
            return(iReturn);
        } // Close DeleteFields method
        }//END UpdateFields method

        // =====================================================================================
        /// <summary>
        /// This class update fields on formfield table using formfield object.
        /// </summary>
        /// <param name="SqlUpdateStatement">StringBuilder: containing the SQL update statemenet</param>
        /// <param name="ParmList">list of SqlParameter objects</param>
        /// <param name="RecordField">EvFormField: a formfield data object</param>
        /// <returns>EvEventCodes: an event code for updating fields</returns>
        // -------------------------------------------------------------------------------------
        private void GenerateUpdateQueryStatements(
            StringBuilder SqlUpdateStatement,
            List <SqlParameter> ParmList,
            EdRecordField RecordField)
        {
            this.LogMethod("updateField method. ");

            //
            // If readonly field exit method.
            //
            if (RecordField.isReadOnly == true)
            {
                return;
            }

            switch (RecordField.TypeId)
            {
            default:
            {
                this.updateSingleValueField(
                    SqlUpdateStatement,
                    ParmList,
                    RecordField,
                    "", 0);
                break;
            }
            }
        }//END updateField method
Exemplo n.º 3
0
    }//END createSignoff method 

    #endregion

    #region Processing FormFields

    // =====================================================================================
    /// <summary>
    /// This class processes the form fields states.  Setting their status and where appropriate
    /// signing them off.
    /// 
    /// </summary>
    /// <param name="Record">EvForm: a form object</param>
    /// <returns>List of EvFormField: a form field object</returns>
    /// <remarks>
    /// This method consists of the following steps: 
    /// 
    /// 1. Loop through the form object's fields
    /// 
    /// 2. Update the appropriate form fields's state and action. 
    /// 
    /// 3. Execute the method to update the form field state. 
    /// 
    /// 4. Add teh formfield object to the list of formfield objects. 
    /// </remarks>
    //  ----------------------------------------------------------------------------------
    private List<EdRecordField> processFormFields ( EdRecord Record )
    {
      this.LogMethod ( "processFormFields method." );
      this.LogValue ( "Field count: " + Record.Fields.Count );
      this.LogValue ( "Form state: " + Record.State );
      this.LogValue ( "Save Action: " + Record.SaveAction );

      // 
      // Iterate through the adverse event fields and update the newField's state and action.
      // 
      for ( int count = 0; count < Record.Fields.Count; count++ )
      {
        EdRecordField field = Record.Fields [ count ];

        this.LogValue ( " >> Field ID: " + field.FieldId + ", Subject: '" + field.Design.Title
          + "', Value: '" + field.ItemValue );

        // 
        // Update the newField currentSchedule value
        // 
        Record.Fields [ count ] = field;

      }//END newField iteration loop.

      // 
      // When completed return the updated newField currentSchedule.
      // 
      return Record.Fields;

    }//END processFormFields method
        }//END getRowData method.

        // =====================================================================================
        /// <summary>
        /// This method processes form field table or matrix object.
        /// </summary>
        /// <param name="Row">DataRow: a sql data row object</param>
        /// <param name="Field">EvFormField: a formfield object</param>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Validate whether the formfield type is matrix and table.
        ///
        /// 2. if the Itemtext value is empty then initialise it with the EvFormField table value.
        ///
        /// 3. Deserialize the formfield item text to the formfield table.
        ///
        /// 4. Empty the formfield itemtext so it will not cause problems when XML styling the record object.
        ///
        /// 5. Iterate through the table for setting the validation objects.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private void processTableRowObject(
            DataRow Row,
            EdRecordField Field)
        {
            //this.LogMethod ( "processTableRowObject method " );
            //this.LogDebugValue ( "FieldId: " + Field.FieldId );
            //this.LogDebugValue ( "Table Length: " + Field.ItemText.Length );
            //
            // Validate whether the formfield type is matrix and table.
            //
            if (Field.TypeId != Evado.Model.EvDataTypes.Special_Matrix &&
                Field.TypeId != Evado.Model.EvDataTypes.Table)
            {
                //this.LogMethodEnd ( "processTableRowObject" );
                return;
            }

            //
            // if the Itemtext value is empty then initialise it with the EvFormField table value.
            //
            if (Field.ItemText == String.Empty)
            {
                //this.LogDebugValue ( "Reset table value to form default." );
                Field.ItemText = EvSqlMethods.getString(Row, EdRecordFields.DB_TABLE);
            }
            //
            // Deserialize the formfield item text to the formfield table.
            //
            Field.Table = Evado.Digital.Model.EvcStatics.DeserialiseObject <EdRecordTable> (Field.ItemText);

            //
            // Empty the formfield itemtext so it will not cause problems when XML styling the record object.
            //
            Field.ItemText = String.Empty;

            //
            // Iterate through the table for setting the validation objects.
            //
            for (int i = 0; i < Field.Table.ColumnCount; i++)
            {
                //
                // Addressing the 'NA' to negative infinity issue for non-numeric fields.
                //
                // Iterate through the table data converting the relevant cell values to NA.
                //
                for (int j = 0; j < Field.Table.Rows.Count; j++)
                {
                    String cell = Field.Table.Rows [j].Column [i];

                    if (Field.Table.Header [i].TypeId != EvDataTypes.Numeric)
                    {
                        Field.Table.Rows [j].Column [i] = Evado.Model.EvStatics.convertNumNullToTextNull(cell);
                    }

                    //this.LogDebugValue ( "R:" + j  + ", C:" + i + ", V: " + cell );
                } //END column iteration loop
            }     //END newField iteration loop
        }         //END processTableRowObject method
    }//END getFilteredList_SelectionField Query

    // ==============================================================================
    /// <summary>
    /// This method creates the record view pageMenuGroup containing a list of commands to 
    /// open the form record.
    /// </summary>
    /// <param name="Field">EdRecordField object.</param>
    /// <returns>List of EvOption objects</returns>
    //  ------------------------------------------------------------------------------
    private List<EvOption> getFilteredList_SelectionOptions (
      EdRecordField Field,
      bool IsSelectionList )
    {
      this.LogMethod ( "getFilteredList_SelectionOptions" );
      //
      // initialise the variables and objects.
      //
      List<EvOption> optionList = new List<EvOption> ( );
      String listId = Field.Design.ExSelectionListId;
      String category = Field.Design.ExSelectionListCategory.ToUpper ( );
      this.LogDebug ( "Field: {0}, List: {1}, Category: {2} ", Field.FieldId, listId, category );

      //
      // the category contains the category field then set the category value to this field value.
      //
      if ( category.Contains ( EdRecordField.CONST_CATEGORY_AUTO_FIELD_IDENTIFIER ) == true )
      {
        var autoCategory = category.Replace ( EdRecordField.CONST_CATEGORY_AUTO_FIELD_IDENTIFIER, String.Empty );

        this.LogDebug ( "autoCategory: {0} ", autoCategory );
        //
        // search the filterfields for a matching field identifier then retrieve the matching filter value
        // as the category for this selection list.
        //
        for ( int index = 0; index < this.queryLayout.FilterFieldIds.Length; index++ )
        {
          if ( this.queryLayout.FilterFieldIds [ index ] == autoCategory )
          {
            category = this.Session.EntitySelectionFilters [ index ];
          }
        }
        this.LogDebug ( "Auto Category: {0} ", category );

        //
        // the auto category selection value is empty exit.
        //
        if ( category == String.Empty )
        {
          return optionList;
        }
      }

      this.LogDebug ( "Parameters List: {0}, Category: {1} ", listId, category );
      //
      // get the external selection list options.
      //
      optionList = this.AdapterObjects.getSelectionOptions ( listId, category, false, IsSelectionList );

      this.LogDebug ( "optionList.Count: {0} ", optionList.Count );

      this.LogMethodEnd ( "getFilteredList_SelectionOptions" );
      return optionList;

    }//ENd Method.
    }//END getGroupListCommand method

    // ==============================================================================
    /// <summary>
    /// This method returns the desciption value for a selection option value.
    /// </summary>
    /// <param name="Entity">EvForm object</param>
    /// <param name="PageGroup"> Evado.UniForm.Model.Group</param>
    //  -----------------------------------------------------------------------------
    private string getSelectionDescription ( EdRecordField Field, String Value )
    {
      this.LogMethod ( "getSelectionDescription" );
      //
      // initialise the methods variables and objects.
      //
      List<EvOption> optionList = Field.Design.OptionList;
      string [ ] arValue = Field.ItemValue.Split ( ';' );
      String outputText = String.Empty;
      String valueList = String.Empty;

      //
      // search selection list if the list is external
      //
      if ( Field.TypeId == EvDataTypes.External_CheckBox_List
        || Field.TypeId == EvDataTypes.External_RadioButton_List
        || Field.TypeId == EvDataTypes.External_Selection_List )
      {
        optionList = this.AdapterObjects.getSelectionOptions (
          Field.Design.ExSelectionListId, String.Empty, false, false );
      }

      //
      // iterate through the list options to retrieve the matching description.
      //
      foreach ( String str in arValue )
      {
        foreach ( EvOption option in optionList )
        {
          if ( option.Value != str )
          {
            continue;
          }

          if ( valueList.Contains ( option.Value ) == true )
          {
            continue;
          }

          valueList += ";" + option.Value;

          if ( outputText != String.Empty )
          {
            outputText += @"[[/br]]";
          }

          outputText += option.Description;
        }
      }

      return outputText;
    }//END Method
        }//END GetItem class

        #endregion

        #region Update FormField object methods

        // =====================================================================================
        /// <summary>
        /// This class saves items to formfield ResultData table.
        /// </summary>
        /// <param name="FormField">EvFormField: a formfield object</param>
        /// <returns>EvEventCodes: an event code for saving items</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the FormGuid or UserCommonName is empty.
        ///
        /// 2. Execute the method for deleting items, if the action code is delete
        ///
        /// 3. Execute the method for adding items, if the formfield's Uid is empty.
        ///
        /// 4. Else, execute the method for updating items.
        ///
        /// 5. Return an event code of the method execution.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EvEventCodes SaveItem(EdRecordField FormField)
        {
            this.LogMethod("saveItem Method");
            this.LogValue("Guid: " + FormField.Guid);
            this.LogValue("FormGuid: " + FormField.LayoutGuid);
            this.LogValue("FieldId: " + FormField.FieldId);
            //
            // Define the local variables.
            //
            EvEventCodes iReturn = EvEventCodes.Ok;

            //
            // Validate whether the FormGuid and UserCommonName are not empty
            //
            if (FormField.LayoutGuid == Guid.Empty)
            {
                this.LogValue("Form Guid Error.");

                return(EvEventCodes.Identifier_Global_Unique_Identifier_Error);
            }

            //
            // If the action is set to delete the object.
            //
            if (FormField.Title == String.Empty &&
                FormField.Design.Instructions == String.Empty)
            {
                iReturn = _DalFormFields.DeleteItem(FormField);
                this.LogClass(_DalFormFields.Log);
                return(iReturn);
            }

            //
            // If the newField FormUid is zero or empty, then create a new newField record.
            //
            if (FormField.Guid == Guid.Empty)
            {
                this.LogValue("Add New Object. ");
                iReturn = _DalFormFields.AddItem(FormField);
                this.LogClass(_DalFormFields.Log);
                return(iReturn);
            }

            //
            // Update the newField record.
            //
            iReturn = _DalFormFields.UpdateItem(FormField);
            this.LogClass(_DalFormFields.Log);
            return(iReturn);
        }//END SaveItem class
        }//End GetList method.

        #endregion

        #region Retrieve TestReport object methods

        // =====================================================================================
        /// <summary>
        /// This class retrieves the formfield object based on Guid.
        /// </summary>
        /// <param name="FieldGuid">Guid: a field global unique identifier</param>
        /// <returns>EvFormField: a formfield ResultData object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Execute the method for retrieving formfield object values.
        ///
        /// 2. Return the formfield object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public EdRecordField getField(Guid FieldGuid)
        {
            this.LogMethod("getField");
            this.LogValue("FieldGuid: " + FieldGuid);
            EdRecordField formField = new EdRecordField( );

            //
            // Query the database
            //
            formField = _DalFormFields.getField(FieldGuid);
            this.LogClass(_DalFormFields.Log);

            return(formField);
        }//END GetItem class
        }//END ExportTableSpacer method.

        //  ==================================================================================
        /// <summary>
        /// This class generates the export ResultData output.
        /// </summary>
        /// <param name="FormField">EvFormField: a formfield object</param>
        /// <param name="ExportFreeText">Boolean: true, if the free text fields are exported</param>
        /// <returns>string: an export record field ResultData string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Switch the header field object's QueryType and export the associated ResultData.
        ///
        /// 2. Return the export record field ResultData string, if the types that have values.
        ///
        /// 3. Else, return empty string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private bool getExportRecordFieldData(EdRecordField FormField,
                                              bool ExportFreeText)
        {
            //
            // Select the field QueryType to export.
            //
            switch (FormField.TypeId)
            {
            case EvDataTypes.Numeric:
            {
                this.exportColumnValue(FormField.FieldId, FormField.ItemValue);
                return(true);
            }

            case EvDataTypes.Table:
            case EvDataTypes.Special_Matrix:
            {
                this.ExportTableData(FormField);
                return(true);
            }

            case EvDataTypes.Check_Box_List:
            {
                this.ExportCheckBoxData(FormField);
                return(true);
            }

            case EvDataTypes.Boolean:
            {
                string value = EvStatics.encodeCsvBoolean(FormField.ItemValue);
                this.exportColumnValue(FormField.FieldId, value);
                return(true);
            }

            case EvDataTypes.Free_Text:
            {
                if (ExportFreeText == true)
                {
                    this.exportColumnValue(FormField.FieldId, FormField.ItemValue);
                }
                return(true);
            }

            default:
            {
                this.exportColumnValue(FormField.FieldId, FormField.ItemValue);
                return(true);
            }
            } //END Switch
        }     //ENd getExportData
        }//END getExportDataHeader method.

        //  ==================================================================================
        /// <summary>
        /// This class exports the checkbox header.
        /// </summary>
        /// <param name="FormField">EvFormField: a form field object</param>
        /// <returns>String: a checkbox header string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loop through the formfield option list and add the formfield values to the output string
        ///
        /// 2. Return the output string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private String ExportCheckBoxHeader(EdRecordField FormField)
        {
            //
            // Output the header static fields
            //
            System.Text.StringBuilder sOutput = new System.Text.StringBuilder( );

            //
            // Output the form field header information
            //
            foreach (EvOption option in FormField.Design.OptionList)
            {
                sOutput.Append(";" + FormField.FieldId + "-" + option.Value.Replace(",", ""));
            }

            return(sOutput.ToString( ));
        }//END getExportCheckBoxHeader method.
        }//END getExportCheckBoxHeader method.

        //  ==================================================================================
        /// <summary>
        /// This class exports the table header
        /// </summary>
        /// <param name="FormField">EvFormField: a form field object</param>
        /// <returns>String: a table header string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loop through the formfield object table's rows and columns
        ///
        /// 2. add the formfield values to the table header string.
        ///
        /// 3. Return the table header string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private string ExportTableHeader(EdRecordField FormField)
        {
            System.Text.StringBuilder sOutput = new System.Text.StringBuilder( );
            //
            // Output the form field header information
            //
            for (int row = 0; row < FormField.Table.Rows.Count; row++)
            {
                for (int col = 0; col < FormField.Table.Header.Length; col++)
                {
                    if (FormField.Table.Header [col].Text == String.Empty)
                    {
                        continue;
                    }
                    sOutput.Append(";" + FormField.FieldId + " R:" + row + " C:" + col);
                } //END column iteration loop
            }     //END row iteration

            return(sOutput.ToString());
        }//END ExportTableHeader method.
        //  ==================================================================================
        /// <summary>
        /// This class exports table spacer
        /// </summary>
        /// <param name="FormField">EvFormField: a formfield object</param>
        /// <returns>String: a table spacer string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loop through the formfield object table rows and columns
        ///
        /// 2. Add the "," character to the table header string.
        ///
        /// 3. Return the table header string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private String ExportTableSpacer(EdRecordField FormField)
        {
            String stTableHeader = String.Empty;

            //
            // Output the form field header information
            //
            for (int row = 0; row < FormField.Table.Rows.Count; row++)
            {
                for (int col = 0; col < FormField.Table.Header.Length; col++)
                {
                    if (FormField.Table.Header [col].Text != String.Empty)
                    {
                        stTableHeader += Evado.Digital.Model.EvcStatics.encodeCsvEmpty;
                    }
                } //END column iteration loop
            }     //END row iteration

            return(stTableHeader);
        }//END ExportTableSpacer method.
Exemplo n.º 13
0
        }         //END processTableRowObject method

        // =====================================================================================
        /// <summary>
        /// This methoid processes the not available values.
        /// </summary>
        /// <param name="Row">DataRow: an sql data row object</param>
        /// <param name="Field">EvFormField: a form field object</param>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. To address Null Numeric bug, convert from 1E-45F to Float Negative Infinity.
        ///
        /// 2. Reset the numeric 'NA' for negative infinity issue and null value.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private void processNotAvailableValues(
            DataRow Row,
            EdRecordField Field)
        {
            //this.LogMethod ( "processNotAvailableValues method " );
            //
            // To address Null Numeric bug, convert from 1E-45F to Float Negative Infinity.
            //
            Field.ItemValue = Evado.Model.EvStatics.convertNumNullToTextNull(Field.ItemValue);

            //
            // Reset the numeric 'NA' for negative infinity issue.
            //
            if (Field.TypeId == Evado.Model.EvDataTypes.Selection_List ||
                Field.TypeId == Evado.Model.EvDataTypes.External_Selection_List ||
                Field.TypeId == Evado.Model.EvDataTypes.Horizontal_Radio_Buttons ||
                Field.TypeId == Evado.Model.EvDataTypes.Radio_Button_List)
            {
                Field.Design.Options = Field.Design.Options.Replace(" :", ":");
                if (Evado.Digital.Model.EvcStatics.hasNumericNul(Field.ItemValue) == true)
                {
                    Field.ItemValue = Evado.Digital.Model.EvcStatics.CONST_NUMERIC_NOT_AVAILABLE;
                }
                if (Field.ItemValue == "0" &&
                    Field.Design.Options.Contains(Evado.Digital.Model.EvcStatics.CONST_NUMERIC_NOT_AVAILABLE + ":") == true &&
                    Field.Design.Options.Contains(@"0:") == false)
                {
                    Field.ItemValue = Evado.Digital.Model.EvcStatics.CONST_NUMERIC_NOT_AVAILABLE;
                }
            }
            if (Field.TypeId != Evado.Model.EvDataTypes.Numeric)
            {
                if (Evado.Digital.Model.EvcStatics.hasNumericNul(Field.ItemValue) == true)
                {
                    Field.ItemValue = Evado.Digital.Model.EvcStatics.CONST_NUMERIC_NOT_AVAILABLE;
                }
            }

            //this.LogMethodEnd ( "processNotAvailableValues" );
        }//END processNotAvailableValues method
        }     //ENd getExportData

        #endregion
        //  ==================================================================================
        /// <summary>
        /// This method creates the export checkbox ResultData header.
        /// </summary>
        /// <param name="FormField">EvFormField: a formfield object</param>
        /// <returns>String: a checkbox export string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loop through the headerfield object optionlist.
        ///
        /// 2. Append the compatible ",1" or ",0" character to the output string.
        ///
        /// 3. Return the output string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private void ExportCheckBoxData(
            EdRecordField FormField)
        {
            this.LogMethod("ExportCheckBoxData method. ");
            //
            // Define the string builder
            //
            string [] values = FormField.ItemValue.Split(';');
            this.LogDebug("ItemValue: " + FormField.ItemValue);

            if (FormField.ItemValue == String.Empty)
            {
                this.LogDebug("EXIT empty value");
                return;
            }

            //
            // Output the form field header information
            //
            foreach (EvOption option in FormField.Design.OptionList)
            {
                //
                // iterate through the value array.
                //
                foreach (string value in values)
                {
                    if (option.Value != value)
                    {
                        continue;
                    }

                    string exportFieldId = FormField.FieldId + "-" + option.Value.Replace(",", "");

                    this.exportColumnValue(exportFieldId, "1");
                }
            }//END option list interation loop.

            this.LogMethodEnd("ExportCheckBoxData");
        }//END ExportCheckBoxData method.
        }//END ExportCheckBoxData method.

        //  ==================================================================================
        /// <summary>
        /// This method creates the export table ResultData header.
        /// </summary>
        /// <param name="FormField">EvFormField: a formfield object</param>
        /// <returns>String: a checkbox export string</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Loop through the headerfield object table's rows.
        ///
        /// 2. if the headerfield row is greater than or equal to formfield's row length,
        /// loop through columns and append the compatible "," character to the output string.
        ///
        /// 3. Else, loop through the column and
        ///
        /// 4. switch the column QueryType and append the formfield object's column value to the output string.
        ///
        /// 5. Return the output string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        private void ExportTableData(
            EdRecordField FormField)
        {
            this.LogMethod("ExportTableData method. ");
            this.LogDebug("record FieldId: " + FormField.FieldId);
            this.LogDebug("table Rows: " + FormField.Table.Rows.Count);

            //
            // Output the form field header information
            //
            for (int row = 0; row < FormField.Table.Rows.Count; row++)
            {
                this.LogDebug("Row: " + row);

                //
                // iterate through the columns inserting null values.
                //
                for (int col = 0; col < FormField.Table.Header.Length; col++)
                {
                    this.LogDebug("Col: " + col);
                    //
                    // Skip empty columns
                    //
                    if (FormField.Table.Header [col].Text == String.Empty)
                    {
                        continue;
                    }
                    string tableFieldId = FormField.FieldId + " R:" + row + " C:" + col;

                    string value = FormField.Table.Rows [row].Column [col];

                    this.exportColumnValue(tableFieldId, value);
                } //END if column iteration
            }     //END row iteration

            this.LogMethodEnd("ExportTableData ");
        }//END ExportTableData method
    // ==============================================================================
    /// <summary>
    /// This method creates the record view pageMenuGroup containing a list of commands to 
    /// open the form record.
    /// </summary>
    /// <param name="PageObject">Evado.Model.Uniform.Page object to add the pageMenuGroup to.</param>
    /// <param name="subjects">EvSubjects subjects to add to selection groups</param>
    /// <param name="subjectVisits">EvSubjectMilestones visits for each subject</param>
    /// <param name="QueryParameters">EvQueryParameters: conting the query parameters</param>
    /// <param name="ApplicationObject">Adapter.ApplicationObjects object.</param>
    //  ------------------------------------------------------------------------------
    private void getFilteredList_SelectionGroup (
      Evado.UniForm.Model.Page PageObject )
    {
      this.LogMethod ( "getFilteredList_SelectionGroup" );
      //
      // Initialise the methods variables and objects.
      //
      Evado.UniForm.Model.Group pageGroup = null;
      Evado.UniForm.Model.Command selectionCommand = null;
      List<EvOption> optionList;
      Evado.UniForm.Model.Field groupField;

      //
      // if hide selection group is enabled exit 
      //
      if ( this._HideSelectionGroup == true )
      {
        return;
      }

      // 
      // Create the new pageMenuGroup for record selection.
      // 
      pageGroup = PageObject.AddGroup (
        EdLabels.Entities_Selection_Group_Title,
        Evado.UniForm.Model.EditAccess.Enabled );
      pageGroup.GroupType = Evado.UniForm.Model.GroupTypes.Default;
      pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Full_Width;
      pageGroup.AddParameter ( Evado.UniForm.Model.GroupParameterList.Offline_Hide_Group, true );

      //
      // if the entity is not selected display an entity selection field.
      //
      if ( this.Session.Selected_EntityLayoutId == String.Empty )
      {
        // 
        // Add the record state selection option
        //
        optionList = new List<EvOption> ( );
        optionList.Add ( new EvOption ( ) );
        foreach ( EdRecord layout in this.AdapterObjects.IssuedEntityLayouts )
        {
          optionList.Add ( layout.SelectionOption );
        }

        groupField = pageGroup.createSelectionListField (
          EdRecord.FieldNames.Layout_Id,
          EdLabels.Label_Form_Id,
          this.Session.Selected_EntityLayoutId,
          optionList );

        groupField.Layout = EuAdapter.DefaultFieldLayout;
        groupField.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 );

        // 
        // Add the selection groupCommand
        // 
       selectionCommand = pageGroup.addCommand (
          EdLabels.Entities_Selection_Command_Title,
          EuAdapter.ADAPTER_ID,
          EuAdapterClasses.Entities.ToString ( ),
          Evado.UniForm.Model.ApplicationMethods.Custom_Method );

        selectionCommand.setCustomMethod ( Evado.UniForm.Model.ApplicationMethods.List_of_Objects );

        selectionCommand.SetPageId ( Evado.Digital.Model.EdStaticPageIds.Entity_Filter_View );

        this.LogDebug ( "Group Command Count {0}. ", pageGroup.CommandList.Count );
        this.LogMethodEnd ( "getFilteredList_SelectionGroup" );
        return;

      }//END layoutId selection

      //
      // if the entity layout id has been defined display the entity selection fields.
      //
      //
      // retrieve the selected entity layout object
      //
      this.queryLayout = this.AdapterObjects.GetEntityLayout ( this.Session.Selected_EntityLayoutId );

      this.LogDebug ( "E: {0} S: {1}.", queryLayout.LayoutId, queryLayout.State );
      this.LogDebug ( "Entity {0}. ", queryLayout.CommandTitle );

      this.LogDebug ( "StaticQueryFilterOptions {0}. ", this.AdapterObjects.Settings.StaticQueryFilterOptions );

      //
      // Insert the static filter selection for organisation city.
      //
      if ( this.AdapterObjects.Settings.StaticQueryFilterOptions.Contains ( EdOrganisation.FieldNames.Address_Country.ToString ( ) ) == true )
      {
        this.getQueryList_StaticOrgFilter ( pageGroup, EdOrganisation.FieldNames.Address_Country );
      }
      if ( this.AdapterObjects.Settings.StaticQueryFilterOptions.Contains ( EdOrganisation.FieldNames.Address_City.ToString ( ) ) == true )
      {
        this.getQueryList_StaticOrgFilter ( pageGroup, EdOrganisation.FieldNames.Address_City );
      }
      if ( this.AdapterObjects.Settings.StaticQueryFilterOptions.Contains ( EdOrganisation.FieldNames.Address_Post_Code.ToString ( ) ) == true )
      {
        this.getQueryList_StaticOrgFilter ( pageGroup, EdOrganisation.FieldNames.Address_Post_Code );
      }

      //
      // iterate through the filter field ids and display the filter field in the selection group.
      //
      for ( int filterIndex = 0; filterIndex < queryLayout.FilterFieldIds.Length; filterIndex++ )
      {
        string fieldId = queryLayout.FilterFieldIds [ filterIndex ];

        if ( fieldId == String.Empty )
        {
          continue;
        }

        this.LogDebug ( "fieldId {0}. ", fieldId );
        //
        // retrieve the matching field object.
        //
        EdRecordField field = queryLayout.GetFieldObject ( fieldId );

        if ( field == null )
        {
          continue;
        }

        this.LogDebug ( "field.FieldId {0} - {1}. ", field.FieldId, field.Title );

        //
        // retrieve the current selection filter value.
        //
        string selectionFilter = this.Session.EntitySelectionFilters [ filterIndex ];
        this.LogDebug ( "selectionFilter {0}. ", selectionFilter );

        //
        // create the selection field object for the selected field.
        //
        this.getFilteredList_SelectionField (
          pageGroup,
          filterIndex,
          selectionFilter,
          field );
      }//END of the Selection filter iteration loop.

      // 
      // Add the selection groupCommand
      // 
      selectionCommand = pageGroup.addCommand (
        EdLabels.Entities_Selection_Command_Title,
        EuAdapter.ADAPTER_ID,
        EuAdapterClasses.Entities.ToString ( ),
        Evado.UniForm.Model.ApplicationMethods.Custom_Method );

      selectionCommand.setCustomMethod ( Evado.UniForm.Model.ApplicationMethods.List_of_Objects );

      selectionCommand.SetPageId ( Evado.Digital.Model.EdStaticPageIds.Entity_Filter_View );
      ;
      this.LogDebug ( "Group Command Count {0}. ", pageGroup.CommandList.Count );
      this.LogMethodEnd ( "getFilteredList_SelectionGroup" );

    }//ENd getFilteredList_SelectionGroup method
    }//END getEntity_Summary_ListGroup method

    // ==============================================================================
    /// <summary>
    /// This method appends the milestone groupCommand to the page milestone list pageMenuGroup
    /// </summary>
    /// <param name="Entity">EvForm object</param>
    /// <param name="PageGroup"> Evado.UniForm.Model.Group</param>
    //  -----------------------------------------------------------------------------
    private void getGroupSummaryListGroup (
      EdRecord Entity,
      Evado.UniForm.Model.Page PageObject )
    {
      this.LogMethod ( "getGroupSummaryListGroup" );
      this.LogDebug ( "Entity.EntityId: " + Entity.EntityId );
      this.LogDebug ( "LinkContentSetting: " + Entity.Design.LinkContentSetting );
      this.LogDebug ( "DefaultPageLayout: " + Entity.Design.DefaultPageLayout );
      // 
      // Initialise the methods variables and objects.
      // 
      Evado.UniForm.Model.Group pageGroup = new Evado.UniForm.Model.Group ( );
      Evado.UniForm.Model.Field groupField = new Evado.UniForm.Model.Field ( );
      Evado.UniForm.Model.Command groupCommand = new Evado.UniForm.Model.Command ( );


      // 
      // Create the record display pageMenuGroup.
      // 
      pageGroup = PageObject.AddGroup ( String.Empty );
      pageGroup.CmdLayout = Evado.UniForm.Model.GroupCommandListLayouts.Horizontal_Orientation;
      pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Dynamic;
      pageGroup.AddParameter ( Evado.UniForm.Model.GroupParameterList.Percent_Width, 25 );

      foreach ( EdRecordField field in Entity.Fields )
      {
        this.LogDebug ( "fid {0} - {1} V: {2}. ", field.FieldId, field.TypeId, field.ItemValue );

        if ( field.Design.IsSummaryField == false
          && field.TypeId != EvDataTypes.Image
          && field.TypeId != EvDataTypes.Text
          && field.TypeId != EvDataTypes.Numeric
          && field.TypeId != EvDataTypes.Telephone_Number
          && field.TypeId != EvDataTypes.Selection_List
          && field.TypeId != EvDataTypes.Radio_Button_List
          && field.TypeId != EvDataTypes.Check_Box_List
          && field.TypeId != EvDataTypes.External_Selection_List
          && field.TypeId != EvDataTypes.External_RadioButton_List
          && field.TypeId != EvDataTypes.External_CheckBox_List )
        {
          continue;
        }

        //
        // skip all empty items.
        //
        if ( field.ItemValue == String.Empty
          || field.ItemValue.Contains ( "E+37" ) == true
          || field.ItemValue.Contains ( "E-35" ) == true )
        {
          continue;
        }


        this.LogDebug ( "FieldId {0}, value {1} ", field.FieldId, field.ItemValue );

        //
        // Define the layout.
        //
        Evado.UniForm.Model.FieldLayoutCodes layout = Evado.UniForm.Model.FieldLayoutCodes.Left_Justified;

        switch ( field.TypeId )
        {
          case EvDataTypes.Image:
            {
              groupField = pageGroup.createImageField (
                String.Empty,
                field.Title,
                field.ItemValue, 125, 0 );
              groupField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled;
              groupField.Layout = layout;

              continue;
            }
          case EvDataTypes.Selection_List:
          case EvDataTypes.Check_Box_List:
          case EvDataTypes.Radio_Button_List:
          case EvDataTypes.Horizontal_Radio_Buttons:
          case EvDataTypes.External_Selection_List:
          case EvDataTypes.External_RadioButton_List:
          case EvDataTypes.External_CheckBox_List:
            {
              var value = this.getSelectionDescription ( field, field.ItemValue );

              groupField = pageGroup.createReadOnlyTextField (
                String.Empty,
                field.Title,
                value );
              groupField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled;
              groupField.Layout = layout;

              continue;
            }

          default:
            {


              groupField = pageGroup.createReadOnlyTextField (
                String.Empty,
                field.Title,
                field.ItemValue );
              groupField.EditAccess = Evado.UniForm.Model.EditAccess.Disabled;
              groupField.Layout = layout;
              continue;
            }
        }//END type switch statement.
      }//END field iteration loop

      //
      // Define the pageMenuGroup groupCommand.
      //
      groupCommand = pageGroup.addCommand (
          Entity.Title,
          EuAdapter.ADAPTER_ID,
          EuAdapterClasses.Entities,
          Evado.UniForm.Model.ApplicationMethods.Get_Object );

      groupCommand.Id = Entity.Guid;
      groupCommand.SetGuid ( Entity.Guid );

      //
      // Define the link groupCommand.
      //
      EdRecordField commandField = Entity.getFirstHttpLinkField ( );

      if ( commandField != null )
      {
        this.LogDebug ( "FieldId {0}, value {1} ", commandField.FieldId, commandField.ItemValue );

        if ( commandField.ItemValue != String.Empty )
        {
          string title = commandField.Title;
          string url = commandField.ItemValue;

          if ( url.Contains ( "^" ) == true )
          {
            string [ ] arValue = commandField.ItemValue.Split ( '^' );

            url = arValue [ 0 ];
            title = arValue [ 1 ];
          }

          groupCommand = pageGroup.addCommand (
              title,
              EuAdapter.ADAPTER_ID,
              EuAdapterClasses.Entities,
              Evado.UniForm.Model.ApplicationMethods.Get_Object );
          groupCommand.Type = Evado.UniForm.Model.CommandTypes.Http_Link;

          groupCommand.AddParameter ( Evado.UniForm.Model.CommandParameters.Link_Url, url );
        }
      }

      this.LogMethodEnd ( "getGroupSummaryListGroup" );

    }//END getGroupListCommand method
Exemplo n.º 18
0
        // =====================================================================================
        /// <summary>
        /// This class reads the content of the data reader object into ChecklistItem business object.
        /// </summary>
        /// <param name="Row">DataRow: an Sql DataReader object</param>
        /// <returns>EvFormField: a formfield object</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Extract the compatible row data to the formfield object.
        ///
        /// 2. Deserialize the xmlData to the formfield design object if it exists.
        ///
        /// 3. Deserialize the xmlvalidationRules to the formfield validationRules object if they exist.
        ///
        /// 4. Reset the horizontal radion button list enumertion
        ///
        /// 5. Ensure that the formfield state is not null.
        ///
        /// 6. if skip retrieving comments is selected, fill the comment list and format it
        ///
        /// 7. Get the table object and the external selection list object.
        ///
        /// 8. Process the NA values in selectionlists.
        ///
        /// 9. Update the current formfield state and type object.
        ///
        /// 10. Return the formfield object.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        private EdRecordField getRowData(
            DataRow Row)
        {
            this.LogMethod("getRowData method");
            //
            // Initialise method template table string, a return formfield object and an annotation string.
            //
            string        stTemplateTable = String.Empty;
            EdRecordField recordField     = new EdRecordField( );

            //
            // Fill the evForm object.l
            //
            recordField.Guid       = EvSqlMethods.getGuid(Row, EdRecordValues.DB_VALUES_GUID);
            recordField.RecordGuid = EvSqlMethods.getGuid(Row, EdRecords.DB_RECORD_GUID);
            recordField.LayoutGuid = EvSqlMethods.getGuid(Row, EdRecordLayouts.DB_LAYOUT_GUID);
            recordField.FieldGuid  = EvSqlMethods.getGuid(Row, EdRecordValues.DB_FIELD_GUID);


            recordField.FieldId = EvSqlMethods.getString(Row, EdRecordFields.DB_FIELD_ID);
            String value = EvSqlMethods.getString(Row, EdRecordFields.DB_TYPE_ID);

            recordField.Design.TypeId = Evado.Model.EvStatics.parseEnumValue <Evado.Model.EvDataTypes> (value);

            recordField.Design.Title                   = EvSqlMethods.getString(Row, EdRecordFields.DB_TITLE);
            recordField.Design.Instructions            = EvSqlMethods.getString(Row, EdRecordFields.DB_INSTRUCTIONS);
            recordField.Design.HttpReference           = EvSqlMethods.getString(Row, EdRecordFields.DB_HTTP_REFERENCE);
            recordField.Design.SectionNo               = EvSqlMethods.getInteger(Row, EdRecordFields.DB_SECTION_ID);
            recordField.Design.Options                 = EvSqlMethods.getString(Row, EdRecordFields.DB_OPTIONS);
            recordField.Design.IsSummaryField          = EvSqlMethods.getBool(Row, EdRecordFields.DB_SUMMARY_FIELD);
            recordField.Design.Mandatory               = EvSqlMethods.getBool(Row, EdRecordFields.DB_MANDATORY);
            recordField.Design.AiDataPoint             = EvSqlMethods.getBool(Row, EdRecordFields.DB_AI_DATA_POINT);
            recordField.Design.HideField               = EvSqlMethods.getBool(Row, EdRecordFields.DB_HIDDEN);
            recordField.Design.ExSelectionListId       = EvSqlMethods.getString(Row, EdRecordFields.DB_EX_SELECTION_LIST_ID);
            recordField.Design.ExSelectionListCategory = EvSqlMethods.getString(Row, EdRecordFields.DB_EX_SELECTION_LIST_CATEGORY);
            recordField.Design.DefaultValue            = EvSqlMethods.getString(Row, EdRecordFields.DB_DEFAULT_VALUE);
            recordField.Design.Unit        = EvSqlMethods.getString(Row, EdRecordFields.DB_UNIT);
            recordField.Design.UnitScaling = EvSqlMethods.getString(Row, EdRecordFields.DB_UNIT_SCALING);

            recordField.Design.ValidationLowerLimit  = EvSqlMethods.getFloat(Row, EdRecordFields.DB_VALIDATION_LOWER_LIMIT);
            recordField.Design.ValidationUpperLimit  = EvSqlMethods.getFloat(Row, EdRecordFields.DB_VALIDATION_UPPER_LIMIT);
            recordField.Design.AlertLowerLimit       = EvSqlMethods.getFloat(Row, EdRecordFields.DB_ALERT_LOWER_LIMIT);
            recordField.Design.AlertUpperLimit       = EvSqlMethods.getFloat(Row, EdRecordFields.DB_ALERT_UPPER_LIMIT);
            recordField.Design.NormalRangeLowerLimit = EvSqlMethods.getFloat(Row, EdRecordFields.DB_NORMAL_LOWER_LIMITD);
            recordField.Design.NormalRangeUpperLimit = EvSqlMethods.getFloat(Row, EdRecordFields.DB_NORMAL_UPPER_LIMIT);

            recordField.Design.FieldCategory        = EvSqlMethods.getString(Row, EdRecordFields.DB_FIELD_CATEGORY);
            recordField.Design.AnalogueLegendStart  = EvSqlMethods.getString(Row, EdRecordFields.DB_ANALOGUE_LEGEND_START);
            recordField.Design.AnalogueLegendFinish = EvSqlMethods.getString(Row, EdRecordFields.DB_ANALOGUE_LEGEND_FINISH);
            recordField.Design.JavaScript           = EvSqlMethods.getString(Row, EdRecordFields.DB_JAVA_SCRIPT);
            recordField.Design.InitialOptionList    = EvSqlMethods.getString(Row, EdRecordFields.DB_INITIAL_OPTION_LIST);
            recordField.Design.InitialVersion       = EvSqlMethods.getInteger(Row, EdRecordFields.DB_INITIAL_VERSION);
            //
            // if the field is a signature then decrypt the field.
            //
            if (recordField.TypeId == EvDataTypes.Signature)
            {
                this.LogDebug("Encrypted Signature string");
                EvEncrypt encrypt = new EvEncrypt(this.ClassParameters.AdapterGuid, recordField.Guid);
                encrypt.ClassParameters = this.ClassParameters;

                value = encrypt.decryptString(recordField.ItemText);
                this.LogDebug("clear string: " + value);
                recordField.ItemText = value;

                this.LogClass(encrypt.Log);
            }

            //
            // Get the table or matric object.
            //
            this.processTableRowObject(Row, recordField);

            //
            // Return the formfield object.
            //
            this.LogMethodEnd("getRowData");
            return(recordField);
        }//END getRowData method.
    // ==============================================================================
    /// <summary>
    /// This method creates an entity filter selection field object.
    /// </summary>
    /// <param name="PageGroup">Evado.Model.Uniform.Group object to add the pageGroup .</param>
    /// <param name="FilterIndex">Integer: filter index</param>
    /// <param name="SelectionFilter">String: filter value </param>
    /// <param name="Field">EdRecordField object.</param>
    //  ------------------------------------------------------------------------------
    private void getFilteredList_SelectionField (
      Evado.UniForm.Model.Group PageGroup,
      int FilterIndex,
      String SelectionFilter,
      EdRecordField Field )
    {
      this.LogMethod ( "getFilteredList_SelectionField" );

      this.LogDebug ( "FilterIndex: {0}, SelectionFilter: {1}. ", FilterIndex, SelectionFilter );
      //this.LogDebug ( "F: {0}, T: {1}, Type {2}. ", Field.FieldId, Field.Title, Field.TypeId );

      List<EvOption> optionList = Evado.UniForm.Model.EuStatics.getStringAsOptionList (
        Field.Design.Options );

      optionList.Sort ( ( n1, n2 ) => n1.Description.CompareTo ( n2.Description ) );

      List<EvOption> selectionOptionList = new List<EvOption> ( );
      selectionOptionList.Add ( new EvOption ( ) );
      foreach ( EvOption opt in optionList )
      {
        selectionOptionList.Add ( opt );
      }

      //
      // user the switch to select the selection data types.
      //
      switch ( Field.TypeId )
      {
        case EvDataTypes.Check_Box_List:
          {
            var field = PageGroup.createCheckBoxListField (
              EuEntities.CONST_SELECTION_FIELD + FilterIndex,
              Field.Title,
              SelectionFilter,
              optionList );
            field.Layout = EuAdapter.DefaultFieldLayout;
            field.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 );

            break;
          }
        case EvDataTypes.Yes_No:
        case EvDataTypes.Boolean:
          {
            var field = PageGroup.createBooleanField (
              EuEntities.CONST_SELECTION_FIELD + FilterIndex,
              Field.Title,
              EvStatics.getBool ( SelectionFilter ) );
            field.Layout = EuAdapter.DefaultFieldLayout;
            field.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 );

            break;
          }
        case EvDataTypes.Selection_List:
        case EvDataTypes.Radio_Button_List:
          {
            var field = PageGroup.createSelectionListField (
              EuEntities.CONST_SELECTION_FIELD + FilterIndex,
              Field.Title,
              SelectionFilter,
              selectionOptionList );
            field.Layout = EuAdapter.DefaultFieldLayout;
            field.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 );

            break;
          }
        case EvDataTypes.External_Selection_List:
        case EvDataTypes.External_RadioButton_List:
          {
            this.LogDebug ( "External_Selection_List filter" );
            selectionOptionList = this.getFilteredList_SelectionOptions ( Field, true );

            if ( selectionOptionList.Count <= 1 )
            {
              this.LogDebug ( "No Selection list options" );
              break;
            }

            var field = PageGroup.createSelectionListField (
              EuEntities.CONST_SELECTION_FIELD + FilterIndex,
              Field.Title,
              SelectionFilter,
              selectionOptionList );
            field.Layout = EuAdapter.DefaultFieldLayout;
            field.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 );
            break;
          }
        case EvDataTypes.External_CheckBox_List:
          {
            this.LogDebug ( "External_CheckBox_List filter" );
            selectionOptionList = this.getFilteredList_SelectionOptions ( Field, false );

            if ( selectionOptionList.Count == 0 )
            {
              this.LogDebug ( "No CheckBox list options" );
              break;
            }


            var field = PageGroup.createCheckBoxListField (
              EuEntities.CONST_SELECTION_FIELD + FilterIndex,
              Field.Title,
              SelectionFilter,
              selectionOptionList );
            field.Layout = EuAdapter.DefaultFieldLayout;
            field.AddParameter ( Evado.UniForm.Model.FieldParameterList.Snd_Cmd_On_Change, 1 );

            break;
          }
      }//END switch statment

      this.LogMethodEnd ( "getFilteredList_SelectionField" );
    }//END getFilteredList_SelectionField Query
Exemplo n.º 20
0
        }//END processNotAvailableValues method

        #endregion

        #region Record field list Queries

        // =====================================================================================
        /// <summary>
        /// This class returns a list of formfield object retrieved by the record Guid.
        /// </summary>
        /// <param name="Record">EvForm: (Mandatory) The record object.</param>
        /// <param name="IncludeComments">bool: true = include field comments.</param>
        /// <returns>List of EvFormField: a formfield object.</returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Return an empty formfield object if the record's Guid is empty
        ///
        /// 2. Define the sql query parameters and sql query string
        ///
        /// 3. Execute the sql query string with parameters and store the results on data table.
        ///
        /// 4. Iterate through the table and extract the data row to the formfield object.
        ///
        /// 5. Add object result to the formfields list.
        ///
        /// 6. Return the formfields list.
        /// </remarks>
        // -------------------------------------------------------------------------------------
        public List <EdRecordField> getRecordFieldList(
            EdRecord Record)
        {
            this.LogMethod("getRecordFieldList method. ");
            this.LogDebug("Record.Guid: " + Record.Guid);
            //
            // Initialise the methods variables and objects.
            //
            List <EdRecordField> recordFieldList = new List <EdRecordField> ( );
            EdRecordField        recordField     = new EdRecordField( );
            Guid previousValueGuid = Guid.Empty;

            //
            // Validate whether the record Guid is not empty.
            //
            if (Record.Guid == Guid.Empty)
            {
                return(recordFieldList);
            }

            //
            // Define the SQL query parameters.
            //
            SqlParameter [] cmdParms = new SqlParameter []
            {
                new SqlParameter(PARM_RECORD_GUID, SqlDbType.UniqueIdentifier),
            };
            cmdParms [0].Value = Record.Guid;

            //
            // Define the query string.
            //
            _Sql_QueryString = SQL_QUERY_VALUES_VIEW + " WHERE ( " + EdRecordValues.DB_RECORD_GUID + " =" + EdRecordValues.PARM_RECORD_GUID + ") "
                               + "ORDER BY " + EdRecordFields.DB_ORDER + "; ";

            this.LogDebug(_Sql_QueryString);

            //
            // Execute the query against the database.
            //
            using (DataTable table = EvSqlMethods.RunQuery(_Sql_QueryString, cmdParms))
            {
                if (table.Rows.Count == 0)
                {
                    return(recordFieldList);
                }

                //
                // Iterate through the results extracting the role information.
                //
                for (int count = 0; count < table.Rows.Count; count++)
                {
                    //
                    // Extract the table row
                    //
                    DataRow row = table.Rows [count];

                    Guid recordValueGuid = EvSqlMethods.getGuid(row, EdRecordValues.DB_VALUES_GUID);

                    this.LogDebug("previousValueGuid: {0}, recordValueGuid: {1}.", previousValueGuid, recordValueGuid);

                    //
                    // Empty fields are skipped.
                    //
                    if (recordValueGuid == Guid.Empty)
                    {
                        this.LogDebug("Skip the value Guid is empty.");
                        continue;
                    }

                    // If the field guid has changed then it is a new field.
                    // So add the previous field then get the data for the new field.
                    //
                    if (previousValueGuid != recordValueGuid)
                    {
                        this.LogDebug("Change of recordValueGuid.");
                        //
                        // Add the last field to the list.
                        //
                        if (recordField.Guid != Guid.Empty)
                        {
                            this.LogDebug("Add field to record field list.");
                            recordFieldList.Add(recordField);
                        }

                        //
                        // Get the object data from the row.
                        //
                        recordField = this.getRowData(row);

                        //
                        // skip all non summary field if summary fields is selected.
                        //
                        if (Record.Design.LinkContentSetting != EdRecord.LinkContentSetting.First_Text_Field &&
                            Record.SelectOnlySummaryFields == true &&
                            recordField.Design.IsSummaryField == false)
                        {
                            this.LogDebug("{0} is a summary field so SKIPPED.", recordField.FieldId);
                            continue;
                        }

                        //
                        // skip all non summary field if summary fields is selected.
                        //
                        if (Record.Design.LinkContentSetting != EdRecord.LinkContentSetting.First_Text_Field &&
                            count > 1)
                        {
                            this.LogDebug("{0} first field retrieved so SKIPPED.", recordField.FieldId);
                            continue;
                        }

                        //
                        // Update the lst field guid to enable the other field values to be collected.
                        //
                        previousValueGuid = recordField.Guid;
                    }//END create new field object.

                    this.LogDebug("Read in value data.");

                    switch (recordField.TypeId)
                    {
                    case Evado.Model.EvDataTypes.Special_Matrix:
                    case Evado.Model.EvDataTypes.Table:
                    {
                        this.getTableCellValue(row, recordField);
                        break;
                    }

                    case Evado.Model.EvDataTypes.Check_Box_List:
                    {
                        this.getCheckBoxValue(row, recordField);
                        break;
                    }

                    case Evado.Model.EvDataTypes.Numeric:
                    {
                        recordField.ItemValue = EvSqlMethods.getString(row, EdRecordValues.DB_VALUES_NUMERIC);
                        this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemValue);
                        break;
                    }

                    case Evado.Model.EvDataTypes.Boolean:
                    case Evado.Model.EvDataTypes.Yes_No:
                    {
                        bool bValue = EvSqlMethods.getBool(row, EdRecordValues.DB_VALUES_NUMERIC);
                        this.LogDebug("bValue: {0}.", bValue);
                        recordField.ItemValue = "No";
                        if (bValue == true)
                        {
                            recordField.ItemValue = "Yes";
                        }

                        this.LogDebug("recordField.ItemValue: {0} bool.", recordField.ItemValue);
                        break;
                    }

                    case Evado.Model.EvDataTypes.Date:
                    {
                        var dtValue = EvSqlMethods.getDateTime(row, EdRecordValues.DB_VALUES_DATE);
                        recordField.ItemValue = EvStatics.getDateAsString(dtValue);
                        this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemValue);
                        break;
                    }

                    case Evado.Model.EvDataTypes.Free_Text:
                    {
                        recordField.ItemText = EvSqlMethods.getString(row, EdRecordValues.DB_VALUES_TEXT);
                        this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemText);
                        break;
                    }

                    default:
                    {
                        if (recordField.isReadOnly == true)
                        {
                            break;
                        }
                        recordField.ItemValue = EvSqlMethods.getString(row, EdRecordValues.DB_VALUES_STRING);
                        this.LogDebug("recordField.ItemValue: {0}.", recordField.ItemValue);
                        break;
                    }
                    }
                } //ENR record iteration loop.
            }     //ENd using statement

            //
            // Add the last field to the list.
            //
            if (recordField.Guid != Guid.Empty)
            {
                recordFieldList.Add(recordField);
            }

            //
            // Return the formfields list.
            //
            return(recordFieldList);
        }//END getRecordFieldList method.
Exemplo n.º 21
0
        }//END updateField method

        // =====================================================================================
        /// <summary>
        /// This class update fields on formfield table using formfield object.
        /// </summary>
        /// <param name="SqlUpdateStatement">StringBuilder: containing the SQL update statemenet</param>
        /// <param name="ParmList">list of SqlParameter objects</param>
        /// <param name="RecordField">EvFormField: a formfield data object</param>
        /// <param name="ColumnId">String: column identifier</param>
        /// <param name="Row">Row: row index</param>
        // -------------------------------------------------------------------------------------
        private void updateSingleValueField(
            StringBuilder SqlUpdateStatement,
            List <SqlParameter> ParmList,
            EdRecordField RecordField,
            String ColumnId,
            int Row)
        {
            this.LogMethod("updateField method. ");
            this.LogDebug("ValueCount: " + _ValueCount);

            //
            // Define the record field Guid
            //
            SqlParameter prm = new SqlParameter(EdRecordValues.PARM_FIELD_GUID + "_" + this._ValueCount, SqlDbType.UniqueIdentifier);

            prm.Value = RecordField.FieldGuid;
            ParmList.Add(prm);

            //
            // Define the record field Guid
            //
            prm       = new SqlParameter(EdRecordValues.PARM_VALUE_GUID + "_" + this._ValueCount, SqlDbType.UniqueIdentifier);
            prm.Value = RecordField.Guid;
            ParmList.Add(prm);
            //
            // Define the record column identifier
            //
            prm       = new SqlParameter(EdRecordValues.PARM_VALUE_COLUMN_ID + "_" + this._ValueCount, SqlDbType.NVarChar, 10);
            prm.Value = ColumnId;
            ParmList.Add(prm);

            //
            // Define the record field Guid
            //
            prm       = new SqlParameter(EdRecordValues.PARM_VALUE_ROW + "_" + this._ValueCount, SqlDbType.SmallInt);
            prm.Value = Row;
            ParmList.Add(prm);


            switch (RecordField.TypeId)
            {
            case EvDataTypes.Yes_No:
            case EvDataTypes.Boolean:
            {
                string value  = "0";
                bool   bValue = EvStatics.getBool(RecordField.ItemValue);
                if (bValue == true)
                {
                    value = "1";
                }

                prm       = new SqlParameter(EdRecordValues.PARM_VALUE_NUMERIC + "_" + this._ValueCount, SqlDbType.Float);
                prm.Value = value;
                ParmList.Add(prm);
                //
                // Create the add query .
                //
                SqlUpdateStatement.AppendLine(" INSERT INTO ED_RECORD_VALUES  "
                                              + "(" + EdRecordValues.DB_RECORD_GUID
                                              + ", " + EdRecordValues.DB_FIELD_GUID
                                              + ", " + EdRecordValues.DB_VALUES_GUID
                                              + ", " + EdRecordValues.DB_VALUES_COLUMN_ID
                                              + ", " + EdRecordValues.DB_VALUES_ROW
                                              + ", " + EdRecordValues.DB_VALUES_NUMERIC
                                              + "  ) ");
                SqlUpdateStatement.AppendLine("VALUES (");
                SqlUpdateStatement.AppendLine(
                    " " + EdRecordValues.PARM_RECORD_GUID
                    + ", " + EdRecordValues.PARM_FIELD_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_COLUMN_ID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_ROW + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_NUMERIC + "_" + +this._ValueCount + " );\r\n");
                break;
            }

            case EvDataTypes.Numeric:
            {
                prm       = new SqlParameter(EdRecordValues.PARM_VALUE_NUMERIC + "_" + this._ValueCount, SqlDbType.Float);
                prm.Value = RecordField.ItemValue;
                ParmList.Add(prm);
                //
                // Create the add query .
                //
                SqlUpdateStatement.AppendLine(" INSERT INTO ED_RECORD_VALUES  "
                                              + "(" + EdRecordValues.DB_RECORD_GUID
                                              + ", " + EdRecordValues.DB_FIELD_GUID
                                              + ", " + EdRecordValues.DB_VALUES_GUID
                                              + ", " + EdRecordValues.DB_VALUES_COLUMN_ID
                                              + ", " + EdRecordValues.DB_VALUES_ROW
                                              + ", " + EdRecordValues.DB_VALUES_NUMERIC
                                              + "  ) ");
                SqlUpdateStatement.AppendLine("VALUES (");
                SqlUpdateStatement.AppendLine(
                    " " + EdRecordValues.PARM_RECORD_GUID
                    + ", " + EdRecordValues.PARM_FIELD_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_COLUMN_ID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_ROW + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_NUMERIC + "_" + +this._ValueCount + " );\r\n");
                break;
            }

            case EvDataTypes.Date:
            {
                if (RecordField.ItemValue == String.Empty)
                {
                    RecordField.ItemValue = EvStatics.CONST_DATE_NULL.ToString("dd-MMM-yyyy");
                }

                prm       = new SqlParameter(EdRecordValues.PARM_VALUE_DATE + "_" + this._ValueCount, SqlDbType.DateTime);
                prm.Value = RecordField.ItemValue;
                ParmList.Add(prm);
                //
                // Create the add query .
                //
                SqlUpdateStatement.AppendLine(" INSERT INTO ED_RECORD_VALUES  "
                                              + "(" + EdRecordValues.DB_RECORD_GUID
                                              + ", " + EdRecordValues.DB_FIELD_GUID
                                              + ", " + EdRecordValues.DB_VALUES_GUID
                                              + ", " + EdRecordValues.DB_VALUES_COLUMN_ID
                                              + ", " + EdRecordValues.DB_VALUES_ROW
                                              + ", " + EdRecordValues.DB_VALUES_DATE
                                              + "  ) ");
                SqlUpdateStatement.AppendLine("VALUES (");
                SqlUpdateStatement.AppendLine(
                    " " + EdRecordValues.PARM_RECORD_GUID
                    + ", " + EdRecordValues.PARM_FIELD_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_COLUMN_ID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_ROW + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_DATE + "_" + this._ValueCount + " );\r\n");

                break;
            }

            case EvDataTypes.Free_Text:
            {
                prm       = new SqlParameter(EdRecordValues.PARM_VALUE_TEXT + "_" + this._ValueCount, SqlDbType.NText);
                prm.Value = RecordField.ItemText;
                ParmList.Add(prm);
                //
                // Create the add query .
                //
                SqlUpdateStatement.AppendLine(" INSERT INTO ED_RECORD_VALUES  "
                                              + "(" + EdRecordValues.DB_RECORD_GUID
                                              + ", " + EdRecordValues.DB_FIELD_GUID
                                              + ", " + EdRecordValues.DB_VALUES_GUID
                                              + ", " + EdRecordValues.DB_VALUES_COLUMN_ID
                                              + ", " + EdRecordValues.DB_VALUES_ROW
                                              + ", " + EdRecordValues.DB_VALUES_TEXT
                                              + "  ) ");
                SqlUpdateStatement.AppendLine("VALUES (");
                SqlUpdateStatement.AppendLine(
                    " " + EdRecordValues.PARM_RECORD_GUID
                    + ", " + EdRecordValues.PARM_FIELD_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_COLUMN_ID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_ROW + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_TEXT + "_" + this._ValueCount + " );\r\n");

                break;
            }

            default:
            {
                prm       = new SqlParameter(EdRecordValues.PARM_VALUE_STRING + "_" + this._ValueCount, SqlDbType.NVarChar, 100);
                prm.Value = RecordField.ItemValue;
                ParmList.Add(prm);
                //
                // Create the add query .
                //
                SqlUpdateStatement.AppendLine(" INSERT INTO ED_RECORD_VALUES  "
                                              + "(" + EdRecordValues.DB_RECORD_GUID
                                              + ", " + EdRecordValues.DB_FIELD_GUID
                                              + ", " + EdRecordValues.DB_VALUES_GUID
                                              + ", " + EdRecordValues.DB_VALUES_COLUMN_ID
                                              + ", " + EdRecordValues.DB_VALUES_ROW
                                              + ", " + EdRecordValues.DB_VALUES_STRING
                                              + "  ) ");
                SqlUpdateStatement.AppendLine("VALUES (");
                SqlUpdateStatement.AppendLine(
                    " " + EdRecordValues.PARM_RECORD_GUID
                    + ", " + EdRecordValues.PARM_FIELD_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_GUID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_COLUMN_ID + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_ROW + "_" + this._ValueCount
                    + ", " + EdRecordValues.PARM_VALUE_STRING + "_" + this._ValueCount + " );\r\n");
                break;
            }
            } //End switch statement
        }     //END method.