Esempio n. 1
0
        internal static void CoreObjectUpdateReferenceAttachmentName(CoreAttachment coreAttachment)
        {
            ICorePropertyBag propertyBag = coreAttachment.PropertyBag;
            string           text        = propertyBag.TryGetProperty(InternalSchema.DisplayName) as string;
            string           text2       = propertyBag.TryGetProperty(InternalSchema.AttachExtension) as string;

            if (!string.IsNullOrEmpty(text))
            {
                text = Attachment.TrimFilename(text);
                propertyBag[InternalSchema.DisplayName] = text;
            }
            if (!string.IsNullOrEmpty(text2))
            {
                text2 = '.' + Attachment.TrimFilename(text2);
                propertyBag[InternalSchema.AttachExtension] = (text2 ?? string.Empty);
            }
        }
        internal static void CoreObjectUpdateStreamAttachmentName(CoreAttachment coreAttachment)
        {
            ICorePropertyBag propertyBag = coreAttachment.PropertyBag;
            string           text        = (propertyBag.TryGetProperty(InternalSchema.AttachLongFileName) as string) ?? (propertyBag.TryGetProperty(InternalSchema.AttachFileName) as string);
            string           text2       = propertyBag.TryGetProperty(InternalSchema.DisplayName) as string;
            string           text3       = propertyBag.TryGetProperty(InternalSchema.AttachExtension) as string;

            if (!string.IsNullOrEmpty(text))
            {
                text = Attachment.TrimFilename(text);
            }
            if (!string.IsNullOrEmpty(text2))
            {
                text2 = Attachment.TrimFilename(text2);
            }
            if (!string.IsNullOrEmpty(text3))
            {
                text3 = '.' + Attachment.TrimFilename(text3);
            }
            string text4 = null;
            string text5 = null;
            string text6 = null;
            string text7 = null;

            Attachment.TryFindFileExtension(text, out text5, out text4);
            Attachment.TryFindFileExtension(text2, out text7, out text6);
            if (!string.IsNullOrEmpty(text5))
            {
                text3 = text5;
            }
            if (!string.IsNullOrEmpty(text7) && string.Compare(text3, text7, StringComparison.OrdinalIgnoreCase) != 0)
            {
                text6 += text7;
            }
            if (string.IsNullOrEmpty(text4))
            {
                text4 = Attachment.GenerateFilename();
            }
            if (EmailMessageHelpers.IsGeneratedFileName(text4) && string.IsNullOrEmpty(text3))
            {
                string text8 = propertyBag.TryGetProperty(InternalSchema.AttachMimeTag) as string;
                if (!string.IsNullOrEmpty(text8))
                {
                    text3 = StreamAttachmentBase.GetExtensionByContentType(text8);
                }
            }
            if (string.IsNullOrEmpty(text6))
            {
                text6 = text4;
            }
            if (!string.IsNullOrEmpty(text3))
            {
                text  = text4 + text3;
                text2 = text6 + text3;
            }
            else
            {
                text  = text4;
                text2 = text6;
                propertyBag.Delete(InternalSchema.AttachExtension);
            }
            propertyBag[InternalSchema.AttachLongFileName] = text;
            propertyBag[InternalSchema.DisplayName]        = text2;
            propertyBag[InternalSchema.AttachExtension]    = (text3 ?? string.Empty);
            bool      flag          = false;
            ICoreItem containerItem = coreAttachment.ParentCollection.ContainerItem;

            if (containerItem != null)
            {
                containerItem.PropertyBag.Load(new PropertyDefinition[]
                {
                    InternalSchema.IsAssociated
                });
                flag = containerItem.PropertyBag.GetValueOrDefault <bool>(InternalSchema.IsAssociated, false);
            }
            if (!flag)
            {
                propertyBag[InternalSchema.AttachFileName] = Attachment.Make8x3FileName(text, coreAttachment != null && coreAttachment.Session != null && coreAttachment.Session.IsMoveUser);
            }
        }