// ===================================================================================== /// <summary> /// This class returns a list of formfield object based on form's Guid /// </summary> /// <param name="ExportParameters">EvExportParameters object, defining the items to exported.</param> /// <param name="UserProfile">EvUserProfile object.</param> /// <returns>List of string where each item is row in a CSv output</returns> /// <remarks> /// This method consists of the following steps: /// /// 1. Execute the method for retrieving the Formfield list based on form's Guid /// /// 2. Return the formfield list. /// </remarks> // ------------------------------------------------------------------------------------- public String exportRecords( EvExportParameters ExportParameters, Evado.Digital.Model.EdUserProfile UserProfile) { this.LogMethod("exportRecords method. "); this.LogDebug(ExportParameters.getRecordExportParameters( )); this.LogDebug("ExportDataSource: " + ExportParameters.ExportDataSource); // // Initialise the methods objects and variables. // List <EdRecord> recordList = new List <EdRecord> ( ); // // if the ResultData sourc is not project or common record exit. // switch (ExportParameters.ExportDataSource) { case EvExportParameters.ExportDataSources.Project_Record: { return(this.exportProjectRecords( ExportParameters, UserProfile)); } default: { return(null); } } }//End getRecordList method.
}//End getRecordList method. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #endregion #region export query record methods // ===================================================================================== /// <summary> /// this method exports the project records a list of csv string objects. /// </summary> /// <param name="ExportParameters">EvExportParameters object, defining the items to exported.</param> /// <param name="UserProfile">EvUserProfile object.</param> /// <returns>List of string where each item is row in a CSv output</returns> // ------------------------------------------------------------------------------------- private String exportProjectRecords( EvExportParameters ExportParameters, Evado.Digital.Model.EdUserProfile UserProfile) { this.LogMethod("exportProjectRecords method. "); // // Initialise the methods objects and variables. // List <EdRecord> recordList = new List <EdRecord> ( ); EdRecords formRecords = new EdRecords(this.ClassParameters); EdQueryParameters queryParameters = new EdQueryParameters( ); // // Set the start and end date filters. // queryParameters.States.Add(EdRecordObjectStates.Withdrawn); queryParameters.States.Add(EdRecordObjectStates.Draft_Record); if (ExportParameters.IncludeDraftRecords == true) { queryParameters.States.Add(EdRecordObjectStates.Withdrawn); } queryParameters.NotSelectedState = true; queryParameters.IncludeRecordValues = true; queryParameters.IncludeSummary = false; queryParameters.LayoutId = ExportParameters.LayoutId; recordList = formRecords.getRecordList(queryParameters); this.LogClass(formRecords.Log); string result = this.createExportFile( recordList, UserProfile, ExportParameters.IncludeFreeTextData, ExportParameters.IncludeDraftRecords); this.LogMethodEnd("exportProjectRecords"); return(result); }//END exportProjectRecords method
}//END getRecordExport_DownloadGroup method //=================================================================================== /// <summary> /// Thie method exports the record list to a export form. /// </summary> /// <param name="pageGroup">Evado.UniForm.Model.Group object</param> /// <param name="iteration">int: iteration loop</param> /// <param name="exportParameters">EvExportParameters object.</param> /// <param name="FormId">String form identifier</param> /// <returns>True export generated.</returns> //----------------------------------------------------------------------------------- private EvEventCodes exportRecordData ( Evado.UniForm.Model.Group pageGroup, int iteration, EvExportParameters exportParameters, String FormId ) { this.LogMethod ( "exportRecordData" ); // // Initialise the methods variables and objects. // String csvDownload = String.Empty; String csvFileName = String.Empty; EvFormRecordExport exportRecords = new EvFormRecordExport ( this.ClassParameters ); // // Generate the export download CSV ResultData file. // csvDownload = exportRecords.exportRecords ( exportParameters, this.Session.UserProfile ); if ( exportRecords.EventCode != EvEventCodes.Ok ) { this.LogDebug ( "EventCode: " + exportRecords.EventCode ); if ( exportRecords.EventCode == EvEventCodes.Data_Export_Empty_Record_List ) { this.ErrorMessage = EdLabels.Form_Record_Export_Empty_List_Error_Message; } this.LogMethodEnd ( "exportRecordData" ); return exportRecords.EventCode; } this.LogClass ( exportRecords.Log ); // // Create the export file name. // csvFileName = FormId + "-Records-" + DateTime.Now.ToString ( "yy-MM-dd" ) + ".csv"; if ( iteration > 0 ) { csvFileName = FormId + "-Records-" + iteration + "-" + DateTime.Now.ToString ( "yy-MM-dd" ) + ".csv"; } this.LogValue ( "csvDownload length: " + csvDownload.Length ); this.LogValue ( "csvFileName: " + csvFileName ); bool result = Evado.Digital.Model.EvcStatics.Files.saveFile ( this.UniForm_BinaryFilePath, csvFileName, csvDownload ); if ( result == false ) { this.ErrorMessage = EdLabels.Record_Export_Error_Message; this.LogDebugClass ( Evado.Digital.Model.EvcStatics.Files.DebugLog ); this.LogDebug ( "ReturnedEventCode: " + Evado.Digital.Model.EvcStatics.Files.ReturnedEventCode ); this.LogDebug ( this.ErrorMessage ); this.LogMethodEnd ( "exportRecordData" ); return Evado.Digital.Model.EvcStatics.Files.ReturnedEventCode; } Evado.UniForm.Model.Field groupField = pageGroup.createHtmlLinkField ( String.Empty, csvFileName, this.UniForm_BinaryServiceUrl + csvFileName ); this.LogMethodEnd ( "exportRecordData" ); return EvEventCodes.Ok; }//END exportRecordData method.
}//END getRecordExport_ListObject method // ============================================================================== /// <summary> /// This method creates the record view pageMenuGroup containing a list of commands to /// open the form record. /// </summary> /// <param name="Page">Evado.Model.Uniform.Page object to add the pageMenuGroup to.</param> // ------------------------------------------------------------------------------ private void getRecordExport_DownloadGroup ( Evado.UniForm.Model.Page Page ) { this.LogMethod ( "getRecordExport_DownloadGroup" ); this.LogDebug ( "FormRecords_IncludeFreeTextData: " + this.Session.FormRecords_IncludeFreeTextData ); this.LogDebug ( "FormRecords_IncludeDraftRecords: " + this.Session.FormRecords_IncludeDraftRecords ); // // 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 ( ); EvFormRecordExport exportRecords = new EvFormRecordExport ( ); EvExportParameters exportParameters = new EvExportParameters ( ); EdQueryParameters queryParameters = new EdQueryParameters ( ); int exportRecordFileLimit = 250; this.LogDebug ( "exportRecordFileLimit: " + exportRecordFileLimit ); // // IF there are not parameters then exit. // if ( this.Session.Selected_EntityLayoutId == String.Empty ) { this.LogDebug ( " Form {0}. ", this.Session.Selected_EntityLayoutId ); this.LogMethodEnd ( "getRecordExport_DownloadGroup" ); return; } exportParameters = new EvExportParameters ( EvExportParameters.ExportDataSources.Project_Record, this.Session.Selected_EntityLayoutId ); exportParameters.IncludeTestSites = false; exportParameters.IncludeFreeTextData = this.Session.FormRecords_IncludeFreeTextData; exportParameters.IncludeDraftRecords = this.Session.FormRecords_IncludeDraftRecords; queryParameters = new EdQueryParameters ( ); queryParameters.LayoutId = this.Session.Selected_EntityLayoutId; queryParameters.States.Add ( EdRecordObjectStates.Withdrawn ); queryParameters.States.Add ( EdRecordObjectStates.Draft_Record ); queryParameters.States.Add ( EdRecordObjectStates.Empty_Record ); queryParameters.States.Add ( EdRecordObjectStates.Completed_Record ); if ( exportParameters.IncludeDraftRecords == true ) { queryParameters.States.Add ( EdRecordObjectStates.Withdrawn ); } queryParameters.NotSelectedState = true; queryParameters.IncludeSummary = true; queryParameters.IncludeRecordValues = false; queryParameters.IncludeComments = false; // // Create the export ResultData file. // int inResultCount = this._Bll_Entities.geyEntityCount ( queryParameters ); this.LogClass ( this._Bll_Entities.Log ); this.LogDebug ( "inResultCount: " + inResultCount ); // // Create the record display pageMenuGroup. // pageGroup = Page.AddGroup ( EdLabels.Record_Export_Download_Group_Title, Evado.UniForm.Model.EditAccess.Enabled ); pageGroup.CmdLayout = Evado.UniForm.Model.GroupCommandListLayouts.Vertical_Orientation; pageGroup.Layout = Evado.UniForm.Model.GroupLayouts.Full_Width; if ( inResultCount == 0 ) { LogDebug ( "Record Count is 0." ); pageGroup.Description = EdLabels.Form_Record_Export_Empty_List_Error_Message; this.LogMethodEnd ( "getRecordExport_DownloadGroup" ); return; } // // If the record list is less thant the exportrecord limit output. // if ( inResultCount <= exportRecordFileLimit ) { // // export the ResultData. // this.exportRecordData ( pageGroup, 0, exportParameters, this.Session.Selected_EntityLayoutId ); } else { // // Initialise the output loop parameters. int iRecordRangeStart = 0; int iRecordRangeFinish = exportRecordFileLimit; int iterations = ( inResultCount / exportRecordFileLimit ) + 1; this.LogValue ( "iterations: " + iterations ); for ( int iLoop = 0; iLoop < iterations && iRecordRangeFinish <= inResultCount; iLoop++ ) { // // export the ResultData. // var result = this.exportRecordData ( pageGroup, iLoop, exportParameters, this.Session.Selected_EntityLayoutId ); if ( result != EvEventCodes.Ok ) { this.LogDebug ( "Result {0}.", result ); this.LogMethodEnd ( "getRecordExport_DownloadGroup" ); return; } // // Increment the start and finish for then next loop // iRecordRangeStart = iRecordRangeFinish + 1; if ( ( iRecordRangeFinish + exportRecordFileLimit ) < inResultCount ) { iRecordRangeFinish += exportRecordFileLimit; } else { iRecordRangeFinish = inResultCount; } }//END loop iteration statement. } this.LogMethodEnd ( "getRecordExport_DownloadGroup" ); return; }//END getRecordExport_DownloadGroup method