public async void FinishedDownload(FinishedDownload finished) { Console.WriteLine("[Downloadanager] FinishedDownload"); Console.WriteLine("[Downloadanager] FinishedDownload Id : {0}", finished.Id); Console.WriteLine("[Downloadanager] FinishedDownload Location : {0}", finished.Location); Download download; bool found = _repo.TryById(finished.Id, out download); if (!found) { var error = new DownloadError { Id = finished.Id, Error = ErrorEnum.FinishedDownload_IdentifierNotFound }; await _bus.SendAsync <DownloadError> (error); return; } bool progressed = download.TryFinish(finished.Location); if (!progressed) { await _bus.SendAsync <DownloadError> (new DownloadError { Id = download.Id, State = download.State, Error = ErrorEnum.FinishedDownload_InvalidState }); return; } _repo.Update(download); await _bus.SendAsync <NotifyProgress> (new NotifyProgress { Url = download.Url, Download = download }); await _bus.SendAsync <NotifyFinish> (new NotifyFinish { Url = download.Url, Download = download, FileLock = finished.FileLock }); }
public async void FinishedDownload (FinishedDownload finished) { Console.WriteLine("[Downloadanager] FinishedDownload"); Console.WriteLine("[Downloadanager] FinishedDownload Id : {0}", finished.Id); Console.WriteLine("[Downloadanager] FinishedDownload Location : {0}", finished.Location); Download download; bool found = _repo.TryById(finished.Id, out download); if (!found) { var error = new DownloadError { Id = finished.Id, Error = ErrorEnum.FinishedDownload_IdentifierNotFound }; await _bus.SendAsync<DownloadError> (error); return; } bool progressed = download.TryFinish (finished.Location); if (!progressed) { await _bus.SendAsync<DownloadError> (new DownloadError { Id = download.Id, State = download.State, Error = ErrorEnum.FinishedDownload_InvalidState }); return; } _repo.Update (download); await _bus.SendAsync<NotifyProgress> (new NotifyProgress { Url = download.Url, Download = download }); await _bus.SendAsync<NotifyFinish> (new NotifyFinish { Url = download.Url, Download = download, FileLock = finished.FileLock }); }