private static Playlog GetPlaylog(IChunithmNetConnector connector) { var getPlaylog = connector.GetPlaylogAsync().Result; if (!getPlaylog.Success) { throw new Exception("プレイ履歴の取得に失敗"); } Console.WriteLine("プレイ履歴取得"); var playlog = getPlaylog.Playlog; if (playlog == null) { throw new Exception("プレイ履歴がnull"); } return(playlog); }
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."); }
private async void playlogToolStripMenuItem_Click(object sender, EventArgs e) { await chunithmNetConnector.GetPlaylogAsync(); }