public void Rename(string targetGroupName, string newName) { SafeCall.Execute(() => { config.RenameGroup(targetGroupName, newName); JsonConfigOperator <RobocopyConfig> .Save(RobocopyConfigParameters.fullConfigFilePath, config); }); }
static public void Run(string command, string arguments = "") { SafeCall.Execute(() => { var proc = new Process { StartInfo = new ProcessStartInfo { FileName = command, Arguments = arguments, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true } }; proc.Start(); while (!proc.StandardOutput.EndOfStream) { string line = proc.StandardOutput.ReadLine(); Console.WriteLine(line); } while (!proc.StandardError.EndOfStream) { string line = proc.StandardError.ReadLine(); Console.Error.WriteLine(line); } }); }
public void Remove(string groupName) { SafeCall.Execute(() => { config.RemoveGroup(groupName); JsonConfigOperator <RobocopyConfig> .Save(RobocopyConfigParameters.fullConfigFilePath, config); }); }
public void List() { SafeCall.Execute(() => { foreach (var group in config.BackupGroups) { Console.WriteLine(group.GroupName); } }); }
public void Add(string groupName) { SafeCall.Execute(() => { config.BackupGroups.Add(new BackupItemGroup { GroupName = groupName.Trim() }); JsonConfigOperator <RobocopyConfig> .Save(RobocopyConfigParameters.fullConfigFilePath, config); }); }
/// <summary> /// Perform safe call catching all exceptions that could happen within it's scope. /// </summary> /// <param name="name">The name of the safe call scope.</param> /// <param name="call">The code to execute.</param> public static void CallSafe(string name, SafeCall call) { try { call(); } catch (Exception e) { Client.FatalError("Safe call " + name + " failed.\n" + e.Message + "\n" + e.StackTrace); } }
public void List(string groupName) { SafeCall.Execute(() => { var group = config.GetGroup(groupName); if (group != null) { foreach (var item in group.BackupItems) { Console.WriteLine($"Name: {item.BackupName}"); Console.WriteLine($"Source: {item.Source}"); Console.WriteLine($"Backup: {item.Target}"); Console.WriteLine(""); } } }); }
/// <summary> /// Perform safe call catching all exceptions that could happen within it's scope. /// </summary> /// <param name="name">The name of the safe call scope.</param> /// <param name="call">The code to execute.</param> public static void CallSafe(string name, SafeCall call) { #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { call(); return; } #endif try { call(); } catch (Exception e) { Client.FatalError("Safe call " + name + " failed.\n" + e.Message + "\n" + e.StackTrace); } }
public void SetPictureImage(Image img) { if (pictureBox1.InvokeRequired) { try { var d = new SafeCall(SetPictureImage); Invoke(d, new object[] { img }); } catch (Exception e) { Console.Write(e.Message); } } else { pictureBox1.Image = img; } }