public AttachmentWellInfo(AttachmentCollection collection, Attachment attachment, bool isJunkOrPhishing) { this.collection = collection; this.attachmentId = attachment.Id; if (isJunkOrPhishing) { this.attachmentLevel = AttachmentPolicy.Level.Block; } else { this.attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(attachment, UserContextManager.GetUserContext()); } this.attachmentType = attachment.AttachmentType; this.fileName = attachment.FileName; if (this.attachmentType == AttachmentType.EmbeddedMessage) { using (Item itemAsReadOnly = ((ItemAttachment)attachment).GetItemAsReadOnly(null)) { this.displayName = AttachmentUtility.GetEmbeddedAttachmentDisplayName(itemAsReadOnly); } this.fileExtension = ".msg"; } else { this.displayName = attachment.DisplayName; this.fileExtension = ((attachment.FileExtension == null) ? string.Empty : attachment.FileExtension); } this.isInline = attachment.IsInline; this.attachmentSize = attachment.Size; this.attachmentName = AttachmentUtility.CalculateAttachmentName(this.displayName, this.fileName); this.mimeType = AttachmentUtility.CalculateContentType(attachment); this.textCharset = attachment.TextCharset; }
// Token: 0x06002C61 RID: 11361 RVA: 0x000F7264 File Offset: 0x000F5464 private Stream GetContactPictureStream(Item item, string attId, out string contentType) { contentType = string.Empty; if (item == null) { return(new MemoryStream()); } if (string.IsNullOrEmpty(attId)) { attId = RenderingUtilities.GetContactPictureAttachmentId(item); } if (string.IsNullOrEmpty(attId)) { return(new MemoryStream()); } AttachmentId id = item.CreateAttachmentId(attId); AttachmentCollection attachmentCollection = Utilities.GetAttachmentCollection(item, true, base.UserContext); Stream result; using (StreamAttachment streamAttachment = attachmentCollection.Open(id) as StreamAttachment) { if (streamAttachment == null) { throw new OwaInvalidRequestException("Attachment is not a stream attachment"); } AttachmentPolicy.Level attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(streamAttachment, base.UserContext); if (attachmentLevel == AttachmentPolicy.Level.Block) { result = new MemoryStream(); } else { contentType = AttachmentEventHandler.GetContentType(streamAttachment.FileName); if (contentType.Length == 0) { ExTraceGlobals.ContactsTracer.TraceDebug <string>((long)this.GetHashCode(), "Cannot determine image type for file: {0}", streamAttachment.FileName); result = new MemoryStream(); } else { result = streamAttachment.GetContentStream(); } } } return(result); }
public AttachmentWellInfo(OwaStoreObjectId owaConversationId, AttachmentInfo attachmentInfo, bool isJunkOrPhishing) { this.messageId = OwaStoreObjectId.CreateFromStoreObjectId(attachmentInfo.MessageId, owaConversationId); this.attachmentId = attachmentInfo.AttachmentId; if (isJunkOrPhishing) { this.attachmentLevel = AttachmentPolicy.Level.Block; } else { this.attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(attachmentInfo, UserContextManager.GetUserContext()); } this.attachmentType = attachmentInfo.AttachmentType; this.fileName = attachmentInfo.FileName; this.displayName = attachmentInfo.DisplayName; this.isInline = attachmentInfo.IsInline; this.attachmentSize = attachmentInfo.Size; this.fileExtension = attachmentInfo.FileExtension; this.attachmentName = AttachmentUtility.CalculateAttachmentName(attachmentInfo.DisplayName, attachmentInfo.FileName); this.mimeType = attachmentInfo.ContentType; }
public AttachmentWellInfo(AttachmentCollection collection, AttachmentLink attachmentLink, bool isJunkOrPhishing) { this.collection = collection; this.attachmentId = attachmentLink.AttachmentId; if (isJunkOrPhishing) { this.attachmentLevel = AttachmentPolicy.Level.Block; } else { this.attachmentLevel = AttachmentLevelLookup.GetAttachmentLevel(attachmentLink, UserContextManager.GetUserContext()); } this.attachmentType = attachmentLink.AttachmentType; this.fileName = attachmentLink.Filename; this.displayName = attachmentLink.DisplayName; this.isInline = attachmentLink.IsInline(true); this.attachmentSize = attachmentLink.Size; this.fileExtension = attachmentLink.FileExtension; this.attachmentName = AttachmentUtility.CalculateAttachmentName(attachmentLink.DisplayName, attachmentLink.Filename); this.mimeType = attachmentLink.ContentType; }
public void GetDocument() { bool flag = false; ExTraceGlobals.MailCallTracer.TraceDebug((long)this.GetHashCode(), "DocumentEventHandler.GetDocument"); base.ShowErrorInPage = true; base.DontWriteHeaders = true; HttpContext httpContext = base.OwaContext.HttpContext; if (!DocumentLibraryUtilities.IsDocumentsAccessEnabled(base.UserContext)) { throw new OwaSegmentationException("Access to this document library is disabled"); } string text = (string)base.GetParameter("id"); string s = (string)base.GetParameter("URL"); DocumentLibraryObjectId documentLibraryObjectId = DocumentLibraryUtilities.CreateDocumentLibraryObjectId(base.OwaContext); if (documentLibraryObjectId == null) { return; } try { this.DataBind(documentLibraryObjectId); } finally { if (this.stream == null) { this.Dispose(); } } if (this.stream == null) { return; } UserContext userContext = base.OwaContext.UserContext; AttachmentPolicy.Level levelForAttachment = AttachmentLevelLookup.GetLevelForAttachment(Path.GetExtension(this.fileName), this.contentType, userContext); if (base.IsParameterSet("allowLevel2")) { flag = true; } if (levelForAttachment == AttachmentPolicy.Level.Block) { string errorDescription = string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetNonEncoded(1280363351), new object[] { this.fileName }); Utilities.TransferToErrorPage(base.OwaContext, errorDescription, null, ThemeFileId.ButtonDialogInfo, true); return; } if (levelForAttachment == AttachmentPolicy.Level.ForceSave && !flag) { string queryStringParameter = Utilities.GetQueryStringParameter(httpContext.Request, "ns"); string text2 = string.Concat(new string[] { "<br> <a onclick=\"return false;\" href=\"ev.owa?ns=", queryStringParameter, "&ev=GetDoc&allowLevel2=1&URL=", Utilities.UrlEncode(s), "&id=", Utilities.UrlEncode(documentLibraryObjectId.ToBase64String()), Utilities.GetCanaryRequestParameter(), "\">", Utilities.HtmlEncode(this.fileName), "</a>" }); string errorDetailedDescription = string.Format(CultureInfo.InvariantCulture, LocalizedStrings.GetHtmlEncoded(-625229753), new object[] { text2 }); Utilities.TransferToErrorPage(base.OwaContext, LocalizedStrings.GetHtmlEncoded(-226672911), errorDetailedDescription, ThemeFileId.ButtonDialogInfo, true, true); return; } int num = AttachmentHandler.SendDocumentContentToHttpStream(httpContext, this.stream, this.fileName, DocumentEventHandler.CalculateFileExtension(this.fileName), this.contentType); if (this.contentType != null && this.contentType.Equals("application/x-zip-compressed", StringComparison.OrdinalIgnoreCase)) { Utilities.DisableContentEncodingForThisResponse(base.OwaContext.HttpContext.Response); } if (Globals.ArePerfCountersEnabled) { if ((documentLibraryObjectId.UriFlags & UriFlags.Sharepoint) != (UriFlags)0) { OwaSingleCounters.WssBytes.IncrementBy((long)num); OwaSingleCounters.WssRequests.Increment(); return; } if ((documentLibraryObjectId.UriFlags & UriFlags.Unc) != (UriFlags)0) { OwaSingleCounters.UncBytes.IncrementBy((long)num); OwaSingleCounters.UncRequests.Increment(); } } }