Example #1
0
        private void SendMessage(CompositionRule cr)
        {
            var client  = new RestClient("http://localhost:9090/api/newRule");
            var request = new RestRequest(Method.POST);

            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", cr.ToJson(), ParameterType.RequestBody);
            Task <Message> retval2 = client.PostAsync <Message>(request);

            retval2.Wait();

            if (retval2.Result == null)
            {
                ErrorMessage = "There has been too many requests from your IP address. If this is a false alert, try to use the service later again.";
            }
            else
            {
                Message result = retval2.Result;
                this.Dispatcher.BeginInvoke(new System.Action(() =>
                {
                    if (result.message == "Success")
                    {
                        this.Close();
                    }
                    else
                    {
                        ErrorMessage = result.message;
                    }
                }));
            }
        }
Example #2
0
        private void UploadButton_Click(object sender, RoutedEventArgs e)
        {
            int             composition     = CompositionNumber.SelectedIndex + 1;
            int             adChampions     = AdChampions.SelectedIndex;
            int             apChampions     = ApChampions.SelectedIndex;
            int             tankChampions   = TankChampions.SelectedIndex;
            int             healerChampions = HealerChampions.SelectedIndex;
            int             pokeChampions   = PokeChampions.SelectedIndex;
            CompositionRule cr = new CompositionRule
            {
                Composition     = composition,
                AdChampions     = adChampions,
                ApChampions     = apChampions,
                TankChampions   = tankChampions,
                HealerChampions = healerChampions,
                PokeChampions   = pokeChampions,
                Counters        = selectedCounters
            };
            Thread t = new Thread(() => SendMessage(cr));

            t.Start();
        }