public override IEventModel CreateNewDataModel()
        {
            Route      nwRoute      = new Route(0, 0, null, null);
            RouteEvent nwRouteEvent = new RouteEvent(nwRoute);

            return(nwRouteEvent);
        }
 public static List <uint> GetParams(RouteEvent routeEvent)
 {
     return(new List <uint>()
     {
         routeEvent.Param1, routeEvent.Param2, routeEvent.Param3, routeEvent.Param4, routeEvent.Param5, routeEvent.Param6, routeEvent.Param7, routeEvent.Param8, routeEvent.Param9, routeEvent.Param10
     });
 }
        public async Task <IActionResult> PutRouteEvent([FromRoute] int id, [FromBody] RouteEvent routeEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != routeEvent.Id)
            {
                return(BadRequest());
            }

            routeEvent.UpdatedAt = DateTimeOffset.Now;

            _context.Entry(routeEvent).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RouteEventExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok(_context.RouteEvents.Find(id)));
        }
Example #4
0
        /// <summary>
        /// Create a RouteEvent.
        /// </summary>
        /// <param name="data">Parameters of the RouteEvent to construct.</param>
        /// <param name="getEventTypeHash">Function to get the StrCode32 hash of a RouteEvent's type.</param>
        /// <returns>The constructed RouteEvent.</returns>
        private static FoxLib.Tpp.RouteSet.RouteEvent Create(RouteEvent data, GetNodeEventTypeHashDelegate getNodeTypeHash, GetEdgeEventTypeHashDelegate getEdgeTypeHash)
        {
            // TODO: Refactor this to not use type checking.
            uint eventTypeHash = uint.MaxValue;

            if (data is RouteNodeEvent)
            {
                eventTypeHash = getNodeTypeHash((data as RouteNodeEvent));
            }
            else if (data is RouteEdgeEvent)
            {
                eventTypeHash = getEdgeTypeHash((data as RouteEdgeEvent));
            }
            else
            {
                Assert.IsTrue(false, "Unrecognized RouteEvent type.");
            }

            return(new FoxLib.Tpp.RouteSet.RouteEvent(
                       eventTypeHash,
                       data.Params[0],
                       data.Params[1],
                       data.Params[2],
                       data.Params[3],
                       data.Params[4],
                       data.Params[5],
                       data.Params[6],
                       data.Params[7],
                       data.Params[8],
                       data.Params[9],
                       data.Snippet
                       ));
        }
Example #5
0
        // POST: api/Routes
        public IHttpActionResult Post(int id, [FromBody] RouteEvent routeEvent)
        {
            try
            {
                if (routeEvent == null)
                {
                    return(BadRequest());
                }

                string commandStatus;

                switch (routeEvent.RouteCommand.ToUpper())
                {
                case "START":
                {
                    commandStatus = RouteService.StartRoute(id);
                }
                break;

                case "FINALIZE":
                    commandStatus = RouteService.FinalizeRoute(id);
                    break;

                default:
                    return(Unauthorized());
                }
                return(Ok(commandStatus));
            }
            catch (Exception error)
            {
                LogicTracker.App.Web.Api.Providers.LogWritter.writeLog(error);
                return(BadRequest());
            }
        }
        public override IItemModelAdapter <IEventModel> CreateDeepCopyOfItemModel(IItemModelAdapter <IEventModel> model)
        {
            RouteEvent routeEvent = (RouteEvent)model.DataModel;
            var        deepCopy   = routeEvent.Copy();
            var        newModel   = new ItemModelAdapterForPassive <IEventModel>(deepCopy);

            return(newModel);
        }
Example #7
0
        protected abstract void DrawSettings();/*
                                                * {
                                                * Rotorz.Games.Collections.ReorderableListGUI.Title("Settings");
                                                *
                                                * var eventTypeContent = new GUIContent("Event type", "The type of this event.");
                                                * @event.Type = (RouteNodeEventType)EditorGUILayout.EnumPopup(eventTypeContent, @event.Type);
                                                *
                                                * var snippetContent = new GUIContent("Snippet", "Must be a maximum of four characters.");
                                                * @event.Snippet = EditorGUILayout.TextField(snippetContent, @event.Snippet);
                                                * }*/

        private static void DrawParams(RouteEvent @event)
        {
            Rotorz.Games.Collections.ReorderableListGUI.Title("Parameters");

            for (int i = 0; i < 10; i++)
            {
                @event.Params[i] = (uint)EditorGUILayout.LongField($"Param {i}", @event.Params[i]);
            }
        }
Example #8
0
        private static void DrawToolShelf(RouteEvent @event)
        {
            var iconAddNode  = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_node") as Texture;
            var iconAddEvent = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_new_event") as Texture;
            var iconParent   = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_parent") as Texture;
            var iconNext     = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_next") as Texture;
            var iconPrev     = Resources.Load("UI/Route Builder/Buttons/routebuilder_button_prev") as Texture;

            Rotorz.Games.Collections.ReorderableListGUI.Title("Tools");
            EditorGUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            // Add node button
            if (FoxKitUiUtils.ToolButton(iconAddNode, "Add a new node."))
            {
                @event.AddNewNode();
            }

            // Add event button
            if (FoxKitUiUtils.ToolButton(iconAddEvent, "Add a new node event."))
            {
                @event.AddNewRouteNodeEvent();
            }

            // Select parent button
            if (FoxKitUiUtils.ToolButton(iconParent, "Select parent."))
            {
                UnitySceneUtils.Select(@event.transform.parent.gameObject);
            }

            // Select previous node button
            if (FoxKitUiUtils.ToolButton(iconPrev, "Select previous node."))
            {
                var node = @event.GetComponent <RouteNode>();
                if (node == null)
                {
                    node = @event.transform.parent.GetComponent <RouteNode>();
                }
                node.SelectPreviousNode();
            }

            // Select next node button
            if (FoxKitUiUtils.ToolButton(iconNext, "Select next node."))
            {
                var node = @event.GetComponent <RouteNode>();
                if (node == null)
                {
                    node = @event.transform.parent.GetComponent <RouteNode>();
                }
                node.SelectNextNode();
            }

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Example #9
0
        private static string GetMarkerOffset(RouteEvent routeEvent)
        {
            if (routeEvent.MaximumSpeed == 0)
            {
                return(DrawingFactory.GetOffset(-12, -12));
            }

            const int desplazamiento = 10;
            var       angulo         = (-(routeEvent.Direction - 90) * 2 * Math.PI) / 360;
            var       dx             = Math.Cos(angulo) * desplazamiento;
            var       dy             = Math.Sin(angulo) * desplazamiento;

            return(DrawingFactory.GetOffset(-12 + dx, -12 - dy));
        }
        ///<summary>
        ///добавить доки/инстанции - только доки
        ///</summary>
        protected void includeButton_Click(object sender, EventArgs e)
        {
            SaveStates();
            if (routeTable != null)
            {
                routeTable.Rows.Clear();
            }

            if (PointList.Count == 0)
            {
                return;
            }

            if (AppList == null)
            {
                AppList = new List <Application>();
            }

            if (EventList == null)
            {
                EventList = new List <RouteEvent>();
            }

            foreach (ListItem item in ApplicationList.Items)
            {
                if (item.Selected)
                {
                    var a = new Application();
                    a.InitApplication(item.Value);

                    foreach (var routePoint in PointList)
                    {
                        var routeEvent = new RouteEvent();
                        routeEvent.InitEvent(a, routePoint);
                        EventList.Add(routeEvent);
                    }

                    AppList.Add(a);
                }
            }

            ApplicationFilterBox.Text = string.Empty;

            FillLists();

            DataBind();
            //BuildRoute();
        }
Example #11
0
 public RouteEventVo(RouteEvent routeEvent)
 {
     InitialDate      = routeEvent.InitialDate.ToDisplayDateTime();
     FinalDate        = routeEvent.FinalDate.ToDisplayDateTime();
     ElapsedTime      = routeEvent.ElapsedTime;
     Distance         = routeEvent.Distance;
     MinimumSpeed     = routeEvent.MinimumSpeed;
     MaximumSpeed     = routeEvent.MaximumSpeed;
     AverageSpeed     = routeEvent.AverageSpeed;
     MaxSpeed         = routeEvent.MaximumSpeed;
     Direction        = routeEvent.Direction;
     InitialLatitude  = routeEvent.InitialLatitude;
     FinalLatitude    = routeEvent.FinalLatitude;
     InitialLongitude = routeEvent.InitialLongitude;
     FinalLongitude   = routeEvent.FinalLongitude;
 }
Example #12
0
        /// <summary>
        /// Create a route node.
        /// </summary>
        /// <returns>The created route node.</returns>
        private static RouteNode CreateRouteNode()
        {
            var position = new Vector3(1.0f, 2.0f, 3.0f);

            var event0 = new RouteEvent(1530489467, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "abcd");
            var event1 = new RouteEvent(1432398056, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "efgh");
            var event2 = new RouteEvent(4202868537, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "ijkl");

            var events = new List <RouteEvent>()
            {
                event0, event1, event2
            };
            var node = new RouteNode(position, event0, events);

            return(node);
        }
        private static RouteNode CreateDummyRouteNode()
        {
            //var position = new Vector3(1667f, 360.0f, -282.0f);
            var position = new Vector3(-1578.3302f, 354.714447f, -285.961426f);

            var event0 = new RouteEvent((uint)Hashing.StrCode("RelaxedWalk"), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "1234");
            var event1 = new RouteEvent(3297759236u, 0, 0, 0, 0, 0, 0, 728838112u, 0, 0, 0, "1234");
            var event2 = new RouteEvent((uint)Hashing.StrCode("VehicleIdle"), 16777985u, 2379809247u, 4106517606u, (uint)Hashing.StrCode(""), (uint)Hashing.StrCode(""), (uint)Hashing.StrCode(""), 0, 0, 0, 0, "1234");

            var events = new List <RouteEvent>()
            {
                event0, event1, event2
            };
            var node = new RouteNode(position, event0, events);

            return(node);
        }
Example #14
0
            public void OnPerform(RouteEvent e)
            {
                Common.StringBuilder msg = new Common.StringBuilder();
                msg.Append("Data: " + e.Data);
                msg.Append(Common.NewLine + "Data2: " + e.Data2);
                msg.Append(Common.NewLine + "DistanceRemaining: " + e.DistanceRemaining);
                msg.Append(Common.NewLine + "DistanceTravelled: " + e.DistanceTravelled);
                msg.Append(Common.NewLine + "EventDirection: " + e.EventDirection);
                msg.Append(Common.NewLine + "EventPosition: " + e.EventPosition);
                msg.Append(Common.NewLine + "EventSource: " + e.EventSource);
                msg.Append(Common.NewLine + "EventType: " + e.EventType);
                msg.Append(Common.NewLine + "ObjectID: " + e.ObjectID);

                GameObject obj = GameObject.GetObject <GameObject>(e.ObjectID);

                if (obj != null)
                {
                    msg.Append(Common.NewLine + "Object Type: " + obj.GetType());
                }

                Route route = mSim.RoutingComponent.GetCurrentRoute();

                if (route != null)
                {
                    msg.Append(Common.NewLine + "NumPaths: " + route.GetNumPaths());

                    for (uint i = 0x0; i < route.GetNumPaths(); i++)
                    {
                        PathData pathData = route.GetPathData(i);

                        msg.Append(Common.NewLine + "PathType: " + pathData.PathType);
                        msg.Append(Common.NewLine + "PortalStartPos: " + pathData.PortalStartPos);
                        msg.Append(Common.NewLine + "ObjectId: " + pathData.ObjectId);

                        obj = GameObject.GetObject <GameObject>(pathData.ObjectId);
                        if (obj != null)
                        {
                            msg.Append(Common.NewLine + "Object Type: " + obj.GetType());
                        }
                    }
                }

                Common.DebugStackLog(msg);
            }
        public async Task <IActionResult> PostRouteEvent([FromBody] RouteEvent routeEvent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            routeEvent.Status = Status.Active;

            var now = DateTimeOffset.Now;

            routeEvent.CreatedAt = now;
            routeEvent.UpdatedAt = now;

            _context.RouteEvents.Add(routeEvent);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRouteEvent", new { id = routeEvent.Id }, routeEvent));
        }
        /// <summary>
        /// Create a route node.
        /// </summary>
        /// <returns>The created route node.</returns>
        private static RouteNode CreateRouteNode(float x, float y, float z, string snippet)
        {
            var position = new Vector3(x, y, z);

            var event0 = new RouteEvent((uint)Hashing.StrCode("RelaxedWalk"), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "1234");

            //var event0 = new RouteEvent((uint)Hashing.StrCode("CautionSquatFire"), 16777473, 1161101791, 1152746673, 1135115795, 1152909810, 0, 0, 0, 0, 0, snippet);
            //var event1 = new RouteEvent((uint)Hashing.StrCode("CautionSquatFire"), 16777473, 1161101791, 1152746673, 1135115795, 1152909810, 0, 0, 0, 0, 0, snippet);
            //var event1 = new RouteEvent(3297759236u, 0, 0, 0, 0, 0, 0, 728838112u, 0, 0, 0, "4160");
            //var event2 = new RouteEvent((uint)Hashing.HashFileNameLegacy("VehicleIdle"), 16777985u, 2379809247u, 4106517606u, (uint)Hashing.HashFileNameLegacy(""), (uint)Hashing.HashFileNameLegacy(""), (uint)Hashing.HashFileNameLegacy(""), 0, 0, 0, 0, ",\"\"]");

            var events = new List <RouteEvent>()
            {
                event0
            };                                             //,event1, event2 };
            var node = new RouteNode(position, event0, events);

            return(node);
        }
        ///<summary>
        ///открыть изменение события
        ///</summary>
        protected void eventButton_Click(object sender, EventArgs e)
        {
            SaveStates();
            var eventButton = sender as Button;

            routeEvent        = EventList.First(x => x.application.ID == eventButton.Attributes["appid"] && x.point.ID == eventButton.Attributes["pointid"]);
            AppNumberBox.Text = routeEvent.application.number;
            PointNameBox.Text = routeEvent.point.divisionName;
            StateBox.Text     = routeEvent.point.state;

            DateBox.Text = FormatDate(routeEvent.date);
            //DateBox.Attributes["defaultChecked"] = "true";
            //DateBox.Attributes["value"] = FormatDate(routeEvent.date);
            //DateBox.Attributes["value"] = FormatDate(routeEvent.date);

            DateRBox.Text = FormatDate(routeEvent.dateR);
            //DateRBox.Attributes["defaultChecked"] = "true";
            //DateRBox.Attributes["value"] = FormatDate(routeEvent.dateR);
            //DateBox.Attributes["value"] = FormatDate(routeEvent.date);

            WorkPlaces.ActiveViewIndex = 1;
        }
Example #18
0
            public void OnPerform(RouteEvent e)
            {
                Common.StringBuilder msg = new Common.StringBuilder();
                msg.Append("Data: " + e.Data);
                msg.Append(Common.NewLine + "Data2: " + e.Data2);
                msg.Append(Common.NewLine + "DistanceRemaining: " + e.DistanceRemaining);
                msg.Append(Common.NewLine + "DistanceTravelled: " + e.DistanceTravelled);
                msg.Append(Common.NewLine + "EventDirection: " + e.EventDirection);
                msg.Append(Common.NewLine + "EventPosition: " + e.EventPosition);
                msg.Append(Common.NewLine + "EventSource: " + e.EventSource);
                msg.Append(Common.NewLine + "EventType: " + e.EventType);
                msg.Append(Common.NewLine + "ObjectID: " + e.ObjectID);

                GameObject obj = GameObject.GetObject<GameObject>(e.ObjectID);
                if (obj != null)
                {
                    msg.Append(Common.NewLine + "Object Type: " + obj.GetType());
                }

                Route route = mSim.RoutingComponent.GetCurrentRoute();
                if (route != null)
                {
                    msg.Append(Common.NewLine + "NumPaths: " + route.GetNumPaths());

                    for (uint i = 0x0; i < route.GetNumPaths(); i++)
                    {
                        PathData pathData = route.GetPathData(i);

                        msg.Append(Common.NewLine + "PathType: " + pathData.PathType);
                        msg.Append(Common.NewLine + "PortalStartPos: " + pathData.PortalStartPos);
                        msg.Append(Common.NewLine + "ObjectId: " + pathData.ObjectId);

                        obj = GameObject.GetObject<GameObject>(pathData.ObjectId);
                        if (obj != null)
                        {
                            msg.Append(Common.NewLine + "Object Type: " + obj.GetType());
                        }
                    }
                }

                Common.DebugStackLog(msg);
            }
Example #19
0
 private string GetIconUrl(RouteEvent aEvent)
 {
     return(aEvent.MaximumSpeed == 0 ? Images.Stopped : string.Format(Images.ImageHandler, GetRouteImage(aEvent.FinalDate), aEvent.Direction));
 }
Example #20
0
        public RouteDto addPath(int floor, List<CoordinateDto> path)
        {
            // TODO: chop up the path into nav-stack events

            RouteEvent newPath = new RouteEvent().setPath(floor, path);
            addEvent(newPath);

            addPathToNavStack(floor, path);

            return this;
        }
 /// <summary>
 /// Default ctor
 /// </summary>
 internal RouteEventBehaviorList(RouteEvent @event)
     : base(@event)
 {
     this.@event = @event;
 }
Example #22
0
 protected virtual void Process(RouteEvent data)
 {
 }
Example #23
0
        public static IEvent GetEvent(DAOFactory daoFactory, GPSPoint inicio, string codigo, Int32?idPuntoDeInteres, Int64 extraData, Int64 extraData2, Int64 extraData3, Coche vehiculo, Empleado chofer)
        {
            IEvent evento = null;
            int    cod;

            if (int.TryParse(codigo, out cod) && cod > 0 && cod < 20)
            {
                evento = new ManualEvent(inicio.Date, inicio.Lat, inicio.Lon, codigo);
            }
            else if (codigo == MessageCode.InsideGeoRefference.GetMessageCode() && idPuntoDeInteres.HasValue)
            {
                evento = new GeofenceEvent(inicio.Date, idPuntoDeInteres.Value, GeofenceEvent.EventoGeofence.Entrada, inicio.Lat, inicio.Lon, chofer);
            }
            else if (codigo == MessageCode.OutsideGeoRefference.GetMessageCode() && idPuntoDeInteres.HasValue)
            {
                evento = new GeofenceEvent(inicio.Date, idPuntoDeInteres.Value, GeofenceEvent.EventoGeofence.Salida, inicio.Lat, inicio.Lon, chofer);
            }
            else if (codigo == MessageCode.TolvaDeactivated.GetMessageCode())
            {
                evento = new TolvaEvent(inicio.Date, TolvaEvent.EstadoTolva.Off, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.TolvaActivated.GetMessageCode())
            {
                evento = new TolvaEvent(inicio.Date, TolvaEvent.EstadoTolva.On, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerStopped.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.Detenido, TrompoEvent.VelocidadTrompo.Undefined, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerClockwiseFast.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.HorarioDerecha, TrompoEvent.VelocidadTrompo.Fast, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerClockwiseSlow.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.HorarioDerecha, TrompoEvent.VelocidadTrompo.Slow, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerClockwise.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.HorarioDerecha, TrompoEvent.VelocidadTrompo.Undefined, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerCounterClockwiseFast.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.AntihorarioIzquierda, TrompoEvent.VelocidadTrompo.Fast, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerCounterClockwiseSlow.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.AntihorarioIzquierda, TrompoEvent.VelocidadTrompo.Slow, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.MixerCounterClockwise.GetMessageCode())
            {
                evento = new TrompoEvent(inicio.Date, TrompoEvent.SentidoTrompo.AntihorarioIzquierda, TrompoEvent.VelocidadTrompo.Undefined, inicio.Lat, inicio.Lon);
            }
            else if (codigo == MessageCode.GarminTextMessageCannedResponse.GetMessageCode())
            {
                // extraData = ID Device
                // extraData2 = ID Entrega / ID Ruta
                // extraData3 = Codigo Mensaje
                STrace.Debug(typeof(EventFactory).FullName, Convert.ToInt32(extraData), "extraData=" + extraData + " extraData2=" + extraData2 + " extraData3=" + extraData3);
                var veh = daoFactory.CocheDAO.FindMobileByDevice(Convert.ToInt32(extraData));

                if (veh != null && veh.Empresa.IntegrationServiceEnabled)
                {
                    var intService = new IntegrationService(daoFactory);

                    if (veh.Empresa.IntegrationServiceCodigoMensajeAceptacion == extraData3.ToString())
                    {
                        var distribucion = daoFactory.ViajeDistribucionDAO.FindById(Convert.ToInt32(extraData2));

                        if (distribucion != null)
                        {
                            var enCurso = daoFactory.ViajeDistribucionDAO.FindEnCurso(veh);
                            if (enCurso == null)
                            {
                                intService.ResponseAsigno(distribucion, true);
                                var eventoInicio = new InitEvent(inicio.Date);
                                var ciclo        = new CicloLogisticoDistribucion(distribucion, daoFactory, new MessageSaver(daoFactory));
                                ciclo.ProcessEvent(eventoInicio);
                            }
                            else
                            {
                                intService.ResponsePreasigno(distribucion, true);
                            }
                        }

                        return(null);
                    }
                    else if (veh.Empresa.IntegrationServiceCodigoMensajeRechazo == extraData3.ToString())
                    {
                        var distribucion = daoFactory.ViajeDistribucionDAO.FindById(Convert.ToInt32(extraData2));
                        distribucion.Vehiculo = null;
                        daoFactory.ViajeDistribucionDAO.SaveOrUpdate(distribucion);

                        var enCurso = daoFactory.ViajeDistribucionDAO.FindEnCurso(veh);
                        if (enCurso == null)
                        {
                            intService.ResponseAsigno(distribucion, false);
                        }
                        else
                        {
                            intService.ResponsePreasigno(distribucion, false);
                        }

                        return(null);
                    }
                }

                if (extraData2 == 0)
                {
                    return(null);
                }
                var entrega   = daoFactory.EntregaDistribucionDAO.FindById(Convert.ToInt32(extraData2));
                var mensajeVo = daoFactory.MensajeDAO.GetByCodigo(extraData3.ToString("#0"), veh.Empresa, veh.Linea);
                try
                {
                    var mensaje = daoFactory.MensajeDAO.FindById(mensajeVo.Id);
                    try
                    {
                        var descriptiva = " - " + entrega.Viaje.Codigo + " - " + entrega.Descripcion;

                        var ms  = new MessageSaver(daoFactory);
                        var log = ms.Save(null, Convert.ToString(extraData3), veh.Dispositivo, veh, chofer, inicio.Date, inicio, descriptiva, entrega.Viaje, entrega);

                        try
                        {
                            entrega.MensajeConfirmacion = log as LogMensaje;
                            daoFactory.EntregaDistribucionDAO.SaveOrUpdate(entrega);
                        }
                        catch (Exception) { }

                        if (mensaje.TipoMensaje.DeConfirmacion)
                        {
                            evento = new GarminEvent(inicio.Date, extraData2, inicio.Lat, inicio.Lon, EntregaDistribucion.Estados.Completado, chofer);
                        }
                        else if (mensaje.TipoMensaje.DeRechazo)
                        {
                            evento = new GarminEvent(inicio.Date, extraData2, inicio.Lat, inicio.Lon, EntregaDistribucion.Estados.NoCompletado, chofer);
                        }
                        else
                        {
                            STrace.Error(typeof(CicloLogisticoFactory).FullName, Convert.ToInt32(extraData), "Respuesta de mensaje de Canned Response inválida sin tipo de mensaje adecuado para la ocasión. (" + extraData2 + "-" + extraData + ")");
                        }
                    }
                    catch (Exception e)
                    {
                        STrace.Exception(typeof(EventFactory).FullName, e,
                                         "E#2 Vehicle=" + veh.Id + " entrega=" +
                                         (entrega == null ? "null" : entrega.Id.ToString("#0")) + " mensajeVo=" +
                                         mensajeVo.Id + " mensaje=" +
                                         (mensaje == null ? "null" : mensaje.Id.ToString("#0")));
                    }
                }
                catch (Exception e)
                {
                    STrace.Exception(typeof(EventFactory).FullName, e,
                                     "E#1 Vehicle=" + veh.Id + " entrega=" +
                                     (entrega == null ? "null" : entrega.Id.ToString("#0")) + " mensajeVo=" +
                                     (mensajeVo == null ? "null" : mensajeVo.Id.ToString("#0")));
                }
            }
            else if (codigo == MessageCode.ValidacionRuteo.GetMessageCode())
            {
                var deviceId = inicio.DeviceId;
                var vehicle  = daoFactory.CocheDAO.FindMobileByDevice(deviceId);
                if (vehicle != null)
                {
                    var ruta = daoFactory.ViajeDistribucionDAO.FindEnCurso(vehicle);
                    if (ruta != null)
                    {
                        evento = new RouteEvent(inicio.Date, ruta.Id, inicio.Lat, inicio.Lon, RouteEvent.Estados.Enviado);
                    }
                }
            }
            else if (codigo == MessageCode.GarminETAReceived.GetMessageCode())
            {
                if (vehiculo.HasActiveStop())
                {
                    var activeStop = vehiculo.GetActiveStop();
                    if (activeStop > 0)
                    {
                        var edDAO   = daoFactory.EntregaDistribucionDAO;
                        var vdDAO   = daoFactory.ViajeDistribucionDAO;
                        var detalle = edDAO.FindById(activeStop);

                        if (detalle != null)
                        {
                            var utcnow  = DateTime.UtcNow;
                            var fechora = vehiculo.EtaEstimated();
                            var minutos = fechora != null && fechora > utcnow?fechora.Value.Subtract(utcnow).TotalMinutes : 0;

                            var texto = String.Format(CultureManager.GetLabel("GARMIN_STOP_ETA_ARRIVAL"), minutos, fechora);

                            if (minutos > 0)
                            {
                                using (var transaction = SmartTransaction.BeginTransaction())
                                {
                                    try
                                    {
                                        try
                                        {
                                            new MessageSaver(daoFactory).Save(null, codigo, vehiculo.Dispositivo, vehiculo, chofer, DateTime.UtcNow, null, texto,
                                                                              detalle.Viaje, detalle);
                                        }
                                        catch (Exception ex)
                                        {
                                            STrace.Exception(typeof(EventFactory).FullName, ex, vehiculo.Dispositivo.Id,
                                                             String.Format("Exception doing MessageSaver.Save({0})", texto));
                                            throw ex;
                                        }
                                        try
                                        {
                                            detalle.GarminETA           = fechora;
                                            detalle.GarminETAInformedAt = utcnow;
                                            vdDAO.SaveOrUpdate(detalle.Viaje);
                                        }
                                        catch (Exception ex)
                                        {
                                            STrace.Exception(typeof(EventFactory).FullName, ex, vehiculo.Dispositivo.Id,
                                                             String.Format("Exception doing MessageSaver.Save({0})", texto));
                                            throw ex;
                                        }
                                        transaction.Commit();
                                    }
                                    catch (Exception ex)
                                    {
                                        transaction.Rollback();
                                        throw ex;
                                    }
                                }
                            }
                        }
                        else
                        {
                            STrace.Error(typeof(EventFactory).FullName, vehiculo.Dispositivo.Id, String.Format("Processing GarminETAReceived cannot be processed because EntregaDistribucion #{0} is null.", activeStop));
                        }
                    }
                    else
                    {
                        STrace.Error(typeof(EventFactory).FullName, vehiculo.Dispositivo.Id, "Processing GarminETAReceived cannot be processed because ActiveStop # is not valid.");
                    }
                }
            }
            else
            {
                var stopstatus = TranslateStopStatus(codigo);
                if (stopstatus != -1)
                {
                    evento = new GarminEvent(inicio.Date, extraData, inicio.Lat, inicio.Lon, stopstatus, chofer);
                }
            }

            return(evento);
        }
Example #24
0
 public bool TryFind(string path, out RouteEvent action)
 {
     return(RouteList.TryGetValue(path, out action));
 }
Example #25
0
 public RouteDto addEvent(RouteEvent s)
 {
     code = CODE_SUCCESS;
     paths.Add(s);
     return this;
 }
Example #26
0
    /// <summary>
    /// Registers a route event instance.
    /// </summary>
    /// <param name="data">Raw data associated with the event.</param>
    /// <param name="owner">GameObject for the event to attach to.</param>
    /// <param name="createEvent">Function to create a new event.</param>
    /// <returns>The new, registered route event instance.</returns>
    public RouteEvent RegisterRouteEvent(FoxLib.Tpp.RouteSet.RouteEvent data, GameObject owner, CreateEventDelegate createEvent)
    {
        RouteEvent eventInstance = createEvent(owner, data);

        return(eventInstance);
    }