/// <summary> /// Export a report using current instance of ListLabel and upload it directly to the Google Drive Cloud Storage. /// </summary> /// <param name="ll">current instance of List & Label</param> /// <param name="exportConfiguration">required export configuration for native ListLabel Export method</param> /// <param name="exportParameters">requied parameters for Google Drive OAuth 2.0 upload.</param> /// <param name="clientSecretFilePath">The full path of client secret file.</param> public static void Export(this Reporting.ListLabel ll, ExportConfiguration exportConfiguration, GoogleDriveExportParameter exportParameters, string clientSecretFilePath) { ll.AutoShowSelectFile = false; ll.AutoShowPrintOptions = false; ll.AutoDestination = LlPrintMode.Export; ll.AutoProjectType = LlProject.List; ll.AutoBoxType = LlBoxType.None; exportConfiguration.ExportOptions.Add("Export.Quiet", "1"); string mimeType = string.Empty; switch (exportConfiguration.ExportTarget) { case LlExportTarget.Pdf: exportParameters.CloudFileName += ".pdf"; mimeType = "application/pdf"; break; case LlExportTarget.Rtf: exportParameters.CloudFileName += ".rtf"; mimeType = "application/rtf"; break; case LlExportTarget.Xls: exportParameters.CloudFileName += ".xls"; mimeType = "application/vnd.ms-excel"; break; case LlExportTarget.Xlsx: exportParameters.CloudFileName += ".xlsx"; mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break; case LlExportTarget.Docx: exportParameters.CloudFileName += ".docx"; mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break; case LlExportTarget.Xps: exportParameters.CloudFileName += ".xps"; mimeType = "application/vnd.ms-xpsdocument"; break; case LlExportTarget.Mhtml: exportParameters.CloudFileName += ".mhtml"; mimeType = "message/rfc822"; break; case LlExportTarget.Text: exportParameters.CloudFileName += ".txt"; mimeType = "text/plain"; break; case LlExportTarget.Pptx: exportParameters.CloudFileName += ".pptx"; mimeType = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; break; default: exportParameters.CloudFileName += ".zip"; mimeType = "application/zip"; exportConfiguration.ExportOptions.Add(LlExportOption.ExportSaveAsZip, "1"); exportConfiguration.ExportOptions.Add(LlExportOption.ExportZipFile, exportParameters.CloudFileName); exportConfiguration.ExportOptions.Add(LlExportOption.ExportZipPath, Path.GetDirectoryName(exportConfiguration.Path)); break; } ll.Export(exportConfiguration); FileStream stream = System.IO.File.Open(string.Concat(Path.GetDirectoryName(exportConfiguration.Path), "\\", exportParameters.CloudFileName), FileMode.Open); Upload(ll, new GoogleDriveUploadParameter() { UploadStream = stream, CloudFileName = exportParameters.CloudFileName, CloudPath = exportParameters.CloudPath, ApplicationName = exportParameters.ApplicationName, MimeType = mimeType }, clientSecretFilePath); }
/// <summary> /// Export a report using current instance of ListLabel and upload it directly to the Dropbox Cloud Storage. /// </summary> /// <param name="ll">current instance of List & Label</param> /// <param name="exportConfiguration">required export configuration for native ListLabel Export method</param> /// <param name="exportParameters">requied parameters to uplaod exported report to Dropbox.</param> /// <param name="appkey">AppKey of your Dropbox App.</param> public static void Export(this Reporting.ListLabel ll, ExportConfiguration exportConfiguration, DropboxExportParameter exportParameters, string appKey) { ll.AutoShowSelectFile = false; ll.AutoShowPrintOptions = false; ll.AutoDestination = LlPrintMode.Export; ll.AutoProjectType = LlProject.List; ll.AutoBoxType = LlBoxType.None; exportConfiguration.ExportOptions.Add("Export.Quiet", "1"); switch (exportConfiguration.ExportTarget) { case LlExportTarget.Pdf: exportParameters.CloudFileName += ".pdf"; break; case LlExportTarget.Rtf: exportParameters.CloudFileName += ".rtf"; break; case LlExportTarget.Xls: exportParameters.CloudFileName += ".xls"; break; case LlExportTarget.Xlsx: exportParameters.CloudFileName += ".xlsx"; break; case LlExportTarget.Docx: exportParameters.CloudFileName += ".docx"; break; case LlExportTarget.Xps: exportParameters.CloudFileName += ".xps"; break; case LlExportTarget.Mhtml: exportParameters.CloudFileName += ".mhtml"; break; case LlExportTarget.Text: exportParameters.CloudFileName += ".txt"; break; case LlExportTarget.Pptx: exportParameters.CloudFileName += ".pptx"; break; default: exportParameters.CloudFileName += ".zip"; exportConfiguration.ExportOptions.Add(LlExportOption.ExportSaveAsZip, "1"); exportConfiguration.ExportOptions.Add(LlExportOption.ExportZipFile, exportParameters.CloudFileName); exportConfiguration.ExportOptions.Add(LlExportOption.ExportZipPath, Path.GetDirectoryName(exportConfiguration.Path)); break; } ll.Export(exportConfiguration); FileStream stream = System.IO.File.Open(string.Concat(Path.GetDirectoryName(exportConfiguration.Path), "\\", exportParameters.CloudFileName), FileMode.Open); Upload(ll, new DropboxUploadParameter() { UploadStream = stream, CloudFileName = exportParameters.CloudFileName, CloudPath = exportParameters.CloudPath }, appKey); }