Пример #1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            int lastRecorded = ConfigFile.SEASON_LAST;
            await WebOps.FindLastSeason();

            lblLastSeason.Text      = "Last Season: " + ConfigFile.SEASON_LAST.ToString();
            lblLastSeason.ForeColor = Color.Green;
            if (lastRecorded != ConfigFile.SEASON_LAST)
            {
                MessageBox.Show("New Last Season found: " + ConfigFile.SEASON_LAST,
                                "Search for last Season available",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1);
            }
            else
            {
                MessageBox.Show("No new Seasons founded." + Environment.NewLine +
                                "Last available Season remains : " + ConfigFile.SEASON_LAST,
                                "Search for last Season available",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1);
            }
            if (ConfigFile.LAST_SEASON_CHECKED)
            {
                //Mex.AddMessage("Last Season found: " + ConfigFile.SEASON_LAST, Mex.INFO);
                //Mex.PrintMessageInForm(Mex.FormatMessageAtIndex());
                Mex.RemoveAll();
            }
            this.Enabled = true;
        }
Пример #2
0
        public static async Task RefreshDownloadTime()
        {
            double time = await WebOps.TestSpeed();

            ConfigFile.TIME_PAGE = time > 0 ? (time / 10000) * 1001 : 0;
            if (ConfigFile.TIME_PAGE > 0)
            {
                MessageBox.Show("Estimated download time per page: " + Math.Round(ConfigFile.TIME_PAGE, 2).ToString() + " ms", "Download Test Speed", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
            }
            else
            {
                MessageBox.Show("Test failed." + Environment.NewLine + "Check your connection.", "Download Test Speed", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
            }
        }
Пример #3
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;
        }
Пример #4
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;
        }
Пример #5
0
        private async void btnDownload_Click(object sender, EventArgs e)
        {
            string email    = txtEMail.Text;
            string password = txtPassword.Text;


            //Task<int> response = await WebOps.CheckCredentials(email, password);
            int response = await WebOps.CheckCredentials(email, password);

            switch (response)
            {
            case 1:
                MessageBox.Show("You must enter an email.", "MWO Credential Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;

            case 2:
                MessageBox.Show("You must enter a password.", "MWO Credential Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;

            case 3:
                MessageBox.Show("Your MWO Credentials are invalid." + Environment.NewLine + "Check your eMail and Password and try again.", "MWO Credential Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;

            case 4:
                break;

            case 5:
                MessageBox.Show("There has been an error while trying to connect." + Environment.NewLine + "Check your connection and try again.", "MWO Credential Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            int tempInt = 0;
            int season  = int.TryParse(cmbSeasonNumber.Text, out tempInt) ? tempInt : ConfigFile.SEASON_LAST;

            if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
            {
                if (string.IsNullOrWhiteSpace(email))
                {
                    Mex.AddMessage("Email field is not valid.", Mex.ERROR);
                }
                if (string.IsNullOrWhiteSpace(password))
                {
                    Mex.AddMessage("Password field is not valid.", Mex.ERROR);
                }
                Mex.AddMessage("Will not proceed.", Mex.WARNING);
                Mex.PrintErrorMessagesInForm();
                Mex.RemoveAll();
                return;
            }

            // saves email & password to a local file
            if (ckbSaveCredentials.Checked)
            {
                if (!new FileInfo(ConfigFile.LOCAL_CREDENTIALS).Exists)
                {
                    File.WriteAllLines(ConfigFile.LOCAL_CREDENTIALS, new string[] { email, password });
                }
                else
                {
                    try
                    {
                        File.Delete(ConfigFile.LOCAL_CREDENTIALS);
                    }
                    catch
                    {
                    }
                    File.WriteAllLines(ConfigFile.LOCAL_CREDENTIALS, new string[] { email, password });
                }
            }

            DownloadData baseData = new DownloadData(user: email,
                                                     password: password,
                                                     season: season);

            if (chbGeneral.Checked)
            {
                int startGeneral;
                int endGeneral;
                if (chbFullGeneral.Checked)
                {
                    startGeneral = (int)ConfigFile.MIN_PAGES - 1;
                    endGeneral   = ConfigFile.MAX_PAGES;
                }
                else
                {
                    startGeneral = int.TryParse(txtStartGeneral.Text, out tempInt) ? tempInt - 1 : (int)ConfigFile.MIN_PAGES;
                    endGeneral   = int.TryParse(txtEndGeneral.Text, out tempInt) ? tempInt - 1 : ConfigFile.MAX_PAGES;
                }
                WebOps.LoginAndDownload(dData: baseData, type: 0, startPage: startGeneral, finishPage: endGeneral, bar: prbPageProgressGeneral, writeDB: true);
            }
            if (chbLight.Checked)
            {
                int startLight;
                int endLight;
                if (chbFullLight.Checked)
                {
                    startLight = (int)ConfigFile.MIN_PAGES - 1;
                    endLight   = ConfigFile.MAX_PAGES;
                }
                else
                {
                    startLight = int.TryParse(txtStartLight.Text, out tempInt) ? tempInt - 1: (int)ConfigFile.MIN_PAGES;
                    endLight   = int.TryParse(txtEndLight.Text, out tempInt) ? tempInt - 1 : ConfigFile.MAX_PAGES;
                }
                WebOps.LoginAndDownload(dData: baseData, type: 1, startPage: startLight, finishPage: endLight, bar: prbPageProgressLight);
            }
            if (chbMedium.Checked)
            {
                int startMedium;
                int endMedium;
                if (chbFullMedium.Checked)
                {
                    startMedium = (int)ConfigFile.MIN_PAGES - 1;
                    endMedium   = ConfigFile.MAX_PAGES;
                }
                else
                {
                    startMedium = int.TryParse(txtStartMedium.Text, out tempInt) ? tempInt - 1: (int)ConfigFile.MIN_PAGES;
                    endMedium   = int.TryParse(txtEndMedium.Text, out tempInt) ? tempInt - 1 : ConfigFile.MAX_PAGES;
                }
                WebOps.LoginAndDownload(dData: baseData, type: 2, startPage: startMedium, finishPage: endMedium, bar: prbPageProgressMedium);
            }
            if (chbHeavy.Checked)
            {
                int startHeavy;
                int endHeavy;
                if (chbFullHeavy.Checked)
                {
                    startHeavy = (int)ConfigFile.MIN_PAGES - 1;
                    endHeavy   = ConfigFile.MAX_PAGES;
                }
                else
                {
                    startHeavy = int.TryParse(txtStartHeavy.Text, out tempInt) ? tempInt - 1: (int)ConfigFile.MIN_PAGES;
                    endHeavy   = int.TryParse(txtEndHeavy.Text, out tempInt) ? tempInt - 1 : ConfigFile.MAX_PAGES;
                }
                WebOps.LoginAndDownload(dData: baseData, type: 3, startPage: startHeavy, finishPage: endHeavy, bar: prbPageProgressHeavy);
            }
            if (chbAssault.Checked)
            {
                int startAssault;
                int endAssault;
                if (chbFullAssault.Checked)
                {
                    startAssault = (int)ConfigFile.MIN_PAGES - 1;
                    endAssault   = ConfigFile.MAX_PAGES;
                }
                else
                {
                    startAssault = int.TryParse(txtStartAssault.Text, out tempInt) ? tempInt - 1: (int)ConfigFile.MIN_PAGES;
                    endAssault   = int.TryParse(txtEndAssault.Text, out tempInt) ? tempInt - 1 : ConfigFile.MAX_PAGES;
                }
                WebOps.LoginAndDownload(dData: baseData, type: 4, startPage: startAssault, finishPage: endAssault, bar: prbPageProgressAssault);
            }
        }