Exemplo n.º 1
0
            protected void SetPropertyValues(Entity annotation, DataAdapterDependencies dataAdapterDependencies)
            {
                var website = dataAdapterDependencies.GetWebsite();

                CreatedOn        = annotation.GetAttributeValue <DateTime?>("createdon").GetValueOrDefault();
                CreatedOnDisplay = CreatedOn.ToString(DateTimeClientFormat);
                var text = annotation.GetAttributeValue <string>("notetext");

                Text                  = AnnotationHelper.FormatNoteText(text).ToString();
                UnformattedText       = text.Replace(AnnotationHelper.WebAnnotationPrefix, string.Empty);
                AttachmentFileName    = annotation.GetAttributeValue <string>("filename");
                HasAttachment         = !string.IsNullOrEmpty(AttachmentFileName);
                AttachmentContentType = annotation.GetAttributeValue <string>("mimetype");
                AttachmentUrl         = HasAttachment ? annotation.GetFileAttachmentUrl(website) : string.Empty;
                var filesize = annotation.GetAttributeValue <int?>("filesize").GetValueOrDefault(0);

                AttachmentSize        = new FileSize(Convert.ToUInt64(filesize < 0 ? 0 : filesize));
                AttachmentSizeDisplay = AttachmentSize.ToString();
                AttachmentIsImage     = HasAttachment && (new List <string> {
                    "image/jpeg", "image/gif", "image/png"
                }).Contains(AttachmentContentType);
                var subject = annotation.GetAttributeValue <string>("subject");

                Subject   = subject;
                IsPrivate = AnnotationHelper.GetNotePrivacy(annotation);
                var noteContact = AnnotationHelper.GetNoteContact(subject);
                var user        = dataAdapterDependencies.GetPortalUser();

                IsPostedByCurrentUser = noteContact != null && user != null && noteContact.Id == user.Id;
                PostedByName          = noteContact == null?AnnotationHelper.GetNoteCreatedByName(annotation) : noteContact.Name;

                if (CanWrite)
                {
                    CanWrite = IsPostedByCurrentUser;
                }
                if (CanDelete)
                {
                    CanDelete = IsPostedByCurrentUser;
                }
                DisplayToolbar = CanWrite || CanDelete;
            }
            protected void SetPropertyValues(IAnnotation annotation, DataAdapterDependencies dataAdapterDependencies)
            {
                CreatedOn        = annotation.CreatedOn;
                CreatedOnDisplay = CreatedOn.ToString(DateTimeClientFormat);
                var text = annotation.NoteText;

                Text            = AnnotationHelper.FormatNoteText(text).ToString();
                UnformattedText = text.Replace(AnnotationHelper.WebAnnotationPrefix, string.Empty);
                if (annotation.FileAttachment != null)
                {
                    AttachmentFileName    = annotation.FileAttachment.FileName;
                    HasAttachment         = annotation.FileAttachment != null;
                    AttachmentContentType = annotation.FileAttachment.MimeType;
                    AttachmentUrl         = HasAttachment
                                                ? annotation.Entity.GetFileAttachmentUrl(dataAdapterDependencies.GetWebsite())
                                                : string.Empty;
                    AttachmentSize        = annotation.FileAttachment.FileSize;
                    AttachmentSizeDisplay = AttachmentSize.ToString();
                    AttachmentIsImage     = HasAttachment &&
                                            (new List <string> {
                        "image/jpeg", "image/gif", "image/png"
                    }).Contains(AttachmentContentType);
                }
                var subject = annotation.Subject;

                Subject   = subject;
                IsPrivate = AnnotationHelper.GetNotePrivacy(annotation);
                var noteContact = AnnotationHelper.GetNoteContact(subject);
                var user        = dataAdapterDependencies.GetPortalUser();

                IsPostedByCurrentUser = noteContact != null && user != null && noteContact.Id == user.Id;
                PostedByName          = noteContact == null?AnnotationHelper.GetNoteCreatedByName(annotation) : noteContact.Name;

                if (CanWrite)
                {
                    CanWrite = IsPostedByCurrentUser;
                }
                if (CanDelete)
                {
                    CanDelete = IsPostedByCurrentUser;
                }
                DisplayToolbar = CanWrite || CanDelete;
            }