Esempio n. 1
0
        /// <summary>
        /// ...
        /// </summary>
        private string ConvertDownloadTypeToFileExtension(Document.DownloadType dt)
        {
            switch (dt)
            {
            case (Document.DownloadType.doc): return("docx");

            case (Document.DownloadType.xls): return("xlsx");

            case (Document.DownloadType.ppt): return("pptx");

            default: return(dt.ToString());
            }
        }
Esempio n. 2
0
        private void DoDocumentDownload(Request documentsRequest, ITaskItem document, string targetFile)
        {
            Document.DownloadType downloadType = Document.DownloadType.html;
            if (!Enum.TryParse <Document.DownloadType>(ExportFormat, out downloadType))
            {
                downloadType = Document.DownloadType.html;
            }

            switch (downloadType)
            {
            case Document.DownloadType.html:
                DoDocumentHtmlDownload(documentsRequest, document, targetFile);
                break;

            default:
                throw new NotImplementedException(string.Format("Download Type '{0}' is unsupported for Documents", downloadType));
            }
        }
Esempio n. 3
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. 4
0
        private void Export_Click(object sender, EventArgs e)
        {
            TreeNode node = this.documentsView.SelectedNode;

            if (node == null)
            {
                return;
            }

            Document d = node.Tag as Document;

            // fill the filter based on the document type
            switch (d.Type)
            {
            case Document.DocumentType.Presentation:
                this.exportDialog.Filter = "PDF|*.pdf|Flash|*.swf|Powerpoint|*.ppt";
                break;

            case Document.DocumentType.Spreadsheet:
                this.exportDialog.Filter = "PDF|*.pdf|HTML|*.html|Excel|*.xls|Comma seperated|*.csv|Open Document Spreadsheet|*.ods|Tab seperated|*.tsv";
                break;

            case Document.DocumentType.PDF:
                return;

            default:
                this.exportDialog.Filter = "PDF|*.pdf|HTML|*.html|Text|*.txt|Open Document|*.ods|Rich Text|*.rtf|Microsoft Word|*.doc|Portable Networks Graphics|*.png";
                break;
            }



            if (this.exportDialog.ShowDialog() == DialogResult.OK)
            {
                Document.DownloadType type = Document.DownloadType.pdf;

                switch (d.Type)
                {
                case Document.DocumentType.Presentation:
                    switch (this.exportDialog.FilterIndex)
                    {
                    case 2:
                        type = Document.DownloadType.swf;
                        break;

                    case 3:
                        type = Document.DownloadType.ppt;
                        break;
                    }
                    break;

                case Document.DocumentType.Spreadsheet:
                    switch (this.exportDialog.FilterIndex)
                    {
                    case 2:
                        type = Document.DownloadType.html;
                        break;

                    case 3:
                        type = Document.DownloadType.xls;
                        break;

                    case 4:
                        type = Document.DownloadType.csv;
                        break;

                    case 5:
                        type = Document.DownloadType.ods;
                        break;

                    case 6:
                        type = Document.DownloadType.tsv;
                        break;
                    }
                    break;

                default:
                    switch (this.exportDialog.FilterIndex)
                    {
                    case 2:
                        type = Document.DownloadType.html;
                        break;

                    case 3:
                        type = Document.DownloadType.txt;
                        break;

                    case 4:
                        type = Document.DownloadType.ods;
                        break;

                    case 5:
                        type = Document.DownloadType.rtf;
                        break;

                    case 6:
                        type = Document.DownloadType.doc;
                        break;

                    case 7:
                        type = Document.DownloadType.png;
                        break;
                    }
                    break;
                }

                Stream stream = this.request.Download(d, type);

                Stream file = this.exportDialog.OpenFile();

                if (file != null)
                {
                    int    nBytes = 2048;
                    int    count  = 0;
                    Byte[] arr    = new Byte[nBytes];

                    do
                    {
                        count = stream.Read(arr, 0, nBytes);
                        file.Write(arr, 0, count);
                    } while (count > 0);
                    file.Flush();
                    file.Close();
                }
                stream.Close();
            }
        }
        /// <summary>
        /// downloads a document.
        /// </summary>
        /// <param name="document">The document to download. It needs to have the document type set, as well as the id link</param>
        /// <param name="type">The output format of the document you want to download</param>
        /// <param name="sheetNumber">When requesting a CSV or TSV file you must specify an additional parameter called
        /// gid which indicates which grid, or sheet, you wish to get (the index is 0 based, so gid 1
        /// actually refers to the second sheet sheet on a given spreadsheet). </param>
        /// <param name="baseDomain">if null, default is used. Otherwise needs to specify the domain to download from, ending with a slash</param>
        /// <returns></returns>
        public Stream Download(Document document, Document.DownloadType type, string baseDomain, int sheetNumber)
        {
            if (document.Type == Document.DocumentType.Unknown)
            {
                throw new ArgumentException("Document has an unknown type");
            }

            if (document.Type == Document.DocumentType.Folder)
            {
                throw new ArgumentException("Document is a folder, can not be downloaded");
            }

            // now figure out the parameters
            string queryUri = "";

            Service s = this.Service;

            switch (document.Type)
            {
            case Document.DocumentType.Spreadsheet:
                // spreadsheet has a different parameter
                if (baseDomain == null)
                {
                    baseDomain = "http://spreadsheets.google.com/";
                }
                queryUri = baseDomain + "feeds/download/spreadsheets/Export?key=" + document.ResourceId + "&exportFormat=";
                s        = this.spreadsheetsService;
                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:
                if (baseDomain == null)
                {
                    baseDomain = "http://docs.google.com/";
                }

                queryUri = baseDomain + "feeds/download/presentations/Export?docID=" + document.ResourceId + "&exportFormat=";
                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;

            default:
                if (baseDomain == null)
                {
                    baseDomain = "http://docs.google.com/";
                }

                queryUri = baseDomain + "feeds/download/documents/Export?docID=" + document.ResourceId + "&exportFormat=" + type.ToString();
                break;
            }

            Uri target = new Uri(queryUri);

            return(s.Query(target));
        }
 /// <summary>
 /// downloads a document.
 /// </summary>
 /// <param name="document">The document to download. It needs to have the document type set, as well as the id link</param>
 /// <param name="type">The output format of the document you want to download</param>
 /// <returns></returns>
 public Stream Download(Document document, Document.DownloadType type)
 {
     return(this.Download(document, type, null, 0));
 }
Esempio n. 7
0
        /// <summary>
        /// Exec backup (internal)
        /// </summary>
        private int ExecBackupSingleUser(string username)
        {
            DoFeedback(new string('-', 80));
            DoFeedback("--- ExecBackupSingleUser - username="******" ---");
            DoFeedback(new string('-', 80));

            _lastException      = null;
            _duplicatedDocNames = new List <string>();

            // Setup credentials and connection
            DoFeedback("Setup connection & get doc list");
            RequestSettings settings;

            if (_config.appsMode == false)
            {
                GDataCredentials credentials = new GDataCredentials(_config.userName, _config.password);
                settings            = new RequestSettings("GDocBackup", credentials);
                settings.AutoPaging = true;
                settings.PageSize   = 100;
            }
            else
            {
                settings            = new RequestSettings("GDocBackup", _config.appsDomain, _config.appsOAuthSecret, username, _config.appsDomain);
                settings.AutoPaging = true;
                settings.PageSize   = 100;
                //settings.Maximum = 10000;
            }

            DocumentsRequest request = new DocumentsRequest(settings);

            if (_config.iwebproxy != null)
            {
                request.Proxy = _config.iwebproxy;
            }


            // Get doc list from GDocs
            Feed <Document> feed = request.GetEverything();
            List <Document> docs = new List <Document>();

            foreach (Document entry in feed.Entries)
            {
                docs.Add(entry);
            }


            // Search for duplicated doc names in the same folder
            _duplicatedDocNames = this.FindDuplicatedNames(docs);
            DoFeedback("Duplicated Doc Names [" + _duplicatedDocNames.Count + "]");
            _duplicatedDocNames.ForEach(delegate(string s) { DoFeedback(" - " + s); });


            // Builds/updates local folder structure
            if (_config.appsMode)
            {
                this.BuildFolders(null, docs, Path.Combine(_config.outDir, username));
            }
            else
            {
                this.BuildFolders(null, docs, _config.outDir);
            }
            foreach (String k in _folderDict.Keys)
            {
                DoFeedbackDebug("FolderDict: " + k + " --> " + _folderDict[k]);
            }
            this.DumpAllDocInfo(docs);

            // Main Docs loop!
            int errorCount = 0;

            for (int i = 0; i < docs.Count; i++)
            {
                Document doc = docs[i];
                DoFeedback("ITEM: " + doc.Title + " (" + doc.Type + ") [" + (i + 1).ToString() + "/" + docs.Count + "]", ((double)i) / docs.Count);

                Document.DownloadType[] downloadTypes = null;
                switch (doc.Type)
                {
                case Document.DocumentType.Document:
                    downloadTypes = _config.docExpType;
                    break;

                case Document.DocumentType.Presentation:
                    downloadTypes = _config.presExpType;
                    break;

                case Document.DocumentType.Spreadsheet:
                    downloadTypes = _config.sprdExpType;
                    break;

                case Document.DocumentType.PDF:
                    downloadTypes = new Document.DownloadType[] { Document.DownloadType.pdf };
                    break;

                case Document.DocumentType.Drawing:
                    downloadTypes = _config.drawExpType;
                    break;

                case Document.DocumentType.Unknown:
                    downloadTypes = new Document.DownloadType[] { Document.DownloadType.zip };      // download format not used! It's only a "place-holder".
                    break;

                default:
                    break;
                }


                if (downloadTypes != null)
                {
                    int maxTentativi = 2;
                    for (int tentativi = 0; tentativi < maxTentativi; tentativi++)
                    {
                        try
                        {
                            // * WorkAround for drawing *
                            // Detect if drawing and then force downloadtype to pdf
                            //bool isDrawing = doc.ResourceId.StartsWith("drawing:");   // drawing:14TBycKwlpXJ25N......
                            //if (isDrawing)
                            //    downloadTypes = new Document.DownloadType[] { Document.DownloadType.pdf };
                            // bool isDrawing = false;

                            foreach (Document.DownloadType downloadtype in downloadTypes)
                            {
                                // Build local file path
                                string outFolderPath;
                                if (doc.ParentFolders.Count == 0)
                                {
                                    outFolderPath = _config.appsMode ? Path.Combine(_config.outDir, username) : _config.outDir;
                                }
                                else
                                {
                                    DoFeedback("Try to get folder from dict using key=[" + doc.ParentFolders[0] + "]");
                                    outFolderPath = _folderDict[doc.ParentFolders[0]];
                                }
                                string outFileFP =
                                    (doc.Type == Document.DocumentType.Unknown) ?
                                    Path.Combine(outFolderPath, this.RemoveInvalidChars(doc.Title, true)) :
                                    Path.Combine(outFolderPath, this.RemoveInvalidChars(doc.Title, false) + "." + ConvertDownloadTypeToFileExtension(downloadtype));

                                // Get current local file in infos
                                FileInfo fi = new FileInfo(outFileFP);
                                DateTime locFileDateTime  = fi.LastWriteTime;
                                DateTime gdocFileDateTime = doc.Updated;

                                // Mono and/or Ubuntu (...linux) does not support milliseconds info when saving DataTime to FileInfo.LastWriteTime. So... I remove it!   :)
                                locFileDateTime  = this.RemoveMilliseconds(locFileDateTime);
                                gdocFileDateTime = this.RemoveMilliseconds(gdocFileDateTime);

                                bool downloadDoc = (!fi.Exists || _config.downloadAll);

                                if (_config.dateDiff.HasValue)
                                {
                                    if (Math.Abs(locFileDateTime.Subtract(gdocFileDateTime).TotalSeconds) > _config.dateDiff.Value)
                                    {
                                        downloadDoc = true;
                                    }
                                }
                                else
                                {
                                    if (locFileDateTime != gdocFileDateTime)
                                    {
                                        downloadDoc = true;
                                    }
                                }


                                if (downloadDoc)
                                {
                                    DoFeedback("Start exporting " + doc.Title + "(Type=" + doc.Type + ") --> " + downloadtype.ToString());
                                    Stream gdocStream = null;
                                    try
                                    {
                                        if (doc.Type == Document.DocumentType.Unknown)
                                        {
                                            String downloadUrl = doc.DocumentEntry.Content.Src.ToString();
                                            Uri    downloadUri = new Uri(downloadUrl);
                                            if (_config.appsMode)
                                            {
                                                // add xoauth_requestor_id to the doc url if not present
                                                if (!downloadUrl.Contains("xoauth_requestor_id="))
                                                {
                                                    downloadUri = new Uri(downloadUrl + "&xoauth_requestor_id=" + this.BuildDomainUserFullName(username));
                                                }
                                            }
                                            gdocStream = request.Service.Query(downloadUri);
                                        }
                                        else if (doc.Type == Document.DocumentType.Document)
                                        {
                                            gdocStream = request.Download(doc, downloadtype.ToString());
                                        }
                                        else if (doc.Type == Document.DocumentType.Spreadsheet)
                                        {
                                            gdocStream = request.Download(doc, downloadtype.ToString());   // WAS: downloadtype.ToString());
                                        }
                                        else if (doc.Type == Document.DocumentType.Presentation)
                                        {
                                            gdocStream = request.Download(doc, downloadtype.ToString());
                                        }
                                        else if (doc.Type == Document.DocumentType.Drawing)
                                        {
                                            gdocStream = request.Download(doc, downloadtype.ToString());
                                        }
                                        else if (doc.Type != Document.DocumentType.PDF)
                                        {
                                            // *** ??? ***
                                            gdocStream = request.Download(doc, downloadtype);
                                        }
                                        else
                                        {
                                            // *** PDF ***
                                            if (_config.appsMode)
                                            {
                                                // add xoauth_requestor_id to the doc url if not present
                                                string url = doc.DocumentEntry.Content.Src.ToString();
                                                if (!url.Contains("xoauth_requestor_id="))
                                                {
                                                    doc.DocumentEntry.Content.Src = new AtomUri(url + "&xoauth_requestor_id=" + this.BuildDomainUserFullName(username));
                                                }
                                            }
                                            gdocStream = request.Download(doc, null);
                                        }

                                        using (FileStream outFile = new FileStream(outFileFP, FileMode.Create, FileAccess.Write))
                                        {
                                            byte[] buffer = new byte[8192];
                                            int    bytesRead;
                                            while ((bytesRead = gdocStream.Read(buffer, 0, buffer.Length)) > 0)
                                            {
                                                outFile.Write(buffer, 0, bytesRead);
                                            }
                                            outFile.Close();
                                        }
                                        gdocStream.Close();
                                    }
                                    finally
                                    {
                                        if (gdocStream != null)
                                        {
                                            gdocStream.Dispose();
                                        }
                                    }

                                    new FileInfo(outFileFP).LastWriteTime = doc.Updated;
                                    DoFeedback("End exporting " + doc.Title + "(Type=" + doc.Type + ") --> " + downloadtype.ToString());

                                    // ------------------------------------------------------------------------------------------------------------------------
                                    // Workaround for Issue 100 - http://code.google.com/p/gdocbackup/issues/detail?id=100
                                    if (doc.Type == Document.DocumentType.Presentation)
                                    {
                                        bool isPPTX = false;

                                        using (FileStream presentationFile = new FileStream(outFileFP, FileMode.Open, FileAccess.Read))
                                        {
                                            int byte1 = presentationFile.ReadByte();
                                            int byte2 = presentationFile.ReadByte();
                                            isPPTX = (byte1 == 80 && byte2 == 75);   // 80 75 = "PK" (pptx is a zip. Every zip starts with "PK"
                                            presentationFile.Close();
                                        }

                                        if (!isPPTX)
                                        {
                                            string newName = outFileFP.Remove(outFileFP.Length - 1);
                                            File.Delete(newName);
                                            File.Move(outFileFP, newName);
                                            DoFeedback("Presentation API bug: renaming output file [" + newName + "]");
                                        }
                                    }
                                    // ------------------------------------------------------------------------------------------------------------------------
                                }
                                else
                                {
                                    DoFeedback("Skipped doc: " + doc.Title);
                                }

                                // Send Feedback
                                DoFeedback(new FeedbackObject(
                                               (_config.appsMode ? username + "#" + doc.Title : doc.Title),
                                               doc.Type.ToString(),
                                               (doc.Type == Document.DocumentType.Unknown) ? "BIN" : downloadtype.ToString(),
                                               downloadDoc ? "BCKUP" : "SKIP",
                                               "", locFileDateTime, gdocFileDateTime));

                                tentativi = maxTentativi;
                            }
                        }
                        catch (Exception ex)
                        {
                            if (tentativi == maxTentativi - 1)
                            {
                                errorCount++;
                                DoFeedback("DOC-ERROR: " + ex.ToString());
                                DoFeedback(new FeedbackObject(
                                               (_config.appsMode ? username + "#" + doc.Title : doc.Title),
                                               doc.Type.ToString(),
                                               "", "ERROR", "", null, null));
                            }
                            else
                            {
                                DoFeedback("DOC-ERROR: (attempt " + tentativi + ") " + ex.ToString());
                            }
                        }
                    }
                }
                else
                {
                    if (doc.Type != Document.DocumentType.Folder)
                    {
                        DoFeedback(new FeedbackObject(doc.Title, doc.Type.ToString(), "", "NONE", "", null, null));
                    }
                }
            }

            return(errorCount);
        }
Esempio n. 8
0
        /*
         * public static Stream GetDocUri_NON_FUNZIONA(DocumentsRequest request, Document doc, Document.DownloadType type)
         * {
         *  // NON FUNZIONA (porca putt...!)
         *  string docID = doc.ResourceId.Replace("document:", "");
         *  string uriS = "http://docs.google.com/feeds/download/documents/Export?" +
         *      "docID=" + docID +
         *      "&exportFormat=" + type.ToString();
         *  Uri target = new Uri(uriS);
         *  return request.Service.Query(target);
         * }
         */

        public static Stream GetDocExportStream(DocumentsRequest request, Document doc, Document.DownloadType downloadtype)
        {
            // Questa funziona ma mi pare na stronz...
            string format = downloadtype.ToString();
            string url    =
                doc.DocumentEntry.Content.AbsoluteUri +
                "&exportFormat=" + format + "&format=" + format;

            return(request.Service.Query(new Uri(url)));
        }
Esempio n. 9
0
        /// <summary>
        /// Setup and preload of many controls
        /// </summary>
        private void SetupControls()
        {
            panelSingleExport.Location = new Point(0, 0);
            panelMultiExport.Location  = new Point(0, 0);

            comboProxyAuthType.Items.Add(ProxyAuthMode.NotAuthenticated);
            comboProxyAuthType.Items.Add(ProxyAuthMode.DefaultCredential);
            comboProxyAuthType.Items.Add(ProxyAuthMode.UsernamePassword);

            comboProxyHostSource.Items.Add(ProxyHostPortSource.Default);
            comboProxyHostSource.Items.Add(ProxyHostPortSource.HostPort);


            Document.DownloadType[] docsDownTypes = new Document.DownloadType[] {
                Document.DownloadType.doc,
                Document.DownloadType.odt,
                Document.DownloadType.rtf,
                Document.DownloadType.txt,
                Document.DownloadType.pdf,
            };

            Document.DownloadType[] sprsDownType = new Document.DownloadType[] {
                Document.DownloadType.xls,
                Document.DownloadType.csv,
                Document.DownloadType.ods,
                Document.DownloadType.tsv,
                Document.DownloadType.pdf,
            };

            Document.DownloadType[] presDownType = new Document.DownloadType[] {
                Document.DownloadType.ppt,
                Document.DownloadType.pdf,
                //Document.DownloadType.swf,
                Document.DownloadType.txt
            };

            Document.DownloadType[] drawDownType = new Document.DownloadType[] {
                Document.DownloadType.pdf,
                Document.DownloadType.svg,
                Document.DownloadType.jpeg,
                Document.DownloadType.png
            };

            for (int i = 0; i < docsDownTypes.Length; i++)
            {
                cbDocFormat.Items.Add(docsDownTypes[i]);
            }
            for (int i = 0; i < sprsDownType.Length; i++)
            {
                cbSprShFormat.Items.Add(sprsDownType[i]);
            }
            for (int i = 0; i < presDownType.Length; i++)
            {
                cbPresFormat.Items.Add(presDownType[i]);
            }
            for (int i = 0; i < drawDownType.Length; i++)
            {
                cbDrawFormat.Items.Add(drawDownType[i]);
            }

            for (int i = 0; i < docsDownTypes.Length; i++)
            {
                clbDocFormat.Items.Add(docsDownTypes[i]);
            }
            for (int i = 0; i < sprsDownType.Length; i++)
            {
                clbSprShFormat.Items.Add(sprsDownType[i]);
            }
            for (int i = 0; i < presDownType.Length; i++)
            {
                clbPresFormat.Items.Add(presDownType[i]);
            }
            for (int i = 0; i < drawDownType.Length; i++)
            {
                clbDrawFormat.Items.Add(drawDownType[i]);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// downloads a document.
        /// </summary>
        /// <param name="document">The document to download. It needs to have the document type set, as well as the id link</param>
        /// <param name="type">The output format of the document you want to download</param>
        /// <param name="sheetNumber">When requesting a CSV or TSV file you must specify an additional parameter called
        /// gid which indicates which grid, or sheet, you wish to get (the index is 0-based, so gid 1
        /// actually refers to the second sheet sheet on a given spreadsheet). </param>
        /// <param name="baseDomain">OBSOLETE - if null, default is used. Otherwise needs to specify the domain to download from, ending with a slash</param>
        /// <returns></returns>
        public Stream Download(Document document, Document.DownloadType type, string baseDomain, int sheetNumber)
        {
            if (document.Type == Document.DocumentType.Folder)
            {
                throw new ArgumentException("Document is a folder, can not be downloaded");
            }

            Service s        = this.Service;
            string  queryUri = this.BuildDocumentPartialExportUrl(document.DocumentEntry.Content.Src.ToString());

            switch (document.Type)
            {
            case Document.DocumentType.Spreadsheet:
                s = this.spreadsheetsService;
                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. 11
0
        /// <summary>
        /// Setup and preload of many controls
        /// </summary>
        private void SetupControls()
        {
            panelSingleExport.Location = new Point(0, 0);
            panelMultiExport.Location = new Point(0, 0);

            comboProxyAuthType.Items.Add(ProxyAuthMode.NotAuthenticated);
            comboProxyAuthType.Items.Add(ProxyAuthMode.DefaultCredential);
            comboProxyAuthType.Items.Add(ProxyAuthMode.UsernamePassword);

            comboProxyHostSource.Items.Add(ProxyHostPortSource.Default);
            comboProxyHostSource.Items.Add(ProxyHostPortSource.HostPort);

            Document.DownloadType[] docsDownTypes = new Document.DownloadType[] {
                Document.DownloadType.doc,
                Document.DownloadType.odt,
                Document.DownloadType.rtf,
                Document.DownloadType.txt,
                Document.DownloadType.pdf,
            };

            Document.DownloadType[] sprsDownType = new Document.DownloadType[]{
                Document.DownloadType.xls,
                Document.DownloadType.csv,
                Document.DownloadType.ods,
                Document.DownloadType.tsv,
                Document.DownloadType.pdf,
            };

            Document.DownloadType[] presDownType = new Document.DownloadType[]{
                Document.DownloadType.ppt,
                Document.DownloadType.pdf,
                //Document.DownloadType.swf,
                Document.DownloadType.txt
            };

            Document.DownloadType[] drawDownType = new Document.DownloadType[]{
                Document.DownloadType.pdf,
                Document.DownloadType.svg,
                Document.DownloadType.jpeg,
                Document.DownloadType.png
            };

            for (int i = 0; i < docsDownTypes.Length; i++) cbDocFormat.Items.Add(docsDownTypes[i]);
            for (int i = 0; i < sprsDownType.Length; i++) cbSprShFormat.Items.Add(sprsDownType[i]);
            for (int i = 0; i < presDownType.Length; i++) cbPresFormat.Items.Add(presDownType[i]);
            for (int i = 0; i < drawDownType.Length; i++) cbDrawFormat.Items.Add(drawDownType[i]);

            for (int i = 0; i < docsDownTypes.Length; i++) clbDocFormat.Items.Add(docsDownTypes[i]);
            for (int i = 0; i < sprsDownType.Length; i++) clbSprShFormat.Items.Add(sprsDownType[i]);
            for (int i = 0; i < presDownType.Length; i++) clbPresFormat.Items.Add(presDownType[i]);
            for (int i = 0; i < drawDownType.Length; i++) clbDrawFormat.Items.Add(drawDownType[i]);
        }