public string Exportar() { var ciudad = ComboCiudad.ComboBox.SelectedItem as Ciudad; if (ciudad == null) { return "No hay ciudad"; } var ficha = datosProceso.Fichas.FirstOrDefault(x => x.Nombre == "EDIFICACIONES"); if (ficha == null) return "La ficha edificaciones no existe"; LogMessage("EXPORTACION: Ciudad" + ciudad.Nombre + " Ficha:" + ficha.Nombre); Task.Factory.StartNew(() => { LogMessage("Cargando Datos"); var filename = string.Format("{0}_{1}.xlsx", ciudad.Nombre, ficha.Nombre); var path = Path.Combine(config.CarpetaSalida, filename); if (File.Exists(path)) File.Delete(path); var datos = new Dictionary<string, IList<Resultado>>(); datos["predios"] = RepoGeneral.Resultados(new ResultadoForm { Ciudad = ciudad.Nombre, Tipo = "predio" }); datos["manzanas"] = RepoGeneral.Resultados(new ResultadoForm { Ciudad = ciudad.Nombre, Tipo = "manzana" }); var exporter = new ExportadorExcel(); exporter.Ficha = ficha; exporter.Guardar(datos, path); LogMessage("Exportado a:" + path); }).ContinueWith(a => { if (a.IsFaulted) { var ex = a.Exception.InnerException; if (ex != null) { LogMessage("Error " + ex.Message, ex); } } }); return ""; }