Пример #1
0
        private void UpdateExportTable(DateTime selectedDate, string filepath, string fileName, string exportType)
        {
            var export = m_Context.Export.FirstOrDefault(c => c.export_date == selectedDate.Date && c.export_type == exportType);

            if (export == null)
            {
                Export exportFile = new Export
                {
                    export_date = selectedDate.Date,
                    export_type = exportType,
                    location    = fileName
                };
                m_Context.Export.Add(exportFile);
                m_Context.SaveChanges();
            }
            else
            {
                export.location = fileName;
                m_Context.SaveChanges();
            }
        }
Пример #2
0
        private void CreateStatus(SystemStatus status)
        {
            Console.WriteLine("Adding health status " + status.ToString());

            ServiceStatusEvent sse = new ServiceStatusEvent
            {
                Status   = status.ToString(),
                dateTime = DateTimeOffset.Now
            };

            m_context.ServiceStatusEvent.Add(sse);
            m_context.SaveChanges();
        }
Пример #3
0
        private void AddDataPoint(SimulatedData_HwyDataPoints point)
        {
            VehicleLocationTimeHistory loc = new VehicleLocationTimeHistory
            {
                dateTime  = DateTimeOffset.UtcNow,
                driverId  = m_driver.Id,
                vehicleId = m_vehicle.Id,
                latitude  = point.Latitude,
                longitude = point.Longitude,
            };

            m_context.VehicleLocationTimeHistory.Add(loc);
            m_context.SaveChanges();
        }
Пример #4
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();
        }
Пример #5
0
        private void createFault(Vehicle vehicle, SimulatedData_FaultEvent fault)
        {
            Console.WriteLine("Adding fault code event to vehicle " + vehicle.Id.ToString() + ": event Id: " + fault.Id.ToString());
            VehicleFaultCodeEvent vfce = new VehicleFaultCodeEvent
            {
                vehicleId                  = vehicle.Id,
                longitude                  = fault.longitude,
                latitude                   = fault.latitude,
                eventComment               = fault.eventComment,
                triggerDate                = DateTimeOffset.UtcNow,
                occurences                 = fault.occurencesCount,
                messageIdentifier          = fault.messageIdentifier,
                parameterOrSubsystemIdType = fault.parameterOrSubsystemIdType,
                sourceAddress              = fault.sourceAddress,
                suspectParameterNumber     = fault.suspectParameterNumber,
                failureModeIdentifier      = fault.failureModeIdentifier,
                urgentFlag                 = fault.urgentFlag,
                odometer                   = fault.odometer,
                engineRpm                  = fault.engineRpm,
                ecmSpeed                   = fault.ecmSpeed,
                ccAccelerationSwitch       = false,
                ccBrakeSwitch              = false,
                ccClutchSwitch             = false,
                ccCoastSwitch              = false,
                ccCruiseSwitch             = false,
                ccResumeSwitch             = false,
                ccSetSwitch                = false,
                ccSpeed              = 0.0M,
                ccSwitch             = false,
                ignitionAccessory    = false,
                ignitionAidContact   = false,
                ignitionCrankContact = false,
                ignitionRunContact   = false,
                gpsQuality           = fault.gpsQuality,
            };

            m_context.Add(vfce);
            m_context.SaveChanges();
        }