//public String getReport(string id, string desde, string hasta, string pais, string negocio, string serneg, // string flg_docto) //{ // GeneraReporte fc = new GeneraReporte(); // byte[] filestream = fc.getReport(desde, hasta, pais, negocio, serneg, flg_docto); // return Convert.ToBase64String(filestream); //} public String getReport(string id, string desde, string hasta, string pais, string negocio, string serneg, string flg_docto) { DataTable tabla = new DataTable(); Models.GeneraReporte ctrlFacturacion = new Models.GeneraReporte(); string serror = ""; tabla = ctrlFacturacion.getReport(out serror, desde, hasta, pais, negocio, serneg, flg_docto); StringBuilder sb = new StringBuilder(); IEnumerable <string> columnNames = tabla.Columns.Cast <DataColumn>(). Select(column => column.ColumnName); sb.AppendLine(string.Join(";", columnNames)); foreach (DataRow row in tabla.Rows) { IEnumerable <string> fields = row.ItemArray.Select(field => field.ToString().Trim()); sb.AppendLine(string.Join(";", fields)); } byte[] plainTextBytes = System.Text.Encoding.UTF32.GetBytes(sb.ToString()); return(System.Convert.ToBase64String(plainTextBytes)); }
public string getReportCostosDesglosados() { DataTable tabla = new DataTable(); Models.GeneraReporte ctrlFacturacion = new Models.GeneraReporte(); string serror = ""; tabla = ctrlFacturacion.getReportCostoDesglose(out serror); StringBuilder sb = new StringBuilder(); IEnumerable <string> columnNames = tabla.Columns.Cast <DataColumn>(). Select(column => column.ColumnName); sb.AppendLine(string.Join(";", columnNames)); foreach (DataRow row in tabla.Rows) { IEnumerable <string> fields = row.ItemArray.Select(field => field.ToString().Trim()); sb.AppendLine(string.Join(";", fields)); } byte[] plainTextBytes = System.Text.Encoding.UTF32.GetBytes(sb.ToString()); return(System.Convert.ToBase64String(plainTextBytes)); }