protected override string GetGraphXml()
        {
            using (var helper = new FusionChartsMultiSeriesHelper())
            {
                if (ReportObjectsList.Count <= 0)
                {
                    throw new Exception("No se encontraron datos asociados a los filtros seleccionados!");
                }

                SetGraphProperties(helper);

                AddDates(helper);

                var maxTurnos = ReportObjectsList.Select(res => res.HsTurnos.Count).Max();

                var colorGenerator = new ColorGenerator();
                FusionChartsDataset niveles;

                for (var i = 0; i < maxTurnos; i++)
                {
                    niveles = new FusionChartsDataset();
                    niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(colorGenerator.GetNextColor()));

                    foreach (var dia in ReportObjectsList)
                    {
                        if (dia.HsTurnos.Count > 1)
                        {
                            niveles.addValue(dia.HsTurnos.First().ToString(CultureInfo.InvariantCulture));
                            dia.HsTurnos.Remove(dia.HsTurnos.First());
                            niveles.addValue(dia.HsReales.First().ToString(CultureInfo.InvariantCulture));
                            dia.HsReales.Remove(dia.HsReales.First());
                            niveles.addValue("0");
                        }
                        else
                        if (dia.HsTurnos.Count == 1)
                        {
                            niveles.addValue("0");
                            niveles.addValue("0");
                            niveles.addValue("0");
                        }
                    }
                    helper.AddDataSet(niveles);
                }

                niveles = new FusionChartsDataset();
                niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(Color.Gray));
                niveles.SetPropertyValue("seriesName", "Fuera de Turno");
                foreach (var dia in ReportObjectsList)
                {
                    niveles.addValue(dia.HsTurnos.First().ToString(CultureInfo.InvariantCulture));
                    niveles.addValue(dia.HsReales.First().ToString(CultureInfo.InvariantCulture));
                    niveles.addValue("0");
                }
                helper.AddDataSet(niveles);

                return(helper.BuildXml());
            }
        }
示例#2
0
        protected override string GetGraphXml()
        {
            ToogleItems(lbBase);

            using (var helper = new FusionChartsMultiSeriesHelper())
            {
                SetGraphConfiguration(helper);

                var iniDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault());
                var finDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault()).AddHours(23).AddMinutes(59).AddSeconds(59);
                var colorGen = new ColorGenerator();

                var noCategoriesAdded = true;
                var hasValue          = false;
                if (lbBase.GetSelectedIndices().Length == 0)
                {
                    lbBase.ToogleItems();
                }

                foreach (var index in lbBase.GetSelectedIndices())
                {
                    var data = ReportFactory.IdleTimesDAO.GetAllMovilesStoppedInPlanta(Convert.ToInt32((string)lbBase.Items[index].Value),
                                                                                       iniDate, finDate, chkUndefined.Checked);

                    var dataset = new FusionChartsDataset {
                        Name = lbBase.Items[index].Text
                    };
                    dataset.SetPropertyValue("SeriesName", lbBase.Items[index].Text);
                    dataset.SetPropertyValue("color", HexColorUtil.ColorToHex(colorGen.GetNextColor()));

                    foreach (var item in data)
                    {
                        if (noCategoriesAdded)
                        {
                            helper.AddCategory(item.Date.ToShortTimeString());
                        }
                        dataset.addValue(item.TotalVehicles.ToString(CultureInfo.InvariantCulture));
                        if (!item.TotalVehicles.Equals(0))
                        {
                            hasValue = true;
                        }
                    }

                    helper.AddDataSet(dataset);
                    noCategoriesAdded = false;
                }

                if (!hasValue)
                {
                    throw new Exception(CultureManager.GetError("NO_MOBILE_IN_BASE"));
                }

                return(helper.BuildXml());
            }
        }
        /// <summary>
        /// Adds engine average consumption refference line.
        /// </summary>
        /// <param name="helper"></param>
        private void AddEnginesConsumptionTrendline(FusionChartsMultiSeriesHelper helper)
        {
            var trendline = new FusionChartsTrendline();

            var avgConsumption = (from nivel in ReportObjectsList select nivel.Consumo).Average();

            trendline.AddPropertyValue("startValue", string.Format("{0}", (int)avgConsumption));
            trendline.AddPropertyValue("displayValue", string.Format("{0}: {1}lit", CultureManager.GetLabel("CONSUMO"), (int)avgConsumption));
            trendline.AddPropertyValue("color", HexColorUtil.ColorToHex(Color.LightCoral));
            trendline.AddPropertyValue("thickness", "3");

            helper.AddTrendLine(trendline);
        }
示例#4
0
        /// <summary>
        /// Searchs result positions to be displayed.
        /// </summary>

        /*private void SearchPositions()
         * {
         *  var route = DAOFactory.RoutePositionDAO.GetPositions(Mobile, InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime());
         *
         *  if (route.Count == 0)
         *  {
         *      ShowInfo("No se encontraron posiciones para los parametros de busqueda ingresados!");
         *
         *      return;
         *  }
         *
         *  var pos = "[";
         *
         *  for (var i = 0; i < route.Count; i++)
         *  {
         *      var dist = i == route.Count - 1 ? 0 : Distancias.Loxodromica(route[i].Latitude, route[i].Longitude, route[i + 1].Latitude, route[i + 1].Longitude);
         *
         *      var duration = i == route.Count - 1 ? 0 : route[i + 1].Date.Subtract(route[i].Date).TotalSeconds;
         *
         *      if (i > 0) pos = string.Concat(pos, ',');
         *
         *      pos = string.Concat(pos, string.Format("{{lon: {0}, lat: {1}, speed: {2}, distance: {3}, duration: {4}, time: new Date{5}}}",
         *          route[i].Longitude.ToString(CultureInfo.InvariantCulture), route[i].Latitude.ToString(CultureInfo.InvariantCulture), route[i].Speed,
         *          dist.ToString(CultureInfo.InvariantCulture), duration.ToString(CultureInfo.InvariantCulture), route[i].Date.ToString("(yyyy, MM, dd, HH, mm, ss)")));
         *  }
         *
         *  pos = string.Concat(pos, "]");
         *
         *  System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "route", string.Format("simulador.createRoute({0});", pos), true);
         * }
         */
        private void SearchPositions()
        {
            var colorGenerator = new ColorGenerator(new List <Color> {
                Color.Red, Color.Blue, Color.Green, Color.Orange, Color.Violet, Color.Cyan, Color.Purple
            });
            var empresa   = DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected);
            var maxMonths = empresa != null && empresa.Id > 0 ? empresa.MesesConsultaPosiciones : 3;

            var route = DAOFactory.RoutePositionsDAO.GetPositionsByRoute(Mobile, InitialDate.ToDataBaseDateTime(), FinalDate.ToDataBaseDateTime(), TimeSpan.Zero, maxMonths);

            if (route.Count == 0)
            {
                ShowInfo("No se encontraron posiciones para los parametros de busqueda ingresados!");

                return;
            }

            var pos = "[";

            for (var j = 0; j < route.Count; j++)
            {
                var tramo = route[j];
                var color = HexColorUtil.ColorToHex(colorGenerator.GetNextColor(j)).Substring(1);
                color = color.Substring(4, 2) + color.Substring(2, 2) + color.Substring(0, 2);
                for (var i = 0; i < tramo.Count; i++)
                {
                    var posicion = tramo[i];
                    var next     = i == tramo.Count - 1
                                   ? j == route.Count - 1 ? null : route[j + 1][0]
                                   : tramo[i + 1];
                    var dist = next == null ? 0 : Distancias.Loxodromica(posicion.Latitude, posicion.Longitude, next.Latitude, next.Longitude);

                    var duration = next == null ? 0 : next.Date.Subtract(posicion.Date).TotalSeconds;

                    if (j > 0 || i > 0)
                    {
                        pos = string.Concat(pos, ',');
                    }

                    pos = string.Concat(pos, string.Format("{{lon: {0}, lat: {1}, speed: {2}, distance: {3}, duration: {4}, time: new Date{5}, 'color': '{6}' }}",
                                                           posicion.Longitude.ToString(CultureInfo.InvariantCulture), posicion.Latitude.ToString(CultureInfo.InvariantCulture), posicion.Speed,
                                                           dist.ToString(CultureInfo.InvariantCulture), duration.ToString(CultureInfo.InvariantCulture), posicion.Date.ToDisplayDateTime().ToString("(yyyy, MM, dd, HH, mm, ss)"), color));
                }
            }
            pos = string.Concat(pos, "]");

            var startflag = CreateAbsolutePath("~/images/salida.png");
            var endflag   = CreateAbsolutePath("~/images/llegada.png");

            System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "route", string.Format("simulador.createRoute({0},'{1}','{2}');", pos, startflag, endflag), true);
        }
        /// <summary>
        /// Adds tank level variation.
        /// </summary>
        /// <param name="helper"></param>
        private void AddEnginesCaudal(FusionChartsMultiSeriesHelper helper)
        {
            var niveles = new FusionChartsDataset();

            var avgCaudal = (from nivel in ReportObjectsList select nivel.Caudal).Average();

            niveles.SetPropertyValue("seriesName", string.Format("{0}: {1}lit", CultureManager.GetLabel("CAUDAL"), (int)avgCaudal));
            niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(Color.SteelBlue));

            foreach (var nivel in ReportObjectsList)
            {
                niveles.addValue(nivel.Caudal.ToString(CultureInfo.InvariantCulture));
            }
            helper.AddDataSet(niveles);
        }
示例#6
0
        /// <summary>
        /// Gets the graph XML file.
        /// </summary>
        /// <returns></returns>
        protected override string GetGraphXml()
        {
            var datasets = new List <FusionChartsDataset>();

            using (var helper = new FusionChartsMultiSeriesHelper())
            {
                SetGraphProperties(helper);
                var flag = true;

                var colores = new ColorGenerator();

                foreach (var m in _horas.Keys)
                {
                    var horas       = new FusionChartsDataset();
                    var descripcion = DAOFactory.CaudalimetroDAO.FindById(m).Descripcion;
                    horas.SetPropertyValue("seriesName", descripcion);
                    horas.SetPropertyValue("color", HexColorUtil.ColorToHex(colores.GetNextColor()));
                    var list = _horas[m];

                    if (list.Count.Equals(0))
                    {
                        continue;
                    }

                    foreach (var h in list)
                    {
                        if (flag)
                        {
                            helper.AddCategory(h.Fecha.ToShortDateString());
                        }
                        horas.addValue(h.HsEnMarcha.ToString(CultureInfo.InvariantCulture));
                    }
                    flag = false;
                    helper.AddDataSet(horas);
                    datasets.Add(horas);
                }
                var categories = new List <string>();
                categories.AddRange(helper.GetCategoriesList());
                GraphCategories = categories;
                GraphDataSet    = datasets;
                return(helper.BuildXml());
            }
        }
示例#7
0
        protected override void GetGraphCategoriesAndDatasets()
        {
            var datasets   = new List <FusionChartsDataset>();
            var categories = new List <string>();

            var iniDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault());
            var finDate  = SecurityExtensions.ToDataBaseDateTime(dtpDate.SelectedDate.GetValueOrDefault()).AddHours(23).AddMinutes(59).AddSeconds(59);
            var colorGen = new ColorGenerator();

            var noCategoriesAdded = true;

            if (lbBase.GetSelectedIndices().Length == 0)
            {
                lbBase.ToogleItems();
            }

            foreach (var index in lbBase.GetSelectedIndices())
            {
                var data = ReportFactory.IdleTimesDAO.GetAllMovilesStoppedInPlanta(Convert.ToInt32((string)lbBase.Items[index].Value),
                                                                                   iniDate, finDate, chkUndefined.Checked);

                var dataset = new FusionChartsDataset {
                    Name = lbBase.Items[index].Text
                };
                dataset.SetPropertyValue("color", HexColorUtil.ColorToHex(colorGen.GetNextColor()));

                foreach (var item in data)
                {
                    if (noCategoriesAdded)
                    {
                        categories.Add(item.Date.ToShortTimeString());
                    }
                    dataset.addValue(item.TotalVehicles.ToString(CultureInfo.InvariantCulture));
                }

                datasets.Add(dataset);
                noCategoriesAdded = false;
            }

            GraphCategories = categories;
            GraphDataSet    = datasets;
        }
示例#8
0
 private string SerializeQtree(QLeaf x, double hres, double vres)
 {
     return
         (string.Format("{{'id':'{0}','lon':{1},'lat':{2},'hres':{3},'vres':{4},'color':'{5}'}}",
                        x.Index.Y.ToString() + "-" + x.Index.X.ToString(),
                        x.Posicion.Longitud.ToString(CultureInfo.InvariantCulture),
                        x.Posicion.Latitud.ToString(CultureInfo.InvariantCulture),
                        hres.ToString(CultureInfo.InvariantCulture),
                        vres.ToString(CultureInfo.InvariantCulture),
                        System.Web.HttpUtility.JavaScriptStringEncode(HexColorUtil.ColorToHex(BaseQtree.GetColorForLevel(x.Valor)))
                        ).Replace("'", "\""));
     //return string.Format("{{ \"id\": '{0}{1}', \"lon\": {2}, \"lat\": {3}, \"hres\": {4}, \"vres\": {5}, \"color\": \"{6}\" }}",
     //    x.Index.Y,
     //    x.Index.X,
     //    x.Posicion.Longitud.ToString(CultureInfo.InvariantCulture),
     //    x.Posicion.Latitud.ToString(CultureInfo.InvariantCulture),
     //    hres.ToString(CultureInfo.InvariantCulture),
     //    vres.ToString(CultureInfo.InvariantCulture),
     //    HexColorUtil.ColorToHex(BaseQtree.GetColorForLevel(x.Valor))
     //    );
 }
示例#9
0
        /// <summary>
        /// Adds tank level variation.
        /// </summary>
        /// <param name="helper"></param>
        private void AddTankLevelVariation(FusionChartsMultiSeriesHelper helper)
        {
            var niveles = new FusionChartsDataset();

            var labelInterval = (ReportObjectsList.Count / _MAX_LABELS) + 1;
            var i             = labelInterval;

            int resto;

            Math.DivRem(Convert.ToInt32(npIntervalo.Value), 1440, out resto);
            var printOnlyDate = resto.Equals(0);

            niveles.SetPropertyValue("seriesName", ddlTanque.SelectedItem.Text);
            niveles.SetPropertyValue("color", HexColorUtil.ColorToHex(Color.SteelBlue));

            if (ReportObjectsList.Any(o => o.VolumenConsumido > 0.01))
            {
                foreach (var nivel in ReportObjectsList)
                {
                    var str = string.Empty;

                    if (i.Equals(labelInterval))
                    {
                        str = printOnlyDate ? String.Format("{0}", nivel.Fecha.ToShortDateString()) :
                              String.Format("{0} - {1}", nivel.Fecha.ToShortDateString(), nivel.Fecha.ToShortTimeString());

                        i = 0;
                    }

                    i++;

                    helper.AddCategory(str);

                    niveles.addValue(nivel.VolumenConsumido.ToString(CultureInfo.InvariantCulture));
                }
            }
            helper.AddDataSet(niveles);
        }
示例#10
0
        protected override void OnSave()
        {
            EditObject.Descripcion      = txtDescripcion.Text;
            EditObject.PorKm            = chkPorKm.Checked;
            EditObject.PorTiempo        = chkPorTiempo.Checked;
            EditObject.PorHoras         = chkPorHoras.Checked;
            EditObject.EsIterativo      = chkEsIterativo.Checked;
            EditObject.EsReseteable     = chkReseteable.Checked;
            EditObject.ReferenciaKm     = EditObject.PorKm ? npKilometrosReferencia.Value: 0;
            EditObject.ReferenciaTiempo = EditObject.PorTiempo ? (int)npDiasReferencia.Value : 0;
            EditObject.ReferenciaHoras  = EditObject.PorHoras ? (int)npHorasReferencia.Value : 0;

            EditObject.Alarma1Km     = EditObject.PorKm ? npKmAlarma1.Value : 0;
            EditObject.Alarma1Tiempo = EditObject.PorTiempo ? (int)npDiasAlarma1.Value: 0;
            EditObject.Alarma1Horas  = EditObject.PorHoras ? (int)npHorasAlarma1.Value : 0;
            EditObject.Alarma1RGB    = !string.IsNullOrEmpty(txtColorAlarma1.Color) ? txtColorAlarma1.Color : HexColorUtil.ColorToHex(Color.White).TrimStart('#');

            EditObject.Alarma2Km     = EditObject.PorKm ? npKmAlarma2.Value: 0;
            EditObject.Alarma2Tiempo = EditObject.PorTiempo ?(int)npDiasAlarma2.Value: 0;
            EditObject.Alarma2Horas  = EditObject.PorHoras ? (int)npHorasAlarma2.Value : 0;
            EditObject.Alarma2Rgb    = !string.IsNullOrEmpty(txtColorAlarma2.Color) ? txtColorAlarma2.Color : HexColorUtil.ColorToHex(Color.White).TrimStart('#');

            var linea   = ddlBase.Selected > 0 ? DAOFactory.LineaDAO.FindById(ddlBase.Selected) : null;
            var empresa = ddlDistrito.Selected > 0 ? DAOFactory.EmpresaDAO.FindById(ddlDistrito.Selected) : linea != null ? linea.Empresa : null;

            EditObject.Empresa = empresa;
            EditObject.Linea   = linea;
            EditObject.Insumo  = cbInsumos.Selected > 0 ? DAOFactory.InsumoDAO.FindById(cbInsumos.Selected) : null;

            var usuario = DAOFactory.UsuarioDAO.FindById(Usuario.Id);

            if (ddclTipos.SelectedValues.Contains(-1))
            {
                ddclTipos.ToogleItems();
            }

            RefreshOdometerVehicleTypes();

            DAOFactory.OdometroDAO.SaveOrUpdate(EditObject, (IEnumerable <int>)VehiculoListBox.SelectedValues, usuario);
        }
示例#11
0
 /// <summary>
 /// Gets a point style for the givenn color.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static string GetPointFromColor(Color color)
 {
     return(string.Format("{{strokeColor: '{0}', fillColor: '{0}', fillOpacity: 0.5}}", HexColorUtil.ColorToHex(color)));
 }
示例#12
0
 public static string GetDottedLineFromColor(Color color, int size, double opacity)
 {
     return(string.Concat("{strokeColor: '", HexColorUtil.ColorToHex(color), "', strokeWidth: " + size + ", strokeDashstyle: 'dot', strokeOpacity: " + opacity.ToString("0.0", CultureInfo.InvariantCulture) + "}"));
 }
示例#13
0
 public static string GetDottedLineFromColor(Color color)
 {
     return(string.Concat("{strokeColor: '", HexColorUtil.ColorToHex(color), "', strokeWidth: 4, strokeDashstyle: 'dot'}"));
 }
示例#14
0
 /// <summary>
 /// Gets a line style for the givenn color.
 /// </summary>
 /// <param name="color"></param>
 /// <returns></returns>
 public static string GetLineFromColor(Color color)
 {
     return(string.Concat("{strokeColor: '", HexColorUtil.ColorToHex(color), "', strokeWidth: 4}"));
 }
示例#15
0
 public static string GetPolygonFromColor(Color backColor, Color borderColor)
 {
     return(string.Format("{{strokeColor: '{0}', fillColor: '{0}', fillOpacity: 0.5, strokeColor: '{1}', strokeWidth: 1}}", HexColorUtil.ColorToHex(backColor), HexColorUtil.ColorToHex(borderColor)));
 }