Beispiel #1
0
        public void GetFolderFiles_WriteToFile()
        {
            using (
                var streamWriter =
                    new StreamWriter(File.Open(@"c:\TripLine\FolderFiles.txt", FileMode.Create, FileAccess.Write)))
            {
                _localFileFolder.Load();

                List <FileExtendedInfo> noInfoFiles = new List <FileExtendedInfo>();

                List <string> geoPositions = new List <string>();

                foreach (var finfo in _localFileFolder.GetFiles())
                {
                    streamWriter.WriteLine(finfo.Serialize());
                }
            }
        }
Beispiel #2
0
        public void GetLocations_FromFilesExifGPS()
        {
            _localFileFolder.Load();

            List <FileExtendedInfo> noInfoFiles = new List <FileExtendedInfo>();

            List <GeoPosition> geoPositions = new List <GeoPosition>();


            //string directory = "", lastDirectory = "";
            List <string> invalidExifPositionFile = new List <string>();

            using (
                var streamWriter =
                    new StreamWriter(File.Open(@"c:\TripLine\FileGpsLocation.txt", FileMode.Create, FileAccess.Write))
                )
            {
                var totalFiles = _localFileFolder.GetFiles().Count();

                foreach (var file in _localFileFolder.GetFiles())
                {
                    Location location;

                    var inf = _exifReader.GetExifInformation(file.FilePath);

                    if (inf == null)
                    {
                        streamWriter.WriteLine($"{file.FilePath} EXIF not found");
                        continue;
                    }

                    if (!inf.GetPosition().IsValid())
                    {
                        streamWriter.WriteLine($"{file.FilePath}  NO GPS  ");
                        invalidExifPositionFile.Add(file.FilePath);
                        continue;
                    }

                    location = _locationService.GetLocation(inf.GetPosition());

                    var message = (location == null)
                        ? "No location result from google: "
                        : (location.City == null && location.State == null && location.Country == null)
                            ? $"Week {location.DisplayName}"
                            : $"Good {location.DisplayName} ";

                    streamWriter.WriteLine($"{file.FilePath} {inf.GetPosition().GetDisplay()} ->: {message}  ");

                    if (location != null)
                    {
                        streamWriter.WriteLine(location.GetShortDisplay());
                    }
                }

                streamWriter.WriteLine($"Invalif EXIF GPS {invalidExifPositionFile.Count} of {totalFiles} ");
                foreach (var file in invalidExifPositionFile)
                {
                    streamWriter.WriteLine($"file : {file}  NO GPS  ");
                    //_exifReader.WriteAllInfomations(file, streamWriter);
                }
            }
        }