示例#1
0
        public static async Task Process()
        {
            try
            {
                config = GetConfig();
                TripSpanCache.LocateSameDay = config.locate_same_day;
                var filePaths      = Directory.EnumerateFiles(config.path, "*.jpg", SearchOption.AllDirectories);
                var copyPhotosTask = Task.Run(() => CopyPhotosTask());
                // var copyPhotosWithoutGPSTask = Task.Run(() => CopyPhotosWithoutGPSTask());

                foreach (var filePath in filePaths)
                {
                    try
                    {
                        var meta = ReadMeta(filePath);
                        if (meta != null)
                        {
                            await GenerateAddress(meta).ConfigureAwait(false);

                            if (meta.HasLocation)
                            {
                                GenerateNewFilePath(meta);
                                TripSpanCache.ExpandDuration(meta);
                                photoQueueWithGPS.Enqueue(meta);
                            }
                            else
                            {
                                photoQueueWithoutGPS.Enqueue(meta);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(string.Format("Error 2: {0}", e.Message));
                    }
                }

                inProgress = false;
                Task.WaitAll(copyPhotosTask);

                //photoWithGPSInProgress = false;
                //Task.WaitAll(copyPhotosWithoutGPSTask);
                CopyPhotosWithoutGPS();

                // Save metadata as log
                SaveMetadata();
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Error: {0}", e.Message));
                // throw;
            }
        }