protected override async Task OpenMayOverrideAsync(object args = null)
		{
			_briefcase = Briefcase.GetCreateInstance();
			await _briefcase.OpenAsync();
			await _briefcase.OpenCurrentBinderAsync();
			RaisePropertyChanged_UI(nameof(Briefcase)); // notify UI once briefcase is open
		}
Beispiel #2
0
		public static Briefcase GetCreateInstance(bool isLight = false)
		{
			lock (_instanceLock)
			{
				if (_instance == null /*|| _instance._isDisposed*/ || _instance._isLight != isLight)
				{
					_instance = new Briefcase(isLight);
				}
				return _instance;
			}
		}
Beispiel #3
0
		private RuntimeData(Briefcase briefcase, bool isLight)
		{
			_briefcase = briefcase;
			_isLight = isLight;
			if (isLight) return;


			_videoDeviceWatcher = DeviceInformation.CreateWatcher(DeviceClass.VideoCapture);
			_audioDeviceWatcher = DeviceInformation.CreateWatcher(DeviceClass.AudioCapture);
		}
Beispiel #4
0
		public static RuntimeData GetInstance(Briefcase briefcase, bool isLight)
		{
			lock (_instanceLocker)
			{
				if (_instance == null /*|| _instance._isDisposed*/ || _instance._isLight != isLight)
				{
					_instance = new RuntimeData(briefcase, isLight);
				}
				return _instance;
			}
		}
Beispiel #5
0
		private async Task ContinueAfterExportBinderPickerAsync(StorageFolder toDir, string dbName, Briefcase bc)
		{
			bool isExported = false;
			try
			{
				if (bc != null && toDir != null)
				{
					_animationStarter.StartAnimation(AnimationStarter.Animations.Updating);

					if (string.IsNullOrWhiteSpace(dbName) /*|| _dbNames?.Contains(dbName) == false */|| toDir == null) return;

					var fromDirectory = await Briefcase.BindersDirectory
						.GetFolderAsync(dbName)
						.AsTask().ConfigureAwait(false);
					if (fromDirectory == null) return;
					// what if you copy a directory to an existing one? Shouldn't you delete the contents first? No! But then, shouldn't you issue a warning?
					var toDirectoryTest = await toDir.TryGetItemAsync(dbName).AsTask().ConfigureAwait(false);
					if (toDirectoryTest != null)
					{
						var confirmation =
							await UserConfirmationPopup.GetInstance().GetUserConfirmationBeforeExportingBinderAsync(CancToken).ConfigureAwait(false);
						if (CancToken.IsCancellationRequested) return;
						if (confirmation == null || confirmation.Item1 == false || confirmation.Item2 == false) return;
					}

					isExported = await bc.ExportBinderAsync(dbName, fromDirectory, toDir).ConfigureAwait(false);
				}
			}
			catch (Exception ex)
			{
				await Logger.AddAsync(ex.ToString(), Logger.FileErrorLogFilename, Logger.Severity.Info).ConfigureAwait(false);
			}
			finally
			{
				_animationStarter.EndAllAnimations();
				if (!CancToken.IsCancellationRequested)
					_animationStarter.StartAnimation(isExported
						? AnimationStarter.Animations.Success
						: AnimationStarter.Animations.Failure);

				IsExportingBinder = false;
			}
		}
Beispiel #6
0
		private async Task ContinueImportBinderStep2_Merge_Async(Briefcase bc, StorageFolder dir)
		{
			bool isImported = false;

			try
			{
				if (bc != null && dir != null)
				{
					_animationStarter.StartAnimation(AnimationStarter.Animations.Updating);
					isImported = await bc.MergeBinderAsync(dir).ConfigureAwait(false);
				}
			}
			catch (Exception ex)
			{
				await Logger.AddAsync(ex.ToString(), Logger.FileErrorLogFilename).ConfigureAwait(false);
			}

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

			IsImportingBinder = false;
		}
Beispiel #7
0
		private async Task ContinueImportBinderStep1Async(Briefcase bc, StorageFolder dir)
		{
			try
			{
				if (bc != null && dir != null)
				{
					var isDbNameAvailable = await bc.IsDbNameAvailableAsync(dir.Name).ConfigureAwait(false);
					if (isDbNameAvailable == BoolWhenOpen.Yes)
					{
						Logger.Add_TPL("ContinueImportBinderStep1Async(): db name is available", Logger.AppEventsLogFilename, Logger.Severity.Info);

						var nextAction = await UserConfirmationPopup.GetInstance().GetUserConfirmationBeforeImportingBinderAsync(CancToken).ConfigureAwait(false);
						if (CancToken.IsCancellationRequested) ContinueImportBinderStep2_Cancel();
						Logger.Add_TPL("ContinueImportBinderStep1Async(): user choice = " + nextAction.Item1.ToString(), Logger.AppEventsLogFilename, Logger.Severity.Info);
						Logger.Add_TPL("ContinueImportBinderStep1Async(): user has interacted = " + nextAction.Item2.ToString(), Logger.AppEventsLogFilename, Logger.Severity.Info);
						if (nextAction.Item1 == ImportBinderOperations.Merge) await ContinueImportBinderStep2_Merge_Async(bc, dir).ConfigureAwait(false);
						else if (nextAction.Item1 == ImportBinderOperations.Import) await ContinueImportBinderStep2_Import_Async(bc, dir).ConfigureAwait(false);
						else ContinueImportBinderStep2_Cancel();
					}
					else if (isDbNameAvailable == BoolWhenOpen.No)
					{
						Logger.Add_TPL("ContinueImportBinderStep1Async(): db name is NOT available", Logger.AppEventsLogFilename, Logger.Severity.Info);
						await ContinueImportBinderStep2_Import_Async(bc, dir).ConfigureAwait(false);
					}
					else if (isDbNameAvailable == BoolWhenOpen.ObjectClosed)
					{
						await Logger.AddAsync("ContinueImportBinderStep1Async(): briefcase is closed, which should never happen, or the operation was cancelled", Logger.AppEventsLogFilename).ConfigureAwait(false);
					}
				}
			}
			catch (Exception ex)
			{
				await Logger.AddAsync(ex.ToString(), Logger.AppEventsLogFilename).ConfigureAwait(false);
			}
			finally
			{
				IsImportingBinder = false;
			}
		}
Beispiel #8
0
		protected override async Task OpenMayOverrideAsync(object args = null)
		{
			_briefcase = Briefcase.GetCreateInstance();
			await _briefcase.OpenAsync();
			RaisePropertyChanged_UI(nameof(Briefcase)); // notify UI once briefcase is open

			await UpdateIsCanImportExportAsync().ConfigureAwait(false);

			if (IsExportingBinder)
			{
				string dbName = RegistryAccess.GetValue(ConstantData.REG_EXPORT_BINDER_DBNAME);
				await ContinueAfterExportBinderPickerAsync(await Pickers.GetLastPickedFolderAsync().ConfigureAwait(false), dbName, _briefcase).ConfigureAwait(false);
			}
			if (IsImportingBinder)
			{
				var dir = await Pickers.GetLastPickedFolderAsync().ConfigureAwait(false);
				//string step = RegistryAccess.GetValue(ConstantData.REG_IMPORT_BINDER_STEP);
				//if (step == "1")
				//{
				await ContinueImportBinderStep1Async(_briefcase, dir).ConfigureAwait(false);
				//}
				//else if (step == "2")
				//{
				//	string action = RegistryAccess.GetValue(ConstantData.REG_IMPORT_BINDER_STEP2_ACTION);
				//	if (action == ImportBinderOperations.Import.ToString())
				//	{
				//		await ContinueImportBinderStep2_Import_Async(_briefcase, dir).ConfigureAwait(false);
				//	}
				//	else if (action == ImportBinderOperations.Merge.ToString())
				//	{
				//		await ContinueImportBinderStep2_Merge_Async(_briefcase, dir).ConfigureAwait(false);
				//	}
				//	else
				//	{
				//		ContinueImportBinderStep2_Cancel();
				//	}
				//}
			}
		}
Beispiel #9
0
		private bool CopyFrom(Briefcase source)
		{
			if (source == null) return false;

			IsAllowMeteredConnection = source._isAllowMeteredConnection;
			IsWantToUseOneDrive = source._isWantToUseOneDrive;
			NewDbName = source._newDbName;
			CurrentBinderName = source._currentBinderName; // CurrentBinder is set later
			CameraCaptureResolution = source._cameraCaptureResolution;
			return true;
		}
Beispiel #10
0
		private async Task ContinueAfterFileOpenPickerAsync(StorageFile file, Briefcase bc)
		{
			bool isImported = false;

			try
			{
				if (bc != null && file != null)
				{
					_animationStarter.StartAnimation(AnimationStarter.Animations.Updating);
					isImported = await bc.ImportSettingsAsync(file).ConfigureAwait(false);
				}
			}
			catch (Exception ex)
			{
				await Logger.AddAsync(ex.ToString(), Logger.AppEventsLogFilename).ConfigureAwait(false);
			}

			_animationStarter.EndAllAnimations();
			if (isImported)
			{
				_animationStarter.StartAnimation(AnimationStarter.Animations.Success);
				Refresh();
			}
			else
			{
				_animationStarter.StartAnimation(AnimationStarter.Animations.Failure);
			}

			IsImportingSettings = false;
		}
Beispiel #11
0
		public SettingsVM(Briefcase briefcase, AnimationStarter animationStarter)
		{
			lock (_instanceLocker)
			{
				_instance = this;

				_animationStarter = animationStarter;
				_backgroundTaskHelper = App.BackgroundTaskHelper;
				RaisePropertyChanged_UI(nameof(BackgroundTaskHelper));
				_briefcase = briefcase;
				RaisePropertyChanged_UI(nameof(Briefcase));
				//UpdateUnassignedFields();
			}
		}
		internal MetaBriefcaseOneDriveReaderWriter(Briefcase briefcase, RuntimeData runtimeData)
		{
			_briefcase = briefcase;
			_runtimeData = runtimeData;
		}
		private MetaBriefcase(RuntimeData runtimeData, Briefcase briefcase)
		{
			_briefcase = briefcase;
			_runtimeData = runtimeData;

			_oneDriveReaderWriter = new MetaBriefcaseOneDriveReaderWriter(_briefcase, _runtimeData);
			_rubbishBin = new MetaBriefcaseRubbishBin(this);
		}
		internal static MetaBriefcase GetInstance(RuntimeData runtimeData, Briefcase briefcase)
		{
			lock (_instanceLocker)
			{
				if (_instance == null)
				{
					_instance = new MetaBriefcase(runtimeData, briefcase);
				}
				return _instance;
			}
		}
		public ChoiceBeforeImportingBinder(string targetBinderName)
		{
			_briefcase = Briefcase.GetCurrentInstance();
			_dbNames.ReplaceAll(_briefcase.DbNames.Where(dbn => dbn != targetBinderName));
			InitializeComponent();
		}