private void buttonCreateSubmit_Click(object sender, RoutedEventArgs e) { Credentials c = this.getCredentials(); MachineContents m = this.getMachine(); try { if (connection.AddUser(this.getUser())) { this.DialogResult = true; //MessageBox.Show("User was created!"); connection.Login(c); if (connection.AddMachine(c, m)) { parentWindow.credentials = c; m = connection.GetMachineWithDirs(c, m); //parentWindow.machine = new MachineContents(c, id, false, false, true); m = local.ReadMachineContents(m); //MachineActions.GetContets(c, id); //MessageBox.Show("Machine was created!"); this.Close(); } else { new SystemMessage(new ActionException("Could not create a machine.", ActionType.Machine)).ShowDialog(); } } else { new SystemMessage(new ActionException("Sorry, an error.", ActionType.User)).ShowDialog(); } } catch (ActionException ex) { new SystemMessage(ex).ShowDialog(); } catch (Exception ex) { new SystemMessage(new ActionException("Sorry, an error.", ActionType.User, null, ex)).ShowDialog(); } }
private void optionDownloadMachine_Click(object sender, RoutedEventArgs e) { try { local.DownloadMachine(connection, credentials, machine); local.ReadMachineContents(machine, true); //machine = connection(credentials, machine); //machine = new MachineContents(credentials, machine, true, true, true); //MachineActions.GetContets(credentials, machine.Identity); RefreshDisplayedMachineInfo(); if (local.SaveMachine(machine)) { new SystemMessage("FileSync", "File sync complete.", "All directories defined in this machine were downloaded and restored.", MemeType.FuckYea).ShowDialog(); } else { new SystemMessage("FileSync", "This is embarassing.", "The machine was not downloaded successfully.").ShowDialog(); } //foreach (DirIdentity did in machine.Directories) { // var files = DirActions.Download(credentials, machine.Identity, did); // foreach (FileContents f in files) // f.SaveToDisk(did); //} //MessageBox.Show("Directories restored.", "FileSync", // MessageBoxButton.OK, MessageBoxImage.Information); } catch (ActionException ex) { new SystemMessage(ex).ShowDialog(); //MessageBox.Show(ex.Message, ex.Title); } }