コード例 #1
0
 public void Rename(string targetGroupName, string newName)
 {
     SafeCall.Execute(() => {
         config.RenameGroup(targetGroupName, newName);
         JsonConfigOperator <RobocopyConfig> .Save(RobocopyConfigParameters.fullConfigFilePath, config);
     });
 }
コード例 #2
0
ファイル: ProcUtil.cs プロジェクト: li-rongcheng/NetCoreUtils
        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);
                }
            });
        }
コード例 #3
0
 public void Remove(string groupName)
 {
     SafeCall.Execute(() => {
         config.RemoveGroup(groupName);
         JsonConfigOperator <RobocopyConfig> .Save(RobocopyConfigParameters.fullConfigFilePath, config);
     });
 }
コード例 #4
0
 public void List()
 {
     SafeCall.Execute(() => {
         foreach (var group in config.BackupGroups)
         {
             Console.WriteLine(group.GroupName);
         }
     });
 }
コード例 #5
0
 public void Add(string groupName)
 {
     SafeCall.Execute(() => {
         config.BackupGroups.Add(new BackupItemGroup {
             GroupName = groupName.Trim()
         });
         JsonConfigOperator <RobocopyConfig> .Save(RobocopyConfigParameters.fullConfigFilePath, config);
     });
 }
コード例 #6
0
 /// <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);
     }
 }
コード例 #7
0
 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("");
             }
         }
     });
 }
コード例 #8
0
ファイル: Utils.cs プロジェクト: RootKiller/MSCMP-OLD-1
        /// <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);
            }
        }
コード例 #9
0
 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;
     }
 }