Ejemplo n.º 1
0
        public void CreateAchive(string databaseConfigFileFullName)
        {
            if (File.Exists(databaseConfigFileFullName) == false)
            {
                //...
                return;
            }

            string databaseConfigPath = Path.GetDirectoryName(databaseConfigFileFullName);

            if (FileHelper.TryToGetConfigurationParams(databaseConfigFileFullName, out fileStorageDirectory, out databaseString) == true)
            {
                string fileStorageDirectoryFullPath = Environment.ExpandEnvironmentVariables(Path.Combine(fileStorageDirectory, fileData));
                string databaseFileFullName = Environment.ExpandEnvironmentVariables(databaseString);

                if (String.IsNullOrEmpty(Path.GetDirectoryName(databaseFileFullName)))
                {
                    databaseFileFullName = Path.Combine(databaseConfigPath, Path.GetFileName(databaseString));
                }

                if (Directory.Exists(fileStorageDirectoryFullPath) == false)
                {
                    //...
                    return;
                }
                if (File.Exists(databaseFileFullName) == false)
                {
                    //...
                    return;
                }

                SaveFileDialog dialog = new SaveFileDialog() { OverwritePrompt = true, ValidateNames = true, FileName = FileHelper.GetArchiveName() };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string archiveFileName = dialog.FileName;

                    progress = new ProgressForm();

                    progress.CancelOperationButtonClick += CancelArchiveButton_Click;

                    backupper = new Backupper();
                    backupper.TotalProgress += TotalProgress;
                    backupper.CurrentEntryBytesProgress += CurrentEnrtyBytesProgress;

                    backupper.OperationComplete += (status) =>
                    {
                        this.Completed();
                    };

                    backupper.StartArchiving(fileStorageDirectoryFullPath, databaseFileFullName, archiveFileName);

                    progress.ShowDialog();
                }

            }
        }
Ejemplo n.º 2
0
        private void RestoreFromArchiveButton_Click(object sender, EventArgs e)
        {
            string databaseConfigFileFullName = ConfigFileTextBox.Text;

            if (File.Exists(databaseConfigFileFullName) == false)
            {
                //...
                return;
            }

            string databaseConfigPath = Path.GetDirectoryName(databaseConfigFileFullName);

            if (FileHelper.TryToGetConfigurationParams(databaseConfigFileFullName, out fileStorageDirectory, out databaseString) == true)
            {
                //string fileStorageDirectoryFullPath = Environment.ExpandEnvironmentVariables(Path.Combine(fileStorageDirectory, fileData));

                string fileStorageDirectoryFullPath = Environment.ExpandEnvironmentVariables(fileStorageDirectory);
                string databaseFileFullName = Environment.ExpandEnvironmentVariables(databaseString);

                if (String.IsNullOrEmpty(Path.GetDirectoryName(databaseFileFullName)))
                {
                    databaseFileFullName = Path.Combine(databaseConfigPath, Path.GetFileName(databaseString));
                }

                //string fileStorageDirectoryFullPath = Path.Combine(fileStorageDirectory, fileData);

                OpenFileDialog dialog = new OpenFileDialog() { };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string archive = dialog.FileName;

                    progress = new ProgressForm();

                    progress.CancelOperationButtonClick += CancelArchiveButton_Click;

                    backupper = new Backupper();
                    backupper.TotalProgress += TotalProgress;
                    backupper.CurrentEntryBytesProgress += CurrentEnrtyBytesProgress;

                    backupper.OperationComplete += (status) =>
                    {
                        this.Completed();
                    };

                    backupper.StartRestoring(fileStorageDirectoryFullPath, databaseFileFullName, archive);

                    progress.ShowDialog();

                    //RestoreFromArchive(archive);
                }
            }
        }