public void Disable(AutoStartEntry autoStart)
 {
     Task.Run(() => {
         Logger.Info("Should disable {@autoStart}", autoStart);
         try {
             AppStatus.IncrementRunningActionCount();
             if (!MessageService.ShowConfirm("Confirm disable", $"Are you sure you want to disable auto start \"{autoStart.Value}\"?"))
             {
                 return;
             }
             if (AutoStartService.IsAdminRequiredForChanges(autoStart))
             {
                 StartSubProcessAsAdmin(autoStart, DisableParameterName);
                 autoStart.ConfirmStatus = ConfirmStatus.Disabled;
             }
             else
             {
                 AutoStartService.DisableAutoStart(autoStart);
             }
             MessageService.ShowSuccess("Auto start disabled", $"\"{autoStart.Value}\" has been disabled.");
         } catch (Exception e) {
             var message = "Failed to disable";
             var err     = new Exception(message, e);
             Logger.Error(err);
             MessageService.ShowError(message, e);
         } finally {
             AppStatus.DecrementRunningActionCount();
         }
     });
 }
Beispiel #2
0
        public void DisableAutoStart_DisablesAutoStart_AndSetsStatusToDisabled(bool useGuid)
        {
            Service.AllCurrentAutoStarts.Add(AutoStartEntry);

            if (useGuid)
            {
                Service.DisableAutoStart(Guid);
            }
            else
            {
                Service.DisableAutoStart(AutoStartEntry);
            }

            A.CallTo(() => ConnectorService.DisableAutoStart(AutoStartEntry)).MustHaveHappenedOnceExactly();
            Assert.AreEqual(ConfirmStatus.Disabled, AutoStartEntry.ConfirmStatus);
        }
 /// <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);
 }