Esempio n. 1
0
        public static void RequireDocumentType(this ITaskItem item, Document.DocumentType requiredDocumentType)
        {
            Document.DocumentType documentType = item.RequireDocumentType();

            if (documentType != requiredDocumentType)
            {
                throw new ArgumentException(string.Format("Document was of type {0} but must be of type {1}", documentType, requiredDocumentType));
            }
        }
Esempio n. 2
0
            public Stream Download(ITaskItem document, string exportFormat)
            {
                Document.DocumentType documentType = document.RequireDocumentType();

                string baseUrl = document.RequireExportUri();

                if (!string.IsNullOrEmpty(exportFormat))
                {
                    baseUrl = this.BuildDocumentPartialExportUrl(baseUrl) + exportFormat;
                }
                Uri queryUri = new Uri(baseUrl);

                return(base.Service.Query(queryUri));
            }
Esempio n. 3
0
        public override bool Execute()
        {
            GDataCredentials credentials = GetDataCredentials();
            RequestSettings  settings    = new RequestSettings("code.google.com/p/exult/", credentials);

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

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

            WarnIfUneven(Tuple.Create("Folders", Folders), Tuple.Create("FolderListings", FolderListings));
            foreach (var tuple in Zip(Folders, FolderListings))
            {
                if (_Cancelled)
                {
                    return(false);
                }

                ITaskItem folder        = tuple.Item1;
                ITaskItem folderListing = tuple.Item2;

                folder.LoadCustomMetadata();
                folder.RequireDocumentType(Document.DocumentType.Folder);

                //yada/hrm.folder -> yada/hrm/
                string folderPath = Path.Combine(Path.GetDirectoryName(folder.ItemSpec), Path.GetFileNameWithoutExtension(folder.ItemSpec));
                RequireDirectory(folderPath);
                PathMapping folderMapping = new PathMapping(folderPath);

                Request request = new Request(settings);

                string resourceId = folder.RequireResourceId();

                Log.LogMessage(MessageImportance.High, "Getting Folder Content \"{0}\"", folder.RequireTitlePath());
                Feed <Document> feed = request.GetFolderContent(resourceId);

                // this takes care of paging the results in
                List <Document> documents = feed.Entries.Where(item => item.Type != Document.DocumentType.Folder).ToList();
                Log.LogMessage(MessageImportance.Normal, "Found {0} Item(s)", documents.Count);

                DateTime folderTimestamp = folder.GetTimestamp();
                DateTime latestTimestamp = folderTimestamp;

                foreach (Document document in documents)
                {
                    if (_Cancelled)
                    {
                        return(false);
                    }

                    if (document.Updated > latestTimestamp)
                    {
                        latestTimestamp = document.Updated;
                    }
                    if (Pattern == null || PatternExpression.IsMatch(document.Title))
                    {
                        Log.LogMessage(MessageImportance.Normal, "Matched \"{0}\"", document.Title);
                        folderContent.Add(BuildContent(folder, document, folderMapping));
                    }
                    else
                    {
                        Log.LogMessage(MessageImportance.Low, "Skipped \"{0}\"", document.Title);
                    }
                }
                folder.CopyMetadataTo(folderListing);
                folderListing.Save(Log, latestTimestamp);
            }
            FolderContent = folderContent.ToArray();
            return(true);
        }
Esempio n. 4
0
            public Stream Download(ITaskItem input, Document.DownloadType type, string baseDomain = null, int sheetNumber = 0)
            {
                input.LoadCustomMetadata();
                Document.DocumentType documentType = input.RequireDocumentType();

                Service s        = this.Service;
                string  queryUri = this.BuildDocumentPartialExportUrl(input.RequireExportUri());

                switch (documentType)
                {
                case Document.DocumentType.Spreadsheet:
                    s = this.Service;
                    switch (type)
                    {
                    case Document.DownloadType.xls:
                        queryUri += "xls";
                        break;

                    case Document.DownloadType.csv:
                        queryUri += "csv&gid=" + sheetNumber.ToString();
                        break;

                    case Document.DownloadType.pdf:
                        queryUri += "pdf";
                        break;

                    case Document.DownloadType.ods:
                        queryUri += "ods";
                        break;

                    case Document.DownloadType.tsv:
                        queryUri += "tsv&gid=" + sheetNumber.ToString();;
                        break;

                    case Document.DownloadType.html:
                        queryUri += "html";
                        break;

                    default:
                        throw new ArgumentException("type is invalid for a spreadsheet");
                    }
                    break;

                case Document.DocumentType.Presentation:
                    switch (type)
                    {
                    case Document.DownloadType.swf:
                        queryUri += "swf";
                        break;

                    case Document.DownloadType.pdf:
                        queryUri += "pdf";
                        break;

                    case Document.DownloadType.ppt:
                        queryUri += "ppt";
                        break;

                    default:
                        throw new ArgumentException("type is invalid for a presentation");
                    }
                    break;

                case Document.DocumentType.Unknown:
                    break;

                default:
                    queryUri += type.ToString();
                    break;
                }

                Uri target = new Uri(queryUri);

                return(s.Query(target));
            }
Esempio n. 5
0
            public Stream Download(ITaskItem input, Document.DownloadType type, string baseDomain = null, int sheetNumber = 0)
            {
                input.LoadCustomMetadata();
                Document.DocumentType documentType = input.RequireDocumentType();

                Service s = this.Service;
                string queryUri = this.BuildDocumentPartialExportUrl(input.RequireExportUri());

                switch (documentType)
                {
                    case Document.DocumentType.Spreadsheet:
                        s = this.Service;
                        switch (type)
                        {
                            case Document.DownloadType.xls:
                                queryUri += "xls";
                                break;
                            case Document.DownloadType.csv:
                                queryUri += "csv&gid=" + sheetNumber.ToString();
                                break;
                            case Document.DownloadType.pdf:
                                queryUri += "pdf";
                                break;
                            case Document.DownloadType.ods:
                                queryUri += "ods";
                                break;
                            case Document.DownloadType.tsv:
                                queryUri += "tsv&gid=" + sheetNumber.ToString(); ;
                                break;
                            case Document.DownloadType.html:
                                queryUri += "html";
                                break;
                            default:
                                throw new ArgumentException("type is invalid for a spreadsheet");
                        }
                        break;

                    case Document.DocumentType.Presentation:
                        switch (type)
                        {
                            case Document.DownloadType.swf:
                                queryUri += "swf";
                                break;
                            case Document.DownloadType.pdf:
                                queryUri += "pdf";
                                break;
                            case Document.DownloadType.ppt:
                                queryUri += "ppt";
                                break;
                            default:
                                throw new ArgumentException("type is invalid for a presentation");
                        }
                        break;

                    case Document.DocumentType.Unknown:
                        break;

                    default:
                        queryUri += type.ToString();
                        break;
                }

                Uri target = new Uri(queryUri);
                return s.Query(target);
            }
Esempio n. 6
0
            public Stream Download(ITaskItem document, string exportFormat)
            {
                Document.DocumentType documentType = document.RequireDocumentType();

                string baseUrl = document.RequireExportUri();
                if (!string.IsNullOrEmpty(exportFormat))
                {
                    baseUrl = this.BuildDocumentPartialExportUrl(baseUrl) + exportFormat;
                }
                Uri queryUri = new Uri(baseUrl);
                return base.Service.Query(queryUri);
            }