Пример #1
0
		private async Task ContinueAfterFilePickAsync(IStorageFile file, IStorageFolder directory, Folder folder, Wallet parentWallet, bool deleteFile = false)
		{
			bool isImported = false;

			try
			{
				if (directory != null && file != null && await file.GetFileSizeAsync().ConfigureAwait(false) <= ConstantData.MAX_IMPORTABLE_MEDIA_FILE_SIZE)
				{
					_animationStarter.StartAnimation(AnimationStarter.Animations.Updating);

					StorageFile newFile = await file.CopyAsync(directory, file.Name, NameCollisionOption.GenerateUniqueName).AsTask().ConfigureAwait(false);

					if (parentWallet == null)
					{
						isImported = await folder.ImportMediaFileIntoNewWalletAsync(newFile).ConfigureAwait(false);

					}
					else
					{
						isImported = await parentWallet.ImportFileAsync(newFile).ConfigureAwait(false);
					}

					if (!isImported)
					{
						// delete the copied file if something went wrong
						if (newFile != null) await newFile.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask().ConfigureAwait(false);
						Logger.Add_TPL("isImported = false", Logger.AppEventsLogFilename, Logger.Severity.Info);
					}
					// delete the original file if it was a photo taken with CameraCaptureUI
					if (deleteFile) await file.DeleteAsync(StorageDeleteOption.PermanentDelete).AsTask().ConfigureAwait(false);
				}
			}
			catch (Exception ex)
			{
				await Logger.AddAsync(ex.ToString(), Logger.AppEventsLogFilename).ConfigureAwait(false);
			}

			_animationStarter.EndAllAnimations();
			_animationStarter.StartAnimation(isImported
				? AnimationStarter.Animations.Success
				: AnimationStarter.Animations.Failure);

			IsImportingMedia = false;
		}