Exemplo n.º 1
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel(DesdeHasta), dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(), dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "km");
                helper.AddConfigEntry("hoverCapSepChar", " - ");
                helper.AddConfigEntry("rotateNames", "1");

                foreach (var kilometer in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("link", Server.UrlEncode(string.Format(
                                                                       "n-{0}Reportes/Estadistica/MonthKilometers.aspx?Movil={1}&InitialDate={2}&FinalDate={3}&SoloEnRuta={4}",
                                                                       ApplicationPath,
                                                                       kilometer.Movil, dpDesde.SelectedDate.GetValueOrDefault().ToString(CultureInfo.InvariantCulture),
                                                                       dpHasta.SelectedDate.GetValueOrDefault().ToString(CultureInfo.InvariantCulture),
                                                                       chkEnCiclo.Checked)));

                    item.AddPropertyValue("color", "AFD8F8");

                    item.AddPropertyValue("name", kilometer.Interno.Replace('&', 'y'));
                    item.AddPropertyValue("value", kilometer.Kilometers.ToString(CultureInfo.InvariantCulture));
                    item.AddPropertyValue("hoverText", kilometer.Interno.Replace('&', 'y'));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 2
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel(DesdeHasta),
                                                               dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(), dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "hs");
                helper.AddConfigEntry("hoverCapSepChar", " - ");
                helper.AddConfigEntry("rotateNames", "1");

                foreach (var time in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "AFD8F8");

                    item.AddPropertyValue("name", time.Intern.Replace('&', 'y'));

                    item.AddPropertyValue("value", time.ElapsedTime.ToString(CultureInfo.InvariantCulture));

                    var hours = TimeSpan.FromHours(time.ElapsedTime);

                    item.AddPropertyValue("hoverText", string.Concat(time.Intern.Replace('&', 'y'), string.Format(" - {0}dd {1}hh {2}mm {3}ss", hours.Days, hours.Hours, hours.Minutes, hours.Seconds)));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Gets graph xml definition based on the report data.
        /// </summary>
        /// <returns></returns>
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", CultureManager.GetLabel(MaximasDiarias));
                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "km/h");
                helper.AddConfigEntry("hoverCapSepChar", " -");
                helper.AddConfigEntry("rotateNames", "1");

                foreach (var speed in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    if (!speed.Dia.DayOfWeek.Equals(DayOfWeek.Saturday) & !speed.Dia.DayOfWeek.Equals(DayOfWeek.Sunday))
                    {
                        item.AddPropertyValue("color", "008ED6");
                    }

                    item.AddPropertyValue("name", speed.Dia.ToString("dd/MM"));
                    item.AddPropertyValue("value", speed.Velocidad.ToString("#0"));
                    item.AddPropertyValue("hoverText", string.Concat(CultureManager.GetLabel(Dia), string.Format(" {0:dd/MM/yyyy}", speed.Dia),
                                                                     " - ", CultureManager.GetLabel("ALCANZADA_POR"), " ", speed.CometidoPor));

                    helper.AddItem(item);
                }

                return(helper.BuildXml());
            }
        }
Exemplo n.º 4
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                var desde = dtFechaDesde.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaDesde.SelectedDate.Value) : new DateTime();

                var hasta = desde.AddMonths(1).AddSeconds(-1);

                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                _dias.Clear();
                var diasMes = GetDiasMes(desde.ToDisplayDateTime().Month, desde.ToDisplayDateTime().Year);

                for (var i = 0; i < diasMes; i++)
                {
                    var fechaDesde = desde.AddDays(i).AddSeconds(-1);
                    var fechaHasta = fechaDesde.AddDays(1);

                    var dm = DAOFactory.DatamartDAO.GetSummarizedDatamart(fechaDesde, fechaHasta, cbVehiculo.Selected);

                    var litrosConsumidos = dm.Consumo;
                    var kmRecorridos     = dm.Kilometros;
                    var hsEnMarcha       = dm.HsMarcha;

                    var litrosXKm   = litrosConsumidos > 0.0 && kmRecorridos > 0.0 ? litrosConsumidos / kmRecorridos : 0;
                    var litrosXHora = litrosConsumidos > 0.0 && hsEnMarcha > 0.0 ? litrosConsumidos / hsEnMarcha : 0;

                    _dias.Add((i + 1) + "/" + desde.ToDisplayDateTime().ToString("MM/yyyy"), new[] { litrosXHora, litrosXKm });
                }

                foreach (var pair in _dias)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "AFD8F8");
                    item.AddPropertyValue("name", pair.Key.Split('/')[0]);
                    item.AddPropertyValue("value", pair.Value[1].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);

                    item = new FusionChartsItem();

                    item.AddPropertyValue("color", "FF5904");
                    item.AddPropertyValue("value", pair.Value[0].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                lblLitrosXKm.Text   = CultureManager.GetLabel("LITROS_X_KM");
                lblLitrosXHora.Text = CultureManager.GetLabel("LITROS_X_HORA");
                pnlInferior.Visible = true;

                return(helper.BuildXml());
            }
        }
Exemplo n.º 5
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel(DesdeHasta), dpDesde.SelectedDate.GetValueOrDefault().ToString("dd/MM/yyyy HH:mm"), dpHasta.SelectedDate.GetValueOrDefault().ToString("dd/MM/yyyy HH:mm")));

                helper.AddConfigEntry("decimalPrecision", "1");
                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("hoverCapSepChar", " - ");
                helper.AddConfigEntry("rotateNames", "1");

                foreach (var checkout in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "AFD8F8");
                    item.AddPropertyValue("name", checkout.Fecha.ToDisplayDateTime().ToString("HH:mm"));
                    item.AddPropertyValue("value", checkout.Cantidad.ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 6
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", CultureManager.GetLabel("MAXIMAS_DIARIAS"));
                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "0");
                helper.AddConfigEntry("showValues", "0");
                helper.AddConfigEntry("numberSuffix", string.Empty);
                helper.AddConfigEntry("rotateNames", "1");
                helper.AddConfigEntry("limitsDecimalPrecision", "0");
                helper.AddConfigEntry("hoverCapSepChar", "-");

                foreach (var t in ReportObjectsList)
                {
                    var item = new FusionChartsItem();
                    item.AddPropertyValue("name", t.Date.ToString("dd/MM"));
                    item.AddPropertyValue("hoverText", t.Max.ToString("0"));
                    item.AddPropertyValue("value", t.Max.ToString("0"));

                    helper.AddItem(item);
                }

                if (ReportObjectsList.Count.Equals(0))
                {
                    ThrowError("NO_MATCHES_FOUND");
                }

                return(helper.BuildXml());
            }
        }
Exemplo n.º 7
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel(DesdeHasta),
                                                               dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(), dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "km");
                helper.AddConfigEntry("hoverCapSepChar", " - ");
                helper.AddConfigEntry("rotateNames", "1");

                foreach (var kilometer in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "AFD8F8");

                    item.AddPropertyValue("name", kilometer.Interno.Replace('&', 'y'));
                    item.AddPropertyValue("value", kilometer.Kilometers.ToString(CultureInfo.InvariantCulture));
                    item.AddPropertyValue("hoverText", kilometer.Interno.Replace('&', 'y'));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 8
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                var desde = dtFechaDesde.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaDesde.SelectedDate.Value) : new DateTime();

                var hasta = dtFechaHasta.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaHasta.SelectedDate.Value) : new DateTime();

                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                _despachos.Clear();
                var despachos = GetResults();

                for (var i = 0; i < despachos.Count; i++)
                {
                    var totalCargado   = despachos[i].Cantidad;
                    var fechaHasta     = i + 1 < despachos.Count ? despachos[i + 1].Fecha.ToDataBaseDateTime() : hasta;
                    var totalDespachos = GetDespachos(despachos[i].Fecha.ToDataBaseDateTime(), fechaHasta);

                    _despachos.Add(despachos[i].Fecha.ToString("dd/MM/yy HH:mm"), new[] { totalCargado, totalDespachos });
                }

                foreach (var pair in _despachos)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "AFD8F8");
                    item.AddPropertyValue("name", pair.Key);
                    item.AddPropertyValue("value", pair.Value[0].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);

                    item = new FusionChartsItem();

                    item.AddPropertyValue("color", "FF5904");
                    item.AddPropertyValue("value", pair.Value[1].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                lblLitrosCargados.Text    = CultureManager.GetLabel("LITROS_CARGADOS");
                lblLitrosDespachados.Text = CultureManager.GetLabel("LITROS_DESPACHADOS");
                pnlInferior.Visible       = true;

                return(helper.BuildXml());
            }
        }
Exemplo n.º 9
0
        private string GetGraphXmlDias(DateTime fecha)
        {
            var desde = fecha.ToDataBaseDateTime();
            var hasta = desde.AddMonths(1).AddSeconds(-1);

            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", "DIAS");
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                _dias.Clear();
                var diasMes = GetDiasMes(desde.ToDisplayDateTime().Month, desde.ToDisplayDateTime().Year);

                for (var i = 0; i < diasMes; i++)
                {
                    var fechaDesde = desde.AddDays(i).AddSeconds(-1);
                    var fechaHasta = fechaDesde.AddDays(1);

                    var valor = GetValorMedicion(fechaDesde, fechaHasta);

                    _dias.Add((i + 1) + "/" + desde.ToDisplayDateTime().ToString("MM/yyyy"), valor);
                }

                var pb = new List <string>();

                foreach (var pair in _dias)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("link", "javascript:a(" + pb.Count + ")");
                    pb.Add(ClientScript.GetPostBackEventReference(btnDia, ""));

                    item.AddPropertyValue("color", "FF5904");
                    item.AddPropertyValue("name", pair.Key.Split('/')[0]);
                    item.AddPropertyValue("value", pair.Value.ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                var script = "var pb =[" + string.Join(",", pb.Select(p => "\"" + p + "\"").ToArray())
                             + "]; function a(n) { document.getElementById('" + hidDia.ClientID + "').value = n; eval(pb[n]); }";

                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "a", script, true);
                return(helper.BuildXml());
            }
        }
Exemplo n.º 10
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                AddConfiguration(helper);

                foreach (var stoppedEvent in ReportObjectsList)
                {
                    AddItem(helper, stoppedEvent);
                }

                return(helper.BuildXml());
            }
        }
Exemplo n.º 11
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                InitializeGraph(helper);

                var previousDateIndex = 0; //for saving last date putted in graph

                for (var i = 0; i < ReportObjectsList.Count; i++)
                {
                    if (!ReportObjectsList[i].Velocidad.HasValue || ReportObjectsList[i].Velocidad < 0)
                    {
                        continue;
                    }

                    var item = new FusionChartsItem();

                    if (i == 0)
                    {
                        item.AddPropertyValue("name", ReportObjectsList[i].FechaHora.TimeOfDay.ToString());
                        ReportObjectsList[i].Hora = ReportObjectsList[i].FechaHora.ToString("hh:mm:ss");
                    }
                    else if ((ReportObjectsList[previousDateIndex].FechaHora.Minute
                              != ReportObjectsList[i].FechaHora.Minute) &&
                             ((i - previousDateIndex) > PointsDistance))//filters minimum distance between dates (points in graph)
                    {
                        item.AddPropertyValue("name", ReportObjectsList[i].FechaHora.TimeOfDay.ToString());
                        ReportObjectsList[i].Hora = ReportObjectsList[i].FechaHora.ToString("hh:mm:ss");
                        previousDateIndex         = i; //saves the index of the most recently date putted in graph
                    }
                    item.AddPropertyValue("hoverText", ReportObjectsList[i].FechaHora.TimeOfDay.ToString());
                    item.AddPropertyValue("value", ReportObjectsList[i].Velocidad.ToString());
                    AddLink(item, i);

                    helper.AddItem(item);
                }

                if (ReportObjectsList.Count.Equals(0))
                {
                    ThrowError("NO_MATCHES_FOUND");
                }

                return(helper.BuildXml());
            }
        }
Exemplo n.º 12
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                var vehicle = DAOFactory.CocheDAO.FindById(ddlMovil.Selected);

                AddConfiguration(helper, vehicle);

                foreach (var kilometer in ReportObjectsList)
                {
                    AddItem(helper, kilometer);
                }

                AddTrendline(helper, vehicle);

                return(helper.BuildXml());
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Gets the graph XML file.
        /// </summary>
        /// <returns></returns>
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                var hs = ReportObjectsList.Sum(d => d.ElapsedTime);
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel(MovilDesdeHasta),
                                                               ddlMovil.SelectedItem.Text.Replace('&', 'y'),
                                                               dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(),
                                                               dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString())
                                      + TimeSpan.FromSeconds(hs).TotalHours.ToString(" - 0.00 hs")
                                      );

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "hs");
                helper.AddConfigEntry("limitsDecimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", "-");
                helper.AddConfigEntry("rotateNames", "1");

                foreach (var timer in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    if (!timer.Fecha.DayOfWeek.Equals(DayOfWeek.Saturday) & !timer.Fecha.DayOfWeek.Equals(DayOfWeek.Sunday))
                    {
                        item.AddPropertyValue("color", "008ED6");
                    }

                    item.AddPropertyValue("name", String.Format("{0:dd/MM}", timer.Fecha));
                    item.AddPropertyValue("value", (timer.ElapsedTime / 3600.0).ToString(CultureInfo.InvariantCulture));
                    item.AddPropertyValue("hoverText", string.Concat(TimeSpan.FromSeconds(timer.ElapsedTime).ToString(), " "));

                    item.AddPropertyValue("link", Server.UrlEncode(string.Format(
                                                                       "n-{0}Monitor/MonitorHistorico/monitorHistorico.aspx?Planta={1}&TypeMobile={2}&Movil={3}&InitialDate={4}&FinalDate={5}&Empresa={6}", ApplicationPath,
                                                                       ddlPlanta.Selected, ddlTipoVehiculo.Selected, ddlMovil.Selected, timer.Fecha.ToDataBaseDateTime().ToString(CultureInfo.InvariantCulture),
                                                                       timer.Fecha.Add(new TimeSpan(23, 59, 59)).ToDataBaseDateTime().ToString(CultureInfo.InvariantCulture), ddlDistrito.Selected)));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 14
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                InitializeGraph(helper);

                for (var i = 0; i < ReportObjectsList.Count; i++)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("name", ReportObjectsList[i].Interno.Replace('&', 'y'));
                    item.AddPropertyValue("hoverText", ReportObjectsList[i].Interno.Replace('&', 'y'));
                    item.AddPropertyValue("value", HoursValue(i));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 15
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel(DesdeHasta), dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(), dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "hs");
                helper.AddConfigEntry("hoverCapSepChar", " - ");
                helper.AddConfigEntry("rotateNames", "1");

                if (ReportObjectsList.Select(r => r.ElapsedTime).Sum() == 0)
                {
                    helper.AddConfigEntry("yAxisMaxValue", "24");
                }

                foreach (var time in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("link", Server.UrlEncode(string.Format(
                                                                       "n-{0}Reportes/ControlDeAccesos/WorkedHours.aspx?Emp={1}&InitialDate={2}&FinalDate={3}", ApplicationPath,
                                                                       time.IdEmpleado, dpDesde.SelectedDate.GetValueOrDefault().ToString(CultureInfo.InvariantCulture),
                                                                       dpHasta.SelectedDate.GetValueOrDefault().ToString(CultureInfo.InvariantCulture))));

                    item.AddPropertyValue("color", "AFD8F8");

                    item.AddPropertyValue("name", time.Empleado);

                    item.AddPropertyValue("value", time.ElapsedTime.ToString(CultureInfo.InvariantCulture));

                    var hours = TimeSpan.FromHours(time.ElapsedTime);

                    item.AddPropertyValue("hoverText", string.Concat(time.Empleado, string.Format(" - {0}dd {1}hh {2}mm {3}ss", hours.Days,
                                                                                                  hours.Hours, hours.Minutes, hours.Seconds)));
                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 16
0
        private string GetGraphXmlHoras(DateTime fecha)
        {
            var desde = fecha.ToDataBaseDateTime();
            var hasta = desde.AddDays(1).AddSeconds(-1);

            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", "HORAS");
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                _horas.Clear();

                for (var i = 0; i < 24; i++)
                {
                    var fechaDesde = desde.AddHours(i).AddSeconds(-1);
                    var fechaHasta = fechaDesde.AddHours(1);

                    var valor = GetValorMedicion(fechaDesde, fechaHasta);

                    _horas.Add(i.ToString("#0"), valor);
                }

                foreach (var pair in _horas)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "FF5904");
                    item.AddPropertyValue("name", pair.Key);
                    item.AddPropertyValue("value", pair.Value.ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                return(helper.BuildXml());
            }
        }
Exemplo n.º 17
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("EMPLEADO_DESDE_HASTA"), ddlEmpleado.SelectedItem.Text, dpDesde.SelectedDate.GetValueOrDefault().ToShortDateString(),
                                                               dpHasta.SelectedDate.GetValueOrDefault().ToShortDateString()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("numberSuffix", "hs");
                helper.AddConfigEntry("limitsDecimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", "-");
                helper.AddConfigEntry("rotateNames", "1");
                helper.AddConfigEntry("yAxisMaxValue", "24");

                foreach (var timer in ReportObjectsList)
                {
                    var item = new FusionChartsItem();

                    if (!timer.Fecha.DayOfWeek.Equals(DayOfWeek.Saturday) & !timer.Fecha.DayOfWeek.Equals(DayOfWeek.Sunday))
                    {
                        item.AddPropertyValue("color", "008ED6");
                    }

                    item.AddPropertyValue("name", String.Format("{0:dd/MM}", timer.Fecha));
                    item.AddPropertyValue("value", timer.ElapsedTime > 0 ? timer.ElapsedTime.ToString(CultureInfo.InvariantCulture) : "0.000001");
                    item.AddPropertyValue("hoverText", string.Concat(TimeSpan.FromHours(timer.ElapsedTime).ToString(), "hs "));

                    item.AddPropertyValue("link", Server.UrlEncode(string.Format(
                                                                       "n-{0}Reportes/ControlDeAccesos/AccessControl.aspx?Emp={1}&InitialDate={2}&FinalDate={3}",
                                                                       ApplicationPath,
                                                                       ddlEmpleado.Selected, timer.Fecha.ToString(CultureInfo.InvariantCulture),
                                                                       timer.Fecha.AddDays(1).ToString(CultureInfo.InvariantCulture))));

                    helper.AddItem(item);
                }
                return(helper.BuildXml());
            }
        }
Exemplo n.º 18
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"),
                                                               dtFecha.SelectedDate.HasValue ? dtFecha.SelectedDate.Value.ToShortDateString() : DateTime.MinValue.ToShortDateString(),
                                                               dtFecha.SelectedDate.HasValue ? dtFecha.SelectedDate.Value.AddMonths(1).AddSeconds(-1).ToShortDateString() : DateTime.MinValue.ToShortDateString()));

                helper.AddConfigEntry("xAxisName", "MESES");
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                divChartDias.InnerHtml  = "";
                divChartHoras.InnerHtml = "";

                _meses.Clear();

                CargarAñoAnterior();
                CargarMesAnterior();
                CargarMesActual();

                var pb = new List <string>();

                foreach (var pair in _meses)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("link", "javascript:a(" + pb.Count + ")");
                    pb.Add(ClientScript.GetPostBackEventReference(btnMes, ""));

                    var split = pair.Key.Split('/');
                    var key   = GetMes(Convert.ToInt32(split[0])) + " " + split[1];

                    item.AddPropertyValue("color", "FF5904");
                    item.AddPropertyValue("name", key);
                    item.AddPropertyValue("value", pair.Value.ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                var hasta = dtFecha.SelectedDate.HasValue ? dtFecha.SelectedDate.Value.AddMonths(1).AddSeconds(-1) : DateTime.MinValue;
                var now   = DateTime.UtcNow;
                if (hasta.Year == now.Year && hasta.Month == now.Month && hasta > now)
                {
                    var promedio   = _meses[hasta.ToString("MM/yyyy")] / now.Day;
                    var proyectado = promedio * GetDiasMes(hasta.Month, hasta.Year);
                    var key        = CultureManager.GetLabel("PROYECTADO") + " " + GetMes(Convert.ToInt32(hasta.Month)) + " " + hasta.Year;

                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "FAB802");
                    item.AddPropertyValue("name", key);
                    item.AddPropertyValue("value", proyectado.ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                var script = "var pb =[" + string.Join(",", pb.Select(p => "\"" + p + "\"").ToArray())
                             + "]; function a(n) { document.getElementById('" + hidMes.ClientID + "').value = n; eval(pb[n]); }";

                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "a", script, true);
                return(helper.BuildXml());
            }
        }
Exemplo n.º 19
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                var desde = dtFechaDesde.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaDesde.SelectedDate.Value) : new DateTime();

                var hasta = dtFechaHasta.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaHasta.SelectedDate.Value) : new DateTime();

                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", XAxisLabel);
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                _despachos.Clear();
                var despachos = GetResults();
                var vehiculo  = DAOFactory.CocheDAO.FindById(cbVehiculo.Selected);
                var entidad   = DAOFactory.EntidadDAO.FindByDispositivo(new[] { vehiculo.Empresa != null ? vehiculo.Empresa.Id : -1 },
                                                                        new[] { vehiculo.Linea != null ? vehiculo.Linea.Id : -1 },
                                                                        new[] { vehiculo.Dispositivo != null ? vehiculo.Dispositivo.Id : -1 });
                var usaTelemetria = entidad != null && entidad.Id != 0;

                for (var i = 0; i < despachos.Count; i++)
                {
                    var    fecha         = despachos[i].Fecha.ToString("dd/MM/yy HH:mm");
                    var    totalDespacho = despachos[i].Cantidad;
                    var    fechaHasta    = i + 1 < despachos.Count ? despachos[i + 1].Fecha : hasta;
                    double totalConsumo;
                    double km;
                    double rendimiento;

                    if (usaTelemetria)
                    {
                        totalConsumo = DAOFactory.DatamartDAO.GetSummarizedDatamart(despachos[i].Fecha, fechaHasta, cbVehiculo.Selected).Consumo;
                    }
                    else
                    {
                        km          = DAOFactory.CocheDAO.GetDistance(vehiculo.Id, despachos[i].Fecha, fechaHasta);
                        rendimiento = vehiculo.CocheOperacion != null && vehiculo.CocheOperacion.Rendimiento > 0.0
                                          ? vehiculo.CocheOperacion.Rendimiento
                                          : vehiculo.Modelo != null
                                                ? vehiculo.Modelo.Rendimiento
                                                : 0.0;
                        totalConsumo = km > 0 && rendimiento > 0 ? (km / 100.0) * rendimiento : 0.0;
                    }

                    while (totalConsumo == 0 && i + 1 < despachos.Count && despachos[i].Fecha.AddMinutes(5) > despachos[i + 1].Fecha)
                    {
                        fecha          = despachos[i + 1].Fecha.ToString("dd/MM/yy HH:mm");
                        totalDespacho += despachos[i + 1].Cantidad;
                        fechaHasta     = i + 2 < despachos.Count ? despachos[i + 2].Fecha : hasta;

                        if (usaTelemetria)
                        {
                            totalConsumo += DAOFactory.DatamartDAO.GetSummarizedDatamart(despachos[i + 1].Fecha, fechaHasta, cbVehiculo.Selected).Consumo;
                        }
                        else
                        {
                            km          = DAOFactory.CocheDAO.GetDistance(vehiculo.Id, despachos[i + 1].Fecha, fechaHasta);
                            rendimiento = vehiculo.CocheOperacion != null && vehiculo.CocheOperacion.Rendimiento > 0.0
                                              ? vehiculo.CocheOperacion.Rendimiento
                                              : vehiculo.Modelo != null
                                                    ? vehiculo.Modelo.Rendimiento
                                                    : 0.0;
                            totalConsumo += km > 0 && rendimiento > 0 ? (km / 100.0) * rendimiento : 0.0;
                        }
                        i++;
                    }

                    _despachos.Add(fecha, new[] { totalDespacho, totalConsumo });
                }

                foreach (var pair in _despachos)
                {
                    var item = new FusionChartsItem();

                    item.AddPropertyValue("color", "AFD8F8");
                    item.AddPropertyValue("name", pair.Key);
                    item.AddPropertyValue("value", pair.Value[0].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);

                    item = new FusionChartsItem();

                    var color = usaTelemetria ? "FF5904" : "FAB802";

                    item.AddPropertyValue("color", color);
                    item.AddPropertyValue("value", pair.Value[1].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                lblLitrosCargados.Text = CultureManager.GetLabel("LITROS_CARGADOS");
                lblLitros.Text         = usaTelemetria ? CultureManager.GetLabel("LITROS_CONS") : CultureManager.GetLabel("LITROS_CALCULADOS");

                tdLitros.BgColor = usaTelemetria ? "FF5904" : "FAB802";

                pnlInferior.Visible = true;

                return(helper.BuildXml());
            }
        }
Exemplo n.º 20
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                InitializeGraph(helper);

                var previousDateIndex = 0; //for saving last date putted in graph

                for (var i = 0; i < ReportObjectsList.Count; i++)
                {
                    var item = new FusionChartsItem();

                    if (i == 0)
                    {
                        item.AddPropertyValue("name", ReportObjectsList[i].Fecha);
                    }
                    else
                    {
                        if ((DateTime.Parse(ReportObjectsList[previousDateIndex].Fecha).Minute
                             != DateTime.Parse(ReportObjectsList[i].Fecha).Minute) &&
                            ((i - previousDateIndex) > PointsDistance))  //filters minimum distance between dates (points in graph)
                        {
                            item.AddPropertyValue("name", DateTime.Parse(ReportObjectsList[i].Fecha).TimeOfDay.ToString());
                            previousDateIndex = i; //saves the index of the most recently date putted in graph
                        }
                    }
                    item.AddPropertyValue("hoverText", DateTime.Parse(ReportObjectsList[i].Fecha).TimeOfDay.ToString());
                    item.AddPropertyValue("value", ReportObjectsList[i].Valor.Replace(',', '.'));

                    helper.AddItem(item);
                }

                if (Subentidad > 0)
                {
                    var subentidad = DAOFactory.SubEntidadDAO.FindById(Subentidad);
                    if (subentidad != null && subentidad.Sensor != null &&
                        subentidad.Sensor.TipoMedicion != null && subentidad.Sensor.TipoMedicion.ControlaLimites)
                    {
                        if (subentidad.ControlaMaximo)
                        {
                            var topInterval = new FusionChartsTrendline();
                            topInterval.AddPropertyValue("value", subentidad.Maximo.ToString(CultureInfo.InvariantCulture));
                            topInterval.AddPropertyValue("color", "ED1C24");
                            helper.AddTrendLine(topInterval);
                        }
                        if (subentidad.ControlaMinimo)
                        {
                            var lowInterval = new FusionChartsTrendline();
                            lowInterval.AddPropertyValue("value", subentidad.Minimo.ToString(CultureInfo.InvariantCulture));
                            lowInterval.AddPropertyValue("color", "579657");
                            helper.AddTrendLine(lowInterval);
                        }
                    }
                }

                if (ReportObjectsList.Count.Equals(0))
                {
                    ThrowError("NO_MATCHES_FOUND");
                }

                return(helper.BuildXml());
            }
        }
Exemplo n.º 21
0
        private string GetGraphXmlDias(DateTime fecha)
        {
            var fechaSel = dtFechaDesde.SelectedDate.HasValue ? SecurityExtensions.ToDataBaseDateTime(dtFechaDesde.SelectedDate.Value) : DateTime.MinValue;
            var desde    = fecha.ToDataBaseDateTime() < fechaSel ? fechaSel : fecha.ToDataBaseDateTime();
            var fin      = new DateTime(desde.Year, desde.Month, 1, 23, 59, 59).AddMonths(1).AddDays(-1).ToDataBaseDateTime();
            var hasta    = dtFechaHasta.SelectedDate.HasValue && fin > SecurityExtensions.ToDataBaseDateTime(dtFechaHasta.SelectedDate.Value)
                            ? SecurityExtensions.ToDataBaseDateTime(dtFechaHasta.SelectedDate.Value)
                            : fin;

            using (var helper = new FusionChartsHelper())
            {
                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", "DIAS");
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                _dias.Clear();

                while (desde.ToDisplayDateTime().Day < hasta.ToDisplayDateTime().Day)
                {
                    fin = new DateTime(desde.Year, desde.Month, desde.Day, 23, 59, 59).ToDataBaseDateTime();

                    var valor            = GetValorMedicion(desde, fin, cbVehiculo.Selected);
                    var consumo          = GetValorConsumo(desde, fin, cbVehiculo.Selected);
                    var consumoCalculado = GetValorConsumoCalculado(desde, fin, cbVehiculo.Selected);

                    _dias.Add(desde.ToDisplayDateTime().ToString("dd/MM/yyyy"), new[] { valor, consumo, consumoCalculado });

                    desde = fin.AddSeconds(1);
                }

                if (desde.ToDisplayDateTime().Day == hasta.ToDisplayDateTime().Day)
                {
                    var valor            = GetValorMedicion(desde, hasta, cbVehiculo.Selected);
                    var consumo          = GetValorConsumo(desde, hasta, cbVehiculo.Selected);
                    var consumoCalculado = GetValorConsumoCalculado(desde, hasta, cbVehiculo.Selected);

                    _dias.Add(desde.ToDisplayDateTime().ToString("dd/MM/yyyy"), new[] { valor, consumo, consumoCalculado });
                }

                foreach (var pair in _dias)
                {
                    var item = new FusionChartsItem();
                    item.AddPropertyValue("color", "AFD8F8");
                    item.AddPropertyValue("name", pair.Key.Split('/')[0]);
                    item.AddPropertyValue("value", pair.Value[1].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);

                    item = new FusionChartsItem();
                    item.AddPropertyValue("color", "FF5904");
                    item.AddPropertyValue("value", pair.Value[0].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);

                    item = new FusionChartsItem();
                    item.AddPropertyValue("color", "FAB802");
                    item.AddPropertyValue("value", pair.Value[2].ToString(CultureInfo.InvariantCulture));

                    helper.AddItem(item);
                }

                lblLitrosCargados.Text   = CultureManager.GetLabel("LITROS_CARGADOS");
                lblLitrosConsumidos.Text = CultureManager.GetLabel("LITROS_CONS");
                lblLitrosCalculados.Text = CultureManager.GetLabel("LITROS_CALCULADOS");
                pnlInferior.Visible      = true;

                return(helper.BuildXml());
            }
        }
Exemplo n.º 22
0
        protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsHelper())
            {
                var desde = dtFechaDesde.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaDesde.SelectedDate.Value) : new DateTime();

                var hasta = dtFechaHasta.SelectedDate != null?SecurityExtensions.ToDataBaseDateTime(dtFechaHasta.SelectedDate.Value) : new DateTime();

                helper.AddConfigEntry("caption", string.Format(CultureManager.GetLabel("DESDE_HASTA"), desde.ToDisplayDateTime(), hasta.ToDisplayDateTime()));

                helper.AddConfigEntry("xAxisName", "MESES");
                helper.AddConfigEntry("yAxisName", YAxisLabel);
                helper.AddConfigEntry("decimalPrecision", "2");
                helper.AddConfigEntry("hoverCapSepChar", " - ");

                divChartDias.InnerHtml = "";
                _meses.Clear();

                if (desde < hasta)
                {
                    while (desde.ToDisplayDateTime().Month < hasta.ToDisplayDateTime().Month || desde.ToDisplayDateTime().Year < hasta.ToDisplayDateTime().Year)
                    {
                        var fin = new DateTime(desde.Year, desde.Month, 1, 23, 59, 59).AddMonths(1).AddDays(-1).ToDataBaseDateTime();

                        var valor            = GetValorMedicion(desde, fin, cbVehiculo.Selected);
                        var consumo          = GetValorConsumo(desde, fin, cbVehiculo.Selected);
                        var consumoCalculado = GetValorConsumoCalculado(desde, fin, cbVehiculo.Selected);

                        _meses.Add(desde.ToDisplayDateTime().ToString("MM/yyyy"), new[] { valor, consumo, consumoCalculado });

                        desde = fin.AddSeconds(1);
                    }

                    if (desde.ToDisplayDateTime().Month == hasta.ToDisplayDateTime().Month&& desde.ToDisplayDateTime().Year == hasta.ToDisplayDateTime().Year)
                    {
                        var valor            = GetValorMedicion(desde, hasta, cbVehiculo.Selected);
                        var consumo          = GetValorConsumo(desde, hasta, cbVehiculo.Selected);
                        var consumoCalculado = GetValorConsumoCalculado(desde, hasta, cbVehiculo.Selected);

                        _meses.Add(desde.ToDisplayDateTime().ToString("MM/yyyy"), new[] { valor, consumo, consumoCalculado });
                    }

                    var pb = new List <string>();

                    foreach (var pair in _meses)
                    {
                        var item = new FusionChartsItem();
                        item.AddPropertyValue("link", "javascript:a(" + pb.Count + ")");

                        item.AddPropertyValue("color", "AFD8F8");
                        item.AddPropertyValue("name", pair.Key.Split('/')[0]);
                        item.AddPropertyValue("value", pair.Value[1].ToString(CultureInfo.InvariantCulture));

                        helper.AddItem(item);

                        item = new FusionChartsItem();
                        item.AddPropertyValue("link", "javascript:a(" + pb.Count + ")");

                        item.AddPropertyValue("color", "FF5904");
                        item.AddPropertyValue("value", pair.Value[0].ToString(CultureInfo.InvariantCulture));

                        helper.AddItem(item);

                        item = new FusionChartsItem();
                        item.AddPropertyValue("link", "javascript:a(" + pb.Count + ")");
                        pb.Add(ClientScript.GetPostBackEventReference(btnMes, ""));

                        item.AddPropertyValue("color", "FAB802");
                        item.AddPropertyValue("value", pair.Value[2].ToString(CultureInfo.InvariantCulture));

                        helper.AddItem(item);
                    }

                    var script = "var pb =[" + string.Join(",", pb.Select(p => "\"" + p + "\"").ToArray())
                                 + "]; function a(n) { document.getElementById('" + hidMes.ClientID + "').value = n; eval(pb[n]); }";

                    System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "a", script, true);
                }

                lblLitrosCargados.Text   = CultureManager.GetLabel("LITROS_CARGADOS");
                lblLitrosConsumidos.Text = CultureManager.GetLabel("LITROS_CONS");
                lblLitrosCalculados.Text = CultureManager.GetLabel("LITROS_CALCULADOS");
                pnlInferior.Visible      = true;

                return(helper.BuildXml());
            }
        }