Beispiel #1
0
 public void TryToBreak(object Player)
 {
     if (!Broken && !InvalidPlayer(Player) && Broke(Player))
     {
         RequestsManager.BrokeCondition(Player, GetType());
     }
 }
        private void loginButton_Click(object sender, RoutedEventArgs e)
        {
            if (user == null)
            {
                // Login
                LoginObject          loginObeject = new LoginObject(loginUsernameTextBox.Text, loginPasswordTextBox.Password);
                Server.Models.Client loginClient  = RequestsManager.Login(clientObject.stream, loginObeject.toJsonObject());

                if (loginClient != null)
                {
                    user = loginClient;
                    TransactionsTab.Visibility = Visibility.Visible;
                    checkAll.Visibility        = Visibility.Visible;


                    loginButton.Content           = "SignOut";
                    loginUsernameTextBox.Text     = "";
                    loginPasswordTextBox.Password = "";
                }
                else
                {
                    checkAll.Visibility        = Visibility.Hidden;
                    TransactionsTab.Visibility = Visibility.Hidden;
                }
            }
            else
            {
                // Sign out
                TransactionsTab.Visibility    = Visibility.Hidden;
                checkAll.Visibility           = Visibility.Hidden;
                loginButton.Content           = "Login";
                loginUsernameTextBox.Text     = "";
                loginPasswordTextBox.Password = "";
            }
        }
Beispiel #3
0
        private static void Cancel(CommandArgs Args)
        {
            if (!GetKeyAndPlayer(Args, out string key, out TSPlayer receiver))
            {
                return;
            }

            RequestResult result = RequestsManager.SenderCancelled(Args.Player,
                                                                   key, receiver, out string realKey, out object realReceiver);
            string name = (receiver?.Name ?? ((TSPlayer)realReceiver)?.Name);

            switch (result)
            {
            case RequestResult.NoRequests:
                Args.Player.SendErrorMessage("You do not have any active " +
                                             ((realKey == null) ? "requests" : $"{realKey} requests") +
                                             ((name == null) ? "." : $" to player {name}."));
                break;

            case RequestResult.NotSpecifiedRequest:
                Args.Player.SendErrorMessage($"You have more than one active " +
                                             ((realKey == null) ? "request" : $"{realKey} request") +
                                             ((name == null) ? "." : $" to player {name}."));
                break;

            case RequestResult.InvalidRequest:
                Args.Player.SendErrorMessage($"Invalid request name '{realKey}'" +
                                             ((name == null) ? "." : $" or player name '{name}'."));
                break;
            }
        }
Beispiel #4
0
        private static void AcceptRefuse(CommandArgs Args, Decision Decision)
        {
            if (!GetKeyAndPlayer(Args, out string key, out TSPlayer sender))
            {
                return;
            }

            RequestResult result = RequestsManager.SetDecision(Args.Player, key,
                                                               sender, Decision, out string realKey, out object realSender);
            string name = (sender?.Name ?? ((realSender is TSPlayer plr) ? plr.Name : null));

            switch (result)
            {
            case RequestResult.NoRequests:
                Args.Player.SendErrorMessage("You do not have any active " +
                                             ((realKey == null) ? "requests" : $"{realKey} requests") +
                                             ((name == null) ? "." : $" from player {name}."));
                break;

            case RequestResult.NotSpecifiedRequest:
                Args.Player.SendErrorMessage($"You have more than one active " +
                                             ((realKey == null) ? "request" : $"{realKey} request"));
                break;

            case RequestResult.InvalidRequest:
                Args.Player.SendErrorMessage($"Invalid request name '{realKey}'" +
                                             ((name == null) ? "." : $" or player name '{name}'."));
                break;
            }
        }
 public LoadManager(RequestsManager requestsManager, DBLPExtractor dBLPExtractor, IEEEXploreExtractor iEEEXploreExtractor, BibTeXExtractor bibTeXExtractor, ILogger <LoadManager> logger)
 {
     this.requestsManager     = requestsManager;
     this.dBLPExtractor       = dBLPExtractor;
     this.iEEEXploreExtractor = iEEEXploreExtractor;
     this.bibTeXExtractor     = bibTeXExtractor;
     _logger = logger;
 }
Beispiel #6
0
        private void createServer()
        {
            server = new ServerObject(IP, HOST);

            server.logger = Log;
            server.intiServer();
            server.startServer();

            server.respose = (s) =>
            {
                string requstType = s.ReadString();
                RequestsManager.ProcessRequst(requstType, s, this);
            };
        }
Beispiel #7
0
        public void Test_EnqueueNewRequest()
        {
            MockHttpClient mockHttp = new MockHttpClient();

            mockHttp.PrepareGetAsyncResponse(
                new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK
            }
                );

            ProgramService  service = new ProgramService("test/url", mockHttp);
            RequestsManager manager = new RequestsManager(service);

            manager.EnqueueNewRequest();
            Assert.AreEqual(1, manager.TotalActiveRequests());
        }
        public MainWindow()
        {
            instance = this;

            InitializeComponent();

            clientObject = new ClientObject();

            clientObject.initClient(IP, HOST);

            clientForCertificate = new ClientObject();
            clientForCertificate.initClient(IP, CA);

            Log("Clinet started");
            Log("Wating certificate");

            KeyManager.generateSessionKey();

            clientObject.connectUntilSuss((e) =>
            {
                RequestsManager.GetPublicKey(e);
            });
        }
        private void signUpSubmitButton_Click(object sender, RoutedEventArgs e)
        {
            SignUpObject signUpObject = new SignUpObject(signUpNameTextBox.Text, signUpUsernameTextBox.Text, signUpPasswordTextBox.Password);
            bool         signUpResult = RequestsManager.SignUp(clientObject.stream, signUpObject.toJsonObject());

            if (signUpResult)
            {
                TransactionsTab.Visibility    = Visibility.Visible;
                checkAll.Visibility           = Visibility.Visible;
                loginButton.Content           = "SignOut";
                loginUsernameTextBox.Text     = "";
                loginPasswordTextBox.Password = "";

                signUpNameTextBox.Text         = "";
                signUpPasswordTextBox.Password = "";
                signUpUsernameTextBox.Text     = "";
            }
            else
            {
                TransactionsTab.Visibility = Visibility.Hidden;
                checkAll.Visibility        = Visibility.Hidden;
            }
        }
        private void transferButton_Click(object sender, RoutedEventArgs e)
        {
            if (user != null)
            {
                TransactionObject transactionObject = new TransactionObject(user.Id.ToString(),
                                                                            reciverIDTextBox.Text.ToString(),
                                                                            ammountTextBox.Text.ToString());

                int selected = trasferAlgorithem.SelectedIndex;
                if (selected == 0)
                {
                    // RSA
                    RequestsManager.TransferWithRSA(clientObject.stream, transactionObject.toJsonObject());
                }
                else
                {
                    RequestsManager.TransferWithPGP(clientObject.stream, transactionObject.toJsonObject());
                }
            }
            else
            {
                MessageBox.Show("You need to login first");
            }
        }
Beispiel #11
0
        private static void Block(CommandArgs args)
        {
            if (args.Parameters.Count < 2)
            {
                args.Player.SendErrorMessage($"{TShock.Config.Settings.CommandSpecifier}block <request> <player>");
                return;
            }

            if (!GetKeyAndPlayer(args, out string key, out TSPlayer player))
            {
                return;
            }

            if (!RequestsManager.RequestKeys.Contains(key))
            {
                args.Player.SendErrorMessage($"Invalid request type '{key}'.");
                return;
            }

            if (!RequestsManager.CanBlockFunc(args.Player, player))
            {
                args.Player.SendErrorMessage($"You cannot block {player.Name}.");
                return;
            }

            if (RequestsManager.IsBlocked(args.Player, key, player))
            {
                RequestsManager.Block(args.Player, key, player, false);
                args.Player.SendSuccessMessage($"Allowed {player.Name} to send you {key} requests.");
            }
            else
            {
                RequestsManager.Block(args.Player, key, player, true);
                args.Player.SendSuccessMessage($"Forbade {player.Name} to send you {key} requests.");
            }
        }
Beispiel #12
0
 // Start is called before the first frame update
 void Awake()
 {
     Instance = this;
 }
 private void checkButton_Click(object sender, RoutedEventArgs e)
 {
     RequestsManager.ViewAllAccounts(clientObject.stream);
 }
 public ExtractDataManager(ILogger <ExtractDataManager> logger, RequestsManager requestsManager)
 {
     _logger = logger;
     this.requestsManager = requestsManager;
 }
Beispiel #15
0
 public PsawClient(RequestsManagerOptions options)
 {
     _requestsManager = new RequestsManager(options);
 }
Beispiel #16
0
 public PsawClient()
 {
     _requestsManager = new RequestsManager();
 }