public FormSerializationCancellationToken(ProgressForm progressForm) : this()
		{
			this._progressForm = progressForm;
		}
		public FormSerializationCancellationToken()
		{
			this._progressForm = null;
		}
Ejemplo n.º 3
0
		private void saveToolStripMenuItem_Click(object sender, EventArgs e)
		{
			frmSaveDialog        saveDialog = new frmSaveDialog();
			ConnectionData       connection = null;
			ConnectionTabControl currentTab = (ConnectionTabControl)tabMain.SelectedTab.Controls[0];

			if (currentTab != null)
			{
				connection = currentTab.GetSelectedConnection();
			}

			if (connection == null)
			{
				saveDialog.DisableCurrentScope();
			}
			else
			{
				saveDialog.SetCurScopeName(connection.SourceConnectionName);
			}

			if (saveDialog.ShowDialog() == DialogResult.OK)
			{
				if (saveDialog.Scope == frmSaveDialog.ScopeToSave.All)
				{
					currentTab = null;
				}

				StorageSerializationInfo serializationInfo = new StorageSerializationInfo(
					this._model,
					currentTab,
					saveDialog.Folder,
					saveDialog.SaveCurrent,
					saveDialog.SaveHistoric
				);

				ProgressForm form = new ProgressForm
				{
					Text = this._model.LocaleManager.GetLocalizedText(
						this.Name,
						"lbSerialization",
						this._model.Settings.InterfaceLanguage
					),
					StartPosition = FormStartPosition.CenterParent
				};

				form.ProgressBar.Style = ProgressBarStyle.Marquee;

				form.Argument = serializationInfo;
				form.DoWork  += DoSerializationWork;

				StartSerializationForm(form);
			}
		}
Ejemplo n.º 4
0
		private void StartSerializationForm(ProgressForm form)
		{
			DialogResult result = form.ShowDialog();

			if (result == DialogResult.Cancel)
			{
				MessageBox.Show(
					this._model.LocaleManager.GetLocalizedText(
						"common",
						"operationCancelled",
						this._model.Settings.InterfaceLanguage
					),
					null,
					MessageBoxButtons.OK,
					MessageBoxIcon.Warning
				);
			}

			if (result == DialogResult.Abort)
			{
				log.Error("Exception at Save MSD", form.Result.Error);

				MessageBox.Show(
					this._model.LocaleManager.GetLocalizedText(
						LocaleManager.Exceptions,
						"saveMsdProblem",
						this._model.Settings.InterfaceLanguage
					),
					null,
					MessageBoxButtons.OK,
					MessageBoxIcon.Error
				);
			}
		}
Ejemplo n.º 5
0
		private void DoSerializationWork(ProgressForm progressForm, DoWorkEventArgs e)
		{
			StorageSerializationInfo serializationInfo = e.Argument as StorageSerializationInfo;

			if (serializationInfo != null)
			{
				var remoteVaultSerializer = new StorageSerializer(
					serializationInfo.Model,
					serializationInfo.TabControl
				);

				ISerializationCancellationToken canceller = new FormSerializationCancellationToken(progressForm);

				try
				{
					remoteVaultSerializer.SaveData(
						serializationInfo.OutputFolder,
						serializationInfo.SaveCurrentDatabase,
						serializationInfo.SaveHistoricDatabase,
						canceller
					);
				}
				catch (OperationCanceledException ex)
				{
					log.Error("Exception at Concelled", ex);
					e.Cancel = true;
				}
			}
		}