コード例 #1
0
 public void TitleTest()
 {
     string baseUri = "TestValue"; // TODO: Initialize to an appropriate value
     DocumentQuery target = new DocumentQuery(baseUri); // TODO: Initialize to an appropriate value
     string expected = "TestValue";            string actual;
     target.Title = expected;
     actual = target.Title;
     Assert.AreEqual(expected, actual);
 }
コード例 #2
0
        internal Document LoadGoogleNotes(string folderUri, AtomId id)
        {
            string message = "Error Loading Google Notes. Cannot connect to Google.\r\nPlease ensure you are connected to the internet. If you are behind a proxy, change your proxy configuration!";

            Document ret = null;
            try
            {
                if (folderUri == null && id == null)
                {
                    // Only log, if not specific Google Notes are searched
                    Logger.Log("Loading Google Notes...", EventType.Information);
                    GoogleNotes = new Collection<Document>();
                }

                if (googleNotesFolder == null)
                    googleNotesFolder = GetOrCreateGoogleFolder(null, "Notes");//ToDo: Make the folder name Notes configurable in SettingsForm, for now hardcode to "Notes");

                if (folderUri == null)
                {
                    if (id == null)
                        folderUri = googleNotesFolder.DocumentEntry.Content.AbsoluteUri;
                    else //if newly created
                        folderUri = DocumentsRequest.BaseUri;
                }

                DocumentQuery query = new DocumentQuery(folderUri);
                query.Categories.Add(new QueryCategory(new AtomCategory("document")));
                query.NumberToRetrieve = 256;
                query.StartIndex = 0;

                //query.ShowDeleted = false;
                //query.OrderBy = "lastmodified";
                Feed<Document> feed = DocumentsRequest.Get<Document>(query);

                while (feed != null)
                {
                    foreach (Document a in feed.Entries)
                    {
                        if (id == null)
                            GoogleNotes.Add(a);
                        else if (id.Equals(a.DocumentEntry.Id))
                        {
                            ret = a;
                            return ret;
                        }
                    }
                    query.StartIndex += query.NumberToRetrieve;
                    feed = DocumentsRequest.Get<Document>(feed, FeedRequestType.Next);

                }

            }
            catch (System.Net.WebException ex)
            {
                //Logger.Log(message, EventType.Error);
                throw new GDataRequestException(message, ex);
            }
            catch (System.NullReferenceException ex)
            {
                //Logger.Log(message, EventType.Error);
                throw new GDataRequestException(message, new System.Net.WebException("Error accessing feed", ex));
            }

            return ret;
        }
コード例 #3
0
        internal List<Document> GetGoogleGroups()
        {
            List<Document> categoryFolders;

            DocumentQuery query = new DocumentQuery(googleNotesFolder.DocumentEntry.Content.AbsoluteUri);
            query.Categories.Add(new QueryCategory(new AtomCategory("folder")));
            query.NumberToRetrieve = 256;
            query.StartIndex = 0;

            //query.ShowDeleted = false;
            //query.OrderBy = "lastmodified";
            Feed<Document> feed = DocumentsRequest.Get<Document>(query);
            categoryFolders = new List<Document>();

            while (feed != null)
            {
                foreach (Document a in feed.Entries)
                {
                    categoryFolders.Add(a);
                }
                query.StartIndex += query.NumberToRetrieve;
                feed = DocumentsRequest.Get<Document>(feed, FeedRequestType.Next);

            }

            return categoryFolders;
        }
コード例 #4
0
        internal Document GetGoogleFolder(Document parentFolder, string title, string uri)
        {
            Document ret = null;

            //First get the Notes folder or create it, if not yet existing
            DocumentQuery query = new DocumentQuery(DocumentsRequest.BaseUri);
            //Doesn't work, therefore used IsInFolder below: DocumentQuery query = new DocumentQuery((parentFolder == null) ? DocumentsRequest.BaseUri : parentFolder.DocumentEntryContent.AbsoluteUri);
            query.Categories.Add(new QueryCategory(new AtomCategory("folder")));
            if (!string.IsNullOrEmpty(title))
                query.Title = title;

            Feed<Document> feed = DocumentsRequest.Get<Document>(query);

            if (feed != null)
            {
                foreach (Document a in feed.Entries)
                {
                    if ((string.IsNullOrEmpty(uri) || a.Self == uri) &&
                        (parentFolder == null || IsInFolder(parentFolder, a)))
                    {
                        ret = a;
                        break;
                    }
                }
                query.StartIndex += query.NumberToRetrieve;
                feed = DocumentsRequest.Get<Document>(feed, FeedRequestType.Next);
            }
            return ret;
        }
コード例 #5
0
        /// <summary>
        /// Cleanup empty GoogleNotesFolders (for Outlook categories)
        /// </summary>
        internal void CleanUpGoogleCategories()
        {
            DocumentQuery query;
            Feed<Document> feed;
            List<Document> categoryFolders = GetGoogleGroups();

            if (categoryFolders != null)
            {
                foreach (Document categoryFolder in categoryFolders)
                {
                    query = new DocumentQuery(categoryFolder.DocumentEntry.Content.AbsoluteUri);
                    query.NumberToRetrieve = 256;
                    query.StartIndex = 0;

                    //query.ShowDeleted = false;
                    //query.OrderBy = "lastmodified";
                    feed = DocumentsRequest.Get<Document>(query);

                    bool isEmpty = true;
                    while (feed != null)
                    {
                        foreach (Document a in feed.Entries)
                        {
                            isEmpty = false;
                            break;
                        }
                        if (!isEmpty)
                            break;
                        query.StartIndex += query.NumberToRetrieve;
                        feed = DocumentsRequest.Get<Document>(feed, FeedRequestType.Next);
                    }

                    if (isEmpty)
                    {
                        DocumentsRequest.Delete(new Uri(Google.GData.Documents.DocumentsListQuery.documentsBaseUri + "/" + categoryFolder.ResourceId), categoryFolder.ETag);
                        Logger.Log("Deleted empty Google category folder: " + categoryFolder.Title, EventType.Information);
                    }

                }
            }
        }
コード例 #6
0
 public void ExactTest()
 {
     string baseUri = "TestValue"; // TODO: Initialize to an appropriate value
     DocumentQuery target = new DocumentQuery(baseUri); // TODO: Initialize to an appropriate value
     bool expected = false; // TODO: Initialize to an appropriate value
     bool actual;
     target.Exact = expected;
     actual = target.Exact;
     Assert.AreEqual(expected, actual);
 }
コード例 #7
0
 public void Init()
 {
     query = new DocumentQuery("");
 }
コード例 #8
0
        private static void DeleteTestNote(DocumentsRequest service)
        {
            //ToDo: Doesn'T work always, frequently throwing 401, Precondition failed, maybe Google API bug
            //service.Delete(createdEntry);

            //Todo: Workaround to load document again
            DocumentQuery query = new DocumentQuery(service.BaseUri);
            query.NumberToRetrieve = 500;

            Feed<Document> feed = service.Get<Document>(query);

            Logger.Log("Loaded Google notes", EventType.Information);

            foreach (Document entry in feed.Entries)
            {
                if (entry.Title == "AN_OUTLOOK_TEST_NOTE")
                {
                    //service.Delete(entry);
                    service.Delete(new Uri(Google.GData.Documents.DocumentsListQuery.documentsBaseUri + "/" + entry.ResourceId), entry.ETag);
                    Logger.Log("Deleted Google note", EventType.Information);
                    //break;
                }
            }
        }