bool CheckAdminWithWarning()
 {
     if (!Interface.ConnectToInstance().HasFlag(ConnectivityLevel.Administrator))
     {
         MessageBox.Show("Only system administrators may use this command!");
         return(false);
     }
     return(true);
 }
Beispiel #2
0
        public CLICommand(IServerInterface I)
        {
            var tmp = new List <Command> {
                new UpdateCommand(), new TestmergeCommand(), new RepoCommand(), new BYONDCommand(), new DMCommand(), new DDCommand(), new ConfigCommand(), new IRCCommand(), new DiscordCommand(), new AutoUpdateCommand(), new SetAutoUpdateCommand()
            };

            if (I.ConnectToInstance().HasFlag(ConnectivityLevel.Administrator))
            {
                tmp.Add(new AdminCommand());
            }
            if (I.ConnectionStatus().HasFlag(ConnectivityLevel.Administrator))
            {
                tmp.Add(new ServiceCommand());
            }
            Children = tmp.ToArray();
        }
Beispiel #3
0
        /// <summary>
        /// Tries to set <see cref="currentInterface"/>'s <see cref="ITGInstance"/> to <paramref name="instanceName"/>, outputting appropriate messages
        /// </summary>
        /// <param name="instanceName">The name of the <see cref="ITGInstance"/> to test</param>
        /// <param name="silentSuccess">If <see langword="true"/>, does not output on success</param>
        /// <returns><see langword="true"/> if a <see cref="ConnectivityLevel.Authenticated"/> was achieved with <see cref="IServerInterface.ConnectToInstance(string, bool)"/>, <see langword="false"/> otherwise</returns>
        static bool CheckInstanceConnectivity(string instanceName, bool silentSuccess)
        {
            var res = currentInterface.ConnectToInstance(instanceName);

            if (!res.HasFlag(ConnectivityLevel.Connected))
            {
                Console.WriteLine("Unable to connect to instance! Does it exist?");
            }
            else if (!res.HasFlag(ConnectivityLevel.Authenticated))
            {
                Console.WriteLine("The current user is not authorized to use this instance!");
            }
            else
            {
                if (!silentSuccess)
                {
                    Console.WriteLine("Successfully conected to instance!");
                }
                return(true);
            }
            return(false);
        }
Beispiel #4
0
 public override ExitCode DoRun(IList <string> parameters)
 {
     if (currentInterface.InstanceName == null)
     {
         OutputProc("Missing instance!");
         return(ExitCode.BadCommand);
     }
     else
     {
         var res = currentInterface.ConnectToInstance();
         if (!res.HasFlag(ConnectivityLevel.Connected))
         {
             OutputProc("Unable to connect to instance!");
             return(ExitCode.ConnectionError);
         }
         else if (!res.HasFlag(ConnectivityLevel.Authenticated))
         {
             OutputProc("The current user is not authorized to use this instance!");
             return(ExitCode.ConnectionError);
         }
     }
     return(base.DoRun(parameters));
 }