public void FetchCurrentBlogAdditionalDataAsync() { if (null == CurrentBlog) { throw new ArgumentException("CurrentBlog may not be null", "CurrentBlog"); } GetPostFormatsRPC rpc = new GetPostFormatsRPC(CurrentBlog); CurrentBlog.showLoadingIndicator(); rpc.Completed += OnFetchPostFormatsRPCCompleted; rpc.ExecuteAsync(); }
private void OnGetNewBlogPostFormatsCompleted(object sender, XMLRPCCompletedEventArgs <PostFormat> args) { GetPostFormatsRPC rpc = sender as GetPostFormatsRPC; rpc.Completed -= OnGetNewBlogPostFormatsCompleted; Blog newBlog = _trackedBlogs.Where(blog => blog.BlogId == rpc.BlogId).FirstOrDefault(); if (null == newBlog) { return; } //report the error, but keep trying to get data if (null != args.Error) { this.DebugLog("OnGetNewBlogPostFormatsCompleted: Exception occurred (" + newBlog.BlogName + ")"); this.DebugLog(args.Error.ToString()); NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } else { newBlog.PostFormats.Clear(); args.Items.ForEach(postFormat => { newBlog.PostFormats.Add(postFormat); }); } this.DebugLog("Blog '" + newBlog.BlogName + "' has finished downloading postFormats."); if (newBlog == CurrentBlog) { NotifyFetchComplete(); } //get the options for the new blog GetOptionsRPC optionRPC = new GetOptionsRPC(newBlog); optionRPC.Completed += OnGetNewBlogOptionsCompleted; optionRPC.ExecuteAsync(); }
private void OnGetNewBlogRecentPostsCompleted(object sender, XMLRPCCompletedEventArgs <PostListItem> args) { GetRecentPostsRPC rpc = sender as GetRecentPostsRPC; rpc.Completed -= OnGetNewBlogRecentPostsCompleted; rpc.ProgressChanged -= OnGetNewBlogRecentPostsRPCProgressChanged; Blog newBlog = _trackedBlogs.Where(blog => blog.BlogId == rpc.BlogId).FirstOrDefault(); if (null == newBlog) { return; } //report the error, but keep trying to get data if (null != args.Error) { this.DebugLog("OnGetNewBlogRecentPostsCompleted: Exception occurred (" + newBlog.BlogName + ")"); this.DebugLog(args.Error.ToString()); NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } else { foreach (PostListItem item in args.Items) { newBlog.PostListItems.Add(item); } } this.DebugLog("Blog '" + newBlog.BlogName + "' has finished downloading posts."); if (newBlog == CurrentBlog) { NotifyFetchComplete(); } //get the pages for the new blog GetPostFormatsRPC postFormatsRPC = new GetPostFormatsRPC(newBlog); postFormatsRPC.Completed += OnGetNewBlogPostFormatsCompleted; postFormatsRPC.ExecuteAsync(); }
private void OnFetchPostFormatsRPCCompleted(object sender, XMLRPCCompletedEventArgs <PostFormat> args) { GetPostFormatsRPC rpc = sender as GetPostFormatsRPC; rpc.Completed -= OnFetchPostFormatsRPCCompleted; if (null == args.Error) { CurrentBlog.PostFormats.Clear(); args.Items.ForEach(postFormat => { CurrentBlog.PostFormats.Add(postFormat); }); // NotifyFetchComplete(); do not notify here } else { NotifyExceptionOccurred(new ExceptionEventArgs(args.Error)); } GetOptionsRPC rpcOption = new GetOptionsRPC(CurrentBlog); rpcOption.Completed += OnFetchOptionsRPCCompleted; rpcOption.ExecuteAsync(); }