Example #1
0
    protected async Task LoadSecretsIfNecessaryAsync()
    {
        if (SecretEncrypterFunction != null)
        {
            return;
        }

        var encrypterSecret = new SecretStringEncrypterFunction();
        var errorsAndInfos  = new ErrorsAndInfos();
        var csLambda        = await SecretRepository.GetAsync(encrypterSecret, errorsAndInfos);

        SecretEncrypterFunction = await SecretRepository.CompileCsLambdaAsync <string, string>(csLambda);

        var decrypterSecret = new SecretStringDecrypterFunction();

        csLambda = await SecretRepository.GetAsync(decrypterSecret, errorsAndInfos);

        SecretDecrypterFunction = await SecretRepository.CompileCsLambdaAsync <string, string>(csLambda);

        if (!errorsAndInfos.AnyErrors())
        {
            return;
        }

        throw new Exception(errorsAndInfos.ErrorsToString());
    }
        public async Task <IEnumerable <BackbendFolderToBeArchived> > AnalyzeAsync(IErrorsAndInfos errorsAndInfos)
        {
            var result          = new List <BackbendFolderToBeArchived>();
            var backbendFolders = await SecretRepository.GetAsync(new BackbendFoldersSecret(), errorsAndInfos);

            if (errorsAndInfos.AnyErrors())
            {
                return(result);
            }
            await backbendFolders.ResolveAsync(FolderResolver, errorsAndInfos);

            if (errorsAndInfos.AnyErrors())
            {
                return(result);
            }
            var archiveFolderFinderSecret = await SecretRepository.GetAsync(new ArchiveFolderFinderSecret(), errorsAndInfos);

            if (errorsAndInfos.AnyErrors())
            {
                return(result);
            }

            var archiveFolderFinder = await SecretRepository.CompileCsLambdaAsync <string, string>(archiveFolderFinderSecret);

            if (archiveFolderFinder == null)
            {
                errorsAndInfos.Errors.Add(Properties.Resources.CouldNotCompileFolderFinder);
                return(result);
            }

            foreach (var backbendFolder in backbendFolders)
            {
                AnalyzeFolderAsync(backbendFolder, archiveFolderFinder, result);
                foreach (var subFolder in Directory.GetDirectories(backbendFolder.GetFolder().FullName).Select(f => new BackbendFolder {
                    Name = f
                }))
                {
                    subFolder.SetFolder(new Folder(subFolder.Name));
                    AnalyzeFolderAsync(subFolder, archiveFolderFinder, result);
                }
            }

            return(result);
        }