public ActionResult DatabaseNew(string taxonId) { TaxonSearchResult searchResult = this.TaxonSearchManager.GetTaxon(taxonId); if (searchResult.NumberOfMatches != 1) { return(RedirectToSearch(taxonId)); } ITaxon taxon = searchResult.Taxon; this.TaxonIdentifier = TaxonIdTuple.Create(taxonId, searchResult.Taxon.Id); ViewBag.Taxon = taxon; var model = ExportDatabaseViewModel.Create(GetCurrentUser(), taxon); model.ClipBoard = this.TaxonIdentifier.Id.Value.ToString(); // RowDelimiter Dropbox var rowDelimiters = from MatchTaxonRowDelimiter rd in Enum.GetValues(typeof(MatchTaxonRowDelimiter)) select new { value = (int)rd, text = rd.GetLocalizedDescription() }; ViewData["RowDelimiter"] = new SelectList(rowDelimiters, "value", "text", model.RowDelimiter.ToString()); ModelState.Remove("TaxonId"); return(View(model)); }
protected void GenerateReport(ExportDatabaseViewModel model) { //Thread.Sleep(10000); //var fileDownloadName = "Dyntaxa database.xls"; //MemoryStream excelFileStream = model.CreateExcelFile(); //var fileStreamResult = new FileStreamResult(excelFileStream, "application/vnd.ms-excel"); //fileStreamResult.FileDownloadName = fileDownloadName; }
public ExportDatabaseView(ExportDatabaseViewModel viewModel) { InitializeComponent(); DataContext = ViewModel = viewModel; ViewModel.Close += (sender, eventArgs) => { DialogResult = eventArgs.IsAccepted; Close(); }; }
/// <summary> /// Exporta las tablas de una base de datos a un directorio /// </summary> private async Task ExportDataBaseAsync() { if (IsExecuting) { SolutionViewModel.MainController.SystemController.ShowMessage("No se pueden exportar los datos en este momento. Espere que finalice la ejecución de los scripts"); } else { ExportDatabaseViewModel viewModel = new ExportDatabaseViewModel(SolutionViewModel); if (SolutionViewModel.MainController.OpenDialog(viewModel) == BauMvvm.ViewModels.Controllers.SystemControllerEnums.ResultType.Yes) { // Exporta los datos using (BlockLogModel block = SolutionViewModel.MainController.Logger.Default .CreateBlock(LogModel.LogType.Info, $"Exportando archivos de {viewModel.ComboConnections.GetSelectedConnection().Name} {viewModel.DataBase}")) { // Arranca la ejecución StartExecution(); // Ejecuta la exportación try { Application.Controllers.Export.ExportDataBaseGenerator generator = new Application.Controllers.Export.ExportDataBaseGenerator(SolutionViewModel.Manager); if (await generator.ExportAsync(block, viewModel.ComboConnections.GetSelectedConnection(), viewModel.DataBase, viewModel.OutputPath, viewModel.FormatType, viewModel.BlockSize, CancellationToken.None)) { block.Info($"Fin de la exportación de la base de datos {viewModel.DataBase}"); SolutionViewModel.MainController.MainWindowController .ShowNotification(BauMvvm.ViewModels.Controllers.SystemControllerEnums.NotificationType.Information, "Explotación de archivos", "Ha terminado correctamente la exportación de archivos"); } else { block.Error($"Error en la exportación de datos. {generator.Errors.Concatenate()}"); } } catch (Exception exception) { block.Error("Exception when create files", exception); } // Detiene la ejecución StopExecuting(); } // Log SolutionViewModel.MainController.Logger.Flush(); } } }
public ActionResult DatabaseNew(ExportDatabaseViewModel model, string downloadTokenValue) { model.UserContext = GetCurrentUser(); if (ModelState.IsValid) { //model.CreateDataTables(); List <ITaxon> taxa = model.GetTaxa(); NewExportDataTableCollection result = ExportDatabaseViewModel.CreateDataTablesWithDyntaxaTree(GetCurrentUser(), taxa); List <DataTable> dataTables = new List <DataTable>(); dataTables.Add(result.TaxonDataTable); dataTables.Add(result.TaxonNameDataTable); dataTables.Add(result.ParentChildDataTable); dataTables.Add(result.SplitTaxonDataTable); dataTables.Add(result.LumpTaxonDataTable); dataTables.Add(result.TaxonReferencesDataTable); dataTables.Add(result.TaxonNameReferencesTable); dataTables.Add(result.TaxonCategoriesTable); dataTables.Add(result.TaxonNameCategoriesTable); dataTables.Add(result.TaxonNameStatusTable); dataTables.Add(result.TaxonNameUsageTable); dataTables.Add(result.ChangeStatusTable); dataTables.Add(result.AlertStatusTable); dataTables.Add(result.AllReferencesTable); ExcelFileFormat fileFormat = ExcelFileFormat.OpenXml; var excelFile = new ExportDatabaseExcelFile(); MemoryStream excelFileStream = excelFile.CreateExcelFile(dataTables, fileFormat, true); var fileStreamResult = new FileStreamResult(excelFileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); var fileDownloadName = "Dyntaxa database" + ExcelFileFormatHelper.GetExtension(fileFormat); fileStreamResult.FileDownloadName = fileDownloadName; Response.AppendCookie(new HttpCookie("fileDownloadToken", downloadTokenValue)); return(fileStreamResult); } // RowDelimiter Dropbox var rowDelimiters = from MatchTaxonRowDelimiter rd in Enum.GetValues(typeof(MatchTaxonRowDelimiter)) select new { value = (int)rd, text = rd.GetLocalizedDescription() }; ViewData["RowDelimiter"] = new SelectList(rowDelimiters, "value", "text", model.RowDelimiter.ToString()); return(View(model)); }
public ActionResult Database(ExportDatabaseViewModel model, string downloadTokenValue) { model.UserContext = GetCurrentUser(); if (ModelState.IsValid) { model.CreateDataTables(); int maxNumberOfRows = 0; foreach (System.Data.DataTable dataTable in model.DataTables) { if (dataTable != null && dataTable.Rows != null) { maxNumberOfRows = Math.Max(maxNumberOfRows, dataTable.Rows.Count); } } ExcelFileFormat fileFormat = ExcelFileFormat.OpenXml; MemoryStream excelFileStream = model.CreateExcelFile(fileFormat); var fileStreamResult = new FileStreamResult(excelFileStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); var fileDownloadName = "Dyntaxa database" + ExcelFileFormatHelper.GetExtension(fileFormat); fileStreamResult.FileDownloadName = fileDownloadName; Response.AppendCookie(new HttpCookie("fileDownloadToken", downloadTokenValue)); return(fileStreamResult); } //Task.Factory.StartNew(() => GenerateReport(model)); //model = ExportViewModel.Create(GetCurrentUser(), taxon, true); // RowDelimiter Dropbox var rowDelimiters = from MatchTaxonRowDelimiter rd in Enum.GetValues(typeof(MatchTaxonRowDelimiter)) select new { value = (int)rd, text = rd.GetLocalizedDescription() }; ViewData["RowDelimiter"] = new SelectList(rowDelimiters, "value", "text", model.RowDelimiter.ToString()); return(View(model)); }