Example #1
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;
                        }
                    }
                }
            }
        }