Example #1
0
        private void CreateLogEvent(SimulatedData_LogEvent sim_le, Vehicle vehicle, Driver driver)
        {
            Console.WriteLine("Adding log event to driver " + driver.Id.ToString() + ": event Id: " + sim_le.Id.ToString());

            //create a log event based on our simulated data store
            LogEvent le = new LogEvent
            {
                Id                 = Guid.NewGuid(),
                driverId           = driver.Id,
                vehicleId          = vehicle.Id,
                locationId         = sim_le.locationId,
                certificationCount = sim_le.certificationCount,
                coDrivers          = sim_le.coDrivers,
                comment            = sim_le.comment,
                dateTime           = DateTimeOffset.Now,
                distanceLastValid  = sim_le.distanceLastValid,
                editDateTime       = sim_le.editDateTime,
                eventDataChecksum  = sim_le.eventDataChecksum,
                eventType          = sim_le.eventType,
                multidayBasis      = sim_le.multidayBasis,
                origin             = sim_le.origin,
                parentId           = sim_le.parentId,
                sequence           = sim_le.sequence,
                state              = sim_le.state,
                verifyDateTime     = sim_le.verifyDateTime,
            };

            m_context.LogEvent.Add(le);

            //add annotations, if available
            List <SimulatedData_LogEventAnnotation> annotations = m_context.SimulatedData_LogEventAnnotation.Where(x => x.logEventId == sim_le.Id).ToList();

            foreach (SimulatedData_LogEventAnnotation annotation in annotations)
            {
                LogEventAnnotation lea = new LogEventAnnotation
                {
                    comment    = annotation.comment,
                    dateTime   = DateTimeOffset.Now,
                    driverId   = le.driverId,
                    Id         = Guid.NewGuid(),
                    logEventId = le.Id
                };
                m_context.LogEventAnnotation.Add(lea);
            }
            m_context.SaveChanges();
        }
Example #2
0
        private SimulatedData_LogEvent GetNextLogEvent()
        {
            if (m_eventIdx >= m_logEvents.Count)
            {
                if (m_keepGoing)
                {
                    m_eventIdx = 0;
                }
                else
                {
                    return(null);
                }
            }
            SimulatedData_LogEvent log = m_logEvents[m_eventIdx];

            m_eventIdx++;
            return(log);
        }
Example #3
0
        private void AddALogEvent(Object source, ElapsedEventArgs e)
        {
            SimulatedData_LogEvent sim_le = GetNextLogEvent();

            if (sim_le != null)
            {
                int driverIndex = sim_le.driverId;
                //just skip this one if the driver ID is > the number of
                //drivers or vehicles we have available
                if (driverIndex > m_maxTrucks)
                {
                    return;
                }
                Driver  driver  = m_drivers[driverIndex];
                Vehicle vehicle = m_vehicles[driverIndex];

                CreateLogEvent(sim_le, vehicle, driver);
            }
        }