Esempio n. 1
0
        static async Task MainAsync(string DataDir, IPlayerGather pg)
        {
            var web_gather = new PlayerWebDataGather(DataDir, pg);

            web_gather.DownloadingPlayer   += DownloadPlayerNotice;
            web_gather.DownloadPlayerError += WritePlayerError;
            web_gather.WritingPlayer       += WritePlayerNotice;

            await web_gather.GatherAndWriteAllPlayerStats();
        }
Esempio n. 2
0
        private async void startBtn_Click(object sender, EventArgs e)
        {
            var WorkingDirectory = Path.Combine(DataDir, $"Week_{DateTime.Now.Iso8601WeekOfYear().ToString("D2")}");
            var PlayerInfo       = new PlayerGather(DataDir);
            var Serializer       = new StatDictSerializer(DataDir);
            var StatMaker        = new StatPopulator(WorkingDirectory, Serializer, PlayerInfo);

            stopButton.Enabled           = true;
            StatMaker.PopulatingAttempt += WritePlayerStats;
            StatMaker.PopulatingError   += WritePlayerStatsError;

            try {
                var web_gather = new PlayerWebDataGather(DataDir, PlayerInfo,
                                                         new Progress <int>(v => {
                    progressBar1.Value = v * 100 / PlayerInfo.Count();
                    progressLabel.Text = $"{v}/{PlayerInfo.Count()}";
                }), cts.Token);
                web_gather.DownloadingPlayer   += DownloadPlayerNotice;
                web_gather.DownloadPlayerError += WritePlayerError;
                web_gather.WritingPlayer       += WritePlayerNotice;

                await web_gather.GatherAndWriteAllPlayerStats();
            } catch (OperationCanceledException) {
                ReportErrorToTextBox("Operation cancelled at user request");
                return;
            }

            DialogResult done = MessageBox.Show("Press OK when DKSalaries.csv is put into this week's directory...", "Salary Input", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

            if (done == DialogResult.Cancel)
            {
                ReportErrorToTextBox("DKSalaries.csv is needed before continuing");
            }

            if (!File.Exists(Path.Combine(DataDir, "statCats.json")))
            {
                // Process data directory
                var statCats = new StatisticsDictionary(WorkingDirectory).GenerateSkeleton();
                Serializer.Serialize(statCats);
            }

            var all_player_stats = StatMaker.PopulateAllPlayerStats();

            nextButton.Enabled = true;
            _ps = all_player_stats.Where(p => p.IsDKSet()).Select(p => p);
            using (var output = new StreamWriter(Path.Combine(WorkingDirectory, "results-dkonly.csv")))
            {
                output.WriteLine(all_player_stats[0].ToCSVHeaderLine());
                foreach (var p in all_player_stats.Where(p => p.IsDKSet()).Select(p => p))
                {
                    output.WriteLine(p.ToCSVLineEntry());
                }
            }
            stopButton.Enabled = false;
        }