public async Task <IMusicLevelGetResponse> GetMusicLevelAsync(IMusicLevelGetRequest request) { if (WebBrowserNavigator.WebBrowser.Url?.AbsoluteUri != ChunithmNetUrl.MusicLevel) { await WebBrowserNavigator.NavigateAsync(ChunithmNetUrl.MusicLevel); } { var document = WebBrowserNavigator.WebBrowser.Document; var content = document.GetElementById("inner"); var form = content.GetElementsByTagName("form").OfType <HtmlElement>().FirstOrDefault(); var select = form.GetElementsByTagName("select").OfType <HtmlElement>().FirstOrDefault(); select.SetAttribute("value", request.Level.ToString()); var raiseEvent = RaiseEventAsync(); select.RaiseEvent("onChange"); await raiseEvent; } var response = new MusicLevelGetResponse(WebBrowserNavigator.WebBrowser); if (response.Success) { var musicLevelParser = new MusicLevelParser(); response.MusicLevel = musicLevelParser.Parse(WebBrowserNavigator.WebBrowser.DocumentText); } return(response); }
public async Task <IMusicLevelGetResponse> GetMusicLevelAsync(IMusicLevelGetRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (WebBrowserNavigator.WebBrowser.Address != ChunithmNetUrl.MusicLevel) { await WebBrowserNavigator.LoadAsync(ChunithmNetUrl.MusicLevel); } await WebBrowserNavigator.EvaluatePageMoveScriptAsync($@" var levelSelecter = document.getElementsByName('level')[0]; levelSelecter.value = {request.Level}; changeSelecter(levelSelecter); "); var responseAsync = MusicLevelGetResponse.CreateResponseAsync(WebBrowserNavigator.WebBrowser); await responseAsync; var response = responseAsync.Result; if (response.Success) { var musicLevelParser = new MusicLevelParser(); response.MusicLevel = musicLevelParser.Parse(response.DocumentText); } return(response); }
public async Task <IMusicLevelGetResponse> GetMusicLevelAsync(IMusicLevelGetRequest request) { var musicLevelContent = new FormUrlEncodedContent(new Dictionary <string, string> { { "level", request.Level.ToString() }, { "token", token }, }); var musicLevelRequest = client.PostAsync(ChunithmNetUrl.CreateUrl("record/musicLevel/sendSearch"), musicLevelContent); await musicLevelRequest; var musicLevel = client.GetAsync(ChunithmNetUrl.CreateUrl("record/musicLevel/search")); await musicLevel; var response = new MusicLevelGetResponse(musicLevel.Result); if (response.Success) { response.MusicLevel = new MusicLevelParser().Parse(response.DocumentText); } return(response); }