/// <summary>
 /// Método que rellena una tabla con los registros detallados de un reporte, en base a su tipo.
 /// </summary>
 /// <param name="reporte">Reporte sobre el cual se realiza el llenado de información</param>
 /// <returns>Texto que contiene los registros detallados de un reporte.</returns>
 protected string ColumnasRastreoEstatico(ReporteRastreo reporte)
 {
     switch (reporte.Tipo)
     {
         case (int)TipoReporteEstatico.Historico: return FillColumnasHistorico(reporte);
         case (int)TipoReporteEstatico.TiempoMuerto: return FillColumnasTiempoMuerto(reporte);
         case (int)TipoReporteEstatico.Eventos: return FillColumnasEventos(reporte);
         case (int)TipoReporteEstatico.ExcesosVelocidad: return FillColumnasExcesos(reporte);
         case (int)TipoReporteEstatico.Ralenti: return FillColumnasRalenti(reporte);
         default: return string.Empty;
     }
 }
    /// <summary>
    /// Obtiene el encabezado de un reporte de rastreo estático,
    /// contiene el nombre del vehículo, la fecha inicial y la fecha final del reporte
    /// </summary>
    /// <param name="reporte">Reporte del cual realizar el encabezado</param>
    /// <returns>Texto que contiene el nombre del vehículo, fecha inicial y fecha final del reporte</returns>
    private static string EncabezadoReporte(ReporteRastreo reporte)
    {
        string contenido = string.Empty;

        contenido += string.Format("<span class=\"tituloReporte\">{0}</span>", reporte.Descripcion);

        contenido += "<table class=\"fechasReporte\">";
        contenido +=  RowResumen(Resources.Reportes.aspx.FechaInicial, reporte.FechaInicial,
            Resources.Reportes.aspx.FechaFinal, reporte.FechaFinal);

        contenido += "</table>";

        return contenido;
    }
 /// <summary>
 /// Obtiene una descripción para un reporte (excel o pdf) en base al reporte.
 /// Ejemplo: "Jetta 22/10/2012 3:00 PM 23/10/2012 4:00 PM
 /// </summary>
 /// <param name="reporte"></param>
 /// <returns></returns>
 private static string DescriptorReporte(ReporteRastreo reporte)
 {
     if (reporte.Tipo == (int)TipoReporteEstatico.PosicionActual || reporte.Tipo == (int)TipoReporteEstatico.PuntosFueraHistorico || reporte.Tipo == (int)TipoReporteEstatico.PuntosEnHistoricoAgrupado)
         return string.Empty;
     return string.Format("{0} {1} {2}", reporte.Descripcion, reporte.FechaInicial.Replace('/', '-').Replace('.', ' '), reporte.FechaFinal.Replace('/', '-').Replace('.', ' '));
 }
    /// <summary>
    /// Método que rellana una tabla con los registros detallados para un reporte de tipo Tiempo Muerto.
    /// </summary>
    /// <param name="reporte">Reporte sobre el cual se realiza el llenado de información</param>
    /// <returns>Texto que contiene los registros detallados de un reporte.</returns>
    protected string FillColumnasTiempoMuerto(ReporteRastreo reporte)
    {
        // no lleva velocidad ni evento
        string contenido = "";
        foreach (UbicacionReporte ubicacion in reporte.Ubicaciones)
        {
            contenido += string.Format("<tr><td>{0}</td>" +
                "<td>{1}</td>" +
                "<td>{2}</td>" +
                "<td>{3}</td>" +
                "<td>{4}</td></tr>",
                ubicacion.Fecha, ubicacion.Calle, ubicacion.Colonia, ubicacion.Ciudad, ubicacion.Tiempo);

        }
        return contenido;
    }
    /// <summary>
    /// Método que rellana una tabla con los registros detallados para un reporte de tipo Ralentí.
    /// </summary>
    /// <param name="reporte">Reporte sobre el cual se realiza el llenado de información</param>
    /// <returns>Texto que contiene los registros detallados de un reporte.</returns>
    protected string FillColumnasRalenti(ReporteRastreo reporte)
    {
        //no lleva evento(se da por entendido que es puro ralenti) ni velocidad
        string contenido = "";
        foreach (UbicacionReporte ubicacion in reporte.Ubicaciones)
        {
            contenido += string.Format("<tr><td>{0}</td>" +
                "<td>{1}</td>" +
                "<td>{2}</td>" +
                "<td>{3}</td>" +
                "<td>{4}</td></tr>",
            ubicacion.Fecha, ubicacion.Calle, ubicacion.Colonia, ubicacion.Ciudad, ubicacion.Tiempo);

        }
        return contenido;
    }
Example #6
0
 /// <summary>
 /// Genera un reporte en PDF de rastreo estático. No incluye Última Posición.
 /// </summary>
 /// <param name="reporte">Contiene la información del reporte a exportar a PDF</param>
 /// <returns>Arreglo de bytes que contiene el archivo en PDF</returns>
 public static byte[] GeneraReporteRastreo(ReporteRastreo reporte,string metrica)
 {
     switch (reporte.Tipo)
     {
         case (int)TipoReporteEstatico.Historico: return Historico(reporte,metrica);
         case (int)TipoReporteEstatico.TiempoMuerto:return TiempoMuerto(reporte);
         case (int)TipoReporteEstatico.Eventos:return Eventos(reporte,metrica);
         case (int)TipoReporteEstatico.ExcesosVelocidad:return Excesos(reporte,metrica);
         case (int)TipoReporteEstatico.Ralenti:return Ralenti(reporte);
         case (int)TipoReporteEstatico.PuntosEnHistorico: return PuntosEnHistorico(reporte,metrica);
         case (int)TipoReporteEstatico.PuntosFueraHistorico: return PuntosFueraDeHistorico(reporte,metrica);
         case (int)TipoReporteEstatico.PuntosEnHistoricoAgrupado: return PuntosEnHistoricoAgrupado(reporte,metrica);
         default:return null;
     }
 }
    /// <summary>
    /// Método que rellana una tabla con los registros detallados para un reporte de tipo Histórico.
    /// </summary>
    /// <param name="reporte">Reporte sobre el cual se realiza el llenado de información</param>
    /// <returns>Texto que contiene los registros detallados de un reporte.</returns>
    protected string FillColumnasHistorico(ReporteRastreo reporte)
    {
        string contenido = "";
        foreach (UbicacionReporte ubicacion in reporte.Ubicaciones)
        {
            contenido += string.Format("<tr><td>{0}</td>" +
                "<td>{1}</td>" +
                "<td>{2}</td>" +
                "<td>{3}</td>" +
                "<td>{4}</td>" +
                "<td>{5}</td>" +
                "<td>{6}</td></tr>",
                 ubicacion.Fecha, ubicacion.Velocidad, ubicacion.Calle, ubicacion.Colonia, ubicacion.Ciudad, ubicacion.Evento, ubicacion.Tiempo);

        }

        return contenido;
    }
    /// <summary>
    /// Genera un reporte en Excel del tipo Puntos Historico Agrupados
    /// </summary>
    /// <param name="reporte">Contiene la información del reporte a utilizar</param>
    /// <param name="template">Contiene la información del template a utilizar para realizar el reporte</param>
    /// <returns>Arreglo de bytes que contiene el reporte en excel.</returns>
    public static byte[] PuntosEnHistoricoAgrupado(ReporteRastreo reporte, MemoryStream template)
    {
        using (ExcelPackage xlPackage = new ExcelPackage(new MemoryStream(), template))
        {
            ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
            int startRow = 8, startColumn = 1;
            if (reporte.PuntosHistorico.Count > 1)
                worksheet.InsertRow(startRow, reporte.PuntosHistorico.Count - 1, startRow);
            worksheet.Cells[3, 5].Value = reporte.Descripcion;

            worksheet.Cells[5, 4].Value = reporte.FechaInicial;
            worksheet.Cells[5, 6].Value = reporte.FechaFinal;

            int rowActual = startRow;
            string mapa = Resources.Reportes.aspx.Mapa;

            // Variables para la sumatoria al final del reporte
            long tiempoTotalEnPunto = 0;
            double recorridoTotal = 0;
            int tiempoTotalEnRecorrido = 0;

            foreach (PuntoHistorico puntoPH in reporte.PuntosHistorico)
            {
                int columna = startColumn;
                string link = string.Format("http://maps.google.com/maps?q={0}", puntoPH.Coordenadas);
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Fecha;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Unidad;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Punto;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Tiempo;
                worksheet.Cells[rowActual, columna++].Value = Math.Round(puntoPH.Distancia, 2);
                worksheet.Cells[rowActual, columna++].Value = puntoPH.MinutosRecorrido;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Calle;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Colonia;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Ciudad;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.FechaSalida;
                worksheet.Cells[rowActual, columna++].Value = Math.Round(puntoPH.Proximidad, 2);

                if (puntoPH.Coordenadas == null)
                    puntoPH.Coordenadas = "";
                worksheet.Cells[rowActual++, columna].Formula = string.Format("HYPERLINK(\"{0}\",\"{1}\")", link, mapa);

                // Sumatoria de los 3 parametros a desplegar al final del reporte
                // Al hacer la division entre 60000 obtenemos los minutos y despreciamos los
                // segundos y milisegundos sobrantes (de la misma manera que se hace al generar
                // el string de Tiempo en punto (ej: "5 hrs 3 mins") donde pudieron ser 3 mins y
                // algunos segundos, sin embargo se descartan. Tambien lo hacemos al calcular el
                // tiempo total para que al sumar manualmente los strings coincidan con el total
                // al final del reporte.
                tiempoTotalEnPunto += (puntoPH.TiempoMs / 60000);
                recorridoTotal += puntoPH.Distancia;
                tiempoTotalEnRecorrido += puntoPH.MinutosRecorrido;

            }

            // Despliega la sumatoria de los 3 parametros al final del reporte
            worksheet.Cells[rowActual, 4].Value = minutosAHorasMinutos(tiempoTotalEnPunto);
            worksheet.Cells[rowActual, 5].Value = Math.Round(recorridoTotal, 2);
            worksheet.Cells[rowActual, 6].Value = minutosAHorasMinutos(tiempoTotalEnRecorrido);

            // Aplicamos estilo Bold y Alineado a la Izquierda a la ultima fila (la de la sumatoria).
            worksheet.Row(rowActual).Style.Font.Bold = true;
            worksheet.Row(rowActual).Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;

            return xlPackage.GetAsByteArray();
        }
    }
    /// <summary>
    /// Genera un reporte en Excel del tipo Puntos FUERA de un Historico
    /// </summary>
    /// <param name="reporte">Contiene la información del reporte a utilizar</param>
    /// <param name="template">Contiene la información del template a utilizar para realizar el reporte</param>
    /// <returns>Arreglo de bytes que contiene el reporte en excel.</returns>
    public static byte[] PuntosFueraHistorico(ReporteRastreo reporte, MemoryStream template)
    {
        using (ExcelPackage xlPackage = new ExcelPackage(new MemoryStream(), template))
        {
            ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
            int startRow = 8, startColumn = 1;
            if (reporte.PuntosHistorico.Count > 1)
                worksheet.InsertRow(startRow, reporte.PuntosHistorico.Count - 1, startRow);
            worksheet.Cells[3, 5].Value = reporte.Descripcion;

            worksheet.Cells[5, 3].Value = reporte.FechaInicial;
            worksheet.Cells[5, 6].Value = reporte.FechaFinal;

            int rowActual = startRow;
            string mapa = Resources.Reportes.aspx.Mapa;

            foreach (PuntoHistorico puntoPH in reporte.PuntosHistorico)
            {
                int columna = startColumn;
                string link = string.Format("http://maps.google.com/maps?q={0}", puntoPH.Coordenadas);
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Punto;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Calle;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Colonia;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Ciudad;
                if (puntoPH.Coordenadas == null)
                    puntoPH.Coordenadas = "";
                worksheet.Cells[rowActual++, columna].Formula = string.Format("HYPERLINK(\"{0}\",\"{1}\")", link, mapa);
            }
            return xlPackage.GetAsByteArray();
        }
    }
    /// <summary>
    /// Genera un reporte en excel de tipo Histórico
    /// </summary>
    /// <param name="reporte">Contiene la información del reporte a utilizar</param>
    /// <param name="template">Contiene la información del template a utilizar para realizar el reporte</param>
    /// <returns>Arreglo de bytes que contiene el reporte en excel.</returns>
    public static byte[] Historico(ReporteRastreo reporte, MemoryStream template, string metrica, HttpContext contexto)
    {
        using (ExcelPackage xlPackage = new ExcelPackage(new MemoryStream(), template))
        {
            ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
            int startRow = 10, startColumn = 1; //los declaramos desde aqui por si hay cambios en el template, ajustarlos facilmente
            if (reporte.Ubicaciones.Count > 1)
                worksheet.InsertRow(startRow, reporte.Ubicaciones.Count - 1, startRow);

            worksheet.Cells[3, 5].Value = reporte.Descripcion;
            worksheet.Cells[5, 2].Value = reporte.kmAprox;
            worksheet.Cells[6, 2].Value = reporte.VMaxima;
            worksheet.Cells[7, 2].Value = reporte.VPromedio;
            worksheet.Cells[5, 4].Value = reporte.TMovimiento;
            worksheet.Cells[6, 4].Value = reporte.TMuerto;
            worksheet.Cells[5, 6].Value = reporte.FechaInicial;
            worksheet.Cells[6, 6].Value = reporte.FechaFinal;
            worksheet.Cells[9, 5].Value = metrica;
            int rowActual = startRow;
            string mapa = Resources.Reportes.aspx.Mapa;

            foreach (UbicacionReporte ubicacion in reporte.Ubicaciones)
            {
                int columna = startColumn;
                string link = string.Format("http://maps.google.com/maps?q={0}", ubicacion.Coordenadas);
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Fecha;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Calle;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Colonia;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Ciudad;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Velocidad;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Evento;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Tiempo;
                if (ubicacion.Coordenadas == null)
                    ubicacion.Coordenadas = "";

                HttpCookie cookie = contexto.Request.Cookies.Get("Usuario");
                string nombre = new Codificador().Desencriptar(cookie.Values.Get("Nombre")).Replace("\0", string.Empty);
                if (nombre.Equals("<Marcela Santana> Triversa Telemetria"))
                {
                    worksheet.Cells[rowActual++, columna].Formula = string.Format("HYPERLINK(\"{0}\",\"{1}\")", link, fixCoordinatesString(ubicacion.Coordenadas, 5));
                }
                else
                {
                    worksheet.Cells[rowActual++, columna].Formula = string.Format("HYPERLINK(\"{0}\",\"{1}\")", link, mapa);
                }
            }
            return xlPackage.GetAsByteArray();
        }
    }
    /// <summary>
    /// Genera un reporte en Excel del tipo Puntos Historico
    /// </summary>
    /// <param name="reporte">Contiene la información del reporte a utilizar</param>
    /// <param name="template">Contiene la información del template a utilizar para realizar el reporte</param>
    /// <returns>Arreglo de bytes que contiene el reporte en excel.</returns>
    public static byte[] PuntosEnHistorico(ReporteRastreo reporte, MemoryStream template)
    {
        using (ExcelPackage xlPackage = new ExcelPackage(new MemoryStream(), template))
        {
            ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
            int startRow = 10, startColumn = 1;
            if (reporte.PuntosHistorico.Count > 1)
                worksheet.InsertRow(startRow, reporte.PuntosHistorico.Count - 1, startRow);
            worksheet.Cells[3, 5].Value = reporte.Descripcion;

            worksheet.Cells[5, 2].Value = reporte.kmAprox;
            worksheet.Cells[5, 4].Value = reporte.TMovimiento;
            worksheet.Cells[5, 6].Value = reporte.FechaInicial;

            worksheet.Cells[6, 2].Value = reporte.VMaxima;
            worksheet.Cells[6, 4].Value = reporte.TiempoMuertoEnPuntos;
            worksheet.Cells[6, 6].Value = reporte.FechaFinal;

            worksheet.Cells[7, 2].Value = reporte.VPromedio;
            worksheet.Cells[7, 4].Value = reporte.TiempoMuertoFueraPuntos;
            worksheet.Cells[7, 6].Value = reporte.DistanciaEnPuntos;

            int rowActual = startRow;
            string mapa = Resources.Reportes.aspx.Mapa;

            // Variables para la sumatoria al final del reporte
            long tiempoTotalEnPunto = 0;
            double recorridoTotal = 0;
            int tiempoTotalEnRecorrido = 0;

            foreach (PuntoHistorico puntoPH in reporte.PuntosHistorico)
            {
                int columna = startColumn;
                string link = string.Format("http://maps.google.com/maps?q={0}", puntoPH.Coordenadas);

                worksheet.Cells[rowActual, columna++].Value = puntoPH.Fecha;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Punto;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Tiempo;
                worksheet.Cells[rowActual, columna++].Value = Math.Round(puntoPH.Distancia, 2);
                worksheet.Cells[rowActual, columna++].Value = puntoPH.MinutosRecorrido;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Calle;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Colonia;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.Ciudad;
                worksheet.Cells[rowActual, columna++].Value = puntoPH.FechaSalida;
                worksheet.Cells[rowActual, columna++].Value = Math.Round(puntoPH.Proximidad, 2);

                if (puntoPH.Coordenadas == null)
                    puntoPH.Coordenadas = "";
                worksheet.Cells[rowActual++, columna].Formula = string.Format("HYPERLINK(\"{0}\",\"{1}\")", link, mapa);

                // Sumatoria de los 3 parametros a desplegar al final del reporte
                tiempoTotalEnPunto += puntoPH.TiempoMs;
                recorridoTotal += puntoPH.Distancia;
                tiempoTotalEnRecorrido += puntoPH.MinutosRecorrido;
            }

            // Despliega la sumatoria de los 3 parametros al final del reporte
            worksheet.Cells[rowActual, 3].Value = minutosAHorasMinutos(tiempoTotalEnPunto / 60000);
            worksheet.Cells[rowActual, 4].Value = Math.Round(recorridoTotal, 2);
            worksheet.Cells[rowActual, 5].Value = minutosAHorasMinutos(tiempoTotalEnRecorrido);

            // Aplicamos estilo Bold y Alineado a la Izquierda a la ultima fila (la de la sumatoria).
            worksheet.Row(rowActual).Style.Font.Bold = true;
            worksheet.Row(rowActual).Style.HorizontalAlignment = ExcelHorizontalAlignment.Left;

            return xlPackage.GetAsByteArray();
        }
    }
 /// <summary>
 /// Genera un reporte en excel de una consulta de rastreo estático. No incluye Última Posición.
 /// </summary>
 /// <param name="reporte">Contiene la información del reporte a realizar.</param>
 /// <param name="context">Contexto Http que sirve para obtener rutas dentro de la aplicación para el template a utilizar</param>
 /// <param name="cultura">Cultura actual, para realizar el reporte. Ejemplo: "es-MX" o "en-US"</param>
 /// <returns>Arreglo de bytes que contiene el reporte en excel</returns>
 public static byte[] GeneraReporteRastreo(ReporteRastreo reporte, HttpContext context, string cultura, string metrica)
 {
     switch (reporte.Tipo)
     {
         case (int)TipoReporteEstatico.Historico:
             return Historico(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.Historico.ToString())))),metrica, context);
         case (int)TipoReporteEstatico.TiempoMuerto:
             return TiempoMuerto(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.TiempoMuerto.ToString())))));
         case (int)TipoReporteEstatico.Eventos:
             return Eventos(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.Eventos.ToString())))),metrica);
         case (int)TipoReporteEstatico.ExcesosVelocidad:
             return ExcesosVelocidad(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.ExcesosVelocidad.ToString())))),metrica);
         case (int)TipoReporteEstatico.Ralenti:
             return Ralenti(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.Ralenti.ToString())))));
         case (int)TipoReporteEstatico.PuntosEnHistorico:
             return PuntosEnHistorico(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.PuntosEnHistorico.ToString())))));
         case (int)TipoReporteEstatico.PuntosFueraHistorico:
             return PuntosFueraHistorico(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.PuntosFueraHistorico.ToString())))));
         case (int)TipoReporteEstatico.PuntosEnHistoricoAgrupado:
             return PuntosEnHistoricoAgrupado(reporte, new MemoryStream(File.ReadAllBytes(context.Server.MapPath(string.Format("Reportes/{0}/{1}.xlsx", cultura, TipoReporteEstatico.PuntosEnHistoricoAgrupado.ToString())))));
         default:
             return null;
     }
 }
Example #13
0
    /// <summary>
    /// Genera un reporte en PDF de tipo de reporte de tiempos muertos.
    /// </summary>
    /// <param name="reporte">Contiene la información para realizar el reporte. </param>
    /// <returns>Arreglo de bytes que contiene el reporte en PDF</returns>
    public static byte[] TiempoMuerto(ReporteRastreo reporte)
    {
        Document document = new Document();
        DefineStyles(document);
        Section section = document.AddSection();

        #region header y fechas
        Paragraph resumen = section.AddParagraph();
        resumen.Style = "Header";
        resumen.Format.Alignment = ParagraphAlignment.Center;
        resumen.AddText(string.Format("{0} {1}: {2}", Resources.Reportes.aspx.TiempoMuerto, Resources.Reportes.aspx.De, reporte.Descripcion));

        section.AddParagraph();

        Table tablaFechas = section.AddTable();
        tablaFechas.Borders.Visible = false;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;

        Row rowFecha = tablaFechas.AddRow();
        rowFecha.HeadingFormat = false;
        rowFecha.Cells[0].AddParagraph(Resources.Reportes.aspx.FechaInicial).Format.Font.Bold = true;
        rowFecha.Cells[1].AddParagraph(reporte.FechaInicial);
        rowFecha.Cells[2].AddParagraph(Resources.Reportes.aspx.FechaFinal).Format.Font.Bold = true;
        rowFecha.Cells[3].AddParagraph(reporte.FechaFinal);

        section.AddParagraph();

        #endregion

        // Put a logo in the header
        Image image = section.Headers.Primary.AddImage(System.Web.HttpContext.Current.Server.MapPath("~/images/index/Logo.png"));
        image.Height = "0.8cm";
        image.LockAspectRatio = true;
        image.RelativeVertical = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top = ShapePosition.Top;
        image.Left = ShapePosition.Left;
        image.WrapFormat.Style = WrapStyle.Through;

        #region resumen
        Table tablaResumen = section.AddTable();
        tablaResumen.Borders.Visible = false;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;

        Row rowResumen = tablaResumen.AddRow();
        rowResumen.HeadingFormat = false;
        rowResumen.Cells[0].AddParagraph(Resources.Reportes.aspx.Distancia).Format.Font.Bold = true;
        rowResumen.Cells[1].AddParagraph(reporte.kmAprox);
        rowResumen.Cells[2].AddParagraph(Resources.Reportes.aspx.TiempoMovimiento).Format.Font.Bold = true;
        rowResumen.Cells[3].AddParagraph(reporte.TMovimiento);

        rowResumen = tablaResumen.AddRow();
        rowResumen.Cells[0].AddParagraph(Resources.Reportes.aspx.VelocidadMaxima).Format.Font.Bold = true;
        rowResumen.Cells[1].AddParagraph(reporte.VMaxima);
        rowResumen.Cells[2].AddParagraph(Resources.Reportes.aspx.TiempoDetenido).Format.Font.Bold = true;
        rowResumen.Cells[3].AddParagraph(reporte.TMuerto);

        rowResumen.Cells[0].AddParagraph(Resources.Reportes.aspx.VelocidadPromedio).Format.Font.Bold = true;
        rowResumen.Cells[1].AddParagraph(reporte.VPromedio);

        section.AddParagraph();
        #endregion
        Table tabla = section.AddTable();
        tabla.Style = EstiloTabla;
        tabla.Borders.Color = ColorBorderTabla;
        tabla.Borders.Width = BorderWidth;
        tabla.Borders.Left.Width = LeftWidth;
        tabla.Borders.Right.Width = RightWidth;
        tabla.Rows.LeftIndent = LeftIndent;

        for (int i = 0; i < MedidasColumnasTiempoMuerto.Length; i++)
            tabla.AddColumn(MedidasColumnasTiempoMuerto[i]);

        Row row = tabla.AddRow();
        row.HeadingFormat = true;
        row.Format.Alignment = AlineamientoTableHead;
        row.Format.Font.Bold = true;
        row.Shading.Color = ColorFondoTableHead;

        for (int i = 0; i < CeldasTiempoMuerto.Length; i++)
            row.Cells[i].AddParagraph(CeldasTiempoMuerto[i]);

        row.HeadingFormat = false;

        foreach (UbicacionReporte ubicacion in reporte.Ubicaciones)
        {
            row = tabla.AddRow();
            int columna = 0;
            row.Cells[columna++].AddParagraph(ubicacion.Fecha == null?"":ubicacion.Fecha);
            row.Cells[columna++].AddParagraph(string.Join(",", new string[] { ubicacion.Calle, ubicacion.Colonia, ubicacion.Ciudad }));
            row.Cells[columna++].AddParagraph(ubicacion.Tiempo == null?"":ubicacion.Tiempo);
        }

        PdfDocumentRenderer renderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);
        renderer.Document = document;
        renderer.RenderDocument();

        using (MemoryStream ms = new MemoryStream())
        {
            renderer.Save(ms, false);
            byte[] buffer = new byte[ms.Length];
            ms.Seek(0, SeekOrigin.Begin);
            ms.Flush();
            ms.Read(buffer, 0, (int)ms.Length);
            return ms.ToArray();
        }
    }
Example #14
0
    /// <summary>
    /// Puntos fuera de Historico
    /// </summary>
    /// <param name="reporte"></param>
    /// <param name="metrica"></param>
    /// <returns></returns>
    public static byte[] PuntosFueraDeHistorico(ReporteRastreo reporte, string metrica)
    {
        Document document = new Document();
        DefineStyles(document);
        Section section = document.AddSection();

        #region header y fechas
        Paragraph resumen = section.AddParagraph();
        resumen.Style = "Header";
        resumen.Format.Alignment = ParagraphAlignment.Center;
        resumen.AddText(string.Format("{0} {1}:", Resources.Reportes.aspx.PuntosNoVisitados, Resources.Reportes.aspx.De));

        Paragraph unidades = section.AddParagraph();
        unidades.Format.Alignment = ParagraphAlignment.Center;
        unidades.AddText(reporte.Descripcion);

        section.AddParagraph();

        Table tablaFechas = section.AddTable();
        tablaFechas.Borders.Visible = false;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaFechas.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;

        Row rowFecha = tablaFechas.AddRow();
        rowFecha.HeadingFormat = false;
        rowFecha.Cells[0].AddParagraph(Resources.Reportes.aspx.FechaInicial).Format.Font.Bold = true;
        rowFecha.Cells[1].AddParagraph(reporte.FechaInicial);
        rowFecha.Cells[2].AddParagraph(Resources.Reportes.aspx.FechaFinal).Format.Font.Bold = true;
        rowFecha.Cells[3].AddParagraph(reporte.FechaFinal);

        section.AddParagraph();

        #endregion

        // Put a logo in the header
        Image image = section.Headers.Primary.AddImage(System.Web.HttpContext.Current.Server.MapPath("~/images/index/Logo.png"));
        image.Height = "0.8cm";
        image.LockAspectRatio = true;
        image.RelativeVertical = RelativeVertical.Line;
        image.RelativeHorizontal = RelativeHorizontal.Margin;
        image.Top = ShapePosition.Top;
        image.Left = ShapePosition.Left;
        image.WrapFormat.Style = WrapStyle.Through;

        #region resumen
        Table tablaResumen = section.AddTable();
        tablaResumen.Borders.Visible = false;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Right;
        tablaResumen.AddColumn("4cm").Format.Alignment = ParagraphAlignment.Left;

        section.AddParagraph();

        #endregion

        #region detalles

        Table tablaDetalles = section.AddTable();
        tablaDetalles.Style = EstiloTabla;
        tablaDetalles.Borders.Color = ColorBorderTabla;
        tablaDetalles.Borders.Width = BorderWidth;
        tablaDetalles.Borders.Left.Width = LeftWidth;
        tablaDetalles.Borders.Right.Width = RightWidth;
        tablaDetalles.Rows.LeftIndent = LeftIndent;

        for (int i = 0; i < MedidasColumnasHistorico.Length; i++)
            tablaDetalles.AddColumn(MedidasColumnasHistorico[i]);

        Row row = tablaDetalles.AddRow();
        row.HeadingFormat = true;
        row.Format.Alignment = AlineamientoTableHead;
        row.Format.Font.Bold = true;
        row.Shading.Color = ColorFondoTableHead;

        //CeldasPuntosEnHistorico[4] = metrica;
        for (int i = 0; i < CeldasPuntosEnHistorico.Length; i++)
            row.Cells[i].AddParagraph(CeldasPuntosEnHistorico[i]);

        row.HeadingFormat = false;

        foreach (PuntoHistorico ph in reporte.PuntosHistorico)
        {
            row = tablaDetalles.AddRow();
            int columna = 0;
            row.Cells[columna++].AddParagraph(ph.Punto == null? "":ph.Punto);
            row.Cells[columna++].AddParagraph(string.Join(",", new string[] { ph.Calle, ph.Colonia, ph.Ciudad }));
            row.Cells[columna++].AddParagraph("-");
            row.Cells[columna++].AddParagraph("-");
            row.Cells[columna++].AddParagraph("-");
        }
        #endregion

        PdfDocumentRenderer renderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);
        renderer.Document = document;
        renderer.RenderDocument();

        using (MemoryStream ms = new MemoryStream())
        {
            renderer.Save(ms, false);
            byte[] buffer = new byte[ms.Length];
            ms.Seek(0, SeekOrigin.Begin);
            ms.Flush();
            ms.Read(buffer, 0, (int)ms.Length);
            return ms.ToArray();
        }
    }
Example #15
0
    /// <summary>
    /// Obtiene el resumen de un reporte histórico o tiempos muertos que contiene
    /// Distancia recorrida, tiempo en movimiento, tiempo detenido, velocidad máxima, velocidad promedio.
    /// </summary>
    /// <param name="reporte">Reporte del cual realizar el resumen</param>
    /// <returns>Texto que contiene el resumen del reporte.</returns>
    private static string ResumenHistorico(ReporteRastreo reporte)
    {
        string contenido = string.Empty;

        contenido += "<table class=\"resumen\">";

        contenido += RowResumen(Resources.Reportes.aspx.Distancia, reporte.kmAprox,
            Resources.Reportes.aspx.TiempoMovimiento, reporte.TMovimiento);

        contenido += RowResumen(Resources.Reportes.aspx.VelocidadMaxima, reporte.VMaxima,
            Resources.Reportes.aspx.TiempoDetenido, reporte.TMuerto);

        contenido += RowResumen(Resources.Reportes.aspx.VelocidadPromedio, reporte.VPromedio, string.Empty, string.Empty);

        return contenido;
    }
    /// <summary>
    /// Genera un reporte en excel de tipo Ralentí.
    /// </summary>
    /// <param name="reporte">Contiene la información del reporte a utilizar</param>
    /// <param name="template">Contiene la información del template a utilizar para realizar el reporte</param>
    /// <returns>Arreglo de bytes que contiene el reporte en excel.</returns>
    public static byte[] Ralenti(ReporteRastreo reporte, MemoryStream template)
    {
        using (ExcelPackage xlPackage = new ExcelPackage(new MemoryStream(), template))
        {
            ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
            int startRow = 9, startColumn = 1; //los declaramos desde aqui por si hay cambios en el template, ajustarlos facilmente
            if (reporte.Ubicaciones.Count > 1)
                worksheet.InsertRow(startRow, reporte.Ubicaciones.Count - 1, startRow);

            worksheet.Cells[3, 4].Value = reporte.Descripcion;
            worksheet.Cells[5, 4].Value = 5;//reporte.TotalTiempo;
            worksheet.Cells[6, 3].Value = reporte.FechaInicial;
            worksheet.Cells[6, 5].Value = reporte.FechaFinal;

            int rowActual = startRow;
            string mapa = Resources.Reportes.aspx.Mapa;

            foreach (UbicacionReporte ubicacion in reporte.Ubicaciones)
            {
                int columna = startColumn;
                string link = string.Format("http://maps.google.com/maps?q={0}", ubicacion.Coordenadas);
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Fecha;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Calle;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Colonia;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Ciudad;
                worksheet.Cells[rowActual, columna++].Value = ubicacion.Tiempo;
                if (ubicacion.Coordenadas == null)
                    ubicacion.Coordenadas = "";
                worksheet.Cells[rowActual++, columna].Formula = string.Format("HYPERLINK(\"{0}\",\"{1}\")", link, mapa);
            }
            return xlPackage.GetAsByteArray();
        }
    }
Example #17
0
    /// <summary>
    /// Obtiene el resumen de un reporte de histo
    /// </summary>
    /// <param name="reporte">Reporte del cual se realiza el resumen</param>
    /// <returns>Texto que contiene el texto del reporte</returns>
    private static string ResumenPuntosHistorico(ReporteRastreo reporte)
    {
        string contenido = string.Empty;

        contenido += "<table class=\"resumen\">";

        //Kilometraje Aproximado y Rango Horario
        contenido += RowResumen(Resources.Reportes.aspx.Distancia, reporte.kmAprox, Resources.Reportes.aspx.TiempoMovimiento,reporte.TMovimiento);

        //Velocidad Maxima y tiempo en Movimiento
        contenido += RowResumen(Resources.Reportes.aspx.VelocidadMaxima,reporte.VMaxima, "Tiempo Muerto en Ruta", reporte.TiempoMuertoEnPuntos);

        //Velocidad Promedio y Tiempo en Ruta
        contenido += RowResumen(Resources.Reportes.aspx.VelocidadPromedio, reporte.VPromedio,"Tiempo Muerto Fuera de Ruta", reporte.TiempoMuertoFueraPuntos);

        //Distancia de Puntos y Tiempo Muerto fuera de Ruta
        contenido += RowResumen("Distancia en Puntos", reporte.DistanciaEnPuntos+"m", string.Empty,string.Empty);

        contenido += "</table>";
        return contenido;
    }
Example #18
0
    /// <summary>
    /// Obtiene el encabezado de un reporte de rastreo estático,
    /// contiene el nombre del vehículo, la fecha inicial y la fecha final del reporte
    /// </summary>
    /// <param name="reporte">Reporte del cual realizar el encabezado</param>
    /// <returns>Texto que contiene el nombre del vehículo, fecha inicial y fecha final del reporte</returns>
    private static string EncabezadoReporte(ReporteRastreo reporte, int zona)
    {
        // Fechas con la correccion de la zona horaria
        DateTime fechaInicialCorregida = Convert.ToDateTime(reporte.FechaInicial).AddHours(zona);
        DateTime fechaFinalCorregida = Convert.ToDateTime(reporte.FechaFinal).AddHours(zona);

        string contenido = string.Empty;

        contenido += string.Format("<span class=\"tituloReporte\">{0}</span>", reporte.Descripcion);

        contenido += "<table class=\"fechasReporte\">";
        contenido += RowResumen(Resources.Reportes.aspx.FechaInicial, fechaInicialCorregida.ToString(),
            Resources.Reportes.aspx.FechaFinal, fechaFinalCorregida.ToString());

        contenido += "</table>";

        return contenido;
    }