public static void DeleteLevelOneAttachments(Item newItem, UserContext userContext) { if (newItem == null) { throw new ArgumentNullException("newItem"); } List <AttachmentId> list = new List <AttachmentId>(); foreach (AttachmentHandle handle in newItem.AttachmentCollection) { using (Attachment attachment = newItem.AttachmentCollection.Open(handle)) { AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(attachment, userContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { list.Add(attachment.Id); } } } if (list.Count != 0) { foreach (AttachmentId attachmentId in list) { newItem.AttachmentCollection.Remove(attachmentId); } ConflictResolutionResult conflictResolutionResult = newItem.Save(SaveMode.ResolveConflicts); if (conflictResolutionResult.SaveStatus == SaveResult.IrresolvableConflict) { newItem.Dispose(); newItem = null; throw new OwaSaveConflictException(LocalizedStrings.GetNonEncoded(-482397486), conflictResolutionResult); } } newItem.Load(); }
public static AttachmentPolicy.Level GetAttachmentLevel(Attachment attachment, UserContext userContext) { if (attachment == null) { throw new ArgumentNullException("attachment"); } return(AttachmentLevelLookup.GetAttachmentLevel(attachment.AttachmentType, attachment.FileExtension, attachment.ContentType ?? attachment.CalculatedContentType, userContext)); }
public static AttachmentPolicy.Level GetAttachmentLevel(AttachmentInfo attachmentInfo, UserContext userContext) { if (attachmentInfo == null) { throw new ArgumentNullException("attachmentInfo"); } return(AttachmentLevelLookup.GetAttachmentLevel(attachmentInfo.AttachmentType, attachmentInfo.FileExtension, attachmentInfo.ContentType, userContext)); }
// Token: 0x0600071C RID: 1820 RVA: 0x00037B9C File Offset: 0x00035D9C private void ProcessAttachment(Attachment attachment, HttpContext httpContext, BlockStatus blockStatus) { if (attachment == null) { throw new ArgumentNullException("attachment"); } OwaContext owaContext = OwaContext.Get(httpContext); UserContext userContext = owaContext.UserContext; Stream stream = null; try { StreamAttachmentBase streamAttachment = AttachmentUtility.GetStreamAttachment(attachment); if (streamAttachment == null) { ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: attachment is not derived from AttachmentStream"); } else { AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, userContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { Utilities.TransferToErrorPage(owaContext, LocalizedStrings.GetNonEncoded(-2000404449), LocalizedStrings.GetNonEncoded(-615885395)); } else { string fileName = AttachmentUtility.CalculateAttachmentName(streamAttachment.DisplayName, streamAttachment.FileName); string text = streamAttachment.FileExtension; if (text == null) { text = string.Empty; } string empty = string.Empty; bool contentType = this.GetContentType(httpContext, streamAttachment, attachmentLevel, out empty); bool isInline = this.GetIsInline(streamAttachment, attachmentLevel); stream = AttachmentUtility.GetStream(streamAttachment); if (stream == null) { ExTraceGlobals.AttachmentHandlingTracer.TraceError((long)this.GetHashCode(), "AttachmentHandler.ProcessAttachment: Image conversion of OLE attachment failure"); } else { AttachmentHandler.SendDocumentContentToHttpStream(httpContext, stream, fileName, text, empty, isInline, streamAttachment.TextCharset, blockStatus, attachmentLevel, contentType); } } } } finally { if (stream != null) { stream.Dispose(); } } }
protected AttachmentPolicy.Level GetAttachmentLevel(AttachmentLink attachmentLink) { if (this.isJunkOrPhishing) { return(AttachmentPolicy.Level.Block); } if (attachmentLink.AttachmentType == AttachmentType.EmbeddedMessage) { return(AttachmentPolicy.Level.Block); } return(AttachmentLevelLookup.GetAttachmentLevel(attachmentLink, this.owaContext.UserContext)); }