예제 #1
0
파일: Form1.cs 프로젝트: vrokolos/DiggBeep
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         lastStories = new StoryCollection(ArticleType.byUserSubmissions, theUser);
     }
     catch { lastStories = null;
     backgroundWorker1.CancelAsync();
     }
 }
예제 #2
0
파일: Parser.cs 프로젝트: vrokolos/DiggBeep
        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();
                }
            }
        }
예제 #3
0
파일: Story.cs 프로젝트: vrokolos/DiggBeep
 /// <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;
 }