Пример #1
0
        public static async Task SeedAttachmentType(ApplicationDbContext _context)
        {
            if (_context.ItemAttachmentTypes.Count() == 0)
            {
                ItemAttachmentType InSide = new ItemAttachmentType
                {
                    Name = "InSide"
                };
                await _context.AddAsync(InSide);

                await _context.SaveChangesAsync();

                ItemAttachmentType OutSide = new ItemAttachmentType
                {
                    Name = "OutSide"
                };
                await _context.AddAsync(OutSide);

                await _context.SaveChangesAsync();

                ItemAttachmentType VideoLink = new ItemAttachmentType
                {
                    Name = "VideoLink"
                };
                await _context.AddAsync(VideoLink);

                await _context.SaveChangesAsync();
            }
        }
Пример #2
0
        // Token: 0x0600199B RID: 6555 RVA: 0x0005A370 File Offset: 0x00058570
        internal static CreateAttachmentResponse CreateAttachmentResponse(AttachmentHierarchy attachmentHierarchy, Attachment attachment, AttachmentType attachmentType, IdAndSession parentIdAndSession, ServiceError warning)
        {
            IdAndSession idAndSession = parentIdAndSession.Clone();

            attachment.Load();
            idAndSession.AttachmentIds.Add(attachment.Id);
            AttachmentType attachmentType2;

            if (attachment is StreamAttachment)
            {
                attachmentType2 = new FileAttachmentType();
            }
            else if (attachment is ReferenceAttachment)
            {
                attachmentType2 = new ReferenceAttachmentType();
                ((ReferenceAttachmentType)attachmentType2).AttachLongPathName  = (string)attachment.TryGetProperty(AttachmentSchema.AttachLongPathName);
                ((ReferenceAttachmentType)attachmentType2).ProviderType        = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderType);
                ((ReferenceAttachmentType)attachmentType2).ProviderEndpointUrl = (string)attachment.TryGetProperty(AttachmentSchema.AttachmentProviderEndpointUrl);
                object obj = attachment.TryGetProperty(AttachmentSchema.AttachContentId);
                if (!(obj is PropertyError))
                {
                    ((ReferenceAttachmentType)attachmentType2).ContentId = (string)obj;
                }
                attachmentType2.Name = attachmentType.Name;
            }
            else
            {
                attachmentType2 = new ItemAttachmentType();
            }
            attachmentType2.AttachmentId = new AttachmentIdType(idAndSession.GetConcatenatedId().Id);
            if (attachmentType is ItemIdAttachmentType || attachmentType is ReferenceAttachmentType)
            {
                attachmentType2.Size = ((attachment.Size > 2147483647L) ? int.MaxValue : ((int)attachment.Size));
            }
            CreateAttachmentResponse       createAttachmentResponse = new CreateAttachmentResponse();
            ServiceResult <AttachmentType> serviceResult            = (warning == null) ? new ServiceResult <AttachmentType>(attachmentType2) : new ServiceResult <AttachmentType>(attachmentType2, warning);

            attachmentHierarchy.RootItem.Load();
            if (serviceResult.Value != null)
            {
                ConcatenatedIdAndChangeKey concatenatedId = IdConverter.GetConcatenatedId(attachmentHierarchy.RootItem.Id, parentIdAndSession, null);
                serviceResult.Value.AttachmentId.RootItemId        = concatenatedId.Id;
                serviceResult.Value.AttachmentId.RootItemChangeKey = concatenatedId.ChangeKey;
            }
            createAttachmentResponse.AddResponses(new ServiceResult <AttachmentType>[]
            {
                serviceResult
            });
            return(createAttachmentResponse);
        }
Пример #3
0
        /// <summary>
        /// Creates an item or file attachment on an item.
        /// </summary>
        /// <param name="parentItemId">Identifies the parent item in the server store that contains the attachment.</param>
        /// <param name="attachmentsType">Attachment type.</param>
        /// <returns>A response message for "CreateAttachment" operation.</returns>
        protected CreateAttachmentResponseType CallCreateAttachmentOperation(string parentItemId, params AttachmentTypeValue[] attachmentsType)
        {
            // Configure attachments.
            int attachmentCount = attachmentsType.Length;

            this.Attachments = new AttachmentType[attachmentCount];
            for (int attachmentIndex = 0; attachmentIndex < attachmentCount; attachmentIndex++)
            {
                AttachmentType attachment = null;

                if (attachmentsType[attachmentIndex] == AttachmentTypeValue.FileAttachment)
                {
                    FileAttachmentType fileAttachment = new FileAttachmentType()
                    {
                        ContentLocation = @"http://www.contoso.com/xyz.abc",
                        Name            = "attach.jpg",

                        // Ensure content id is unique.
                        ContentId   = Guid.NewGuid().ToString(),
                        ContentType = "image/jpeg",
                        Content     = Convert.FromBase64String("/9j/4AAQSkZJRgABAQEAYABgAAD/7AARRHVja3kAAQAEAAAARgAA/9sAQwACAQECAQECAgICAgICAgMFAwMDAwMGBAQDB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PqLxp8PG8feIrjU5dG8O60ZWMYuDeW1tjyyUKeWzALtZWGFG3Oe+aK/OP4ja3c+CfiZ4m07TJTbWdvq90iIQJSAsrKMs+WJwo6miuFZRbT2svvX+QoZTQirXf4f5H/2Q==")
                    };

                    attachment = fileAttachment;
                }
                else if (attachmentsType[attachmentIndex] == AttachmentTypeValue.ReferenceAttachment)
                {
                    ReferenceAttachmentType referenceAttachment = new ReferenceAttachmentType()
                    {
                        AttachLongPathName     = @"http://www.contoso.com/xyz.abc",
                        ProviderType           = "abc",
                        ProviderEndpointUrl    = @"http://www.contoso.com",
                        AttachmentPreviewUrl   = @"http://www.contoso.com/Preview.abc",
                        AttachmentThumbnailUrl = @"http://www.contoso.com/Thumbnail.abc",
                        ContentLocation        = @"http://www.contoso.com/xyz.abc",
                        Name        = "RefAttachment",
                        ContentId   = Guid.NewGuid().ToString(),
                        ContentType = "image/jpeg",
                    };

                    attachment = referenceAttachment;
                }
                else
                {
                    ItemAttachmentType itemAttachment = new ItemAttachmentType()
                    {
                        ContentLocation = @"http://www.contoso.com/xyz.abc",
                        Name            = "ItemName",

                        // Ensure content id is unique.
                        ContentId   = Guid.NewGuid().ToString(),
                        ContentType = "image/jpeg",
                    };

                    switch (attachmentsType[attachmentIndex])
                    {
                    case AttachmentTypeValue.ItemAttachment:
                        itemAttachment.Item = new ItemType();
                        break;

                    case AttachmentTypeValue.MessageAttachment:
                        itemAttachment.Item = new MessageType()
                        {
                            Body = new BodyType()
                            {
                                BodyType1 = BodyTypeType.HTML,
                                Value     = "<html><body><b>Bold</b><script>alert('Alert!');</script></body></html>"
                            },
                        };
                        break;

                    case AttachmentTypeValue.CalendarAttachment:
                        itemAttachment.Item = new CalendarItemType()
                        {
                            StartSpecified = true,
                            EndSpecified   = true
                        };
                        break;

                    case AttachmentTypeValue.ContactAttachment:
                        itemAttachment.Item = new ContactItemType();
                        break;

                    case AttachmentTypeValue.PostAttachment:
                        itemAttachment.Item = new PostItemType();
                        break;

                    case AttachmentTypeValue.TaskAttachment:
                        itemAttachment.Item = new TaskType();
                        break;

                    case AttachmentTypeValue.MeetingMessageAttachemnt:
                        itemAttachment.Item = new MeetingMessageType();
                        break;

                    case AttachmentTypeValue.MeetingRequestAttachment:
                        itemAttachment.Item = new MeetingRequestMessageType();
                        break;

                    case AttachmentTypeValue.MeetingResponseAttachment:
                        itemAttachment.Item = new MeetingResponseMessageType();
                        break;

                    case AttachmentTypeValue.MeetingCancellationAttachment:
                        itemAttachment.Item = new MeetingCancellationMessageType();
                        break;

                    case AttachmentTypeValue.PersonAttachment:
                        itemAttachment.Item = new AbchPersonItemType()
                        {
                            AntiLinkInfo   = "",
                            PersonId       = Guid.NewGuid().ToString(),
                            ContactHandles = new AbchPersonContactHandle[] {
                                new AbchPersonContactHandle(),
                            },
                            ContactCategories = new string[] {
                                "test category"
                            },
                        };
                        break;
                    }

                    attachment = itemAttachment;
                }

                this.Attachments[attachmentIndex] = attachment;
            }

            CreateAttachmentType createAttachmentRequest = new CreateAttachmentType()
            {
                ParentItemId = new ItemIdType()
                {
                    Id = parentItemId
                },
                Attachments = this.Attachments
            };

            return(this.ATTAdapter.CreateAttachment(createAttachmentRequest));
        }