/// <summary> /// Creates an xml excel file with species observations data. /// </summary> /// <param name="speciesObservations">The species observations data.</param> /// <param name="useLabelAsColumnHeader">Use label as column header.</param> /// <returns>The xml Excel file.</returns> public static SpeciesObservationsCsv GetSpeciesObservationsAsCsv( List <Dictionary <ViewTableField, string> > speciesObservations, bool useLabelAsColumnHeader) { SpeciesObservationsCsv file = new SpeciesObservationsCsv( speciesObservations, useLabelAsColumnHeader); return(file); }
/// <summary> /// Method that generates an CSV file with species observations. /// </summary> /// <param name="presentationCoordinateSystem">Coordinate system to use.</param> /// <param name="columnsSet">Which columns set to use.</param> /// <param name="columnsHeadersType">Columns headers type to use.</param> /// <returns>A CSV file.</returns> public FileResult SpeciesObservationsAsCsv( int?presentationCoordinateSystem, int?columnsSet, int?columnsHeadersType) { if (NoFilterSelected) { throw new Exception("Too much data! You must set taxa filter or spatial filter."); } var coordinateSystemId = GetCoordinateSystemIdFromArgument( presentationCoordinateSystem, SessionHandler.MySettings.Presentation.Map.DownloadCoordinateSystemId); SpeciesObservationTableColumnsSetId speciesObservationTableColumnsSetId = GetSpeciesObservationTableColumnsSetIdFromArgument( columnsSet, SessionHandler.MySettings.Presentation.Table.SpeciesObservationTable.SpeciesObservationTableColumnsSetId); bool useLabelAsColumnHeader = GetUselabelAsColumnHeaderFromArgument( columnsHeadersType, SessionHandler.MySettings.Presentation.Table.SpeciesObservationTable.UseLabelAsColumnHeader); SpeciesObservationResultCalculator resultCalculator = new SpeciesObservationResultCalculator(GetCurrentUser(), SessionHandler.MySettings); List <Dictionary <ViewTableField, string> > result = resultCalculator.GetTableResult( coordinateSystemId, speciesObservationTableColumnsSetId); SpeciesObservationsCsv file = FileExportManager.GetSpeciesObservationsAsCsv( result, useLabelAsColumnHeader); MemoryStream returnStream = file.ToStream(); SetServerDone(); return(File( returnStream.ToArray(), "text/csv", FilenameGenerator.CreateFilename("SpeciesObservations", FileType.Csv))); }