Exemplo n.º 1
0
        public override void ProcessCommand(string[] arguments, Authentication authentication, User caller)
        {
            if (arguments.Length < 2)
            {
                OutputConsole.WriteLine("Usage: removeaccounttag <userid> <tag>");
                return;
            }

            string userId = arguments[0];
            string tag    = arguments[1];

            User user = UserManager.Instance.GetUserFromId(userId);

            if (user == null)
            {
                OutputConsole.WriteLine("Could not find user with it \"" + userId + "\"");
                return;
            }

            bool removed = user.AccoutTags.Remove(tag);

            if (removed)
            {
                user.Save();
                OutputConsole.WriteLine("Removed tag \"" + tag + "\" from " + user.Username + ".");
            }
            else
            {
                OutputConsole.WriteLine(user.Username + " doesnt have a \"" + tag + "\" tag.");
            }
        }
 public ScriptFileViewModel(OutputConsole outputConsole)
 {
     mOutputConsole              = outputConsole;
     mWorker                     = new BackgroundWorker();
     mWorker.DoWork             += worker_DoWork;
     mWorker.RunWorkerCompleted += worker_RunWorkerCompleted;
 }
Exemplo n.º 3
0
        public override JsonOperationResponseBase OnOperation(Arguments arguments, Authentication authentication)
        {
            ContentType = "text/plain";

            SignInData request = new SignInData()
            {
                password = arguments["password"],
                username = arguments["username"]
            };

            if (!request.IsValidRequest())
            {
                return(new SignInResponse()
                {
                    Error = "All fields were not filled out"
                });
            }

            Session session = UserManager.Instance.SignInAsUser(request.username, request.password);

            if (session == null)
            {
                return(new SignInResponse()
                {
                    Error = "Either the specified username or the password was wrong"
                });
            }

            OutputConsole.WriteLine(request.username + " signed in");

            return(new SignInResponse()
            {
                sessionID = session.Key
            });
        }
Exemplo n.º 4
0
        public static string DownloadText(Uri uri)
        {
            string result = string.Empty;

            using (var client = new WebClient())
            {
                try
                {
                    Stream       stream = client.OpenRead(uri);
                    StreamReader reader = new StreamReader(stream);
                    result = reader.ReadToEnd();

                    reader.Close();
                    stream.Flush();
                    stream.Close();
                }
                catch (WebException e)
                {
                    OutputConsole.PrintVerbose(e, $"Cannot download file '{uri}'.", 1);
                    return(string.Empty);
                }
            }

            return(result);
        }
Exemplo n.º 5
0
 private void Process()
 {
     if (isAborted)
     {
         return;
     }
     try
     {
         producerThread          = new Thread(Produce);
         producerThread.Priority = ThreadPriority.AboveNormal;
         consumerThread          = new Thread(Consume);
         consumerThread.Priority = ThreadPriority.AboveNormal;
         producerThread.Start();
         blocksHandler.Start();
         consumerThread.Start();
         producerThread.Join();
         consumerThread.Join();
         if (!isAborted)
         {
             blocksHandler.Stop();
         }
     }
     catch (Exception ex)
     {
         OutputConsole.DisplayError(ex);
     }
 }
Exemplo n.º 6
0
 private void PreComponentInitialise()
 {
     _outputConsole = new OutputConsole();
     ConsoleWrite   = WriteToConsole;
     this.Width     = SystemParameters.MaximizedPrimaryScreenWidth;
     this.Height    = SystemParameters.MaximizedPrimaryScreenHeight;
     _outputConsole.Show();
 }
Exemplo n.º 7
0
        private CleanupDirectory ReadCleanupDirectory(XElement item)
        {
            CleanupDirectory result = new CleanupDirectory
            {
                LocalDirectory = XElementExtender.ReadPath(item)
            };

            OutputConsole.PrintVerbose(result, 5);
            return(result);
        }
Exemplo n.º 8
0
        private Player ReadPlayer(XElement player)
        {
            Player result = new Player
            {
                Name  = XElementExtender.ReadName(player),
                Image = XElementExtender.ReadImage(player)
            };

            OutputConsole.PrintVerbose(result, 2);
            return(result);
        }
Exemplo n.º 9
0
        public override void ProcessCommand(string[] arguments, Authentication authentication, User caller)
        {
            User user = UserManager.Instance.GetUserFromUsername(arguments[0]);

            if (user == null)
            {
                OutputConsole.WriteLine("The provided user, \"" + arguments[0] + "\" doesnt exist");
                return;
            }
            OutputConsole.WriteLine(arguments[0] + "s userId is: " + user.UserID);
        }
Exemplo n.º 10
0
        public void Save()
        {
            if (instance == null)
            {
                return;
            }

            Serialize();

            OutputConsole.Print(instance);
            OutputConsole.Print("[Settings saved]");
        }