private void bwRestore_DoWork(object sender, DoWorkEventArgs e) { bwRestore.ReportProgress(0, "Extracting files..."); ExtractZipFile(txtBackupFile.Text, _tempPath); string jsonConfig = File.ReadAllText(Path.Combine(_tempPath, "provisioner.settings")); ProvisionerSettings settings = ProvisionerSettings.ReadFromJson(jsonConfig); IProvisionerRestore provisioner = ProvisionRestoreResolver.GetRestoreProvisioner(settings); provisioner.SetProjectFolder(txtProjectFolder.Text); provisioner.SetSettings(settings); provisioner.SetSourceFolder(_tempPath); bwRestore.ReportProgress(60, "Importing VM..."); VirtualBox box = new VirtualBox(_vBoxManagePath, _tempPath); box.ImportBox(); bwRestore.ReportProgress(90, "Copying data..."); DirectoryExtension.CopyRecursive(Path.Combine(_tempPath, "files"), txtProjectFolder.Text); provisioner.Restore(box.ImportedUUID); bwRestore.ReportProgress(100, "Done."); }
public static IProvisionerRestore GetRestoreProvisioner(ProvisionerSettings settings) { switch (settings.provisionerName) { case PuphpetRestore.Name: return(new PuphpetRestore()); } return(null); }
public ProvisionerSettings GetProvisionerSettings() { ProvisionerSettings settings = new ProvisionerSettings(); settings.provisionerName = "puphpet"; string replacePath = _projectPath + "\\"; settings.Set("idPath", txtIDFilePath.Text.Replace(replacePath, "")); settings.Set("actionProvisionPath", txtActionProvisionPath.Text.Replace(replacePath, "")); settings.Set("syncedFoldersPath", txtSyncedFoldersPath.Text.Replace(replacePath, "")); settings.Set("projectPath", _projectPath); return(settings); }
private void btnBackup_Click(object sender, EventArgs e) { if (_provisioner == null) { return; } if (!_provisioner.CanPerformBackup()) { MessageBox.Show("Please fill out all provisioner settings.", "Cannot perform backup", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrWhiteSpace(txtDestination.Text)) { MessageBox.Show("Please fill out backup file destination.", "Cannot perform backup", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } SetControlsEnabled(false); ProvisionerSettings settings = _provisioner.GetProvisionerSettings(); File.WriteAllText(Path.Combine(_tempPath, "provisioner.settings"), settings.ToJson()); List<BackupItem> backupItems = new List<BackupItem>(); foreach(BackupItem item in clbFileList.CheckedItems) { backupItems.Add(item); } bwBackup.RunWorkerAsync(new WorkerConfig() { vboxManagePath = _vBoxManagePath, outputPath = txtDestination.Text, tempPath = _tempPath, backupItems = backupItems, projectPath = txtProjectFolder.Text }); }
public void SetSettings(ProvisionerSettings settings) { _settings = settings; }