Ejemplo n.º 1
0
        public void EnableAutoStart_EnablesAutoStart(bool useGuid)
        {
            if (useGuid)
            {
                Service.AllCurrentAutoStarts.Add(AutoStartEntry);
                Service.EnableAutoStart(Guid);
            }
            else
            {
                Service.EnableAutoStart(AutoStartEntry);
            }

            Assert.AreEqual(ConfirmStatus.Enabled, AutoStartEntry.ConfirmStatus);
            A.CallTo(() => ConnectorService.EnableAutoStart(AutoStartEntry)).MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 2
0
 public void Enable(AutoStartEntry autoStart)
 {
     Task.Run(() => {
         Logger.Info("Should enable {@autoStart}", autoStart);
         try {
             AppStatus.IncrementRunningActionCount();
             if (!MessageService.ShowConfirm("Confirm enable", $"Are you sure you want to enable auto start \"{autoStart.Value}\"?"))
             {
                 return;
             }
             if (AutoStartService.IsAdminRequiredForChanges(autoStart))
             {
                 StartSubProcessAsAdmin(autoStart, EnableParameterName);
                 autoStart.ConfirmStatus = ConfirmStatus.Enabled;
             }
             else
             {
                 AutoStartService.EnableAutoStart(autoStart);
             }
             MessageService.ShowSuccess("Auto start enabled", $"\"{autoStart.Value}\" has been enabled.");
         } catch (Exception e) {
             var message = "Failed to enable";
             var err     = new Exception(message, e);
             Logger.Error(err);
             MessageService.ShowError(message, e);
         } finally {
             AppStatus.DecrementRunningActionCount();
         }
     });
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Handles auto starts if command line parameters are set
 /// </summary>
 /// <param name="args">Command line parameters</param>
 /// <returns>True, if parameters were set, correctly handled and the program can be closed</returns>
 private bool HandleCommandLineParameters(string[] args)
 {
     for (int i = 0; i < args.Length; i++)
     {
         var arg = args[i];
         if (string.Equals(arg, RevertAddParameterName, StringComparison.OrdinalIgnoreCase))
         {
             Logger.Info("Adding should be reverted");
             AutoStartEntry autoStartEntry = LoadAutoStartFromParameter(args, i);
             AutoStartService.RemoveAutoStart(autoStartEntry);
             Logger.Info("Finished");
             return(true);
         }
         else if (string.Equals(arg, RevertRemoveParameterName, StringComparison.OrdinalIgnoreCase))
         {
             Logger.Info("Removing should be reverted");
             AutoStartEntry autoStartEntry = LoadAutoStartFromParameter(args, i);
             AutoStartService.AddAutoStart(autoStartEntry);
             Logger.Info("Finished");
             return(true);
         }
         else if (string.Equals(arg, EnableParameterName, StringComparison.OrdinalIgnoreCase))
         {
             Logger.Info("Auto start should be enabled");
             AutoStartEntry autoStartEntry = LoadAutoStartFromParameter(args, i);
             AutoStartService.EnableAutoStart(autoStartEntry);
             Logger.Info("Finished");
             return(true);
         }
         else if (string.Equals(arg, DisableParameterName, StringComparison.OrdinalIgnoreCase))
         {
             Logger.Info("Auto start should be disabled");
             AutoStartEntry autoStartEntry = LoadAutoStartFromParameter(args, i);
             AutoStartService.DisableAutoStart(autoStartEntry);
             Logger.Info("Finished");
             return(true);
         }
     }
     return(false);
 }