Пример #1
0
 public override void DoImpl()
 {
     MakeSureItsSafeToCloseTheVault();
     
     var vaultDialog = new VaultDialogForm(VaultAction.Create);
     if (vaultDialog.ShowDialog(DataVaultEditor) == DialogResult.OK)
     {
         var vault = vaultDialog.SelectedVault.AssertNotNull();
         Ctx.SetVault(vault, true);
     }
     else
     {
         throw new CommandExecutionCancelledException();
     }
 }
Пример #2
0
        public override void DoImpl()
        {
            // check for modifications of current vault
            MakeSureItsSafeToCloseTheVault();

            // open a new vault
            var vaultDialog = new VaultDialogForm(VaultAction.Open);
            if (vaultDialog.ShowDialog(DataVaultEditor) == DialogResult.OK)
            {
                var vault = vaultDialog.SelectedVault.AssertNotNull();
                Ctx.SetVault(vault, true);
            }
            else
            {
                throw new CommandExecutionCancelledException();
            }

            // load previously opened views for the vault loaded
            Ctx.Execute(new CtxInitializeViews(Ctx));
        }
Пример #3
0
        public override void DoImpl()
        {
            var vaultDialog = new VaultDialogForm(VaultAction.Import);
            if (vaultDialog.ShowDialog(DataVaultEditor) == DialogResult.OK)
            {
                using (var vault = vaultDialog.SelectedVault.AssertNotNull())
                {
                    if (Vault.Uri == vault.Uri)
                    {
                        throw new ValidationException(Resources.Validation_SourceAndTargetOfExportImportAreTheSame);
                    }
                    else
                    {
                        if (MessageBox.Show(Resources.Import_Precaution_Message, Resources.Import_Precaution_Title,
                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                        {
                            // we need to discard views before import
                            // to avoid possible side-effects they introduce
                            Views.ForEach(v => { v.Discard(); Views.Pop(); });

                            var @this = Ctx.Vault;
                            @this.Root.Delete();
                            @this.ImportFrom(vault);
                            @this.Save();

                            Ctx.SetVault(@this, true);
                        }
                        else
                        {
                            throw new CommandExecutionCancelledException();
                        }
                    }
                }
            }
            else
            {
                throw new CommandExecutionCancelledException();
            }
        }
Пример #4
0
 public override void DoImpl()
 {
     var vaultDialog = new VaultDialogForm(VaultAction.Export);
     if (vaultDialog.ShowDialog(DataVaultEditor) == DialogResult.OK)
     {
         using (var vault = vaultDialog.SelectedVault.AssertNotNull())
         {
             if (Vault.Uri == vault.Uri)
             {
                 throw new ValidationException(Resources.Validation_SourceAndTargetOfExportImportAreTheSame);
             }
             else
             {
                 vault.ImportFrom(vault, CollisionHandling.Overwrite);
                 vault.Save();
             }
         }
     }
     else
     {
         throw new CommandExecutionCancelledException();
     }
 }