private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { try { lastStories = new StoryCollection(ArticleType.byUserSubmissions, theUser); } catch { lastStories = null; backgroundWorker1.CancelAsync(); } }
public static void populateStoryCollection(StoryCollection alStories, string diggWebServiceUrl) { Story newStory = new Story(); XmlTextReader reader = Parser.CreateWebRequest(diggWebServiceUrl); while (reader.Read()) { if (reader.Name == "story") { // for (int i = 0; i < reader.AttributeCount; i++) //{ // switch (i) // { if (reader.GetAttribute("id") != null) { newStory.Id = reader.GetAttribute("id").ToString(); newStory.Link = reader.GetAttribute("href").ToString(); newStory.Diggs = reader.GetAttribute("diggs").ToString(); newStory.Comments = reader.GetAttribute("comments").ToString(); newStory.Status = reader.GetAttribute("status").ToString(); } /*case 0: newStory.Id = reader.GetAttribute(i).ToString(); break; case 5: newStory.Link = reader.GetAttribute(i).ToString(); newStory.Status = reader.GetAttribute(i).ToString(); break; case 2: newStory.SubmitDate = reader.GetAttribute(i).ToString(); break; case 3: newStory.Diggs = reader.GetAttribute(i).ToString(); break; case 4: //newStory.Comments = new CommentsCollection(newStory); break; newStory.Comments = reader.GetAttribute(i).ToString(); break; case 7: newStory.CommentsUrl = reader.GetAttribute(i).ToString(); break; case 6: newStory.PromoteDate = reader.GetAttribute(i).ToString(); break; */ //} //} } if (reader.Name == "title") { newStory.Title = reader.ReadString(); } if (reader.Name == "description") { newStory.Description = reader.ReadString(); } if (reader.Name == "user") { for (int i = 0; i < reader.AttributeCount; i++) { switch (i) { case 0: newStory.Submitter = reader.GetAttribute(i).ToString(); break; case 1: newStory.SubmitterIcon = reader.GetAttribute(i).ToString(); break; case 3: newStory.SubmitterProfileViews = reader.GetAttribute(i).ToString(); break; } } } if (reader.Name == "topic") { newStory.Topic = reader.GetAttribute(0).ToString(); } if (reader.Name == "container") { newStory.Container = reader.GetAttribute(0); alStories.Add(newStory); newStory = new Story(); } } }
/// <summary> /// Builds Story Object Based on Story ID /// </summary> /// <param name="storyId">Story ID</param> /// <returns>Story Object</returns> public Story GetStoryByID(string storyId) { Story iStory = new Story(); StoryCollection articles = new StoryCollection(ArticleType.byId, storyId); foreach (Story aStory in articles) { iStory = aStory; } return iStory; }