예제 #1
0
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>Loads a test file with an error return</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void GoogleBaseErrorTest()
        {
            Tracing.TraceMsg("Entering GoogleBaseErrorTest");

            FeedQuery query = new FeedQuery();

            Uri uri = new Uri(CreateUri(this.resourcePath + "batcherror.xml"));

            query.Uri = uri;
            Service service = new GBaseService(this.ApplicationName, this.gBaseKey);


            AtomFeed errorFeed = service.Query(query);

            foreach (AtomEntry errorEntry in errorFeed.Entries)
            {
                GDataBatchEntryData data = errorEntry.BatchData;
                if (data.Status.Code == 400)
                {
                    Assert.IsTrue(data.Status.Errors.Count == 2);
                    GDataBatchError error = data.Status.Errors[0];

                    Assert.IsTrue(error.Type == "data");
                    Assert.IsTrue(error.Field == "expiration_date");
                    Assert.IsTrue(error.Reason != null);
                    Assert.IsTrue(error.Reason.StartsWith("Invalid type specified"));

                    error = data.Status.Errors[1];

                    Assert.IsTrue(error.Type == "data");
                    Assert.IsTrue(error.Field == "price_type");
                    Assert.IsTrue(error.Reason == "Invalid price type");
                }
            }
        }
예제 #2
0
        private void Search()
        {
            YouTubeService myservice = new YouTubeService("aa", myDeveloperKey);
            FeedQuery      fq        = new FeedQuery();

            if (page == 0)
            {
                videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos?q=" + searchString + "&safeSearch=none&orderby=viewCount&max-results=10");
            }
            else
            {
                page          = (page * 10) + 1;
                videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos?q=" + searchString + "&safeSearch=none&orderby=viewCount&max-results=10&start-index=" + page);
            }

            fq.Uri = videoEntryUrl;
            Feed <Video> videoFeed = new Feed <Video>(myservice, fq);

            foreach (Video entry in videoFeed.Entries)
            {
                results.Add(new SearchResult(entry.VideoId,
                                             entry.Title,
                                             entry.Thumbnails.First(),
                                             entry.ViewCount));
            }
        }
        /////////////////////////////////////////////////////////////////////////////


        ////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new feed, saves and loads it back</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateFeedObjectSaveAndLoad()
        {
            Tracing.TraceMsg("Entering CreateFeedObjectSaveAndLoad test");

            Service  service = new Service();
            AtomFeed feed    = new AtomFeed(new Uri("http://www.atomfeed.com/"), service);

            feed.Self      = "http://www.atomfeed.com/self";
            feed.Feed      = "http://www.atomfeed.com/feed";
            feed.NextChunk = "http://www.atomfeed.com/next";
            feed.PrevChunk = "http://www.atomfeed.com/prev";
            feed.Post      = "http://www.atomfeed.com/post";

            ObjectModelHelper.DumpAtomObject(feed, CreateDumpFileName("CreateFeedSaveAndLoad"));


            // let's try loading this...
            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateFeedSaveAndLoad"));

            feed = service.Query(query);


            Assert.AreEqual("http://www.atomfeed.com/self", feed.Self, "Feed.Self is not correct");
            Assert.AreEqual("http://www.atomfeed.com/feed", feed.Feed, "Feed.Feed is not correct");
            Assert.AreEqual("http://www.atomfeed.com/next", feed.NextChunk, "Feed.Next is not correct");
            Assert.AreEqual("http://www.atomfeed.com/prev", feed.PrevChunk, "Feed.Prev is not correct");
            Assert.AreEqual("http://www.atomfeed.com/post", feed.Post, "Feed.Post is not correct");
        }
        /////////////////////////////////////////////////////////////////////////////



        ////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new entry, saves and loads it back</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateEmptyEntrySaveAndLoad()
        {
            Tracing.TraceMsg("Entering Create/Save/Load test");

            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);

            entry.Content.Type    = "text";
            entry.Content.Content = "";

            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateEmptyEntrySaveAndLoad"));


            // let's try loading this...
            Service service = new Service();

            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateEmptyEntrySaveAndLoad"));
            AtomFeed feed = service.Query(query);

            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
            // that feed should have ONE entry
            if (feed.Entries != null)
            {
                AtomEntry theOtherEntry = feed.Entries[0];
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry), "Entries should be identical");
            }
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] Creates a feedquery and checks if the SSL translation works</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void QuerySSLTest()
        {
            Tracing.TraceMsg("Entering QuerySSLTest test");

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri("http://www.google.com/");
            Assert.AreEqual("http://www.google.com/", query.Uri.ToString(), "both uris should be http now");
            query.UseSSL = true;
            Assert.AreEqual("https://www.google.com/", query.Uri.ToString(), "both uris should be https now");
            query.UseSSL = false;
            Assert.AreEqual("http://www.google.com/", query.Uri.ToString(), "both uris should be http now");

            // now construct the other way round

            query     = new FeedQuery();
            query.Uri = new Uri("https://www.google.com/");

            Assert.IsTrue(query.UseSSL, "Use SSL should be true due to detection of the https string");

            Assert.AreEqual("https://www.google.com/", query.Uri.ToString(), "both uris should be https now");
            query.UseSSL = false;
            Assert.AreEqual("http://www.google.com/", query.Uri.ToString(), "both uris should be http now");
            query.UseSSL = true;
            Assert.AreEqual("https://www.google.com/", query.Uri.ToString(), "both uris should be https now");
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>[Test] creates a new entry, saves and loads it back
        ///   uses HTML content to test the persistence/encoding code
        /// </summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void CreateHTMLEntrySaveAndLoad()
        {
            Tracing.TraceMsg("Entering CreateHTMLEntrySaveAndLoad");

            AtomEntry entry = ObjectModelHelper.CreateAtomEntry(1);

            entry.Content.Type    = "html";
            entry.Content.Content = HttpUtility.HtmlDecode("<b>this is a &lt;test&gt;</b>");

            Tracing.TraceMsg("Content: " + entry.Content.Content);

            ObjectModelHelper.DumpAtomObject(entry, CreateDumpFileName("CreateHTMLEntrySaveAndLoad"));


            // let's try loading this...
            Service service = new Service();

            service.RequestFactory = this.factory;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUriLogFileName("CreateHTMLEntrySaveAndLoad"));
            AtomFeed feed = service.Query(query);

            Assert.IsTrue(feed.Entries != null, "Feed.Entries should not be null");
            Assert.AreEqual(1, feed.Entries.Count, "Feed.Entries should have ONE element");
            // that feed should have ONE entry
            if (feed.Entries != null)
            {
                AtomEntry theOtherEntry = feed.Entries[0];
                Tracing.TraceMsg("Loaded Content: " + theOtherEntry.Content.Content);
                Assert.IsTrue(ObjectModelHelper.IsEntryIdentical(entry, theOtherEntry));
            }
        }
        public object All([FromQuery] FeedQuery feedQuery)
        {
            var moderationItems = _ctx.ModerationItems
                                  .Include(x => x.Reviews)
                                  .Where(x => !x.Deleted)
                                  .OrderFeed(feedQuery)
                                  .ToList();

            var targets = moderationItems.GroupBy(x => x.Type)
                          .SelectMany(x =>
            {
                var targetIds = x.Select(m => m.Target).ToArray();
                if (x.Key == ModerationTypes.Trick)
                {
                    return(_ctx.Tricks
                           .Include(t => t.User)
                           .Where(t => targetIds.Contains(t.Id))
                           .Select(TrickViewModels.FlatProjection)
                           .ToList());
                }

                return(Enumerable.Empty <object>());
            });

            return(new
            {
                ModerationItems = moderationItems.Select(ModerationItemViewModels.CreateFlat).ToList(),
                Targets = targets,
            });
        }
예제 #8
0
        public void BloggerPublicFeedTest()
        {
            Tracing.TraceMsg("Entering BloggerPublicFeedTest");

            FeedQuery      query   = new FeedQuery();
            BloggerService service = new BloggerService(this.ApplicationName);

            String publicURI = (String)this.externalHosts[0];

            if (publicURI != null)
            {
                service.RequestFactory = this.factory;

                query.Uri = new Uri(publicURI);
                AtomFeed feed = service.Query(query);

                if (feed != null)
                {
                    // look for the one with dinner time...
                    foreach (AtomEntry entry in feed.Entries)
                    {
                        Assert.IsTrue(entry.ReadOnly, "The entry should be readonly");
                    }
                }
            }
        }
예제 #9
0
 /// <summary>
 /// Gets the domain's Email Routing settings
 /// </summary>
 /// <returns>a <code>AdminSettingsFeed</code> containing the results of the
 /// operation</returns>
 public AdminSettingsFeed GetEmailRouting()
 {
     string uri = AppsDomainSettingsNameTable.AppsAdminSettingsBaseFeedUri
        + domain + AppsDomainSettingsNameTable.EmailroutingUriSuffix;
     FeedQuery feedQuery = new FeedQuery(uri);
     return Query(feedQuery) as AdminSettingsFeed;
 }
        /////////////////////////////////////////////////////////////////////////////


        //////////////////////////////////////////////////////////////////////
        /// <summary>creates a number or rows </summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void DefaultHostInsertAndStay()
        {
            Tracing.TraceMsg("Entering DefaultHostInsertAndStay");

            int       iCount = 0;
            FeedQuery query  = new FeedQuery();

            Service service = new Service();

            service.RequestFactory = this.factory;

            query.Uri = new Uri(this.defaultHost);
            AtomFeed  returnFeed = service.Query(query);
            AtomEntry entry;


            iCount = returnFeed.Entries.Count;

            // now we have all we need.

            for (int i = 0; i < this.iIterations; i++)
            {
                Tracing.TraceMsg("DefaultHostInsertAndStay: inserting entry #: " + i);
                entry = ObjectModelHelper.CreateAtomEntry(i);
                entry = returnFeed.Insert(entry);
            }

            Tracing.TraceMsg("DefaultHostInsertAndStay: inserted lot's of  entries");
            // done doing the inserts...

            // now query the guy again.

            returnFeed = service.Query(query);
            Assert.AreEqual(iCount + this.iIterations, returnFeed.Entries.Count, "feed should have " + this.iIterations + " more entries now");
        }
        /// <summary>
        /// Retrieves and prints the access control lists of all
        /// of the authenticated user's calendars.
        /// </summary>
        /// <param name="service">The authenticated CalendarService object.</param>
        static void RetrieveAcls(CalendarService service)
        {
            FeedQuery query = new FeedQuery();

            query.Uri = new Uri("http://www.google.com/calendar/feeds/default");
            AtomFeed calFeed = service.Query(query);

            Console.WriteLine();
            Console.WriteLine("Sharing permissions for your calendars:");

            // Retrieve the meta-feed of all calendars.
            foreach (AtomEntry calendarEntry in calFeed.Entries)
            {
                Console.WriteLine("Calendar: {0}", calendarEntry.Title.Text);
                AtomLink link = calendarEntry.Links.FindService(
                    AclNameTable.LINK_REL_ACCESS_CONTROL_LIST, null);

                // For each calendar, retrieve its ACL feed.
                if (link != null)
                {
                    AclFeed feed = service.Query(new AclQuery(link.HRef.ToString()));
                    foreach (AclEntry aclEntry in feed.Entries)
                    {
                        Console.WriteLine("\tScope: Type={0} ({1})", aclEntry.Scope.Type,
                                          aclEntry.Scope.Value);
                        Console.WriteLine("\tRole: {0}", aclEntry.Role.Value);
                    }
                }
            }
        }
예제 #12
0
        public void getContentFeed(String feedUri)
        {
            FeedQuery query = new FeedQuery(feedUri);
            AtomFeed  feed  = service.Query(query);

            printContentFeed(feed);
        }
예제 #13
0
        private void test(object sender, MouseEventArgs e)
        {
            listView1.BackColor = Color.Aqua;


            listView1.FullRowSelect = true;

            string youTubeSearchTerm;

            youTubeSearchTerm = textBox1.Text;

            YouTubeService myservice = new YouTubeService("aa", myDeveloperKey);

            Uri videoEntryUrl = new Uri("http://gdata.youtube.com/feeds/api/videos?q=" + youTubeSearchTerm + "&safeSearch=none&orderby=viewCount");


            FeedQuery fq = new FeedQuery();

            fq.Uri = videoEntryUrl;

            Feed <Video> videoFeed = new Feed <Video>(myservice, fq);

            foreach (Video entry in videoFeed.Entries)
            {
                listView1.Items.Add((new ListViewItem(new string[] { entry.VideoId.ToString() })));
            }
        }
예제 #14
0
        public async Task <IList <Contact> > ReadContactsAsync(string query)
        {
            var secrets = Paths.BinDir.CatDir("client_secret_292564741141-6fa0tqv21ro1v8s28gj4upei0muvuidm.apps.googleusercontent.com.json").Read(GoogleClientSecrets.Load).Secrets;

            var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                secrets,
                new string[] { "https://www.google.com/m8/feeds" },
                credentialProvider.GetCredential().UserName,
                CancellationToken.None,
                null);

            var parameters = new Google.GData.Client.OAuth2Parameters()
            {
                ClientId     = secrets.ClientId,
                ClientSecret = secrets.ClientSecret,
                RedirectUri  = redirectUri,
                Scope        = scope,
                AccessToken  = credential.Token.AccessToken,
                RefreshToken = credential.Token.RefreshToken,
            };

            var contacts = new ContactsRequest(new RequestSettings("hagen", parameters));
            var q        = new FeedQuery("https://www.google.com/m8/feeds/contacts/default/full")
            {
                Query = query
            };
            var feed    = contacts.Get <Contact>(q);
            var entries = feed.Entries.ToList();

            return(entries);
        }
예제 #15
0
        public async Task ReadContactsAsync()
        {
            var secrets = Paths.BinDir.CatDir("client_secret_292564741141-6fa0tqv21ro1v8s28gj4upei0muvuidm.apps.googleusercontent.com.json").Read(GoogleClientSecrets.Load).Secrets;

            var credentialProvider = Sidi.CredentialManagement.Factory.GetCredentialProvider("https://www.google.com/m8/feeds");

            var credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                secrets,
                new string[] { "https://www.google.com/m8/feeds" },
                credentialProvider.GetCredential().UserName,
                CancellationToken.None,
                new FileDataStore("Contacts2"));

            var parameters = new Google.GData.Client.OAuth2Parameters()
            {
                ClientId     = secrets.ClientId,
                ClientSecret = secrets.ClientSecret,
                RedirectUri  = redirectUri,
                Scope        = "https://www.google.com/m8/feeds",
                AccessToken  = credential.Token.AccessToken,
                RefreshToken = credential.Token.RefreshToken,
            };

            var contacts = new ContactsRequest(new RequestSettings("hagen", parameters));
            var q        = new FeedQuery("https://www.google.com/m8/feeds/contacts/default/full")
            {
                Query = "Grimme"
            };
            var feed = contacts.Get <Contact>(q);

            log.Info(feed.Entries.ListFormat());
        }
        public void FeedQueryConstructorTest()
        {
            string    baseUri = "http://www.test.com/"; // TODO: Initialize to an appropriate value
            FeedQuery target  = new FeedQuery(baseUri);

            Assert.AreEqual(target.Uri, new Uri(baseUri));
        }
        public void InsertExtendedPropertyContactsTest()
        {
            Tracing.TraceMsg("Entering InsertExtendedPropertyContactsTest");

            DeleteAllContacts();

            RequestSettings rs = new RequestSettings(this.ApplicationName, this.userName, this.passWord);

            rs.AutoPaging = true;

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(CreateUri(this.resourcePath + "contactsextendedprop.xml"));



            ContactsRequest cr = new ContactsRequest(rs);

            Feed <Contact> f = cr.Get <Contact>(query);

            Contact newEntry = null;

            foreach (Contact c in f.Entries)
            {
                ExtendedProperty e = c.ExtendedProperties[0];
                Assert.IsTrue(e != null);
                newEntry = c;
            }

            f = cr.GetContacts();

            Contact createdEntry = cr.Insert <Contact>(f, newEntry);

            cr.Delete(createdEntry);
        }
예제 #18
0
    /// <summary>
    /// Lists the user's blogs and returns the URI for posting new entries to the blog which the user selected.
    /// </summary>
    /// <param name="service"></param>
    /// <returns></returns>

    private Uri SelectUserBlog(Service service)
    {
        FeedQuery query = new FeedQuery();

        // Retrieving a list of blogs
        query.Uri = new Uri("http://www.blogger.com/feeds/default/blogs");
        AtomFeed feed = service.Query(query);

        // Publishing a blog post
        Uri blogPostUri = null;

        if (feed != null)
        {
            foreach (AtomEntry entry in feed.Entries)
            {
                // find the href in the link with a rel pointing to the blog's feed
                for (int i = 0; i < entry.Links.Count; i++)
                {
                    if (entry.Links[i].Rel.Equals("http://schemas.google.com/g/2005#post"))
                    {
                        blogPostUri = new Uri(entry.Links[i].HRef.ToString());
                    }
                }
                return(blogPostUri);
            }
        }
        return(blogPostUri);
    }
예제 #19
0
        static void Main(string[] args)
        {
            Console.WriteLine("Suchwort:");
            string searchTerm = Console.ReadLine();

            string uriSearchTerm = HttpUtility.UrlEncode(searchTerm);
            string url           = "http://gdata.youtube.com/feeds/videos?q=" + uriSearchTerm;

            Console.WriteLine("Connection to YouTube - Searching: " + searchTerm);

            FeedQuery query   = new FeedQuery("");
            Service   service = new Service("youtube", "sample");

            query.Uri              = new Uri(url);
            query.StartIndex       = 0;
            query.NumberToRetrieve = 20;
            AtomFeed resultFeed = service.Query(query);

            foreach (AtomEntry entry in resultFeed.Entries)
            {
                Console.WriteLine("Title: " + entry.Title.Text);
                Console.WriteLine("Link: " + entry.AlternateUri.Content);
                Console.WriteLine("Tags:");
                foreach (AtomCategory cat in entry.Categories)
                {
                    Console.Write(cat.Term + ", ");
                }
                Console.WriteLine();
            }

            Console.ReadLine();
        }
예제 #20
0
        private void RefreshFeedList()
        {
            string codeSearchURI = this.CodeSearchURI.Text;

            FeedQuery         query   = new FeedQuery();
            CodeSearchService service = new CodeSearchService("CodeSearchSampleApp");

            query.Uri              = new Uri(codeSearchURI);
            query.Query            = this.Query.Text;
            query.StartIndex       = 1;
            query.NumberToRetrieve = 2;
            // start repainting
            this.FeedView.BeginUpdate();
            Cursor.Current = Cursors.WaitCursor;
            // send the request.
            CodeSearchFeed feed = service.Query(query);

            // Clear the TreeView each time the method is called.
            this.FeedView.Nodes.Clear();
            int iIndex = this.FeedView.Nodes.Add(new TreeNode(feed.Title.Text));

            this.FeedView.Nodes.Add(new TreeNode("Number of entries "));
            this.FeedView.Nodes.Add(new TreeNode(feed.Entries.Count.ToString()));

            if (iIndex >= 0)
            {
                foreach (CodeSearchEntry entry in feed.Entries)
                {
                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              "Entry title: " + entry.Title.Text));
                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              "File Name"));
                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              entry.FileElement.Name));

                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              "Package Name"));
                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              entry.PackageElement.Name));
                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              "Package Uri"));
                    this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                              entry.PackageElement.Uri));

                    int jIndex = this.FeedView.Nodes[iIndex].Nodes.Add(new TreeNode(
                                                                           "Matches:"));
                    foreach (Match m in entry.Matches)
                    {
                        this.FeedView.Nodes[iIndex].Nodes[jIndex].Nodes.Add(new TreeNode(
                                                                                m.LineNumber + ": " +
                                                                                m.LineTextElement));
                    }
                }
            }
            // Reset the cursor to the default for all controls.
            Cursor.Current = Cursors.Default;
            // End repainting the combobox
            this.FeedView.EndUpdate();
        }
예제 #21
0
 /// <summary>
 /// the virtual creator function for feeds, so that we can create feedsubclasses in
 /// in subclasses of the request
 /// </summary>
 /// <param name="q"></param>
 /// <returns></returns>
 protected override Feed <Y> CreateFeed <Y>(FeedQuery q)
 {
     if (typeof(Y) == typeof(Data))
     {
         return(new Dataset(this.AtomService, q) as Feed <Y>);
     }
     return(base.CreateFeed <Y>(q));
 }
예제 #22
0
 public Task <List <object> > GetUserSubmissions(string id, [FromQuery] FeedQuery feedQuery) =>
 _ctx.Submissions
 .Include(x => x.Video)
 .Include(x => x.User)
 .Where(x => x.UserId.Equals(id))
 .OrderFeed(feedQuery)
 .Select(SubmissionViewModels.Projection)
 .ToListAsync();
예제 #23
0
        public async Task <ActionResult> GetNextTopFeedsAsync(FeedQuery query)
        {
            var meta = await AppUsers.GetCurrentAsync().ConfigureAwait(true);

            var model = await Feeds.GetFeedsAsync(this.Tenant, meta.UserId, query).ConfigureAwait(true);

            return(this.Ok(model));
        }
예제 #24
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>empty a feed</summary>
        //////////////////////////////////////////////////////////////////////
        protected void FeedCleanup(String uriToClean, String userName, String pwd, int protocolMajor)
        {
            Tracing.TraceCall();
            Tracing.TraceCall("Cleaning URI: " + uriToClean);

            if (!this.wipeFeeds)
            {
                Tracing.TraceInfo("Skipped cleaning URI due to configuration.");
                return;
            }

            FeedQuery query   = new FeedQuery();
            Service   service = new Service();

            service.ProtocolMajor = protocolMajor;

            if (uriToClean != null)
            {
                if (userName != null)
                {
                    service.Credentials = new GDataCredentials(userName, pwd);
                }

                service.RequestFactory = this.factory;

                query.Uri = new Uri(uriToClean);

                Tracing.TraceCall("Querying " + uriToClean);
                AtomFeed feed = service.Query(query);
                Tracing.TraceCall("Queryed " + uriToClean);
                if (feed != null)
                {
                    Tracing.TraceCall("Entries: " + feed.Entries.Count.ToString());
                }

                int iCount = 0;

                if (feed.Entries.Count > 0)
                {
                    while (feed.Entries.Count > 0)
                    {
                        Tracing.TraceCall("Feed has still " + feed.Entries.Count.ToString() + " entries left.");
                        foreach (AtomEntry entry in feed.Entries)
                        {
                            Tracing.TraceCall("Deleting entry " + iCount);
                            entry.Delete();
                            iCount++;
                            Tracing.TraceCall("Deleted entry " + iCount);
                        }
                        feed = service.Query(query);
                    }

                    Assert.AreEqual(0, feed.Entries.Count, "Feed should have no more entries, it has: " + feed.Entries.Count);
                    service.Credentials = null;
                }
            }
        }
예제 #25
0
        /// <summary>
        ///  overwritten Query method
        /// </summary>
        /// <param name="feedQuery">The CodeSearchQuery touse</param>
        /// <returns>the retrieved CodeSearchFeed</returns>
        public new CodeSearchFeed Query(FeedQuery feedQuery)
        {
            Stream         feedStream = Query(feedQuery.Uri);
            CodeSearchFeed feed       = new CodeSearchFeed(feedQuery.Uri, this);

            feed.Parse(feedStream, AlternativeFormat.Atom);
            feedStream.Close();
            return(feed);
        }
예제 #26
0
        public ActionResult IndexOLD(string id)
        {
            string uri;
            bool   permalink = false;

            if (string.IsNullOrEmpty(id))
            {
                uri = _baseUri;
            }
            else
            {
                uri       = postUri(id);
                permalink = true;
            }

            FeedQuery query = new FeedQuery();

            query.Uri = new Uri(uri);

            if (!permalink)
            {
                query.StartIndex       = 0;
                query.NumberToRetrieve = 2;
            }

            AtomFeed feed = null;

            feed = _service.Query(query);

            var bpl = new List <BlogPost>();

            foreach (var e in feed.Entries)
            {
                var bp = new BlogPost()
                {
                    Title   = e.Title.Text,
                    Content = e.Content.Content,
                    Date    = e.Published,
                    ID      = e.EditUri.Content.Substring(e.EditUri.Content.LastIndexOf('/') + 1)
                };
                bpl.Add(bp);
            }

            return(View(new BlogListData()
            {
                //SideBarData = new Models.Shared.MainSideBarData(),
                Posts = bpl
                        //Posts = feed.Entries.Select(e => new BlogPost()
                        //{
                        //    Title = e.Title.Text,
                        //    Content = e.Content.Content,
                        //    Date = e.Published,
                        //    ID = Regex.Replace(e.Links.Single(l => l.Rel == "edit").HRef.ToString(), uri + "/", "")
                        //}).ToList()
            }));
        }
        /////////////////////////////////////////////////////////////////////////////



        //////////////////////////////////////////////////////////////////////
        /// <summary>reads one external feed and inserts it locally</summary>
        //////////////////////////////////////////////////////////////////////
        [Test] public void DefaultHostInsertExternalFeed()
        {
            Tracing.TraceMsg("Entering DefaultHostInsertExternalFeed");

            if (this.strRemoteHost != null)
            {
                // remove old data
                DefaultHostDeleteAll();

                FeedQuery query   = new FeedQuery();
                Service   service = new Service();

                service.RequestFactory = (IGDataRequestFactory) new GDataLoggingRequestFactory(this.ServiceName, this.ApplicationName);
                query.Uri = new Uri(this.strRemoteHost);
                AtomFeed remoteFeed = service.Query(query);

                query.Uri = new Uri(this.defaultHost);
                AtomFeed localFeed = service.Query(query);

                foreach (AtomEntry remoteEntry in remoteFeed.Entries)
                {
                    localFeed.Entries.Add(remoteEntry);
                    Tracing.TraceInfo("added: " + remoteEntry.Title.Text);
                }
                bool f;

                foreach (AtomEntry localEntry in localFeed.Entries)
                {
                    f = localEntry.IsDirty();
                    Assert.AreEqual(true, f, "This entry better be dirty now");
                }

                f = localFeed.IsDirty();
                Assert.AreEqual(true, f, "This feed better be dirty now");

                localFeed.Publish();

                foreach (AtomEntry localEntry in localFeed.Entries)
                {
                    f = localEntry.IsDirty();
                    Assert.AreEqual(false, f, "This entry better NOT be dirty now");
                }

                f = localFeed.IsDirty();
                Assert.AreEqual(false, f, "This feed better NOT be dirty now");

                // requery
                localFeed = service.Query(query);

                foreach (AtomEntry localEntry in localFeed.Entries)
                {
                    AtomSource source = localEntry.Source;
                    Assert.AreEqual(source.Id.Uri.ToString(), remoteFeed.Id.Uri.ToString(), "This entry better has the same source ID than the remote feed");
                }
            }
        }
        public void UseSSLTest()
        {
            FeedQuery target   = new FeedQuery(); // TODO: Initialize to an appropriate value
            bool      expected = true;
            bool      actual;

            target.UseSSL = expected;
            actual        = target.UseSSL;
            Assert.AreEqual(expected, actual);
        }
        public void UriTest()
        {
            FeedQuery target   = new FeedQuery(); // TODO: Initialize to an appropriate value
            Uri       expected = new Uri("http://www.test.com/");
            Uri       actual;

            target.Uri = expected;
            actual     = target.Uri;
            Assert.AreEqual(expected, actual);
        }
 public IEnumerable <object> ListSubmissionsForTrick(string trickId, [FromQuery] FeedQuery feedQuery)
 {
     return(_ctx.Submissions
            .Include(x => x.Video)
            .Include(x => x.User)
            .Where(x => x.TrickId.Equals(trickId, StringComparison.InvariantCultureIgnoreCase))
            .OrderFeed(feedQuery)
            .Select(SubmissionViewModels.PerspectiveProjection(UserId))
            .ToList());
 }