Esempio n. 1
0
        public static async Task <List <EGDPlayer> > GetAllPlayersUsingHttpClient(List <Player> players)
        {
            List <EGDPlayer> ret = new List <EGDPlayer>();

            try
            {
                for (int i = 0; i < players.Count; i++)
                {
                    var    player = players[i];
                    string link   = "https://www.europeangodatabase.eu/EGD/GetPlayerDataByPIN.php?pin=" + player.EGDPinCode.ToString();


                    using (var client = new HttpClient())
                    {
                        //client.DefaultRequestHeaders.Add("Accept", "application/json");
                        var response = await client.GetAsync(link).ConfigureAwait(false);

                        var       content   = response.Content.ReadAsStringAsync().Result;
                        EGDPlayer egdPlayer = JsonConvert.DeserializeObject <EGDPlayer>(content);
                        if (egdPlayer != null)
                        {
                            ret.Add(egdPlayer);
                        }
                    }
                }
            }
            catch (Exception)
            {
                // No internet connection
            }


            return(ret);
        }
Esempio n. 2
0
        public static async Task <EGDPlayer> GetPlayerByIDUsingHttpClient(int pinCode)
        {
            string link = "https://www.europeangodatabase.eu/EGD/GetPlayerDataByPIN.php?pin=" + pinCode.ToString();

            EGDPlayer ret = new EGDPlayer();

            try
            {
                using (var client = new HttpClient())
                {
                    //client.DefaultRequestHeaders.Add("Accept", "application/json");
                    var response = await client.GetAsync(link).ConfigureAwait(false);

                    var content = response.Content.ReadAsStringAsync().Result;
                    ret = JsonConvert.DeserializeObject <EGDPlayer>(content);
                    ret.Last_Appearance = DateTime.Now.ToLongDateString() + " - " + DateTime.Now.ToLongTimeString();
                }
            }
            catch (Exception)
            {
                // No internet connection
            }

            if (ret == null)
            {
                ret = new EGDPlayer();
            }

            return(ret);
        }
Esempio n. 3
0
        public static EGDPlayer GetPlayerByIDUsingWebRequest(int pinCode)
        {
            string link = "https://www.europeangodatabase.eu/EGD/GetPlayerDataByPIN.php?pin=" + pinCode.ToString();

            EGDPlayer ret;

            WebRequest myWebRequest = WebRequest.Create(link);

            // Assign the response object of 'WebRequest' to a 'WebResponse' variable.
            WebResponse myWebResponse = myWebRequest.GetResponse();

            Stream       streamResponse = myWebResponse.GetResponseStream();
            StreamReader reader         = new StreamReader(streamResponse);

            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            ret = JsonConvert.DeserializeObject <EGDPlayer>(responseFromServer);

            if (ret == null)
            {
                ret = new EGDPlayer();
            }

            return(ret);
        }
 private void HfbRequestPlayer_Click(object sender, EventArgs e)
 {
     UnsubscriveFromEvents();
     Form2Rec();
     _EGDPlayer = DBHelper.GetPlayerByIDUsingHttpClient(_UserPIN).Result;
     Rec2Form();
     SubscribeToEvents();
 }
Esempio n. 5
0
        private void ListPlayers_SelectedIndexChanged(object sender, EventArgs e)
        {
            UnsubscribeFromEvents();

            _SelectedPlayer = _Players[listPlayers.SelectedIndex];

            _SelectedEGDPlayer = DBHelper.GetPlayerByIDUsingHttpClient(_Players[listPlayers.SelectedIndex].EGDPinCode).Result;

            Rec2Form();

            SubscribeToEvents();
        }
Esempio n. 6
0
        private void PrepareUI()
        {
            listPlayers.Items.Clear();

            for (int i = 0; i < _Players.Count; i++)
            {
                Player player = _Players[i];
                listPlayers.Items.Add(player.Name);
            }

            listPlayers.SelectedIndex = 0;
            _SelectedPlayer           = _Players[0];

            _SelectedEGDPlayer = DBHelper.GetPlayerByIDUsingHttpClient(_Players[0].EGDPinCode).Result;
        }
 private void TxtEGDPin_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar != (char)13)
     {
         if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
             (e.KeyChar != '.'))
         {
             e.Handled = true;
         }
     }
     else
     {
         UnsubscriveFromEvents();
         Form2Rec();
         _EGDPlayer = DBHelper.GetPlayerByIDUsingHttpClient(_UserPIN).Result;
         Rec2Form();
         SubscribeToEvents();
     }
 }
Esempio n. 8
0
        public void InitializeUC(GoGame game)
        {
            PrepareUI();

            _Game = game;

            if (game.IsGamePlayed)
            {
                grpResult.Enabled       = false;
                cmbResult.SelectedIndex = (int)game.Result;
            }

            _EGDPlayer1 = DBHelper.GetPlayerByIDUsingHttpClient(game.Player1.EGDPinCode).Result;
            _EGDPlayer2 = DBHelper.GetPlayerByIDUsingHttpClient(game.Player2.EGDPinCode).Result;
            ucPlayerInfo1.InitializeUC(game.Player1, _EGDPlayer1);
            ucPlayerInfo2.InitializeUC(game.Player2, _EGDPlayer2);
            lblGameName.Text  = game.GameLabel;
            txtTableName.Text = game.GameLabel;
            txtHandicap.Text  = "";

            SubscribeToEvents();
        }
Esempio n. 9
0
 public void InitializeUC(EGDPlayer eGDPlayer)
 {
     _SelectedEGDPlayer = eGDPlayer;
     Rec2Form();
 }
Esempio n. 10
0
 public void InitializeUC(Player player, EGDPlayer eGDPlayer)
 {
     _SelectedPlayer    = player;
     _SelectedEGDPlayer = eGDPlayer;
     Rec2Form();
 }