Esempio n. 1
0
        private static void RenderAttachments(TextWriter output, ArrayList attachmentList, UserContext userContext)
        {
            if (attachmentList == null)
            {
                return;
            }
            int count = attachmentList.Count;

            if (count <= 0)
            {
                return;
            }
            int       num = 0;
            ArrayList previousAttachmentDisplayNames = new ArrayList();

            for (int i = 0; i < count; i++)
            {
                AttachmentWellInfo attachmentInfoObject = (AttachmentWellInfo)attachmentList[i];
                PrintAttachmentWell.RenderAttachment(output, attachmentInfoObject, userContext, previousAttachmentDisplayNames);
                if (num < count - 1)
                {
                    output.Write(" ; ");
                }
                num++;
            }
        }
Esempio n. 2
0
        public void AddAttachmentToZip(AttachmentWellInfo attachmentWellInfo, UserContext userContext, HttpContext httpContext)
        {
            if (attachmentWellInfo == null)
            {
                throw new ArgumentNullException("attachmentWellInfo");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (httpContext == null)
            {
                throw new ArgumentNullException("httpContext");
            }
            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
            {
                this.hasEmbeddedItem = true;
            }
            bool   doNeedToFilterHtml = AttachmentUtility.DoNeedToFilterHtml(attachmentWellInfo.MimeType, attachmentWellInfo.FileExtension, attachmentWellInfo.AttachmentLevel, userContext);
            bool   isNotHtmlandNotXml = !AttachmentUtility.GetIsHtmlOrXml(attachmentWellInfo.MimeType, attachmentWellInfo.FileExtension);
            bool   doNotSniff         = AttachmentUtility.GetDoNotSniff(attachmentWellInfo.AttachmentLevel, userContext);
            string text = attachmentWellInfo.AttachmentName;

            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
            {
                text += attachmentWellInfo.FileExtension;
            }
            string text2 = this.ConditionZipEntryFileName(text);

            attachmentWellInfo.FileName = text2;
            ZipEntryAttachment value = new ZipEntryAttachment(text2, attachmentWellInfo, doNeedToFilterHtml, doNotSniff, isNotHtmlandNotXml);

            this.files.Add(text2, value);
        }
Esempio n. 3
0
        private static void RenderAttachment(TextWriter output, AttachmentWellInfo attachmentInfoObject, UserContext userContext, ArrayList previousAttachmentDisplayNames)
        {
            ItemAttachment itemAttachment = null;
            Item           item           = null;
            string         value          = null;

            try
            {
                if (attachmentInfoObject.AttachmentType == AttachmentType.EmbeddedMessage)
                {
                    itemAttachment = (ItemAttachment)attachmentInfoObject.OpenAttachment();
                    item           = itemAttachment.GetItemAsReadOnly(new PropertyDefinition[]
                    {
                        TaskSchema.TaskType
                    });
                }
                if (item != null)
                {
                    value = Utilities.HtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(AttachmentUtility.GetEmbeddedAttachmentDisplayName(item), previousAttachmentDisplayNames, true));
                }
                else
                {
                    value = Utilities.HtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(attachmentInfoObject.AttachmentName, previousAttachmentDisplayNames, false));
                }
            }
            catch (ObjectNotFoundException)
            {
                return;
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
                if (itemAttachment != null)
                {
                    itemAttachment.Dispose();
                    itemAttachment = null;
                }
            }
            output.Write("<span id=\"spnAtmt\" tabindex=\"-1\">");
            output.Write(value);
            long size = attachmentInfoObject.Size;

            if (size > 0L)
            {
                output.Write(userContext.DirectionMark);
                output.Write(" ");
                output.Write(LocalizedStrings.GetHtmlEncoded(6409762));
                Utilities.RenderSizeWithUnits(output, size, true);
                output.Write(userContext.DirectionMark);
                output.Write(LocalizedStrings.GetHtmlEncoded(-1023695022));
            }
            output.Write("</span>");
        }
        // Token: 0x060009F6 RID: 2550 RVA: 0x00045548 File Offset: 0x00043748
        private void CreateAttachmentInfobarHelper(ArrayList attachmentList)
        {
            if (attachmentList == null || attachmentList.Count <= 0)
            {
                return;
            }
            StringBuilder    stringBuilder    = new StringBuilder();
            int              num              = 0;
            UserContext      userContext      = UserContextManager.GetUserContext();
            AttachmentPolicy attachmentPolicy = userContext.AttachmentPolicy;

            foreach (object obj in attachmentList)
            {
                AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                bool flag = AttachmentUtility.IsWebReadyDocument(attachmentWellInfo.FileExtension, attachmentWellInfo.MimeType);
                if (flag && (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Block || attachmentPolicy.ForceWebReadyDocumentViewingFirst))
                {
                    this.hasWebReadyFirst = true;
                }
                if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Block)
                {
                    this.hasLevelOne = true;
                    if (!flag)
                    {
                        this.hasLevelOneAndBlock = true;
                        num++;
                        if (num == 16)
                        {
                            stringBuilder.Append(",...");
                        }
                        else if (num <= 15)
                        {
                            if (num != 1)
                            {
                                stringBuilder.Append(", ");
                            }
                            stringBuilder.Append(attachmentWellInfo.AttachmentName);
                        }
                    }
                }
                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.ForceSave)
                {
                    this.hasLevelTwo = true;
                }
                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Allow)
                {
                    this.hasLevelThree = true;
                }
            }
            if (stringBuilder.Length > 0)
            {
                this.fileNameStringForLevelOneAndBlock = stringBuilder.ToString();
            }
        }
Esempio n. 5
0
 // Token: 0x06002AB8 RID: 10936 RVA: 0x000F049C File Offset: 0x000EE69C
 protected void CreateAttachmentHelpers()
 {
     this.attachmentWellRenderObjects = AttachmentWell.GetAttachmentInformation(base.Item, base.AttachmentLinks, base.UserContext.IsPublicLogon, base.IsEmbeddedItem);
     foreach (object obj in this.attachmentWellRenderObjects)
     {
         AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
         if (string.CompareOrdinal("ContactPicture.jpg", attachmentWellInfo.FileName) == 0)
         {
             this.attachmentWellRenderObjects.Remove(attachmentWellInfo);
             break;
         }
     }
     this.shouldRenderAttachmentWell = RenderingUtilities.AddAttachmentInfobarMessages(base.Item, base.IsEmbeddedItem, false, this.infobar, this.attachmentWellRenderObjects);
 }
 // Token: 0x06001980 RID: 6528 RVA: 0x00095038 File Offset: 0x00093238
 internal ZipEntryAttachment(string fileName, AttachmentWellInfo attachmentWellInfo, bool doNeedToFilterHtml, bool doNotSniff, bool isNotHtmlandNotXml)
 {
     this.fileName             = fileName;
     this.encodedfileNameBytes = this.GetEncodedString(fileName);
     this.attachmentWellInfo   = attachmentWellInfo;
     this.doNeedToFilterHtml   = doNeedToFilterHtml;
     this.doNotSniff           = doNotSniff;
     this.isNotHtmlandNotXml   = isNotHtmlandNotXml;
     if (this.NeedsCompression(attachmentWellInfo))
     {
         this.compressionMethod  = 8;
         this.generalPurposeFlag = 2056;
     }
     else
     {
         this.compressionMethod  = 0;
         this.generalPurposeFlag = 2048;
     }
     this.currentDateTime = this.CurrentDosDateTime();
 }
        // Token: 0x0600071D RID: 1821 RVA: 0x00037CBC File Offset: 0x00035EBC
        private void DownloadAllAttachments(Item item, HttpContext httpContext, UserContext userContext)
        {
            BlockStatus itemBlockStatus      = AttachmentUtility.GetItemBlockStatus(item);
            string      subject              = this.GetSubject(item);
            ArrayList   attachmentListForZip = AttachmentUtility.GetAttachmentListForZip(item, true, userContext);

            if (attachmentListForZip == null || attachmentListForZip.Count == 0)
            {
                ExTraceGlobals.AttachmentHandlingTracer.TraceDebug((long)this.GetHashCode(), "AttachmentHandler.DownloadAllAttachments: No attachments returned for item");
                return;
            }
            ZipFileAttachments zipFileAttachments = new ZipFileAttachments(itemBlockStatus, subject);

            foreach (object obj in attachmentListForZip)
            {
                AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                zipFileAttachments.AddAttachmentToZip(attachmentWellInfo, userContext, httpContext);
            }
            zipFileAttachments.WriteArchive(httpContext);
        }
Esempio n. 8
0
 // Token: 0x060027F9 RID: 10233 RVA: 0x000E277C File Offset: 0x000E097C
 protected void CreateAttachmentHelpers()
 {
     if (base.Item != null)
     {
         this.attachmentWellRenderObjects = AttachmentWell.GetAttachmentInformation(base.Item, base.AttachmentLinks, base.UserContext.IsPublicLogon);
         foreach (object obj in this.attachmentWellRenderObjects)
         {
             AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
             if (string.CompareOrdinal("ContactPicture.jpg", attachmentWellInfo.FileName) == 0)
             {
                 this.attachmentWellRenderObjects.Remove(attachmentWellInfo);
                 break;
             }
         }
         InfobarRenderingHelper infobarRenderingHelper = new InfobarRenderingHelper(this.attachmentWellRenderObjects);
         if (infobarRenderingHelper.HasLevelOne)
         {
             this.infobar.AddMessage(SanitizedHtmlString.FromStringId(-2118248931), InfobarMessageType.Informational, AttachmentWell.AttachmentInfobarHtmlTag);
         }
     }
 }
Esempio n. 9
0
 protected static void RemoveContactPhoto(ArrayList attachmentWellRenderObjects)
 {
     if (attachmentWellRenderObjects == null)
     {
         throw new ArgumentNullException("attachmentWellRenderObjects");
     }
     for (int i = 0; i < attachmentWellRenderObjects.Count; i++)
     {
         AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)attachmentWellRenderObjects[i];
         using (Attachment attachment = attachmentWellInfo.OpenAttachment())
         {
             attachment.Load(new PropertyDefinition[]
             {
                 AttachmentSchema.IsContactPhoto
             });
             if (attachment.IsContactPhoto)
             {
                 attachmentWellRenderObjects.RemoveAt(i);
                 break;
             }
         }
     }
 }
 // Token: 0x06001984 RID: 6532 RVA: 0x000952E0 File Offset: 0x000934E0
 private bool NeedsCompression(AttachmentWellInfo attachmentWellInfo)
 {
     return(!ZipEntryAttachment.alreadyCompressedRegex.IsMatch(attachmentWellInfo.FileExtension) && attachmentWellInfo.Size >= 1000L);
 }
Esempio n. 11
0
        private static void RenderAttachments(TextWriter output, AttachmentWellType wellType, ArrayList attachmentList, string itemId, UserContext userContext, AttachmentWell.AttachmentWellFlags flags)
        {
            if (attachmentList == null)
            {
                return;
            }
            int count = attachmentList.Count;

            if (count <= 0)
            {
                return;
            }
            if (Utilities.GetEmbeddedDepth(HttpContext.Current.Request) >= AttachmentPolicy.MaxEmbeddedDepth)
            {
                flags |= AttachmentWell.AttachmentWellFlags.RenderReachedMaxEmbeddedDepth;
            }
            ArrayList previousAttachmentDisplayNames = new ArrayList();
            bool      prependSemicolon = false;

            foreach (object obj in attachmentList)
            {
                AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                AttachmentUtility.AttachmentLinkFlags attachmentLinkFlag = AttachmentUtility.GetAttachmentLinkFlag(wellType, attachmentWellInfo);
                if (AttachmentUtility.AttachmentLinkFlags.Skip != (AttachmentUtility.AttachmentLinkFlags.Skip & attachmentLinkFlag) && (!attachmentWellInfo.IsInline || (flags & AttachmentWell.AttachmentWellFlags.RenderInLine) == AttachmentWell.AttachmentWellFlags.RenderInLine) && ((flags & AttachmentWell.AttachmentWellFlags.RenderInLine) == AttachmentWell.AttachmentWellFlags.RenderInLine || (!attachmentWellInfo.IsInline && attachmentWellInfo.AttachmentType != AttachmentType.Ole)))
                {
                    Item           item           = null;
                    ItemAttachment itemAttachment = null;
                    try
                    {
                        if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
                        {
                            itemAttachment = (ItemAttachment)attachmentWellInfo.OpenAttachment();
                            item           = itemAttachment.GetItemAsReadOnly(null);
                        }
                        if (item != null)
                        {
                            AttachmentWell.RenderAttachmentLinkForItem(output, attachmentWellInfo, item, itemId, userContext, previousAttachmentDisplayNames, flags, prependSemicolon);
                        }
                        else
                        {
                            AttachmentWell.RenderAttachmentLink(output, wellType, attachmentWellInfo, itemId, userContext, previousAttachmentDisplayNames, flags | AttachmentWell.AttachmentWellFlags.RenderAttachmentSize, prependSemicolon);
                        }
                        prependSemicolon = true;
                    }
                    catch (ObjectNotFoundException)
                    {
                    }
                    finally
                    {
                        if (item != null)
                        {
                            item.Dispose();
                            item = null;
                        }
                        if (itemAttachment != null)
                        {
                            itemAttachment.Dispose();
                            itemAttachment = null;
                        }
                    }
                }
            }
        }
Esempio n. 12
0
        internal static void RenderAttachmentLink(TextWriter output, AttachmentWellType wellType, AttachmentWellInfo attachmentInfoObject, string itemId, UserContext userContext, ArrayList previousAttachmentDisplayNames, AttachmentWell.AttachmentWellFlags flags, bool prependSemicolon = false)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (attachmentInfoObject == null)
            {
                throw new ArgumentNullException("attachmentInfoObject");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (string.IsNullOrEmpty(itemId))
            {
                throw new ArgumentException("itemId may not be null or empty string");
            }
            SanitizedHtmlString value = null;
            string fileExtension      = string.Empty;
            SanitizedHtmlString sanitizedHtmlString = null;

            AttachmentUtility.AttachmentLinkFlags attachmentLinkFlag = AttachmentUtility.GetAttachmentLinkFlag(wellType, attachmentInfoObject);
            if ((flags & AttachmentWell.AttachmentWellFlags.RenderReachedMaxEmbeddedDepth) != (AttachmentWell.AttachmentWellFlags) 0)
            {
                string format = "<a id=\"{0}\" href=\"#\" onclick=\"{1}\" title=\"{2}\">{3}";
                string text   = AttachmentUtility.TrimAttachmentDisplayName(attachmentInfoObject.AttachmentName, previousAttachmentDisplayNames, false);
                value = SanitizedHtmlString.Format(format, new object[]
                {
                    "lnkAtmt",
                    "return alert(L_ErrRchMxEmbDpth)",
                    attachmentInfoObject.AttachmentName,
                    text
                });
            }
            else
            {
                string format2 = "<a id=\"{0}\" href=\"attachment.ashx?attach=1&{1}\" target=_blank onclick=\"{2}\" title=\"{3}\">{4}";
                SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>();
                if (AttachmentWell.AttachmentWellFlags.RenderEmbeddedAttachment != (flags & AttachmentWell.AttachmentWellFlags.RenderEmbeddedAttachment))
                {
                    sanitizingStringBuilder.Append("id=");
                    sanitizingStringBuilder.Append(Utilities.UrlEncode(itemId));
                    sanitizingStringBuilder.Append("&attid0=");
                    sanitizingStringBuilder.Append(Utilities.UrlEncode(attachmentInfoObject.AttachmentId.ToBase64String()));
                    sanitizingStringBuilder.Append("&attcnt=1");
                }
                else
                {
                    sanitizingStringBuilder.Append(AttachmentWell.RenderEmbeddedQueryString(itemId));
                    sanitizingStringBuilder.Append(Utilities.UrlEncode(attachmentInfoObject.AttachmentId.ToBase64String()));
                }
                sanitizedHtmlString = sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>();
                if (attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.ForceSave)
                {
                    string text2 = AttachmentUtility.TrimAttachmentDisplayName(attachmentInfoObject.AttachmentName, previousAttachmentDisplayNames, false);
                    value = SanitizedHtmlString.Format(format2, new object[]
                    {
                        "lnkAtmt",
                        sanitizedHtmlString,
                        "return onClkAtmt(2)",
                        attachmentInfoObject.AttachmentName,
                        text2
                    });
                }
                if (attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.Allow)
                {
                    string text3 = AttachmentUtility.TrimAttachmentDisplayName(attachmentInfoObject.AttachmentName, previousAttachmentDisplayNames, false);
                    value = SanitizedHtmlString.Format(format2, new object[]
                    {
                        "lnkAtmt",
                        sanitizedHtmlString,
                        "return onClkAtmt(3)",
                        attachmentInfoObject.AttachmentName,
                        text3
                    });
                }
            }
            if (prependSemicolon)
            {
                output.Write("; ");
            }
            output.Write("<span id=\"spnAtmt\" tabindex=\"-1\" level=\"");
            output.Write((int)attachmentInfoObject.AttachmentLevel);
            if (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink != (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag) && (flags & AttachmentWell.AttachmentWellFlags.RenderReachedMaxEmbeddedDepth) == (AttachmentWell.AttachmentWellFlags) 0)
            {
                output.Write("\" class=\"dsbl");
            }
            output.Write("\">");
            output.Write("<img class=\"sI\" src=\"");
            if (attachmentInfoObject.FileExtension != null)
            {
                fileExtension = attachmentInfoObject.FileExtension;
            }
            SmallIconManager.RenderFileIconUrl(output, userContext, fileExtension);
            output.Write("\" alt=\"\">");
            if (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink == (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag) || (flags & AttachmentWell.AttachmentWellFlags.RenderReachedMaxEmbeddedDepth) != (AttachmentWell.AttachmentWellFlags) 0)
            {
                output.Write(value);
            }
            else
            {
                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(attachmentInfoObject.AttachmentName, previousAttachmentDisplayNames, false), output);
            }
            if (AttachmentWell.AttachmentWellFlags.RenderAttachmentSize == (flags & AttachmentWell.AttachmentWellFlags.RenderAttachmentSize))
            {
                long size = attachmentInfoObject.Size;
                if (size > 0L)
                {
                    output.Write(userContext.DirectionMark);
                    output.Write(" ");
                    output.Write(SanitizedHtmlString.FromStringId(6409762));
                    Utilities.RenderSizeWithUnits(output, size, true);
                    output.Write(userContext.DirectionMark);
                    output.Write(SanitizedHtmlString.FromStringId(-1023695022));
                }
            }
            output.Write("</a>");
            if (AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink == (AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink & attachmentLinkFlag))
            {
                output.Write("<span class=\"wvsn\">[<a id=\"wvLnk\" href=\"#\" onclick=\"");
                output.Write("opnWin('WebReadyView.aspx?t=att&");
                output.Write(sanitizedHtmlString);
                output.Write("')\">");
                output.Write(SanitizedHtmlString.FromStringId(1547877601));
                output.Write("</a>]</span>");
            }
            output.Write("</span>");
        }
Esempio n. 13
0
        internal static void RenderAttachmentLinkForItem(TextWriter output, AttachmentWellInfo attachmentInfoObject, Item item, string itemId, UserContext userContext, ArrayList previousAttachmentDisplayNames, AttachmentWell.AttachmentWellFlags flags, bool prependSemicolon = false)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (attachmentInfoObject == null)
            {
                throw new ArgumentNullException("attachmentInfoObject");
            }
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            SanitizedHtmlString value;
            bool flag;

            if ((attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.ForceSave || attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.Allow) && AttachmentWell.AttachmentWellFlags.RenderEmbeddedItem == (flags & AttachmentWell.AttachmentWellFlags.RenderEmbeddedItem))
            {
                string format = string.Empty;
                if (attachmentInfoObject.AttachmentLevel == AttachmentPolicy.Level.Allow)
                {
                    format = "<a id=\"{0}\" href=\"#\" onclick=\"{1}\" title=\"{2}\" oncontextmenu=\"return false;\">{3}</a>";
                }
                else
                {
                    format = "<a id=\"{0}\" href=\"#\" onclick=\"{1}\" title=\"{2}\">{3}</a>";
                }
                SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>();
                sanitizingStringBuilder.Append("?ae=Item&t=");
                sanitizingStringBuilder.Append(Utilities.UrlEncode(item.ClassName));
                sanitizingStringBuilder.Append("&atttyp=embdd");
                if (ObjectClass.IsCalendarItemCalendarItemOccurrenceOrRecurrenceException(item.ClassName))
                {
                    sanitizingStringBuilder.Append("&a=Read");
                }
                SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder2 = new SanitizingStringBuilder <OwaHtml>();
                if ((flags & AttachmentWell.AttachmentWellFlags.RenderReachedMaxEmbeddedDepth) == (AttachmentWell.AttachmentWellFlags) 0)
                {
                    sanitizingStringBuilder2.Append("return onClkEmbItem('");
                    sanitizingStringBuilder2.Append <SanitizedHtmlString>(sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>());
                    sanitizingStringBuilder2.Append("','");
                    sanitizingStringBuilder2.Append(Utilities.UrlEncode(attachmentInfoObject.AttachmentId.ToBase64String()));
                    sanitizingStringBuilder2.Append("');");
                }
                else
                {
                    sanitizingStringBuilder2.Append("return alert(L_ErrRchMxEmbDpth)");
                }
                string embeddedAttachmentDisplayName = AttachmentUtility.GetEmbeddedAttachmentDisplayName(item);
                value = SanitizedHtmlString.Format(format, new object[]
                {
                    "lnkAtmt",
                    sanitizingStringBuilder2.ToSanitizedString <SanitizedHtmlString>(),
                    embeddedAttachmentDisplayName,
                    AttachmentUtility.TrimAttachmentDisplayName(embeddedAttachmentDisplayName, previousAttachmentDisplayNames, true)
                });
                flag = false;
            }
            else
            {
                value = Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(AttachmentUtility.GetEmbeddedAttachmentDisplayName(item), previousAttachmentDisplayNames, true));
                flag  = true;
            }
            if (prependSemicolon)
            {
                output.Write("; ");
            }
            output.Write("<span id=\"spnAtmt\" tabindex=\"-1\" level=\"3\"");
            if (flag)
            {
                output.Write(" class=\"dsbl\"");
            }
            output.Write(">");
            output.Write("<img class=\"sI\" src=\"");
            SmallIconManager.RenderItemIconUrl(output, userContext, item.ClassName);
            output.Write("\" alt=\"\">");
            output.Write(value);
            output.Write("</span>");
        }
        // Token: 0x06001E1F RID: 7711 RVA: 0x000AE510 File Offset: 0x000AC710
        public static void RenderAttachments(TextWriter output, AttachmentWellType wellType, ArrayList attachmentList, UserContext userContext, bool isConversationAndIrmCopyRestricted)
        {
            if (output == null)
            {
                throw new ArgumentNullException("output");
            }
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (attachmentList == null || attachmentList.Count <= 0)
            {
                return;
            }
            bool flag = true;

            Utilities.GetEmbeddedDepth(HttpContext.Current.Request);
            ArrayList previousAttachmentDisplayNames = new ArrayList();
            Item      item = null;

            try
            {
                foreach (object obj in attachmentList)
                {
                    AttachmentWellInfo attachmentWellInfo = (AttachmentWellInfo)obj;
                    AttachmentUtility.AttachmentLinkFlags attachmentLinkFlag = AttachmentUtility.GetAttachmentLinkFlag(wellType, attachmentWellInfo);
                    if (AttachmentUtility.AttachmentLinkFlags.Skip != (AttachmentUtility.AttachmentLinkFlags.Skip & attachmentLinkFlag))
                    {
                        ItemAttachment itemAttachment = null;
                        Item           item2          = null;
                        try
                        {
                            if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
                            {
                                if (attachmentWellInfo.MessageId != null)
                                {
                                    if (item != null)
                                    {
                                        StoreObjectId storeObjectId = StoreId.GetStoreObjectId(item.Id);
                                        if (!storeObjectId.Equals(attachmentWellInfo.MessageId.StoreObjectId))
                                        {
                                            item.Dispose();
                                            item = null;
                                        }
                                    }
                                    if (item == null)
                                    {
                                        item = Utilities.GetItem <Item>(userContext, attachmentWellInfo.MessageId, false, null);
                                    }
                                    AttachmentCollection attachmentCollection = item.AttachmentCollection;
                                    if (userContext.IsIrmEnabled && Utilities.IrmDecryptIfRestricted(item, userContext))
                                    {
                                        attachmentCollection = ((RightsManagedMessageItem)item).ProtectedAttachmentCollection;
                                    }
                                    itemAttachment = (ItemAttachment)attachmentCollection.Open(attachmentWellInfo.AttachmentId);
                                }
                                else
                                {
                                    itemAttachment = (ItemAttachment)attachmentWellInfo.OpenAttachment();
                                }
                                item2 = itemAttachment.GetItemAsReadOnly(new PropertyDefinition[]
                                {
                                    TaskSchema.TaskType
                                });
                            }
                            if (!flag)
                            {
                                output.Write("; ");
                            }
                            else
                            {
                                flag = false;
                            }
                            output.Write("<span id=spnAtmt tabindex=\"-1\" ");
                            if (wellType == AttachmentWellType.ReadOnly && AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink != (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag))
                            {
                                output.Write("class=\"dsbl\"");
                            }
                            if (attachmentWellInfo.MessageId != null)
                            {
                                output.Write(" _sId=\"");
                                Utilities.SanitizeHtmlEncode(attachmentWellInfo.MessageId.ToString(), output);
                                output.Write("\"");
                            }
                            string text;
                            if (item2 != null)
                            {
                                text = AttachmentUtility.GetEmbeddedAttachmentDisplayName(item2);
                            }
                            else
                            {
                                text = attachmentWellInfo.AttachmentName;
                            }
                            output.Write(" _attid=\"");
                            output.Write(Utilities.SanitizeHtmlEncode(attachmentWellInfo.AttachmentId.ToBase64String()));
                            output.Write("\" _level=");
                            output.Write((int)attachmentWellInfo.AttachmentLevel);
                            output.Write(" _attname=\"");
                            output.Write(Utilities.SanitizeHtmlEncode(text));
                            output.Write("\" _attsize=\"");
                            output.Write(attachmentWellInfo.Size);
                            output.Write("\" _fIsItem=\"");
                            output.Write(item2 != null);
                            output.Write("\"");
                            if (attachmentWellInfo.AttachmentType != AttachmentType.EmbeddedMessage)
                            {
                                output.Write(" _protectable=\"");
                                bool flag2 = false;
                                try
                                {
                                    flag2 = ProtectorsManager.Instance.IsProtectorRegistered(attachmentWellInfo.FileExtension);
                                }
                                catch (AttachmentProtectionException)
                                {
                                }
                                output.Write(flag2 ? "1" : "0");
                                output.Write("\"");
                            }
                            if (item2 != null)
                            {
                                Task task = item2 as Task;
                                if ((task != null && !TaskUtilities.IsAssignedTask(task)) || item2 is Contact || item2 is DistributionList)
                                {
                                    output.Write(" _qs=\"ae=PreFormAction&a=OpenEmbedded&t=");
                                }
                                else
                                {
                                    output.Write(" _qs=\"ae=Item&t=");
                                }
                                Utilities.SanitizeHtmlEncode(Utilities.UrlEncode(item2.ClassName), output);
                                if (task != null && TaskUtilities.IsAssignedTask(task))
                                {
                                    output.Write("&s=Assigned");
                                }
                                output.Write("\"");
                            }
                            output.Write(">");
                            bool flag3 = AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink == (AttachmentUtility.AttachmentLinkFlags.AttachmentClickLink & attachmentLinkFlag);
                            if (flag3)
                            {
                                string text2 = null;
                                if (item2 != null || attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.Allow)
                                {
                                    text2 = "3";
                                }
                                else if (attachmentWellInfo.AttachmentLevel == AttachmentPolicy.Level.ForceSave)
                                {
                                    text2 = "2";
                                }
                                if (text2 != null)
                                {
                                    output.Write("<a class=\"lnkClickAtmt\" id=\"lnkAtmt\" _fAllwCM=\"1\" href=\"#\" target=_blank ");
                                    Utilities.RenderScriptHandler(output, "onclick", string.Concat(new string[]
                                    {
                                        "atLnk(event, ",
                                        text2,
                                        ", ",
                                        isConversationAndIrmCopyRestricted ? "1" : "0",
                                        ");"
                                    }));
                                    output.Write(" title=\"");
                                    Utilities.SanitizeHtmlEncode(text, output);
                                    if (text2 == "3" & item2 != null)
                                    {
                                        output.Write("\" oncontextmenu=\"return false;");
                                    }
                                    output.Write("\">");
                                }
                            }
                            if (item2 != null)
                            {
                                SmallIconManager.RenderItemIcon(output, userContext, item2.ClassName, false, "sI", new string[0]);
                            }
                            else
                            {
                                string fileExtension = string.Empty;
                                if (attachmentWellInfo.FileExtension != null)
                                {
                                    fileExtension = attachmentWellInfo.FileExtension;
                                }
                                SmallIconManager.RenderFileIcon(output, userContext, fileExtension, "sI", new string[0]);
                            }
                            if (item2 != null)
                            {
                                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, true), output);
                            }
                            else
                            {
                                Utilities.SanitizeHtmlEncode(AttachmentUtility.TrimAttachmentDisplayName(text, previousAttachmentDisplayNames, false), output);
                                long size = attachmentWellInfo.Size;
                                if (size > 0L)
                                {
                                    output.Write(userContext.DirectionMark);
                                    output.Write(" ");
                                    output.Write(SanitizedHtmlString.FromStringId(6409762));
                                    Utilities.RenderSizeWithUnits(output, size, true);
                                    output.Write(userContext.DirectionMark);
                                    output.Write(SanitizedHtmlString.FromStringId(-1023695022));
                                }
                            }
                            if (flag3)
                            {
                                output.Write("</a>");
                            }
                            if (item2 == null && AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink == (AttachmentUtility.AttachmentLinkFlags.OpenAsWebPageLink & attachmentLinkFlag))
                            {
                                AttachmentWell.RenderWebReadyLink(output, userContext);
                            }
                            if (wellType == AttachmentWellType.ReadWrite)
                            {
                                output.Write("<span class=\"delLnk\">");
                                userContext.RenderThemeImage(output, ThemeFileId.DeleteSmall, null, new object[]
                                {
                                    "id=delImg"
                                });
                                output.Write("</span>");
                            }
                            output.Write("</span>");
                        }
                        catch (ObjectNotFoundException)
                        {
                        }
                        catch (StorageTransientException)
                        {
                        }
                        finally
                        {
                            if (item2 != null)
                            {
                                item2.Dispose();
                                item2 = null;
                            }
                            if (itemAttachment != null)
                            {
                                itemAttachment.Dispose();
                                itemAttachment = null;
                            }
                        }
                    }
                }
            }
            finally
            {
                if (item != null)
                {
                    item.Dispose();
                    item = null;
                }
            }
        }
        // Token: 0x06000431 RID: 1073 RVA: 0x0002396C File Offset: 0x00021B6C
        public void RenderAttachmentList()
        {
            AttachmentWellInfo attachmentWellInfo             = null;
            ArrayList          previousAttachmentDisplayNames = new ArrayList();

            base.SanitizingResponse.Write("<form name=\"delFrm\" action=\"?ae=Dialog&t=Attach&a=Del\" method=\"POST\">");
            base.SanitizingResponse.Write("<input type=\"hidden\" name=\"{0}\" value=\"{1}\">", "hidid", this.messageIdString);
            base.SanitizingResponse.Write("<input type=\"hidden\" name=\"{0}\" value=\"{1}\">", "hid64bitmsgid", Utilities.UrlEncode(this.messageIdString));
            base.SanitizingResponse.Write("<input type=\"hidden\" name=\"{0}\" value=\"{1}\">", "hidchk", this.changeKeyString);
            base.SanitizingResponse.Write("<div id=\"{0}\">", "lstArId");
            base.SanitizingResponse.Write("<table cellpadding=1 cellspacing=0 border=\"0\" class=\"attchList\"><caption>");
            base.SanitizingResponse.Write(LocalizedStrings.GetNonEncoded(573876176));
            base.SanitizingResponse.Write("</caption><tr>");
            base.SanitizingResponse.Write("<th class=\"lftcrnr\"><img src=\"");
            base.SanitizingResponse.Write(base.UserContext.GetThemeFileUrl(ThemeFileId.Clear));
            base.SanitizingResponse.Write("\" alt=\"\" class=\"invimg\"></th>");
            base.SanitizingResponse.Write("<th class=\"chkbx\">");
            base.SanitizingResponse.Write("<input type=\"checkbox\" name=\"chkAll\" id=\"chkAll\" onclick=\"chkAttchAll();\" alt=\"");
            base.SanitizingResponse.Write(LocalizedStrings.GetNonEncoded(-288583276));
            base.SanitizingResponse.Write("\"></th>");
            base.SanitizingResponse.Write("<th>");
            base.SanitizingResponse.Write(LocalizedStrings.GetNonEncoded(796893232));
            base.SanitizingResponse.Write("</th>");
            base.SanitizingResponse.Write("<th align=\"right\" class=\"sze\">");
            base.SanitizingResponse.Write(LocalizedStrings.GetNonEncoded(-837446919));
            base.SanitizingResponse.Write("</th>");
            base.SanitizingResponse.Write("<th class=\"rtcrnr\"><img src=\"");
            base.SanitizingResponse.Write(base.UserContext.GetThemeFileUrl(ThemeFileId.Clear));
            base.SanitizingResponse.Write("\" alt=\"\" class=\"invimg\"></th>");
            base.SanitizingResponse.Write("</tr>");
            if (this.attachmentList.Count > 0)
            {
                string value = null;
                for (int i = 0; i < this.attachmentList.Count; i++)
                {
                    string arg;
                    if (i == 0)
                    {
                        arg   = "class=\"frst\"";
                        value = "frst ";
                    }
                    else
                    {
                        arg   = null;
                        value = null;
                    }
                    attachmentWellInfo = (this.attachmentList[i] as AttachmentWellInfo);
                    base.SanitizingResponse.Write("<tr>");
                    base.SanitizingResponse.Write("<td {0} style=\"padding:0 0 0 0;\"><img src=\"{1}\" alt=\"\" class=\"invimg\"></td>", arg, base.UserContext.GetThemeFileUrl(ThemeFileId.Clear));
                    base.SanitizingResponse.Write("<td {0}><input type=checkbox name=\"{1}\" id=\"{1}\" value=\"{2}\" onclick=\"onClkChkBx(this);\"></td>", arg, "dLst", attachmentWellInfo.AttachmentId.ToBase64String());
                    base.SanitizingResponse.Write("<td {0}>", arg);
                    bool flag = false;
                    if (attachmentWellInfo.AttachmentType == AttachmentType.EmbeddedMessage)
                    {
                        using (Attachment attachment = attachmentWellInfo.OpenAttachment())
                        {
                            ItemAttachment itemAttachment = attachment as ItemAttachment;
                            if (itemAttachment != null)
                            {
                                using (Item item = itemAttachment.GetItem())
                                {
                                    flag = true;
                                    AttachmentWell.RenderAttachmentLinkForItem(base.SanitizingResponse, attachmentWellInfo, item, this.messageIdString, base.UserContext, previousAttachmentDisplayNames, AttachmentWell.AttachmentWellFlags.None, false);
                                }
                            }
                        }
                    }
                    if (!flag)
                    {
                        AttachmentWell.RenderAttachmentLink(base.SanitizingResponse, AttachmentWellType.ReadWrite, attachmentWellInfo, this.messageIdString, base.UserContext, previousAttachmentDisplayNames, AttachmentWell.AttachmentWellFlags.None, false);
                    }
                    base.SanitizingResponse.Write("</td>");
                    base.SanitizingResponse.Write("<td colspan=2 class=\"");
                    base.SanitizingResponse.Write(value);
                    base.SanitizingResponse.Write("sze\">");
                    double num = 0.0;
                    if (attachmentWellInfo.Size > 0L)
                    {
                        num = (double)attachmentWellInfo.Size / 1024.0 / 1024.0;
                        num = Math.Round(num, 2);
                        this.attachUsage += num;
                    }
                    if (num == 0.0)
                    {
                        base.SanitizingResponse.Write(" < 0.01");
                    }
                    else
                    {
                        base.SanitizingResponse.Write(num);
                    }
                    base.SanitizingResponse.Write(" MB</td>");
                    base.SanitizingResponse.Write("</tr>");
                }
            }
            else
            {
                base.SanitizingResponse.Write("<tr>");
                base.SanitizingResponse.Write("<td colspan=5 class=\"noattach\" nowrap>");
                base.SanitizingResponse.Write(LocalizedStrings.GetNonEncoded(-1907299050));
                base.SanitizingResponse.Write("</td>");
                base.SanitizingResponse.Write("</tr>");
            }
            base.SanitizingResponse.Write("</table>");
            base.SanitizingResponse.Write("</div>");
            Utilities.RenderCanaryHidden(base.SanitizingResponse, base.UserContext);
            base.SanitizingResponse.Write("</form>");
        }