public Periodo Obtener(DateTime fecha) { Periodo periodo = new Periodo(); TimeSpan ti = new TimeSpan(14, 0, 0); periodo.Inicio = fecha.Date + ti; TimeSpan tf = new TimeSpan(13, 59, 0); periodo.Fin = fecha.Date.AddDays(1) + tf; return periodo; }
public async Task<HttpResponseMessage> ObtenerPorPeriodoCSV(Periodo periodo) { var periodoCompleto = new PeriodoService().Obtener(periodo.Inicio); byte[] output = null; await Task.Run(() => { using (var stream = _servicioServiceExt.GenerarExcelServiciosResumen(periodoCompleto)) { stream.Flush(); output = stream.ToArray(); } }); if (output != null) { var result = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(output) }; result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "servicios.xls" }; result.Content.Headers.Add("x-filename", "servicios.xls"); return result; } return this.Request.CreateErrorResponse(HttpStatusCode.NoContent, "No hay datos."); }