internal IDictionary GetDictionary() { const int Count = 18; var dictionary = new StatisticsDictionary(Count) { { "BuffersReceived", _buffersReceived }, { "BuffersSent", _buffersSent }, { "BytesReceived", _bytesReceived }, { "BytesSent", _bytesSent }, { "CursorOpens", _cursorOpens }, { "IduCount", _iduCount }, { "IduRows", _iduRows }, { "PreparedExecs", _preparedExecs }, { "Prepares", _prepares }, { "SelectCount", _selectCount }, { "SelectRows", _selectRows }, { "ServerRoundtrips", _serverRoundtrips }, { "SumResultSets", _sumResultSets }, { "Transactions", _transactions }, { "UnpreparedExecs", _unpreparedExecs }, { "ConnectionTime", ADP.TimerToMilliseconds(_connectionTime) }, { "ExecutionTime", ADP.TimerToMilliseconds(_executionTime) }, { "NetworkServerTime", ADP.TimerToMilliseconds(_networkServerTime) } }; Debug.Assert(dictionary.Count == Count); return(dictionary); }
public Collection(StatisticsDictionary dictionary, ICollection collection) { Debug.Assert(dictionary != null); Debug.Assert(collection != null); Debug.Assert((collection is KeyCollection) || (collection is ValueCollection)); _dictionary = dictionary; _collection = collection; }
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; }
static void Main(string[] args) { // var Desktop = $@"C:\Users\{Environment.UserName}\Desktop"; var DataDir = Path.Combine(Desktop, "PGA Stats"); 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); StatMaker.PopulatingAttempt += WritePlayerStats; StatMaker.PopulatingError += WritePlayerStatsError; MainAsync(DataDir, PlayerInfo).Wait(); //Populate data dir Console.WriteLine("Press enter key when DKSalaries.csv is put into this week's directory..."); var foo = Console.ReadLine(); 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(); 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()); } } }