Ejemplo n.º 1
0
        protected override void OnRowDataBound(C1GridView grid, C1GridViewRowEventArgs e, TolvaTourVo dataItem)
        {
            var vehiculo = DAOFactory.CocheDAO.FindById(dataItem.IdVehiculo);

            var posInicio = new GPSPoint(dataItem.EntradaHora, (float)dataItem.LatitudInicio, (float)dataItem.LongitudInicio);
            var posFin    = new GPSPoint(dataItem.SalidaHora, (float)dataItem.LatitudFin, (float)dataItem.LongitudFin);

            var estadoInicio = GeocercaManager.CalcularEstadoVehiculo(vehiculo, posInicio, DAOFactory);
            var estadoFin    = GeocercaManager.CalcularEstadoVehiculo(vehiculo, posFin, DAOFactory);

            var geocerca = estadoInicio.GeocercasDentro.Intersect(estadoFin.GeocercasDentro).FirstOrDefault();
            var text     = geocerca != null
                ? geocerca.Geocerca.Descripcion
                : GeocoderHelper.GetDescripcionEsquinaMasCercana(dataItem.LatitudInicio, dataItem.LongitudInicio);

            e.Row.Cells[TolvaTourVo.Index.Ubicacion].Text = text;
            if (dataItem.Entrada == DateTime.MinValue)
            {
                e.Row.Cells[TolvaTourVo.Index.Entrada].Text     = "";
                e.Row.Cells[TolvaTourVo.Index.EntradaHora].Text = "";
            }
            if (dataItem.Salida == DateTime.MinValue)
            {
                e.Row.Cells[TolvaTourVo.Index.Salida].Text     = "";
                e.Row.Cells[TolvaTourVo.Index.SalidaHora].Text = "";
            }
        }
Ejemplo n.º 2
0
        private void ProcessConfirmacionUbox(string code, Event generico, GPSPoint point)
        {
            var extraText    = string.Empty;
            var distribucion = DaoFactory.ViajeDistribucionDAO.FindEnCurso(Coche);

            if (distribucion != null)
            {
                var estado   = GeocercaManager.CalcularEstadoVehiculo(Coche, point, DaoFactory);
                var detalles = distribucion.Detalles.Where(d => estado.GeocercasDentro.Select(g => g.Geocerca.Id).Contains(d.ReferenciaGeografica.Id));

                var conEntrada = detalles.Where(d => d.Entrada.HasValue && !d.Manual.HasValue)
                                 .OrderBy(d => d.Entrada.Value);

                detalles = conEntrada.Any() ? conEntrada : detalles.Where(d => !d.Manual.HasValue);

                var detalle = detalles.Any() ? detalles.First() : null;

                if (detalle != null)
                {
                    DaoFactory.Session.Refresh(detalle);

                    extraText      = " (" + detalle.Orden + ") -> " + detalle.Viaje.Codigo + " - " + detalle.Descripcion;
                    detalle.Estado = generico.GetData().ToString("#0") == MessageCode.TareaRealizada.GetMessageCode() ? EntregaDistribucion.Estados.Completado : EntregaDistribucion.Estados.NoCompletado;
                    detalle.Manual = generico.GetDateTime();
                    DaoFactory.EntregaDistribucionDAO.SaveOrUpdate(detalle);
                }
            }

            var textoEvento = ExtraText.GetExtraText(generico, code) + extraText;
            var chofer      = GetChofer(generico.GetRiderId());

            MessageSaver.Save(generico, code, Dispositivo, Coche, chofer, generico.GetDateTime(), generico.GeoPoint, textoEvento, ZonaManejo);
            MessageSaver.Save(MessageCode.EstadoLogisticoCumplidoManual.GetMessageCode(), Coche, chofer, generico.GetDateTime(), generico.GeoPoint, textoEvento);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Process the givenn message as a VelocidadExcedida event.
        /// </summary>
        /// <param name="velocidadExcedida">A message.</param>
        private HandleResults ProcessVelocidadExcedidaEvent(SpeedingTicket velocidadExcedida)
        {
            var inicio = velocidadExcedida.StartPoint ?? velocidadExcedida.TicketPoint;

            if (IsInvalidVelocidadExcedidaMessage(inicio, velocidadExcedida))
            {
                return(HandleResults.BreakSuccess);
            }

            var texto              = GetVelocidadExcedidaText(velocidadExcedida);
            var chofer             = GetChofer(velocidadExcedida.GetRiderId());
            var velocidadPermitida = Convert.ToInt32(velocidadExcedida.SpeedLimit);
            var velocidadAlcanzada = Convert.ToInt32(velocidadExcedida.SpeedReached);
            var estado             = GeocercaManager.CalcularEstadoVehiculo(Coche, inicio, DaoFactory);
            var zona = estado != null && estado.ZonaManejo != null && estado.ZonaManejo.ZonaManejo > 0
                    ? DaoFactory.ZonaDAO.FindById(estado.ZonaManejo.ZonaManejo) : null;

            if (Coche.Empresa.AsignoInfraccionPorAgenda)
            {
                var reserva = DaoFactory.AgendaVehicularDAO.FindByVehicleAndDate(Coche.Id, inicio.Date);
                if (reserva != null)
                {
                    chofer = reserva.Empleado;
                }
            }

            var evento = MessageSaver.Save(velocidadExcedida, MessageCode.SpeedingTicket.GetMessageCode(), Dispositivo, Coche, chofer, inicio.Date, inicio, velocidadExcedida.EndPoint, texto, velocidadPermitida, velocidadAlcanzada, null, zona);

            var infraccion = new Infraccion
            {
                Vehiculo         = Coche,
                Alcanzado        = velocidadAlcanzada,
                CodigoInfraccion = Infraccion.Codigos.ExcesoVelocidad,
                Empleado         = evento.Chofer,
                Fecha            = inicio.Date,
                Latitud          = inicio.Lat,
                Longitud         = inicio.Lon,
                FechaFin         = velocidadExcedida.EndPoint.Date,
                LatitudFin       = velocidadExcedida.EndPoint.Lat,
                LongitudFin      = velocidadExcedida.EndPoint.Lon,
                Permitido        = velocidadPermitida,
                Zona             = zona,
                FechaAlta        = DateTime.UtcNow
            };

            DaoFactory.InfraccionDAO.Save(infraccion);

            return(HandleResults.Success);
        }
Ejemplo n.º 4
0
        protected override HandleResults OnDeviceHandleMessage(Event message)
        {
            //STrace.Debug(typeof(Events).FullName, message.DeviceId, "OnDeviceHandleMessage (EventsHandler)");

            AdjustRfidData(message);
            var code = GetGenericEventCode(message);

            STrace.Debug(typeof(Events).FullName, message.DeviceId, String.Format("code:{0} Subcode:{1}", code, message.GetData()));

            #region protect garmin on/off messages from be banned because of invalid date

            if ((code == MessageCode.GarminOn.GetMessageCode() || code == MessageCode.GarminOff.GetMessageCode()) && message.GeoPoint != null && FechaInvalida(message.GeoPoint.Date, DeviceParameters))
            {
                message.GeoPoint.Date = DateTime.UtcNow;
            }

            #endregion protect garmin on/off messages from be banned because of invalid date

            //if (IsGarbageMessage(code))
            //{
            //    return HandleResults.BreakSuccess;
            //}

            if (IsInvalidMessage(code, message))
            {
                return(HandleResults.BreakSuccess);
            }

            ExtraText = new ExtraText(DaoFactory);

            if (MessageIdentifierX.IsEntityMessage(code))
            {
                ProcessEntityEvent(message, code);
            }
            else if (Coche != null)
            {
                var estado = GeocercaManager.CalcularEstadoVehiculo(Coche, message.GeoPoint, DaoFactory);
                ZonaManejo = estado != null && estado.ZonaManejo != null && estado.ZonaManejo.ZonaManejo > 0
                    ? DaoFactory.ZonaDAO.FindById(estado.ZonaManejo.ZonaManejo) : null;
                ProcessEvent(code, message);
                ProcessPosition(message);
            }

            return(HandleResults.Success);
        }