public void AddAttachment(AttachedDocumentSummary document, EnumValueInfo category) { var attachment = new AttachmentSummary(category, null, Platform.Time, document); this.AttachmentTable.Items.Add(attachment); this.Modified = true; }
/// <summary> /// Downloads a document at a specified relativeUrl to a temporary file. /// </summary> /// <param name="documentSummary"></param> /// <returns>The location of the downloaded file.</returns> public static string DownloadFile(AttachedDocumentSummary documentSummary) { Platform.CheckForNullReference(documentSummary, "documentSummary"); // if already cached locally, return local file name var tempFile = TempFileManager.Instance.GetFile(documentSummary.DocumentRef); if (!string.IsNullOrEmpty(tempFile)) { return(tempFile); } var ftpFileTransfer = new FtpFileTransfer( AttachedDocumentSettings.Default.FtpUserId, AttachedDocumentSettings.Default.FtpPassword, AttachedDocumentSettings.Default.FtpBaseUrl, AttachedDocumentSettings.Default.FtpPassiveMode); var fullUrl = new Uri(ftpFileTransfer.BaseUri, documentSummary.ContentUrl); var fileExtension = Path.GetExtension(fullUrl.LocalPath).Trim('.'); var localFilePath = TempFileManager.Instance.CreateFile(documentSummary.DocumentRef, fileExtension, TimeSpan.FromSeconds(AttachedDocumentSettings.Default.DownloadCacheTimeToLive)); ftpFileTransfer.Download(new FileTransferRequest(fullUrl, localFilePath)); return(localFilePath); }
public AttachedDocumentSummary CreateAttachedDocumentSummary(AttachedDocument doc) { var summary = new AttachedDocumentSummary(); UpdateAttachedDocumentSummary(doc, summary); return(summary); }
public void UpdateAttachedDocumentSummary(AttachedDocument doc, AttachedDocumentSummary summary) { summary.DocumentRef = doc.GetRef(); summary.CreationTime = doc.CreationTime; summary.ReceivedTime = doc.DocumentReceivedTime; summary.MimeType = doc.MimeType; summary.ContentUrl = doc.ContentUrl; summary.FileExtension = doc.FileExtension; summary.DocumentHeaders = new Dictionary <string, string>(doc.DocumentHeaders); summary.DocumentTypeName = doc.DocumentTypeName; }
private AttachedDocumentSummary UploadFile() { AttachedDocumentSummary result = null; var data = File.ReadAllBytes(this.FilePath); Platform.GetService <IDocumentsService>(service => { var response = service.Upload(new UploadRequest("pdf", "pdf", data)); result = response.Document; }); return(result); }
public void AddAttachment(AttachedDocumentSummary document, EnumValueInfo category) { _component.AddAttachment(document, category); }
public UploadResponse(AttachedDocumentSummary document) { Document = document; }