Пример #1
0
        private Event createIdleEvent(GTSLocationMessage locationMessage, GTSLocationMessage prevMessage)
        {
            int idleTresh = 15; // get idle number form config for client/tracker

            Events.TrackerEvents.ExcessiveIdling idleEvent;
            // && prevMessage.DInput5 == true
            if (new TimeSpan(prevMessage.IdleTime).TotalMinutes >= idleTresh && prevMessage.DInput5 == true)
            {
                // TODO migh be a better way to select this using Linq to xml
                //Update or create new event
                GTSDataStorage.Event eventT = context.Events.Where(e => e.ObjectId == prevMessage.TrackerID).
                                              Where(e => e.Time == prevMessage.ClientRecordedDateTime).FirstOrDefault();

                if (eventT != null)
                {
                    // update the event
                    idleEvent = new TrackerEvents.ExcessiveIdling(eventT);
                    idleEvent.AddLocationMessage(locationMessage);
                }
                else
                {
                    // create a new one
                    idleEvent = new TrackerEvents.ExcessiveIdling();
                    idleEvent.AddLocationMessage(prevMessage, locationMessage);
                }

                return(idleEvent);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Factory Method for Events
        /// </summary>
        /// <param name="eventId"></param>
        /// <returns></returns>
        public GTSBizObjects.Events.TrackerEvents.TrackerEvent GetEvent(int eventId)
        {
            GPSTrackerEntities1 dbContext = new GPSTrackerEntities1();

            GTSDataStorage.Event theEvent = dbContext.Events.Where(t => t.Id == eventId).FirstOrDefault();
            Events.TrackerEvents.TrackerEvent retEvent;

            switch (theEvent.Type)
            {
            // Should find a better, more configurable way to get names for Inputs - TODO
            // Configurable by client and probably type, including tempat for description
            // TODO - Exception Handling
            case 1: retEvent = new TrackerEvents.Speeding(theEvent);



                break;

            case 2: retEvent = new TrackerEvents.ExcessiveIdling(theEvent); break;

            //case 3: retEvent = new TrackerEvents.EngineCutOn(theEvent); break;
            //case 4: retEvent = new TrackerEvents.EngineCutOff(theEvent); break;
            //case 5: retEvent = new TrackerEvents.EnterLocation(theEvent); break;
            //case 6: retEvent = new TrackerEvents.ExitLocation(theEvent); break;
            case 7: retEvent = new TrackerEvents.ExternalPowerCut(theEvent); break;

            case 8: retEvent = new TrackerEvents.GPSBlindAreaEntered(theEvent); break;

            case 9: retEvent = new TrackerEvents.GPSBlindAreaExited(theEvent); break;

            case 10: retEvent = new TrackerEvents.LowBattery(theEvent); break;

            case 11: retEvent = new TrackerEvents.TrackerTurnedOn(theEvent); break;

            case 12: retEvent = new TrackerEvents.GPSAntennaCut(theEvent); break;

            case 13: retEvent = new TrackerEvents.InputActive(theEvent); break;

            case 14: retEvent = new TrackerEvents.InputInactive(theEvent); break;

            case 15: retEvent = new TrackerEvents.InputActive(theEvent); break;

            case 16: retEvent = new TrackerEvents.InputInactive(theEvent); break;

            default: retEvent = new TrackerEvents.TrackerAlarm(theEvent); break;
            }

            return(retEvent);
        }