Example #1
0
        private async Task CleanupAsync(TargetFtpConfig targetFtp, LastRunConfig lastRun, List <FileInfo> files)
        {
            if (lastRun == null)
            {
                return;
            }

            using (var helper = IFtpFactory.CleanupHelper(targetFtp))
            {
                IOutputConsole.ClearLine();
                IOutputConsole.Write("cleanup...");

                helper.DidCleanup += (sender, remoteFile) =>
                {
                    IOutputConsole.ClearLine();
                    IOutputConsole.Write($"cleanup [{remoteFile}]");
                };

                helper.Error += (sender, remoteFile) =>
                {
                    IOutputConsole.ClearLine();
                    IOutputConsole.Write($"error [{remoteFile}]");
                };

                await helper.DeleteNotContainedFiles(lastRun, files);
            }
        }
Example #2
0
        private async Task WriteLastRunAsync(IFtpClient ftpClient, List <FileInfo> files)
        {
            var root = IRootHelper.GetRoot();

            var lastRun = new LastRunConfig
            {
                Dt = DateTime.Now,

                Files =
                    files
                    .Select(x => root.GetRealtive(x))
                    .ToList()
            };

            var json = lastRun.ToJsonWithTypeInformation();

            await ftpClient.UploadStringAsync(_LastRunFileName, json);
        }
Example #3
0
        private List <FileInfo> GetNewFiles(LastRunConfig lastRun, List <FileInfo> files)
        {
            var result = new List <FileInfo>();

            var root      = IRootHelper.GetRoot();
            var lastFiles = lastRun.Files.ToHashSet();

            foreach (var file in files)
            {
                var relative = root.GetRealtive(file);

                if (lastFiles.Contains(relative))
                {
                    continue;
                }

                result.Add(file);
            }

            return(result);
        }