public async Task <IActionResult> DownloadDocVacacionesPdf([FromQuery] long idEmpresa, long idDocumento) { try { byte[] mybytearray = null; Servcios srv = new Servcios(); String strHTML = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\ClientKeyString"); mybytearray = srv.PDF_vacDocumento(strHTML, idEmpresa, idDocumento); string mimeType = "application/octet-stream"; string FileOutPutName = "asd"; return(new FileContentResult(mybytearray, mimeType) { FileDownloadName = FileOutPutName }); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <IActionResult> descargaArchivo([FromBody] dynamic paramsBody) { Servcios srv = new Servcios(); try { byte[] mybytearray = null; //srv.setLog("TestPrint"); string stringHtml = paramsBody.html; // BORRAR DESPUES DE PROBAR TODO //string e = ""; //try //{ // e = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"ClientApp/dist/assets/documents/docVacaciones.html"); //} //catch (Exception) //{ // e = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + @"\ClientApp\src\assets\documents\docVacaciones.html"); //} long idEmpresa = Convert.ToInt64(paramsBody.idEmpresa); long idDocuemnto = Convert.ToInt64(paramsBody.idDocumento); mybytearray = srv.PDF_vacDocumento(stringHtml, idEmpresa, idDocuemnto); string mimeType = "application/octet-stream"; string FileOutPutName = "asd"; try { return(new FileContentResult(mybytearray, mimeType) { FileDownloadName = FileOutPutName }); } catch (Exception exx) { Console.WriteLine(exx.Message); throw; } //using (var httpClient = new HttpClient()) //{ // using (var response = await httpClient.GetAsync(filtro.Replace("\"", string.Empty))) // { // string result = null; // result = response.Content.ReadAsStringAsync().Result.Replace("\"", string.Empty); // byte[] mybytearray = Convert.FromBase64String(result); // string mimeType = "application/octet-stream"; // string FileOutPutName = "asd"; // return new FileContentResult(mybytearray, mimeType) // { // FileDownloadName = FileOutPutName // }; // } //} } catch (Exception ex) { srv.setLog(ex.Message); return(BadRequest(ex.Message)); } }