private AttachmentInfo CreateAttachmentInfo(string data) { AttachmentMetadata attachmentMetadata = new AttachmentMetadata("filename"); Stream stream = new MemoryStream(Encoding.UTF8.GetBytes(data)); return(new AttachmentInfo(attachmentMetadata, stream)); }
public AggregateReportInfo(Dmarc.AggregateReport aggregateReport, EmailMetadata emailMetadata, AttachmentMetadata attachmentMetadata) { AggregateReport = aggregateReport; EmailMetadata = emailMetadata; AttachmentMetadata = attachmentMetadata; }
public ContentThumbnailFileWriter(AttachmentMetadata attMeta, long syncId) { if (attMeta == null) { throw new NullReferenceException("Parameter attMeta is null"); } _syncId = syncId; _meta = attMeta; }
private AggregateReportInfo CreateAggregateReportInfo() { Dmarc.AggregateReport.Parser.Lambda.Domain.Dmarc.AggregateReport aggregateReport = new Dmarc.AggregateReport.Parser.Lambda.Domain.Dmarc.AggregateReport { Records = new Record[0] }; EmailMetadata emailMetadata = new EmailMetadata("", "", 1); AttachmentMetadata attachmentMetadata = new AttachmentMetadata(""); return(new AggregateReportInfo(aggregateReport, emailMetadata, attachmentMetadata)); }
/// <summary> /// Creates a new attachment in the entity package with the specified file name. /// </summary> /// <param name="fileName"></param> /// <param name="category"></param> /// <param name="path"></param> /// <param name="attachmentData"></param> /// <returns></returns> public Attachment CreateAttachment(string fileName, string category, string path, Stream attachmentData) { var metadata = new AttachmentMetadata { Category = category, Created = DateTime.Now, CreatedBy = User.GetCurrentUser().LoginName, Etag = Etag.Empty, FileName = fileName, Modified = DateTime.Now, ModifiedBy = User.GetCurrentUser().LoginName, Path = path, Properties = new Dictionary <string, string>(), Size = attachmentData.Length, TimeLastModified = DateTime.Now, Url = "", }; return(CreateAttachment(fileName, metadata, attachmentData)); }
private static AggregateReportInfo Create(string requestId = "RequestId", string orginalUri = "OriginalUri", string emailFilename = "EmailFilename", long filesize = 1, string attachmentFilename = "AttachmentFilename") { AggregateReportDomain aggregateReport = new AggregateReportDomain { ReportMetadata = new ReportMetadata { Range = new DateRange() }, PolicyPublished = new PolicyPublished(), Records = new[] { new Record { Row = new Row { PolicyEvaluated = new PolicyEvaluated { Reasons = new [] { new PolicyOverrideReason(), } } }, Identifiers = new Identifier(), AuthResults = new AuthResult { Dkim = new [] { new DkimAuthResult() }, Spf = new [] { new SpfAuthResult() } } } } }; EmailMetadata emailMetadata = new EmailMetadata(requestId, string.Empty, orginalUri, emailFilename, filesize); AttachmentMetadata attachmentMetadata = new AttachmentMetadata(attachmentFilename); return(new AggregateReportInfo(aggregateReport, emailMetadata, attachmentMetadata)); }
protected bool Equals(AttachmentMetadata other) { return(string.Equals(Filename, other.Filename)); }
internal AttachmentBody(SmartStore store, AttachmentMetadata attMetadata) : base(store) { _attMetadata = attMetadata; AttachmentId = attMetadata.Id; }
private Attachment CreateAttachment(string fileName, AttachmentMetadata attachment, Stream attachmentData) { if (fileName.IsNullOrWhiteSpace()) { throw new ArgumentNullException("fileName"); } if (attachment == null) { throw new ArgumentNullException("attachment"); } var defaultEntityPart = GetDefaultEntityPartPackagePart(); var attachmentRelationships = defaultEntityPart.GetRelationshipsByType(Data.Constants.AttachmentRelationship); var attachmentUri = GetAttachmentUriFromAttachmentFileName(fileName); var attachmentMetadataUri = GetAttachmentMetadataUriFromAttachmentFileName(fileName); var existingAttachmentRelationship = attachmentRelationships.FirstOrDefault(ar => ar.TargetUri == attachmentUri); if (existingAttachmentRelationship != null) { throw new InvalidOperationException("An attachment with the specified name already exists in the package: " + fileName); } var attachmentPackagePart = m_package.CreatePart(attachmentUri, StringHelper.GetMimeTypeFromFileName(fileName)); if (attachmentData != null) { attachmentData.CopyTo(attachmentPackagePart.GetStream()); } //Create a relationship between the default entity part and the attachment part. defaultEntityPart.CreateRelationship(attachmentUri, TargetMode.Internal, Data.Constants.EntityPartRelationship); //Create the attachment metadata object. var attachmentMetadataPackagePart = m_package.CreatePart(attachmentMetadataUri, Data.Constants.EntityPartContentType); //Throw the metadata in the file. var attachmentMetadata = new AttachmentMetadata { Category = attachment.Category, Created = attachment.Created, CreatedBy = attachment.CreatedBy, Etag = attachment.Etag.IncrementBy(1), FileName = fileName, Modified = attachment.Modified, ModifiedBy = attachment.ModifiedBy, Path = attachment.Path, Properties = attachment.Properties, Size = attachment.Size, TimeLastModified = attachment.TimeLastModified, Url = attachment.Url }; var metadata = JsonConvert.SerializeObject(attachmentMetadata, new EtagJsonConverter()); //Copy the metadata to the entity part metadata part. using (var fileStream = new StringStream(metadata)) { fileStream.CopyTo(attachmentMetadataPackagePart.GetStream()); } return(MapAttachmentFromPackagePart(attachmentPackagePart)); }