Ejemplo n.º 1
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            // gray out this form
            this.Enabled = false;
            // increments active tasks
            ConfigFile.IncrementTaskStarted();
            // asks for the "player name" to the user
            string playerName = Interaction.InputBox("Insert Player Name to download:", "Download all data of Player", "PlayerName", -1, -1);

            lblElaborating.Text      = "Retriving data...";
            lblElaborating.ForeColor = Color.Green;
            // opens a "waiting to complete" form
            //frmWaiting waiting = new frmWaiting("Retriving data from remote DB...");
            //waiting.lblInformation.Text = "Retriving data from remote DB...";
            //waiting.Enabled = true;
            //waiting.Show();
            //waiting.BringToFront();

            playerName = playerName.Trim();
            if (!string.IsNullOrWhiteSpace(playerName))
            {
                List <PlayerStatT> player = SqlOps.RetrievePlayerStat(playerName);
                lblElaborating.Text      = "Elaborating data...";
                lblElaborating.ForeColor = Color.Red;
                //waiting.lblInformation.Text = "Elaborating data...";
                if (player.Count > 0)
                {
                    player = DataOps.AddAbsoluteSeason(player, playerName);
                    player = DataOps.PopulateKDpM(player);
                    FileInfo      textFile = DataOps.PlayerDataToFile(player);
                    frmShowCharts newChart = new frmShowCharts();
                    newChart.Elaborate(player, playerName, textFile);
                    //waiting.Dispose();
                    newChart.Visible = true;
                }
                else
                {
                    //waiting.Dispose();
                    MessageBox.Show("Player not found.", "Search Player in DB: WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                    this.BringToFront();
                }
            }
            this.BringToFront();
            ConfigFile.IncrementTaskFinished();
            //waiting.Dispose();
            lblElaborating.Text      = "Not elaborating.";
            lblElaborating.ForeColor = Color.Green;
            this.BringToFront();
            this.Enabled = true;
        }
Ejemplo n.º 2
0
        private async void button2_Click(object sender, EventArgs e)
        {
            frmGetDataSingle getList = new frmGetDataSingle();
            DialogResult     result  = getList.ShowDialog();

            if (result == DialogResult.OK)
            {
                if (ConfigFile.ACTUAL_PLAYER_LIST.Count > 0)
                {
                    prbPlayerList.Maximum = 5 * ConfigFile.ACTUAL_PLAYER_LIST.Count;
                    prbPlayerList.Enabled = true;
                    prbPlayerList.Value   = 0;
                    ConfigFile.IncrementTaskStarted();

                    foreach (string playerName in ConfigFile.ACTUAL_PLAYER_LIST)
                    {
                        if (!string.IsNullOrWhiteSpace(playerName.Trim()))
                        {
                            ConfigFile._Global = new Semaphore(1, 1);
                            List <int> typeList = new List <int> {
                                0, 1, 2, 3, 4
                            };
                            List <int> seasonsList = new List <int>();
                            for (int i = 1; i <= ConfigFile.SEASON_LAST; i++)
                            {
                                seasonsList.Add(i);
                            }

                            ConfigFile.GLOBAL_PLAYER = new List <PlayerStatT>();

                            List <int> actualSeason = new List <int> {
                                1
                            };
                            List <int> actualType = new List <int> {
                                1
                            };

                            //await WebOps.SearchPlayer(playerName, new List<int> { 1 }, new List<int> { 0 }, ConfigFile.DEFAULT_USER, ConfigFile.DEFAULT_PASS);


                            int[] typeArray   = typeList.ToArray();
                            int[] seasonArray = actualSeason.ToArray();
                            for (int typeCat = 0; typeCat <= 4; typeCat++)
                            {
                                await Task.WhenAll(seasonsList.Select(i => WebOps.SearchPlayer(playerName.Trim(), new List <int> {
                                    i
                                }, new List <int> {
                                    typeCat
                                }, ConfigFile.DEFAULT_USER, ConfigFile.DEFAULT_PASS)).ToArray());

                                prbPlayerList.Value = prbPlayerList.Value + 1;
                            }
                            // Code 00
                            ConfigFile.GLOBAL_PLAYER = DataOps.AddAbsoluteSeason(ConfigFile.GLOBAL_PLAYER, playerName.Trim());
                            ConfigFile.GLOBAL_PLAYER = DataOps.PopulateKDpM(ConfigFile.GLOBAL_PLAYER);
                            FileInfo      textFile = DataOps.PlayerDataToFile(ConfigFile.GLOBAL_PLAYER);
                            frmShowCharts newChart = new frmShowCharts();
                            newChart.Elaborate(ConfigFile.GLOBAL_PLAYER, playerName, textFile);
                            newChart.btnPrintCharts_Click(this, null);
                            //newChart.Visible = true;
                        }
                        else
                        {
                            prbPlayerList.Value = prbPlayerList.Value + 5;
                        }
                    }

                    ConfigFile.IncrementTaskFinished();
                    MessageBox.Show("Finished elaborating stats and printing relative PDFs for " + ConfigFile.ACTUAL_PLAYER_LIST.Count() + " players.", "Stats Elaboration", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
                else
                {
                    MessageBox.Show("No Player Names inserted." + Environment.NewLine + "No data will be elaborated.", "Stats Elaboration", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                MessageBox.Show("No Player Names inserted." + Environment.NewLine + "No data will be elaborated.", "Stats Elaboration", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
            }

            //this.Enabled = false;
            //ConfigFile.IncrementTaskStarted();
            //string playerName = Interaction.InputBox("Insert Player Name to download:", "Download all data of Player", "PlayerName", -1, -1);
            //playerName = playerName.Trim();
            //if (!string.IsNullOrWhiteSpace(playerName))
            //{
            //    ConfigFile._Global = new Semaphore(1, 1);
            //    List<int> typeList = new List<int> { 0, 1, 2, 3, 4 };
            //    List<int> seasonsList = new List<int>();
            //    for (int i = 1; i <= ConfigFile.SEASON_LAST; i++)
            //        seasonsList.Add(i);

            //    ConfigFile.GLOBAL_PLAYER = new List<PlayerStatT>();

            //    List<int> actualSeason = new List<int> { 1 };
            //    List<int> actualType = new List<int> { 1 };

            //    //await WebOps.SearchPlayer(playerName, new List<int> { 1 }, new List<int> { 0 }, ConfigFile.DEFAULT_USER, ConfigFile.DEFAULT_PASS);

            //    prbSinglePlayer.Maximum = 5;
            //    prbSinglePlayer.Enabled = true;
            //    prbSinglePlayer.Value = 0;

            //    int[] typeArray = typeList.ToArray();
            //    int[] seasonArray = actualSeason.ToArray();
            //    for (int typeCat = 0; typeCat <= 4; typeCat++)
            //    {
            //        await Task.WhenAll(seasonsList.Select(i => WebOps.SearchPlayer(playerName, new List<int> { i }, new List<int> { typeCat }, ConfigFile.DEFAULT_USER, ConfigFile.DEFAULT_PASS)).ToArray());
            //        prbSinglePlayer.Value = typeCat + 1;
            //    }
            //    // Code 00
            //    ConfigFile.GLOBAL_PLAYER = DataOps.AddAbsoluteSeason(ConfigFile.GLOBAL_PLAYER, playerName);
            //    ConfigFile.GLOBAL_PLAYER = DataOps.PopulateKDpM(ConfigFile.GLOBAL_PLAYER);
            //    FileInfo textFile = DataOps.PlayerDataToFile(ConfigFile.GLOBAL_PLAYER);
            //    frmShowCharts newChart = new frmShowCharts();
            //    newChart.Elaborate(ConfigFile.GLOBAL_PLAYER, playerName, textFile);
            //    newChart.Visible = true;
            //}
            //ConfigFile.IncrementTaskFinished();
            //this.Enabled = true;
        }
Ejemplo n.º 3
0
        private async void btnTest2_Click(object sender, EventArgs e)
        {
            this.Enabled = false;

            ConfigFile.IncrementTaskStarted();
            string playerName = string.Empty; //Interaction.InputBox("Insert Player Name to download:", "Download all data of Player", "PlayerName", -1, -1);


            frmInputBoxX input  = new frmInputBoxX();
            DialogResult result = input.ShowDialog();

            if (result == DialogResult.OK)
            {
                playerName = string.IsNullOrWhiteSpace(ConfigFile.ACTUAL_PLAYER) ? null : ConfigFile.ACTUAL_PLAYER;
            }

            if (!string.IsNullOrWhiteSpace(playerName))
            {
                playerName = playerName.Trim();
                if (!string.IsNullOrWhiteSpace(playerName))
                {
                    ConfigFile._Global = new Semaphore(1, 1);
                    List <int> typeList = new List <int> {
                        0, 1, 2, 3, 4
                    };
                    List <int> seasonsList = new List <int>();
                    for (int i = 1; i <= ConfigFile.SEASON_LAST; i++)
                    {
                        seasonsList.Add(i);
                    }

                    ConfigFile.GLOBAL_PLAYER = new List <PlayerStatT>();

                    List <int> actualSeason = new List <int> {
                        1
                    };
                    List <int> actualType = new List <int> {
                        1
                    };

                    //await WebOps.SearchPlayer(playerName, new List<int> { 1 }, new List<int> { 0 }, ConfigFile.DEFAULT_USER, ConfigFile.DEFAULT_PASS);

                    prbSinglePlayer.Maximum = 5;
                    prbSinglePlayer.Enabled = true;
                    prbSinglePlayer.Value   = 0;

                    int[] typeArray   = typeList.ToArray();
                    int[] seasonArray = actualSeason.ToArray();
                    for (int typeCat = 0; typeCat <= 4; typeCat++)
                    {
                        await Task.WhenAll(seasonsList.Select(i => WebOps.SearchPlayer(playerName, new List <int> {
                            i
                        }, new List <int> {
                            typeCat
                        }, ConfigFile.DEFAULT_USER, ConfigFile.DEFAULT_PASS)).ToArray());

                        prbSinglePlayer.Value = typeCat + 1;
                    }
                    // Code 00
                    ConfigFile.GLOBAL_PLAYER = DataOps.AddAbsoluteSeason(ConfigFile.GLOBAL_PLAYER, playerName);
                    ConfigFile.GLOBAL_PLAYER = DataOps.PopulateKDpM(ConfigFile.GLOBAL_PLAYER);
                    FileInfo      textFile = DataOps.PlayerDataToFile(ConfigFile.GLOBAL_PLAYER);
                    frmShowCharts newChart = new frmShowCharts();
                    newChart.Elaborate(ConfigFile.GLOBAL_PLAYER, playerName, textFile);
                    newChart.Visible = true;
                }
                ConfigFile.IncrementTaskFinished();
            }
            this.Enabled = true;
        }