From 1f51cf4cfb49f622d5c66ab75a5c2148de7897dc Mon Sep 17 00:00:00 2001 From: NecronomiconCoding Date: Mon, 1 Aug 2016 01:06:39 +0200 Subject: [PATCH] csv dumping thanks to rowellx68 --- PoGo.NecroBot.Logic/DataDumper/Dumper.cs | 13 +++++++------ .../Tasks/DisplayPokemonStatsTask.cs | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/PoGo.NecroBot.Logic/DataDumper/Dumper.cs b/PoGo.NecroBot.Logic/DataDumper/Dumper.cs index 631f1c14b..715bfec72 100644 --- a/PoGo.NecroBot.Logic/DataDumper/Dumper.cs +++ b/PoGo.NecroBot.Logic/DataDumper/Dumper.cs @@ -16,11 +16,11 @@ public static class Dumper /// /// /// File to clear/param> - public static void ClearDumpFile(ISession session, string filename) + public static void ClearDumpFile(ISession session, string filename, string extension = "csv") { var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps"); var file = Path.Combine(path, - $"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.txt"); + $"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}"); if (!Directory.Exists(path)) Directory.CreateDirectory(path); // Clears all contents of a file first if overwrite is true @@ -33,11 +33,12 @@ public static void ClearDumpFile(ISession session, string filename) /// /// Dumps the string data to the file /// Filename to be used for naming the file. - public static void Dump(ISession session, string data, string filename) + /// FileExt. + public static void Dump(ISession session, string data, string filename, string extension = "csv") { string uniqueFileName = $"{filename}"; - DumpToFile(session, data, uniqueFileName); + DumpToFile(session, data, uniqueFileName, extension); } /// @@ -46,10 +47,10 @@ public static void Dump(ISession session, string data, string filename) /// /// Dumps the string data to the file /// Filename to be used for naming the file. - private static void DumpToFile(ISession session, string data, string filename) + private static void DumpToFile(ISession session, string data, string filename, string extension = "csv") { var path = Path.Combine(session.LogicSettings.ProfilePath, "Dumps", - $"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.txt"); + $"NecroBot-{filename}-{DateTime.Today.ToString("yyyy-MM-dd")}-{DateTime.Now.ToString("HH")}.{extension}"); using ( var dumpFile = diff --git a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs index df90a539c..fb39ea486 100644 --- a/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs +++ b/PoGo.NecroBot.Logic/Tasks/DisplayPokemonStatsTask.cs @@ -106,7 +106,7 @@ public static async Task Execute(ISession session) if (session.LogicSettings.DumpPokemonStats) { const string dumpFileName = "PokeBagStats"; - Dumper.ClearDumpFile(session, dumpFileName); + Dumper.ClearDumpFile(session, dumpFileName, "csv"); foreach (var pokemon in allPokemonInBag) { int candy = PokemonInfo.GetCandy(pokemon, myPokemonFamilies, myPokeSettings); @@ -123,7 +123,7 @@ public static async Task Execute(ISession session) Dumper.Dump(session, string.Format($"NAME: {pokeName, -25} LVL: {PokemonInfo.GetLevel(pokemon).ToString("00"), -7} CP: {pokemon.Cp.ToString() + " / " + PokemonInfo.CalculateMaxCp(pokemon).ToString(), -15} IV: {PokemonInfo.CalculatePokemonPerfection(pokemon).ToString("0.00"), -10} MOVE1: {pokemon.Move1, -20} MOVE2: {pokemon.Move2, -20} Candies: {candy}"), - dumpFileName); + dumpFileName, "csv"); } } await Task.Delay(500);