private bool ToastificationHandle(ToastNotificationActivatedEventArgs toastActivationArgs) { Frame rootFrame = Window.Current.Content as Frame; // Parse the query string QueryString args = QueryString.Parse(toastActivationArgs.Argument); // See what action is being requested switch (args["action"]) { case "HotNews": // The URL retrieved from the toast args string queryString = args["queryString"]; News news = JsonSerializeHelper.Deserialize <News>(queryString); //二级Frame才显示该页 if (NavigationService.DetailFrame.Content is NewsBodyPage && (NavigationService.DetailFrame.Content as NewsBodyPage).NewsBodyViewModel.News.Id.Equals(news.Id)) { break; } // Otherwise navigate to view it NavigationService.DetailFrameNavigate(typeof(NewsBodyPage), news); return(true); } //导航失败 return(false); }
public async static Task <PostResult> PostBlogCommentVoteAsync(VoteBlogComment voteBlogComment) { try { string data = JsonSerializeHelper.Serialize(voteBlogComment); string json = await HttpHelper.Post(WcfApiUrlConstants.VoteBlogComment, data, CacheManager.LoginUserInfo.Cookies); PostResult response = JsonSerializeHelper.Deserialize <PostResult>(json); return(response); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); return(new PostResult() { IsSuccess = false, Message = "提交时发送异常" }); } }
public async static Task <LoginResult> SignInAsync(LoginUserInfo loginUserInfo) { try { string data = JsonSerializeHelper.Serialize(loginUserInfo); var content = new StringContent(data, Encoding.UTF8, Constants.JsonMediaType); Uri uri = new Uri(WcfApiUrlConstants.LoginUrl); content.Headers.Add(Constants.XRequestWith, Constants.XmlHttpRequest); content.Headers.Add(Constants.VerificationToken, loginUserInfo.VerificationToken); HttpHelper.HttpClientHandler.CookieContainer.Add(uri, new Cookie(Constants.ServerId, loginUserInfo.ServerId)); HttpHelper.HttpClientHandler.CookieContainer.Add(uri, new Cookie(Constants.AspxAutoDetectCookieSupport, "1")); var response = await HttpHelper.HttpClient.PostAsync(uri, content); response.EnsureSuccessStatusCode(); string responseContent = await response.Content.ReadAsStringAsync(); LoginResult postResult = JsonSerializeHelper.Deserialize <LoginResult>(responseContent); if (postResult.Success)// || postResult.Message == Constants.HadLogined)//提示已登录过cnblogs不能从响应中获取cookie。 { Cookie cookie = HttpHelper.LoadCookieFromHeader(response.Headers, Constants.AuthenticationCookiesName); HttpHelper.HttpClientHandler.CookieContainer.Add(uri, cookie); //登录成功先保存cookie CacheManager.Current.UpdateCookies(cookie); } return(postResult); } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(exception.Message); return(new LoginResult() { Success = false, Message = exception.Message }); } }