}//END exportProjectRecords method

        //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        #endregion

        #region export methods

        // =====================================================================================
        /// <summary>
        /// This method creates the content for the common record export file as a CSV file.
        /// </summary>
        /// <param name="FormRecordList">List of EvForm: a list of form objects</param>
        /// <param name="UserProfile">Evado.Digital.Model.EdUserProfile: The user profile.</param>
        /// <param name="IncludeFreeTextData">Boolean: True, if the free text fields are exported.</param>
        /// <param name="IncludeDraftRecords">Boolean: True, if the initialised records are included</param>
        /// <returns>String: an export file string. </returns>
        /// <remarks>
        /// This method consists of the following steps:
        ///
        /// 1. Exit, if the form objects list is empty.
        ///
        /// 2. Loop through the form list and the associated form field list.
        ///
        /// 3. Add the formfield list's values to the output string.
        ///
        /// 4. Return the output string.
        /// </remarks>
        //  ----------------------------------------------------------------------------------
        public String createExportFile(
            System.Collections.Generic.List <EdRecord> FormRecordList,
            Evado.Digital.Model.EdUserProfile UserProfile,
            bool IncludeFreeTextData,
            bool IncludeDraftRecords)
        {
            this.LogMethod("createExportFile method ");
            this.LogDebug("IncludeFreeTextData:" + IncludeFreeTextData);
            this.LogDebug("IncludeDraftRecords:" + IncludeDraftRecords);
            try
            {
                //
                // Initialise the methods variables and objects.
                //
                EdRecord headerForm = new EdRecord( );
                System.Text.StringBuilder stCsvData = new System.Text.StringBuilder( );

                //
                // Only process the common records if more than one exists.
                //
                if (FormRecordList.Count == 0)
                {
                    this.LogDebug("FormRecordList count is zero.");
                    this.EventCode = EvEventCodes.Data_Export_Empty_Record_List;

                    this.LogMethodEnd("createExportFile");
                    return(stCsvData.ToString( ));
                }

                //
                // Using the last record get a form header i.e. the latest version.
                //
                headerForm = FormRecordList [(FormRecordList.Count - 1)];

                //
                // Create the report header
                //
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Form Type: " + EvStatics.getEnumStringValue(headerForm.TypeId)));
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("FormId: " + headerForm.LayoutId));
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Form Title: " + headerForm.Title));
                stCsvData.AppendLine(Evado.Digital.Model.EvcStatics.encodeCsvFirstColumn("Exported on: " + DateTime.Now.ToString("dd MMM yyyy HH:mm")
                                                                                         + " By " + UserProfile.CommonName));

                this.LogDebug("Form Type: " + headerForm.Design.TypeId);
                this.LogDebug("FormId: " + headerForm.LayoutId);
                this.LogDebug("Form Title: " + headerForm.Title);
                this.LogDebug("Exported on: " + DateTime.Now.ToString("dd MMM yyyy HH:mm")
                              + " By " + UserProfile.CommonName);

                //
                // Ouput the ResultData header.
                //
                this._OutputDataColumnCount = this.createExportRecordHeader(headerForm, IncludeFreeTextData);

                //
                // Append the CSV data header row.
                //
                stCsvData.AppendLine(this.ConvertToCsv(this._ExportColumnHeader));


                this.LogDebug("Commence export record data.");
                //
                // Iterate through the datagrid processing each letter in the grid
                //
                foreach (EdRecord record in FormRecordList)
                {
                    this._ExportColumnRow = new string [this._OutputDataColumnCount];
                    //
                    // IF the item is a valid record output it.
                    //
                    if (record.State == EdRecordObjectStates.Withdrawn)
                    {
                        this.LogDebug("RecordID: " + record.RecordId + " >> Withdrawn or querid record.");
                        continue;
                    }

                    if (record.State == EdRecordObjectStates.Draft_Record &&
                        IncludeDraftRecords == false)
                    {
                        this.LogDebug("RecordID: " + record.RecordId + " >> Initialised record.");
                        continue;
                    }
                    this.LogDebug("RecordID: " + record.RecordId);
                    this.LogDebug("Field Count: " + record.Fields.Count);

                    //
                    // Output the record left hand static fields.
                    //
                    this._ExportColumnRow [0] = record.RecordId;
                    this._ExportColumnRow [1] = record.stRecordDate;

                    //
                    // Output the record fields
                    //
                    foreach (EdRecordField recordField in record.Fields)
                    {
                        this.LogDebug("FieldId: " + recordField.FieldId);
                        this.LogDebug("field Type: " + recordField.TypeId);
                        this.LogDebug("Field Guid: " + recordField.Guid);
                        this.LogDebug("ItemValue: " + recordField.ItemValue);
                        this.LogDebug("ItemText: " + recordField.ItemText);

                        if (recordField.isReadOnly == true)
                        {
                            continue;
                        }

                        //
                        // Export form field
                        //
                        if (recordField.Guid == Guid.Empty)
                        {
                            continue;
                        }

                        //
                        // select the field type to export.
                        //
                        switch (recordField.TypeId)
                        {
                        case EvDataTypes.Special_Matrix:
                        case EvDataTypes.Table:
                        {
                            this.ExportTableData(recordField);
                            break;
                        }

                        case EvDataTypes.Check_Box_List:
                        {
                            this.ExportCheckBoxData(recordField);
                            break;
                        }

                        default:
                        {
                            this.getExportRecordFieldData(
                                recordField,
                                IncludeFreeTextData);
                            break;
                        }
                        } //END switch statement
                    }     //END field iteration loop.


                    this.LogDebug("Comment.Count: " + record.CommentList.Count);

                    String stComments = String.Empty;
                    foreach (EdFormRecordComment comment in record.CommentList)
                    {
                        stComments += comment.Content
                                      + " by "
                                      + comment.UserCommonName
                                      + " on "
                                      + comment.CommentDate.ToString("dd-MMM-yy HH:mm") + " ";
                    }

                    //
                    // record footer information
                    //
                    this.exportColumnValue(StaticHeaderColumns.Comments, stComments);

                    //
                    // Convert the output row into a CSV row.
                    //
                    stCsvData.AppendLine(this.ConvertToCsv(this._ExportColumnRow));
                }//END record list  iteration loop

                this.LogDebug("ExportFile length: " + stCsvData.Length);

                this.LogMethodEnd("createExportFile");

                //
                // Return the new record.
                //
                return(stCsvData.ToString( ));
            } //End Try
            catch (Exception Ex)
            {
                this.EventCode = EvEventCodes.Data_Export_Exception_Event;
                this.LogException(Ex);
            } // End catch.

            this.LogMethodEnd("createExportFile");
            return(String.Empty);
        }//END createExportFile class