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); } }
public override async Task Process(OkCommand command) { IOutputConsole.Write($"Waiting for [{command.Url}]..."); var start = DateTime.Now; while (true) { var status = await ICurlHelper.Curl(command.Url); if (status == HttpStatusCode.OK) { var ts = DateTime.Now - start; IOutputConsole.WriteLine($" {(int)ts.TotalSeconds} sec. OK"); IOutputConsole.WriteLine(""); return; } } }
private async Task <List <FileInfo> > UploadFilesAsync(TargetFtpConfig targetFtp, List <FileInfo> files) { var result = new List <FileInfo>(); var worker = new FtpWorker(targetFtp); Container.Shared.Inject(worker); worker.Enqueue(files.ToArray()); var root = IRootHelper.GetRoot(); worker.FileWillUpload += (sender, a) => { lock (this) { IOutputConsole.ClearLine(); IOutputConsole.Write($"uploading {a.FilesLeft} {root.GetRealtive(a.File)}"); } }; worker.FileDidUpload += (sender, a) => { lock (result) { result.Add(a.File); } }; worker.FileError += (sender, a) => { lock (this) { IOutputConsole.ClearLine(); IOutputConsole.WriteLine($"error: {root.GetRealtive(a.File)}, [{a.Message}]"); } }; await worker.UploadAsync(); return(result); }
private async Task UploadLastRunAsync(IFtpClient ftpClient, List <FileInfo> files) { IOutputConsole.ClearLine(); IOutputConsole.Write("uploading .LastRun"); await WriteLastRunAsync(ftpClient, files); }