private async Task <ItemGroup <MovieItem> > FetchMessageFromAPIAsync( string headString, string loc_id = "108288", uint start = 0, uint count = 8, int offset = 0) { var gmodel = default(ItemGroup <MovieItem>); try { var minised = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; string result = await BeansproutRequestHelper.FetchTypeCollectionList(headString, loc_id, start, count, minised, SubjectType.Movies); if (result != null) { gmodel = JsonHelper.FromJson <ItemGroup <MovieItem> >(result); if (gmodel.Items == null || gmodel.Items.Count < count) { isFinished = true; } } else { ReportWhenGoesWrong("WebActionError"); return(gmodel); } } catch { ReportHelper.ReportAttentionAsync(GetUIString("FetchJsonDataError")); } return(gmodel); }
private async Task <ItemGroup <MovieItem> > FetchMessageFromAPIAsync( string group, string loc_id = "108288", uint start = 0, uint count = 8, int offset = 0) { var gmodel = default(ItemGroup <MovieItem>); try { var minised = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; var result = await BeansproutRequestHelper.FetchTypeCollectionList(group, loc_id, start, count, minised, SubjectType.Movies, RequestType.SubjectCollection); if (result != null) { gmodel = JsonHelper.FromJson <ItemGroup <MovieItem> >(result); } else { ReportWhenGoesWrong("WebActionError"); return(gmodel); } } catch { ReportHelper.ReportAttentionAsync(GetUIString("UnknownError")); } IncrementalLoadingBorder.SetVisibility(false); return(gmodel); }
private async Task <ItemGroup <BookItem> > FetchMessageFromAPIAsync( string headString, string loc_id = "108288", uint start = 0, uint count = 8, int offset = 0) { var gmodel = default(ItemGroup <BookItem>); try { var minised = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds; var result = await BeansproutRequestHelper.FetchTypeCollectionList(headString, loc_id, start, count, minised, SubjectType.Music); if (result == null) { ReportWhenGoesWrong("WebActionError"); return(gmodel); } JObject jo = JObject.Parse(result); gmodel = DataProcess.SetGroupResources(jo, gmodel); gmodel = SetSingletonResources(jo, gmodel); } catch { ReportHelper.ReportAttentionAsync(GetUIString("FetchJsonDataError")); } IncrementalLoadingBorder.SetVisibility(false); return(gmodel); }
/// <summary> /// if login failed, re-navigate to the target Uri, otherwise, show status detail of you. /// </summary> /// <param name="htmlContent">html of websites</param> private async void CheckIfLoginSucceedAsync(string htmlBodyContent) { var doc = new HtmlDocument(); doc.LoadHtml(@"<html> <head> <title>......</title > <link href='style.css' rel='stylesheet' type='text/css'> <script language='JavaScript1.2' src='nocache.js'></script > </head><body>" + htmlBodyContent + "</body></html>"); if (htmlBodyContent.Contains("验证码")) // login failed. { ReportHelper.ReportAttentionAsync(GetUIString("LoginFailed")); } else { // login successful... MainLoginPopup.IsOpen = false; try { string result = await BeansproutRequestHelper.AccessOauth2Token(EmailBox.Text, PasswordBox.Password); var tokenReturn = default(APITokenReturn); try { JObject jo = JObject.Parse(result); tokenReturn = new APITokenReturn { AccessToken = jo["access_token"].Value <string>(), RefreshToken = jo["refresh_token"].Value <string>(), ExpiresIn = jo["expires_in"].Value <string>(), UserId = jo["douban_user_id"].Value <string>(), UserName = jo["douban_user_name"].Value <string>(), }; MainLoginPopup.IsOpen = false; SettingsHelper.SaveSettingsValue(SettingsSelect.UserID, UserID = tokenReturn.UserId); SettingsHelper.SaveSettingsValue(SettingsSelect.AccessToken, AccessToken = tokenReturn.AccessToken); SettingsHelper.SaveSettingsValue(SettingsSelect.RefreshToken, RefreshToken = tokenReturn.RefreshToken); try { await MainPage.SetUserStatusAsync(tokenReturn.UserId); } catch { /* Ignore */ } IsLogined = true; NavigateToBase?.Invoke( null, null, GetFrameInstance(FrameType.UserInfos), GetPageType(NavigateType.UserInfo)); } catch { /* Ignore. */ } } catch { try { MainPage.SetUserStatus(doc); } catch (Exception e) { Debug.WriteLine(e.Message + "\n" + e.StackTrace); } } NavigateToBase?.Invoke( null, null, GetFrameInstance(FrameType.UserInfos), GetPageType(NavigateType.UserInfo)); } }