Пример #1
0
        public static void Main(string[] args)
        {
            var parameters = ExecutionParameters.GetParametersFromArgs(args);

            if (parameters == null)
            {
                Log.Fatal("No config file could be found in the default location (my documents) and none was specified in the parameters.");
                Environment.Exit(0);
            }

            var errors = parameters.GetValidationErrors();

            if (errors.Any())
            {
                Log.Fatal("Configuration/parameter errors occurredt:");
                foreach (var e in errors)
                {
                    Log.Fatal(e);
                }
                Environment.Exit(0);
            }

            Log.InfoFormat("Glacier valut: {0}", parameters.Glacier.VaultName);
            var glacierGateway = new GlacierGateway(parameters.Glacier);

            Log.InfoFormat("Archiving pictures from: {0}", parameters.Avalanche.CatalongFilePath);
            var lightroomRepository = new LightroomRepository(parameters.Avalanche.CatalongFilePath);

            Log.InfoFormat("Collection name: {0}", parameters.Avalanche.AdobeCollectionName);
            var allPictures = lightroomRepository.GetAllPictures(parameters.Avalanche.AdobeCollectionName);
            var toUpload    = allPictures.Where(a => a.LibraryCount > 0 && string.IsNullOrWhiteSpace(a.CopyName)).ToList();

            Log.InfoFormat("Selected {0} pictures out from {1}", toUpload.Count, allPictures.Count);
            using (var insomniac = new Insomniac())
            {
                var uploader = new GlacierUploader(lightroomRepository, glacierGateway, parameters.DryRun);
                uploader.RunUploader(toUpload);
            }

            var missing = allPictures.Where(p => !File.Exists(Path.Combine(p.AbsolutePath, p.FileName))).ToList();

            Log.InfoFormat("Downloading {0} missing files...", missing.Count);

            Log.Info("Done");
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var parameters = ExecutionParameters.GetParametersFromArgs(args);

            if (parameters == null)
            {
                _log.Fatal("No config file could be found in the default location (my documents) and none was specified in the parameters.");
                Environment.Exit(0);
            }

            var errors = parameters.GetValidationErrors();

            if (errors.Any())
            {
                _log.Fatal("Configuration/parameter errors occurredt:");
                foreach (var e in errors)
                {
                    _log.Fatal(e);
                }
                Environment.Exit(0);
            }

            using (var insomniac = new Insomniac())
            {
                var lightroomRepo = new LightroomRepository(parameters.Avalanche.CatalongFilePath);
                var avalancheRepo = new AvalancheRepository(parameters.Avalanche.AvalancheFilePath);
                var gateway       = new GlacierGateway(parameters.Glacier);

                var catalogId        = lightroomRepo.GetUniqueId();
                var allPictures      = lightroomRepo.GetAllPictures();
                var filteredPictures = allPictures.Where(a => a.LibraryCount > 0 && !avalancheRepo.FileIsArchived(a.FileId)).ToList();

                _log.InfoFormat("Backing up {0} images", filteredPictures.Count);

                var index = 0;
                foreach (var f in filteredPictures)
                {
                    _log.InfoFormat("Archiving {0}/{1}: {2}", ++index, filteredPictures.Count, Path.Combine(f.AbsolutePath, f.FileName));

                    // Try three times
                    ArchivedPictureModel archive = null;
                    for (var i = 0; i < 3; ++i)
                    {
                        try
                        {
                            archive = gateway.SaveImage(f, parameters.Glacier.VaultName);
                        }
                        catch (Exception ex)
                        {
                            _log.ErrorFormat("Error!!! {0}", ex);
                            continue;
                        }
                        break;
                    }

                    if (archive == null)
                    {
                        continue;
                    }

                    avalancheRepo.MarkFileAsArchived(archive, parameters.Glacier.VaultName, parameters.Glacier.Region, parameters.Avalanche.CatalongFilePath, catalogId.ToString());
                }

                _log.Info("Done");
            }
        }
Пример #3
0
 public DependencyInjectionInstaller(ExecutionParameters executionParameters)
 {
     _executionParameters = executionParameters;
 }