Пример #1
0
        protected void BtVerCercanosClick(object sender, EventArgs e)
        {
            var pos = SharedPositions.GetLastPositions(new List <Coche> {
                pageCoche
            }).FirstOrDefault();

            if (pos != null)
            {
                VehiculosCercanos(pageCoche, pos);
            }
            divCercanos.Visible     = true;
            spanVerCercanos.Visible = false;
        }
Пример #2
0
        protected void VehiculosCercanos(Coche vehiculo, LogUltimaPosicionVo posicion)
        {
            var vehiculos = DAOFactory.CocheDAO.GetList(IdsEmpresas, IdsLineas)
                            .Where(v => v.Dispositivo != null)
                            .ToList();
            var positions = SharedPositions.GetLastPositions(vehiculos);

            var distancias = from pos in positions
                             where pos.IdCoche != vehiculo.Id
                             select new VehiculoDistancia
            {
                Distancia = Distancias.Loxodromica(posicion.Latitud, posicion.Longitud, pos.Latitud, pos.Longitud),
                Id        = pos.IdCoche, Interno = pos.Coche
            };
            var cercanas = (from pos in distancias orderby pos.Distancia select pos).Take(5);

            gridMov.DataSource = cercanas;
            gridMov.DataBind();
        }
Пример #3
0
            private string GetLabelStyle(Coche coche, DAOFactory daoFactory)
            {
                var upm = SharedPositions.GetLastPositions(new List <Coche> {
                    coche
                }).FirstOrDefault();

                if (upm == null)
                {
                    return("ol_marker_labeled_red");
                }

                string style;

                if (upm.FechaMensaje >= DateTime.UtcNow.AddMinutes(-5))
                {
                    style = upm.Velocidad == 0 ? "ol_marker_labeled" : "ol_marker_labeled_green";
                }
                else
                {
                    style = upm.FechaMensaje >= DateTime.UtcNow.AddHours(-48) ? "ol_marker_labeled_yellow" : "ol_marker_labeled_red";
                }

                return(style);
            }
Пример #4
0
        void MonitorTick(object sender, MonitorEventArgs e)
        {
            if (Usuario == null)
            {
                return;
            }

            try
            {
                Monitor.TimerInterval    = 20;
                Monitor.CallbackArgument = DateTime.UtcNow.ToString();

                var count = 0;

                if (SelectedEntidades.Count > 0)
                {
                    foreach (var entidad in SelectedEntidades)
                    {
                        var style = GetMarkerStyle(entidad);

                        AddMarker(entidad, style);
                        count++;
                        if (SelectedEntidades.Count == 1)
                        {
                            Monitor.SetCenter(entidad.ReferenciaGeografica.Latitude, entidad.ReferenciaGeografica.Longitude);
                        }
                    }

                    if (SelectedMessages.Count > 0)
                    {
                        var selectedDispositivos = SelectedEntidades.Select(entidad => entidad.Dispositivo).ToList();

                        var popups = SharedPositions.GetNewPopupsM2M(selectedDispositivos, DAOFactory)
                                     .Where(p => SelectedMessages.Contains(p.CodigoMensaje));

                        var sonidos   = new List <string>();
                        var lastMsg   = LastMessage;
                        var newPopups = 0;
                        foreach (var popup in popups)
                        {
                            if (popup.Id > lastMsg)
                            {
                                Monitor.AddCallbackScript("AddEvent('" + GetMessageM2M(popup) + "');");
                                if (!string.IsNullOrEmpty(popup.Sound) &&
                                    !sonidos.Contains(Config.Directory.SoundsDir + popup.Sound))
                                {
                                    sonidos.Add(Config.Directory.SoundsDir + popup.Sound);
                                }
                                LastMessage = Math.Max(popup.Id, LastMessage);
                                newPopups++;
                            }
                        }
                        if (sonidos.Count > 0)
                        {
                            Monitor.AddCallbackScript("enqueueSounds(['" + string.Join("','", sonidos.ToArray()) + "']);");
                        }

                        if (newPopups > 0)
                        {
                            Monitor.AddCallbackScript("if(!PopupPanelOpen)ShowEvents();");
                        }
                    }
                }

                // Inserto un script personalizado que muestra un mensaje en pantalla
                Monitor.AddCallbackScript(string.Format("$get('{0}').innerHTML = '{1}';",
                                                        lblInfo.ClientID,
                                                        string.Format(CultureManager.GetSystemMessage("ONLINE_UPDATED_POSITIONS"),
                                                                      count,
                                                                      DateTime.UtcNow.ToDisplayDateTime().ToString("HH:mm:ss"))));
            }
            catch (Exception ex)
            {
                // Inserto un script personalizado que muestra el error en pantalla
                Monitor.AddCallbackScript(string.Format("$get('{0}').innerHTML = '{1}';", lblInfo.ClientID, ex.Message));
            }

            Monitor.AddCallbackScript("lastUpdate = new Date();");
        }
Пример #5
0
        protected void TimerGeocoderTick(object sender, EventArgs e)
        {
            if (LoadStep == 0)
            {
                // Paso 0: Direccion - Geocoder
                try
                {
                    var latlon = lblPosicion.Text.TrimStart('(').TrimEnd(')').Split(',');
                    var lat    = Convert.ToDouble(latlon[0].Trim(), CultureInfo.InvariantCulture);
                    var lon    = Convert.ToDouble(latlon[1].Trim(), CultureInfo.InvariantCulture);

                    lblPosicion.Text = GeocoderHelper.GetDescripcionEsquinaMasCercana(lat, lon);
                }
                catch
                {
                    lblPosicion.Text = "No se encontró posición.";
                }
                LoadStep = 1;
            }
            else if (LoadStep == 1)
            {
                // Paso 1: Ultimo Login
                var lastFrid = DAOFactory.LogUltimoLoginDAO.GetLastVehicleRfidEvent(pageCoche);
                if (lastFrid != null)
                {
                    var chofer = lastFrid.Chofer ?? CultureManager.GetLabel("REVISAR_TARJETA");
                    lblLastRfid.Text = string.Format("{0} ({1})", chofer, lastFrid.Fecha.Value.ToDisplayDateTime());
                }
                divUltimoLogin.Visible = lastFrid != null;
                LoadStep = 2;
            }
            else if (LoadStep == 2)
            {
                // Paso 2: Solapa Ticket
                LoadTicket(pageCoche);
                LoadStep = 3;
            }
            else if (LoadStep == 3)
            {
                // Paso 3: Trabajando para... Clientes
                lblClientes.Text    = pageCoche.Clientes.Cast <Cliente>().Aggregate(String.Empty, (current, c) => String.Concat(current, c.DescripcionCorta));
                divClientes.Visible = !string.IsNullOrEmpty(lblClientes.Text);
                LoadStep            = 4;
            }
            else if (LoadStep == 4)
            {
                // Paso 4: Vehiculos Cercanos
                var pos = SharedPositions.GetLastPositions(new List <Coche> {
                    pageCoche
                }).FirstOrDefault();
                if (pos != null)
                {
                    VehiculosCercanos(pageCoche, pos);
                }
                LoadStep = 5;
            }
            else if (LoadStep == 5)
            {
                // Paso 5: Solapa Rutaa
                LoadRuta(pageCoche);
                timerGeocoder.Enabled = false;
            }
        }