예제 #1
0
 private void TaskError_Received(TaskError error)
 {
     Console.WriteLine("[Downloader] TaskError");
     Console.WriteLine("[Downloader] TaskError Id : {0}", error.Id);
     Console.WriteLine("[Downloader] TaskError Error : {0}", error.Error);
     Console.WriteLine("[Downloader] TaskError Description : {0}", error.Description);
 }
        public async void TaskError(TaskError error)
        {
            Console.WriteLine("[Downloadanager] TaskError");
            Console.WriteLine("[Downloadanager] TaskError Id          : {0}", error.Id);
            Console.WriteLine("[Downloadanager] TaskError Error       : {0}", error.Error);
            Console.WriteLine("[Downloadanager] TaskError Description : {0}", error.Description);
            Console.WriteLine("[Downloadanager] TaskError StatusCode  : {0}", error.StatusCode);

            Download download;
            bool     found = _repo.TryById(error.Id, out download);

            if (!found)
            {
                var invalididentifier = new DownloadError {
                    Id    = error.Id,
                    Error = ErrorEnum.TaskError_IdentifierNotFound
                };
                await _bus.SendAsync <DownloadError> (invalididentifier);

                return;
            }

            bool failed = download.TryFail(error.StatusCode, error.Error, error.Description);

            if (!failed)
            {
                await _bus.SendAsync <DownloadError> (new DownloadError {
                    Id    = download.Id,
                    State = download.State,
                    Error = ErrorEnum.TaskError_InvalidState
                });

                return;
            }
            _repo.Update(download);

            await _bus.SendAsync <NotifyProgress> (new NotifyProgress {
                Url      = download.Url,
                Download = download
            });
        }
		private void TaskError_Received(TaskError error) 
		{
			Console.WriteLine("[Downloader] TaskError");
			Console.WriteLine("[Downloader] TaskError Id : {0}", error.Id);
			Console.WriteLine("[Downloader] TaskError Error : {0}", error.Error);
			Console.WriteLine("[Downloader] TaskError Description : {0}", error.Description);
		}
		public async void TaskError(TaskError error) {

			Console.WriteLine("[Downloadanager] TaskError");
			Console.WriteLine("[Downloadanager] TaskError Id          : {0}", error.Id);
			Console.WriteLine("[Downloadanager] TaskError Error       : {0}", error.Error);
			Console.WriteLine("[Downloadanager] TaskError Description : {0}", error.Description);
			Console.WriteLine("[Downloadanager] TaskError StatusCode  : {0}", error.StatusCode);

			Download download;
			bool found = _repo.TryById(error.Id, out download);

			if (!found) {
				var invalididentifier = new DownloadError {
					Id = error.Id,
					Error = ErrorEnum.TaskError_IdentifierNotFound
				};
				await _bus.SendAsync<DownloadError> (invalididentifier);
				return;
			}

			bool failed = download.TryFail (error.StatusCode, error.Error, error.Description);
			if (!failed) {
				await _bus.SendAsync<DownloadError> (new DownloadError {
					Id = download.Id,
					State = download.State,
					Error = ErrorEnum.TaskError_InvalidState
				});
				return;
			}
			_repo.Update (download);

			await _bus.SendAsync<NotifyProgress> (new NotifyProgress {
				Url = download.Url,
				Download = download
			});

		}