public void Call(string[] args) { var arg = new Argument(args); var musicDataTable = new MusicDataTable(); using (var connector = new ChunithmNetHttpClientConnector()) using (var databaseConnector = new ChunithmMusicDatabaseHttpClientConnector(arg.DataBaseUrl)) { var currentTable = databaseConnector.GetTableAsync().GetMusicDatabaseApiResult("get current table... "); connector.LoginAsync(arg.SegaId, arg.Password).GetNetApiResult("login... "); connector.SelectAimeAsync(arg.AimeIndex).GetNetApiResult("selecting aime... "); var musicGenre = connector.GetMusicGenreAsync(GENRE_CODE_ALL, Difficulty.Master).GetNetApiResult("downloading music list... "); musicDataTable.Add(musicGenre.MusicGenre); if (currentTable.MusicDataTable.GetTableUnits().Count() == musicDataTable.GetTableUnits().Count()) { Console.WriteLine("skip update."); return; } for (var i = 0; i < arg.MaxLevelValue; i++) { var musicLevel = connector.GetMusicLevelAsync(i).GetNetApiResult($"downloading level info ({i + 1}/{arg.MaxLevelValue})", false); musicDataTable.Add(musicLevel.MusicLevel); } databaseConnector.UpdateTableAsync(musicDataTable.MusicDatas).GetMusicDatabaseApiResult("sending table... "); Console.WriteLine("completed."); } }
private async void 楽曲更新ToolStripMenuItem_Click(object sender, EventArgs e) { var maxLevel = 14; var loadNum = maxLevel + 1; Console.WriteLine($"楽曲の取得中... (1/{loadNum})"); var musicGenre = chunithmNetBackgroundConnector.GetMusicGenreAsync(Utility.GENRE_ALL_CODE, Difficulty.Master); await musicGenre; if (!musicGenre.Result.Success) { Console.WriteLine("!! Failed !!"); Console.WriteLine("Error Code : " + musicGenre.Result.ErrorCode); Console.WriteLine(musicGenre.Result.ErrorMessage); return; } var musicGenreDocument = musicGenre.Result.DocumentText; var musicLevelDocuments = new List <string>(); for (var i = 1; i <= maxLevel; i++) { Console.WriteLine($"楽曲の取得中... ({i + 1}/{loadNum})"); var musicLevel = chunithmNetBackgroundConnector.GetMusicLevelAsync(i); await musicLevel; if (!musicLevel.Result.Success) { Console.WriteLine("!! Failed !!"); Console.WriteLine("Error Code : " + musicLevel.Result.ErrorCode); Console.WriteLine(musicLevel.Result.ErrorMessage); return; } musicLevelDocuments.Add(musicLevel.Result.DocumentText); } Console.WriteLine("Success"); Console.WriteLine("楽曲テーブルを生成します..."); var musicDataTable = new MusicDataTable(); var musicGenreParser = new MusicGenreParser(); var musicLevelParser = new MusicLevelParser(); musicDataTable.Add(musicGenreParser.Parse(musicGenreDocument)); foreach (var musicLevel in musicLevelDocuments) { musicDataTable.Add(musicLevelParser.Parse(musicLevel)); } var tableUpdate = dataManagerConnector.UpdateTableAsync(musicDataTable.MusicDatas); await tableUpdate; Console.WriteLine("Success"); }