private static void UpdateHistory() { var historyCsvPath = "./playlog/history.csv"; var playlog = RequestPlaylog(); var playlogRecordTable = new PlaylogRecordTable(); playlogRecordTable.Add(playlog); foreach (var unit in playlogRecordTable.TableUnits) { var musicData = musicDataTable.GetTableUnit(unit.Name); if (musicData != null) { unit.Id = musicData.Id; unit.Genre = musicData.Genre; unit.BaseRating = musicData.GetBaseRating(unit.Difficulty); unit.Rating = Utility.GetRating(unit.BaseRating, unit.Score); } } { var writer = new PlaylogRecordTableCsvWriter(); var csvPath = $"./playlog/playlog_{DateTime.Now.ToString("yyyyMMdd_HHmmss")}.csv"; writer.Set(playlogRecordTable); writer.Write(csvPath); Console.WriteLine($"最新プレイ履歴のCSV出力 : {csvPath}"); } { var history = File.Exists(historyCsvPath) ? ReadHistory(historyCsvPath) : new History(); Program.history = MergeHistory(history, playlogRecordTable); WriteHistory(historyCsvPath, Program.history); Console.WriteLine("HistoryのCSV出力"); } }
public void PlaylogRecordTable_CsvIO_Test1() { var expectedPlaylogRecordTable = new PlaylogRecordTable(); expectedPlaylogRecordTable.Add <PlaylogRecordTableUnit>(new List <PlaylogRecordTableUnit>() { new PlaylogRecordTableUnit { Id = 1, Name = "TEST MUSIC 1", Genre = "POPS & ANIME", Difficulty = Difficulty.Basic, Score = 1000000, Rank = Rank.SS, BaseRating = 1.0, Rating = 2.0, IsNewRecord = false, IsClear = true, ComboStatus = ComboStatus.FullCombo, ChainStatus = 0, PlayDate = new DateTime(2018, 2, 14, 0, 0, 0), } }); var path = "PlaylogRecord/CsvIOTest/csv_io_test_1.csv"; var writer = new PlaylogRecordTableCsvWriter(); writer.Set(expectedPlaylogRecordTable); writer.Write(TestUtility.GetResourcePath(path)); var reader = new PlaylogRecordTableCsvReader(); var actualPlaylogRecordTable = reader.Read(TestUtility.LoadResource(path)); PlaylogRecordTableTestUtility.AreEqual(expectedPlaylogRecordTable, actualPlaylogRecordTable); }