Exemplo n.º 1
0
        public GoogleDocsRepository(string code)
        {
            m_token = GetSessionToken(code);

            if (string.IsNullOrEmpty(m_email))
            {
                using (MiniProfiler.Current.Step("Get gmail address"))
                {
                    DocumentsRequest request = new DocumentsRequest(new RequestSettings(MvcApplication.APPNAME, m_token.access_token));
                    m_email = request.GetFolders().AtomFeed.Authors[0].Email;
                }
            }
        }
Exemplo n.º 2
0
        public override bool Execute()
        {
            GDataCredentials credentials = GetDataCredentials();
            RequestSettings  settings    = new RequestSettings("code.google.com/p/exult/", credentials);

            settings.AutoPaging = true;
            settings.PageSize   = 100;

            DocumentsRequest request = new DocumentsRequest(settings);
            Feed <Document>  feed    = request.GetFolders();

            List <ITaskItem> outputs = new List <ITaskItem>();

            // this takes care of paging the results in
            List <Document> entries = feed.Entries.ToList();
            IDictionary <string, Document> documentDictionary = entries.ToDictionary(item => item.Self);

            RequireDirectory(TargetDirectory);

            foreach (Document entry in entries)
            {
                if (_Cancelled)
                {
                    return(false);
                }

                List <PathMapping> paths = GetPaths(entry, documentDictionary).ToList();

                //handle each path, as we may allow multiple locations for a collection
                foreach (PathMapping path in paths)
                {
                    if (Pattern == null || PatternExpression.IsMatch(path.TitlePath))
                    {
                        Log.LogMessage(MessageImportance.High, "Matched \"{0}\"", path.TitlePath);
                        outputs.Add(BuildFolder(entry, path));
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.Low, "Skipped \"{0}\"", path.TitlePath);
                    }
                }
            }
            Folders = outputs.ToArray();
            return(true);
        }
Exemplo n.º 3
0
        public IList <CategoryValue> SelectAll()
        {
            //var query = new DocumentsListQuery();
            //query.ShowFolders=true;

            //DocumentsFeed feed = Service.Query(query);
            //var res= new List<CategoryValue>();
            //foreach (var d in feed.Entries.Cast<DocumentEntry>().Where(e => e.IsFolder))
            //{

            //   res.Add(new CategoryValue
            //               {
            //                   Name = d.Title.Text,

            //               });
            //}
            //return res;


            RequestSettings settings = new RequestSettings("GoogleDocumentsSample", Service.Credentials);

            var req  = new DocumentsRequest(settings);
            var res  = new List <CategoryValue>();
            var feed = req.GetFolders();

            foreach (var d in feed.Entries)
            {
                var cat = new CategoryValue
                {
                    Name       = d.Title,
                    CategoryID = GetInternalId(d.ResourceId)
                };
                if (d.ParentFolders.Count > 0)
                {
                    cat.ParentCategoryID = GetInternalId(GetGlobaId(d.ParentFolders[0]));
                }
                res.Add(cat);
            }
            return(res);
        }
        /// <summary>
        /// tests etag refresh on an entry level
        /// </summary>
        [Test] public void ModelTestFolders()
        {
            const string testTitle = "That is a new & weird subfolder";
            const string parentTitle = "Granddaddy folder";

            string parentID;
            string folderID;

            RequestSettings settings = new RequestSettings(this.ApplicationName, this.userName, this.passWord);
            // settings.PageSize = 15;
            DocumentsRequest r = new DocumentsRequest(settings);

            Document folder = new Document();
            folder.Type = Document.DocumentType.Folder;
            folder.Title = testTitle;

            /// first create the folder
            folder = r.CreateDocument(folder);

            Assert.IsTrue(folder.Title == testTitle);

            r.Delete(folder);

            // let's create a hierarchy

            Document parent = new Document();
            parent.Type = Document.DocumentType.Folder;
            parent.Title = parentTitle;

            parent = r.CreateDocument(parent);
            parentID = parent.Id;

            // create the child

            folder = new Document();
            folder.Type = Document.DocumentType.Folder;
            folder.Title = testTitle;

            /// first create the folder
            folder = r.CreateDocument(folder);
            folderID = folder.Id;

            // now move the folder into the parent
            r.MoveDocumentTo(parent, folder);


            // now get the folder list
            Feed<Document> folders = r.GetFolders();

            int iVerify = 2; 

            List<Document> list = new List<Document>();
            foreach (Document f in folders.Entries )
            {
                list.Add(f);
            }

            
            
            bool found = false; 

            foreach (Document f in list )
            {
                Assert.IsTrue(f.Type == Document.DocumentType.Folder, "this should be a folder");
                if (f.Id == parentID)
                {
                    iVerify--;
                }
                if (f.Id == folderID)
                {
                    iVerify--;
                    
                    // let's find the guy again.
                    foreach (Document d in list)
                    {
                        if (f.ParentFolders.Contains(d.Self))
                        {
                            found = true;
                            break;
                        }
                    }
                }
            }
            Assert.IsTrue(found, "we did not find the parent folder");

            Assert.IsTrue(iVerify==0, "We should have found both folders"); 
        }
Exemplo n.º 5
0
        /// <summary>
        /// tests etag refresh on an entry level
        /// </summary>
        [Test] public void ModelTestFolders()
        {
            const string testTitle   = "That is a new & weird subfolder";
            const string parentTitle = "Granddaddy folder";

            string parentID;
            string folderID;

            RequestSettings settings = new RequestSettings(this.ApplicationName, this.userName, this.passWord);
            // settings.PageSize = 15;
            DocumentsRequest r = new DocumentsRequest(settings);

            Document folder = new Document();

            folder.Type  = Document.DocumentType.Folder;
            folder.Title = testTitle;

            /// first create the folder
            folder = r.CreateDocument(folder);

            Assert.IsTrue(folder.Title == testTitle);

            r.Delete(folder);

            // let's create a hierarchy

            Document parent = new Document();

            parent.Type  = Document.DocumentType.Folder;
            parent.Title = parentTitle;

            parent   = r.CreateDocument(parent);
            parentID = parent.Id;

            // create the child

            folder       = new Document();
            folder.Type  = Document.DocumentType.Folder;
            folder.Title = testTitle;

            /// first create the folder
            folder   = r.CreateDocument(folder);
            folderID = folder.Id;

            // now move the folder into the parent
            r.MoveDocumentTo(parent, folder);


            // now get the folder list
            Feed <Document> folders = r.GetFolders();

            int iVerify = 2;

            List <Document> list = new List <Document>();

            foreach (Document f in folders.Entries)
            {
                list.Add(f);
            }



            bool found = false;

            foreach (Document f in list)
            {
                Assert.IsTrue(f.Type == Document.DocumentType.Folder, "this should be a folder");
                if (f.Id == parentID)
                {
                    iVerify--;
                }
                if (f.Id == folderID)
                {
                    iVerify--;

                    // let's find the guy again.
                    foreach (Document d in list)
                    {
                        if (f.ParentFolders.Contains(d.Self))
                        {
                            found = true;
                            break;
                        }
                    }
                }
            }
            Assert.IsTrue(found, "we did not find the parent folder");

            Assert.IsTrue(iVerify == 0, "We should have found both folders");
        }
Exemplo n.º 6
0
        public override bool Execute()
        {
            GDataCredentials credentials = GetDataCredentials();
            RequestSettings settings = new RequestSettings("code.google.com/p/exult/", credentials);
            settings.AutoPaging = true;
            settings.PageSize = 100;

            DocumentsRequest request = new DocumentsRequest(settings);
            Feed<Document> feed = request.GetFolders();

            List<ITaskItem> outputs = new List<ITaskItem>();

            // this takes care of paging the results in
            List<Document> entries = feed.Entries.ToList();
            IDictionary<string, Document> documentDictionary = entries.ToDictionary(item => item.Self);

            RequireDirectory(TargetDirectory);

            foreach (Document entry in entries)
            {
                if (_Cancelled)
                {
                    return false;
                }

                List<PathMapping> paths = GetPaths(entry, documentDictionary).ToList();

                //handle each path, as we may allow multiple locations for a collection
                foreach (PathMapping path in paths)
                {
                    if (Pattern == null || PatternExpression.IsMatch(path.TitlePath))
                    {
                        Log.LogMessage(MessageImportance.High, "Matched \"{0}\"", path.TitlePath);
                        outputs.Add(BuildFolder(entry, path));
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.Low, "Skipped \"{0}\"", path.TitlePath);
                    }
                }

            }
            Folders = outputs.ToArray();
            return true;
        }