Пример #1
0
 private void ConvertDeviceGPXInArchiveToGPXFile(GPS gps = null)
 {
     if (gps == null)
     {
         foreach (var item in DeviceGPXCollection)
         {
             //if(item.GPX=="")
             //{
             //    item.GPX = DeviceWaypointGPXes.getXML(item.RowID);
             //}
             var gpxFile = Entities.GPXFileViewModel.ConvertToGPXFile(item);
             AddToDictionary(gpxFile.GPS, gpxFile);
         }
     }
     else
     {
         List<GPXFile> gpxFiles = new List<GPXFile>();
         if (ArchivedGPXFiles.Keys.Contains(gps) && ArchivedGPXFiles[gps].Count > 0)
         {
             gpxFiles = ArchivedGPXFiles[gps];
         }
         foreach (var item in DeviceGPXCollection.Where(t => t.GPS.DeviceID == gps.DeviceID))
         {
             if (item.GPX == "")
             {
                 item.GPX = DeviceWaypointGPXes.getXML(item.RowID);
             }
             var gpxFile = Entities.GPXFileViewModel.ConvertToGPXFile(item);
             if (!gpxFiles.Contains(gpxFile))
             {
                 AddToDictionary(gpxFile.GPS, gpxFile);
             }
         }
     }
 }
Пример #2
0
 public DeviceGPX GetDeviceGPX(DeviceGPX deviceGPX)
 {
     return(DeviceGPXCollection
            .Where(t => t.GPS.DeviceID == deviceGPX.GPS.DeviceID)
            .Where(t => t.Filename == deviceGPX.Filename)
            .FirstOrDefault());
 }
Пример #3
0
 public List<DateTime> GetMonthsInArchive(GPS gps)
 {
     return DeviceGPXCollection
         .Where(t => t.GPS.DeviceID == gps.DeviceID)
         .OrderBy(t => t.TimeRangeStart)
         .GroupBy(t => t.TimeRangeStart.ToString("MMM-yyyy"))
         .Select(g => g.First().TimeRangeStart)
         .ToList();
 }
Пример #4
0
        public DeviceGPX GetDeviceGPX(GPS gps, string fileName)
        {
            var g = DeviceGPXCollection
                    .Where(t => t.GPS.DeviceID == gps.DeviceID)
                    .Where(t => t.Filename == Path.GetFileName(fileName))
                    .FirstOrDefault();

            return(g);
        }
Пример #5
0
        public DeviceGPX GetDeviceGPX(int id)
        {
            var gpx = DeviceGPXCollection.Where(t => t.RowID == id).FirstOrDefault();
            if (gpx.GPX == "")
            {
                gpx.GPX = DeviceWaypointGPXes.getXML(id);
            }
            return gpx;

        }
Пример #6
0
 public DeviceGPX GetDeviceGPX(GPS gps, DateTime month_year)
 {
     var gpx = DeviceGPXCollection
         .Where(t => t.GPS.DeviceID == gps.DeviceID)
         .FirstOrDefault();
     if (gpx.GPX == "")
     {
         gpx.GPX = DeviceWaypointGPXes.getXML(gpx.RowID);
     }
     return gpx;
 }
Пример #7
0
        public bool AddRecordToRepo(DeviceGPX gpx)
        {
            int oldCount = DeviceGPXCollection.Count;

            if (gpx == null)
            {
                throw new ArgumentNullException("Error: The argument is Null");
            }
            DeviceGPXCollection.Add(gpx);
            AddToDictionary(gpx.GPS, Entities.GPXFileViewModel.GetFile(gpx.GPS, gpx.Filename));
            return(DeviceGPXCollection.Count > oldCount);
        }
Пример #8
0
        public DeviceGPX GetDeviceGPX(GPS gps, string fileName)
        {
            var gpx = DeviceGPXCollection
                .Where(t => t.GPS.DeviceID == gps.DeviceID)
                .Where(t => t.Filename == Path.GetFileName(fileName))
                .FirstOrDefault();

            if (gpx.GPX == "")
            {
                gpx.GPX = DeviceWaypointGPXes.getXML(gpx.RowID);
            }
            return gpx;
        }
Пример #9
0
        public DeviceGPX GetDeviceGPX(DeviceGPX deviceGPX)
        {
            var gpx = DeviceGPXCollection
                .Where(t => t.GPS.DeviceID == deviceGPX.GPS.DeviceID)
                .Where(t => t.Filename == deviceGPX.Filename)
                .FirstOrDefault();

            if (gpx.GPX == "")
            {
                gpx.GPX = DeviceWaypointGPXes.getXML(gpx.RowID);
            }
            return gpx;
        }
Пример #10
0
        public List<DeviceGPX> GetAllDeviceWaypointGPX()
        {
            var gpxes = DeviceGPXCollection.ToList();

            foreach (var gpx in gpxes)
            {
                if (gpx.GPX == "")
                {
                    gpx.GPX = DeviceWaypointGPXes.getXML(gpx.RowID);
                }
            }

            return gpxes;
        }
Пример #11
0
        public List<DeviceGPX> GetAllDeviceWaypointGPX(GPS gps)
        {
            var gpxes = DeviceGPXCollection.Where(t => t.GPS.DeviceID == gps.DeviceID).ToList();

            foreach (var gpx in gpxes)
            {
                if (gpx.GPX == "")
                {
                    gpx.GPX = DeviceWaypointGPXes.getXML(gpx.RowID);
                }
            }

            return gpxes;
        }
Пример #12
0
        public void DeleteRecordFromRepo(int rowID)
        {
            if (rowID == 0)
                throw new Exception("Record ID cannot be null");

            int index = 0;
            while (index < DeviceGPXCollection.Count)
            {
                if (DeviceGPXCollection[index].RowID == rowID)
                {
                    DeviceGPXCollection.RemoveAt(index);
                    break;
                }
                index++;
            }
        }
Пример #13
0
        public List<GPSDataSummary> GetGPSDataSummaries()
        {
            var list = new List<GPSDataSummary>();
            var gpsUnits = Entities.GPSViewModel.GetAll();
            foreach (var item in Entities.GPSViewModel.GetAll())
            {
                int count500 = 0;
                int countLess500 = 0;
                var listTracks = DeviceGPXCollection
                    .Where(t => t.GPS.DeviceID == item.DeviceID && t.GPXType == "track")
                    .ToList();

                foreach (var deviceGPX in listTracks)
                {
                    foreach (var track in Entities.TrackViewModel.ReadTracksFromXML(deviceGPX))
                    {
                        if (track.Statistics.Length <= 0.5)
                        {
                            ++countLess500;
                        }
                        else
                        {
                            ++count500;
                        }
                    }

                }

                var listWpts = DeviceGPXCollection
                    .Where(t => t.GPS.DeviceID == item.DeviceID && t.GPXType == "waypoint")
                    .ToList();



                var summaryItem = new GPSDataSummary { GPS = item, NumberOfSavedTracks = listTracks.Count, NumberOfSavedWaypoints = listWpts.Count, NumberTrackLength500m = count500, NumberTrackLengthLess500m = countLess500 };


                list.Add(summaryItem);
            }

            return list;
        }
Пример #14
0
        public bool AddRecordToRepo(DeviceGPX gpx)
        {
            int oldCount = DeviceGPXCollection.Count;
            if (gpx == null)
                throw new ArgumentNullException("Error: The argument is Null");
            DeviceGPXCollection.Add(gpx);
            if (_editSuccess)
            {
                GPXFile gpxFile = Entities.GPXFileViewModel.GetFile(gpx.GPS, gpx.Filename);
                if (gpxFile == null)
                {
                    gpxFile = new GPXFile(gpx.Filename) { GPS = gpx.GPS, XML = gpx.GPX };
                    gpxFile.ComputeStats(gpx);


                    Entities.GPXFileViewModel.Add(gpxFile);
                }
                AddToDictionary(gpx.GPS, gpxFile);
            }
            return DeviceGPXCollection.Count > oldCount;
        }
Пример #15
0
        public List<DateTime> GetAllMonthYear(DateTime? startingDate = null)
        {
            DateTime earliest;
            if (startingDate == null)
            {
                earliest = DeviceGPXCollection.OrderBy(t => t.TimeRangeStart).First().TimeRangeStart;
            }
            else
            {
                earliest = (DateTime)startingDate;
            }
            var latest = DeviceGPXCollection.OrderByDescending(t => t.TimeRangeStart).First().TimeRangeStart;
            var dates = new List<DateTime>();

            while (earliest <= latest)
            {
                dates.Add(new DateTime(earliest.Year, earliest.Month, 1));
                earliest = earliest.AddMonths(1);
            }
            return dates;

        }
Пример #16
0
 public DeviceGPX GetDeviceGPX(int id)
 {
     return(DeviceGPXCollection.Where(t => t.RowID == id).FirstOrDefault());
 }
Пример #17
0
 public DeviceGPX GetDeviceGPX(GPS gps)
 {
     return(DeviceGPXCollection
            .Where(t => t.GPS.DeviceID == gps.DeviceID)
            .FirstOrDefault());
 }
Пример #18
0
 public DeviceGPX GetDeviceGPX(GPS gps, DateTime month_year)
 {
     return(DeviceGPXCollection
            .Where(t => t.GPS.DeviceID == gps.DeviceID)
            .FirstOrDefault());
 }
Пример #19
0
 public List <DeviceGPX> GetAllDeviceWaypointGPX()
 {
     return(DeviceGPXCollection.ToList());
 }
Пример #20
0
 public List <DeviceGPX> GetAllDeviceWaypointGPX(GPS gps)
 {
     return(DeviceGPXCollection.Where(t => t.GPS.DeviceID == gps.DeviceID).ToList());
 }
Пример #21
0
 public List<GPS> GetAllGPS()
 {
     return DeviceGPXCollection.GroupBy(t => t.GPS).Select(g => g.First().GPS).OrderBy(t => t.DeviceName).ToList();
 }