コード例 #1
0
        private static History MergeHistory(History history, PlaylogRecordTable palylogRecordTable)
        {
            var mergedHistory = new History(history);
            var lastPlayUnit  = history.GetTableUnits().LastOrDefault();
            var lastNumber    = lastPlayUnit?.Number ?? 0;
            var lastPlayDate  = lastPlayUnit?.PlayDate ?? new DateTime();
            var updated       = palylogRecordTable.GetTableUnits()
                                .Where(u => u.PlayDate > lastPlayDate)
                                .Where(u => u.Id != DefaultParameter.Id && u.Difficulty != Difficulty.WorldsEnd)
                                .Select((u, index) => new HistoryUnit(u)
            {
                Number = lastNumber + (index + 1)
            });

            mergedHistory.Add(updated);
            return(mergedHistory);
        }
コード例 #2
0
        public void PlaylogRecordTable_JsonIO_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/JsonIOTest/json_io_test_1.json";

            var writer = new PlaylogRecordTableJsonWriter();

            writer.Set(expectedPlaylogRecordTable);
            writer.Write(TestUtility.GetResourcePath(path));

            var reader = new PlaylogRecordTableJsonReader();
            var actualPlaylogRecordTable = reader.Read(TestUtility.LoadResource(path));

            PlaylogRecordTableTestUtility.AreEqual(expectedPlaylogRecordTable, actualPlaylogRecordTable);
        }
コード例 #3
0
        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出力");
            }
        }
コード例 #4
0
        public async Task UpdatePlaylogAsync()
        {
            await LoadGlobalMusicDataTable();

            DebugLogger.WriteLine("PlaylogDetailRecord更新の開始");
            List <TableUnit> savedPlaylogDetailRecordUnits = null;

            {
                var   readAsync = ReadPlaylogDetailRecordAsync("./test.csv");
                await readAsync;
                savedPlaylogDetailRecordUnits = readAsync.Result;
            }

            DebugLogger.WriteLine("Playlog の取得");
            IPlaylogRecordTable <IPlaylogRecordTableUnit> playlogRecord = null;
            {
                var   playlogSend = chunithmNetConnector.GetPlaylogAsync();
                await playlogSend;

                if (!playlogSend.Result.Success)
                {
                    throw new Exception("Playlogの取得に失敗しました");
                }

                var _playlogRecord = new PlaylogRecordTable();
                _playlogRecord.Add(playlogSend.Result.Playlog);
                playlogRecord = _playlogRecord;
            }

            List <TableUnit> updatedPlaylogDetailRecordUnits = null;

            {
                var   getAsync = GetUpdatedPlaylogDetailRecordUnitsAsync(playlogRecord, savedPlaylogDetailRecordUnits.LastOrDefault());
                await getAsync;
                updatedPlaylogDetailRecordUnits = getAsync.Result;
            }

            if (updatedPlaylogDetailRecordUnits.Count == 0)
            {
                DebugLogger.WriteLine("更新データなし");
                return;
            }

            DebugLogger.WriteLine("楽曲別レコードテーブル生成");
            var playlogDetailRecordUnitsGroupByMusic = GroupByMusic(updatedPlaylogDetailRecordUnits);

            DebugLogger.WriteLine("楽曲別レコードテーブル書き込み");
            await WritePlaylogDetailRecordByMusic(updatedPlaylogDetailRecordUnits);

            DebugLogger.WriteLine("更新データ書き込み");
            {
                var record = new Table();

                foreach (var recordUnit in savedPlaylogDetailRecordUnits)
                {
                    record.RecordUnits.Add(recordUnit);
                }

                foreach (var recordUnit in updatedPlaylogDetailRecordUnits)
                {
                    record.RecordUnits.Add(recordUnit);
                }

                var writer = new TableCsvWriter();
                writer.Set(record);
                writer.Write("./test.csv");
            }

            DebugLogger.WriteLine("Done.");
        }