public HttpResponseMessage GetReporteExcelRegistroControl([FromUri] ParametersRegistroControl parms) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest); List <ReporteRegistroControlPartialModel> Lista = GetRegistroControlFiltro(parms); MemoryStream memoryStream = new MemoryStream(); List <string[]> header = new List <string[]>(); header.Add(new string[] { "A" }); header.Add(new string[] { "B" }); header.Add(new string[] { "C" }); header.Add(new string[] { "D" }); header.Add(new string[] { "E" }); byte[] fileExcell = reportExcelService.CreateReportBinary <ReporteRegistroControlPartialModel>(header, Lista, "Excel1"); var contentLength = fileExcell.Length; var statuscode = HttpStatusCode.OK; response = Request.CreateResponse(statuscode); response.Content = new StreamContent(new MemoryStream(fileExcell)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentLength = contentLength; ContentDispositionHeaderValue contentDisposition = null; if (ContentDispositionHeaderValue.TryParse("inline; filename=" + "document" + ".xlsx", out contentDisposition)) { response.Content.Headers.ContentDisposition = contentDisposition; } return(response); }
public IHttpActionResult GenerateRolesBinary() { var listRoles = new List <ApplicationRole>(); var role = RoleManager.Roles; foreach (var item in role) { var newitem = (ApplicationRole)item; listRoles.Add(newitem); } List <string[]> headerRow = new List <string[]>() { new string[] { "Id", "Name", "Status" } }; var result = listRoles.Select(c => new { Id = c.Id, Name = c.Name, Status = c.Estatus }); List <dynamic> dynaList = new List <dynamic>(); foreach (var item in result) { dynaList.Add(item.ToDynamic()); } var byteresult = reporterService.CreateReportBinary <ApplicationRole>(new List <string[]>(), listRoles, $"reportRoles{System.DateTime.Now.ToString(dateFormat)}"); //reporterService.CreateReport<object>(headerRow, result); return(new FileResult(byteresult)); }
public HttpResponseMessage GetReporteExcel([FromUri] PartidaModel parms) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest); int activo = Convert.ToInt16(BusinessEnumerations.Estatus.ACTIVO); var tmp = service.Query(x => x.SC_ESTATUS == activo); var result = tmp.Select(x => new { EMPRESA_NOMBRE = x.SAX_EMPRESA != null ? (x.SAX_EMPRESA.CE_COD_EMPRESA.Trim() + "-" + x.SAX_EMPRESA.CE_NOMBRE.Trim()) : string.Empty, MONEDA_NOMBRE = x.SAX_MONEDA != null ? (x.SAX_MONEDA.CC_NUM_MONEDA.Trim() + "-" + x.SAX_MONEDA.CC_DESC_MONEDA.Trim()) : string.Empty, CUENTA_CONTABLE_NOMBRE = x.SAX_CUENTA_CONTABLE != null ? (x.SAX_CUENTA_CONTABLE.CO_CUENTA_CONTABLE.Trim() + x.SAX_CUENTA_CONTABLE.CO_COD_AUXILIAR.Trim() + x.SAX_CUENTA_CONTABLE.CO_NUM_AUXILIAR.Trim()) : string.Empty, SC_SALDOS = x.SC_SALDOS }).OrderBy(y => y.EMPRESA_NOMBRE).ThenBy(z => z.MONEDA_NOMBRE).ThenBy(a => a.CUENTA_CONTABLE_NOMBRE); if (result != null && result.Count() == 0) { var codeHttp = HttpStatusCode.BadRequest; response = Request.CreateResponse(codeHttp); response.Content = new StringContent("No hay cuentas contables para ser limpiadas."); return(response); } var dt = result.ToList().AnonymousToDataTable(); if (dt != null && dt.Columns.Count > 0) { dt.Columns[0].Caption = "Empresa"; dt.Columns[1].Caption = "Moneda"; dt.Columns[2].Caption = "Cuenta Contable"; dt.Columns[3].Caption = "Saldo"; } byte[] fileExcell = reportExcelService.CreateReportBinary(dt, "Hoja1"); var contentLength = fileExcell.Length; var statuscode = HttpStatusCode.OK; response = Request.CreateResponse(statuscode); response.Content = new StreamContent(new MemoryStream(fileExcell)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentLength = contentLength; ContentDispositionHeaderValue contentDisposition = null; if (ContentDispositionHeaderValue.TryParse("inline; filename=" + "document" + ".xlsx", out contentDisposition)) { response.Content.Headers.ContentDisposition = contentDisposition; } return(response); }
public HttpResponseMessage GetReporteCuentaConcilia([FromUri] ParametrosCuentaContableModel model) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest); MemoryStream memoryStream = new MemoryStream(); List <string[]> header = new List <string[]>(); int activo = Convert.ToInt16(BusinessEnumerations.Estatus.ACTIVO); var listCuentaContable = this.GetDataReporteCuentaContable(model); var listaCtaRaw = listCuentaContable.Select(x => x); if (listaCtaRaw.Count() == 0) { return(response); } var source = listaCtaRaw.ToList().Select(c => new { Empresa = NameEmpresa(c.CE_ID_EMPRESA), CuentaContable = $"{c.CO_CUENTA_CONTABLE}{c.CO_COD_AUXILIAR}{c.CO_NUM_AUXILIAR.Trim()}", NombreCuenta = c.CO_NOM_AUXILIAR.Trim(), Concilia = GetConcilia(c.CO_COD_CONCILIA), Naturaleza = GetNaturaleza(c.CO_COD_NATURALEZA), AreaOperativa = NameAreaOperativa(c.ca_id_area) }).ToList(); var dt = source.ToList().AnonymousToDataTable(); byte[] fileExcell = reportExcelService.CreateReportBinary(dt, "Excel1"); var contentLength = fileExcell.Length; //200 //successful var statuscode = HttpStatusCode.OK; response = Request.CreateResponse(statuscode); response.Content = new StreamContent(new MemoryStream(fileExcell)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentLength = contentLength; ContentDispositionHeaderValue contentDisposition = null; if (ContentDispositionHeaderValue.TryParse("inline; filename=" + "document" + ".xlsx", out contentDisposition)) { response.Content.Headers.ContentDisposition = contentDisposition; } return(response); }
//public HttpResponseMessage GetReporteExcelSaldoContable([FromUri]ParametersSaldoContable parms) public async Task <HttpResponseMessage> GetReporteExcelSaldoContable([FromUri] ParametersSaldoContable parms) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest); IdentityUser user = await UserManager.FindByIdAsync(User.Identity.GetUserId()); var userArea = usuarioAreaService.GetAll(d => d.US_ID_USUARIO == user.Id && d.UA_ESTATUS == 1, null, includes: c => c.AspNetUsers).ToList(); var userAreacod = new List <AreaOperativaModel>(); foreach (var item in userArea) { userAreacod.Add(areaOperativaService.GetSingle(d => d.CA_ID_AREA == item.CA_ID_AREA)); } List <ReporteSaldoContablePartialModel> Lista = GetSaldoContableFiltro(parms, user); MemoryStream memoryStream = new MemoryStream(); List <string[]> header = new List <string[]>(); header.Add(new string[] { "A" }); header.Add(new string[] { "B" }); header.Add(new string[] { "C" }); header.Add(new string[] { "D" }); header.Add(new string[] { "E" }); byte[] fileExcell = reportExcelService.CreateReportBinary <ReporteSaldoContablePartialModel>(header, Lista, "Excel1"); var contentLength = fileExcell.Length; var statuscode = HttpStatusCode.OK; response = Request.CreateResponse(statuscode); response.Content = new StreamContent(new MemoryStream(fileExcell)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response.Content.Headers.ContentLength = contentLength; ContentDispositionHeaderValue contentDisposition = null; if (ContentDispositionHeaderValue.TryParse("inline; filename=" + "document" + ".xlsx", out contentDisposition)) { response.Content.Headers.ContentDisposition = contentDisposition; } return(response); }