Beispiel #1
0
        private void CreateTripPoints(string SourceTrip)
        {
            try
            {
                CurrentTrip.RecordedTimeStamp = DateTime.UtcNow;
                //CurrentTrip.Name = $"Trip {tripCount}";
                CurrentTrip.Name = $"Trip {DateTime.Now}";
                CurrentTrip.Id   = Guid.NewGuid().ToString(); //Create trip ID
                                                              //TODO: Make this so that once Authenticated we use the Login Information from the JWT Token if Authentication will be used
                CurrentTrip.UserId = "Hacker 1";              //_toProcess[0][1]; //"MicrosoftAccount:cd3744e78c2d3d2d" //"Twitter:128169747"//Hacker1


                foreach (var tps in tripInfo)
                {
                    TripPoints _tripPoint = new TripPoints()
                    {
                        TripId                       = CurrentTrip.Id,
                        Id                           = Guid.NewGuid().ToString(),
                        Latitude                     = Convert.ToDouble(tps.Lat),
                        Longitude                    = Convert.ToDouble(tps.Lon),
                        Speed                        = Convert.ToDouble(tps.Speed),
                        RecordedTimeStamp            = Convert.ToDateTime(tps.Recordedtimestamp),
                        Sequence                     = Convert.ToInt32(tps.Sequence),
                        Rpm                          = Convert.ToDouble(tps.Enginerpm),
                        ShortTermFuelBank            = Convert.ToDouble(tps.Shorttermfuelbank),
                        LongTermFuelBank             = Convert.ToDouble(tps.Longtermfuelbank),
                        ThrottlePosition             = Convert.ToDouble(tps.Throttleposition),
                        RelativeThrottlePosition     = Convert.ToDouble(tps.Relativethrottleposition),
                        Runtime                      = Convert.ToDouble(tps.Runtime),
                        DistanceWithMalfunctionLight = Convert.ToDouble(tps.Distancewithmil),
                        EngineLoad                   = Convert.ToDouble(tps.Engineload),
                        MassFlowRate                 = Convert.ToDouble(tps.Mafflowrate),
                        EngineFuelRate               = Convert.ToDouble(tps.Enginefuelrate)
                    };
                    CurrentTrip.TripPoints.Add(_tripPoint);
                }


                //Get Source POIs
                tripPOIsource = ctx.Poisource.Where(p => p.TripId == SourceTrip).ToList();

                //Update Time Stamps to current date and times before sending to IOT Hub
                UpdateTripPointTimeStamps(CurrentTrip);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Could not create/update Trip Points. For more detail see: {ex.Message}.");
            }
        }
        private void CreateTripPoints()
        {
            try
            {
                foreach (var tps in TripPointSourceInfo)
                {
                    TripPoints _tripPoint = new TripPoints()
                    {
                        TripId                       = CurrentTrip.Id,
                        Id                           = Guid.NewGuid().ToString(),
                        Latitude                     = Convert.ToDouble(tps.Lat),
                        Longitude                    = Convert.ToDouble(tps.Lon),
                        Speed                        = Convert.ToDouble(tps.Speed),
                        RecordedTimeStamp            = Convert.ToDateTime(tps.Recordedtimestamp),
                        Sequence                     = Convert.ToInt32(tps.Sequence),
                        Rpm                          = Convert.ToDouble(tps.Enginerpm),
                        ShortTermFuelBank            = Convert.ToDouble(tps.Shorttermfuelbank),
                        LongTermFuelBank             = Convert.ToDouble(tps.Longtermfuelbank),
                        ThrottlePosition             = Convert.ToDouble(tps.Throttleposition),
                        RelativeThrottlePosition     = Convert.ToDouble(tps.Relativethrottleposition),
                        Runtime                      = Convert.ToDouble(tps.Runtime),
                        DistanceWithMalfunctionLight = Convert.ToDouble(tps.Distancewithmil),
                        EngineLoad                   = Convert.ToDouble(tps.Engineload),
                        MassFlowRate                 = Convert.ToDouble(tps.Mafflowrate),
                        EngineFuelRate               = Convert.ToDouble(tps.Enginefuelrate)
                    };
                    CurrentTrip.TripPoints.Add(_tripPoint);
                }



                //Update Time Stamps to current date and times before sending to IOT Hub
                UpdateTripPointTimeStamps(CurrentTrip);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Could not create/update Trip Points. For more detail see: {ex.Message}.");
            }
        }