示例#1
0
		public AttachmentSummary(EnumValueInfo category, StaffSummary attachedBy, DateTime attachedTime, AttachedDocumentSummary document)
		{
			this.Category = category;
			this.AttachedBy = attachedBy;
			this.AttachedTime = attachedTime;
			this.Document = document;
		}
示例#2
0
		public AttachedDocumentSummary CreateAttachedDocumentSummary(AttachedDocument doc)
		{
			var summary = new AttachedDocumentSummary();

			UpdateAttachedDocumentSummary(doc, summary);

			return summary;
		}
示例#3
0
		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;
		}
示例#4
0
		/// <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,
			                                                        fn => ftpFileTransfer.Download(new FileTransferRequest(fullUrl, fn)),
			                                                        TimeSpan.FromSeconds(AttachedDocumentSettings.Default.DownloadCacheTimeToLive));

			return localFilePath;
		}
示例#5
0
 public AttachmentSummary(EnumValueInfo category, StaffSummary attachedBy, DateTime attachedTime, AttachedDocumentSummary document)
 {
     this.Category     = category;
     this.AttachedBy   = attachedBy;
     this.AttachedTime = attachedTime;
     this.Document     = document;
 }