예제 #1
0
        public static UserResult From(UserData item, ISessionAwareCoreService client)
        {
            var result = new UserResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription)
            };

            if (item.IsEnabled == false)
            {
                result.Status = TextEntry.From(Resources.Disabled, Resources.LabelStatus);
            }
            if (item.Privileges == 1)
            {
                result.IsAdministrator = TextEntry.From(Resources.Yes, Resources.LabelIsAdministrator);
            }
            if (item.LanguageId != null)
            {
                result.Language = TextEntry.From(GetLanguageById(item.LanguageId.Value, client), Resources.LabelLanguage);
            }
            if (item.LocaleId != null)
            {
                result.Locale = TextEntry.From(GetLocaleById(item.LocaleId.Value), Resources.LabelLocale);
            }
            if (item.GroupMemberships != null)
            {
                result.GroupMemberships = TextEntry.From(GetGroupMembershipSummary(item.GroupMemberships), Resources.LabelGroupMemberships);
            }

            AddCommonProperties(item, result);
            return(result);
        }
예제 #2
0
        public static ComponentTemplateResult From(ComponentTemplateData item, ISessionAwareCoreService client, string currentUserId)
        {
            var result = new ComponentTemplateResult
            {
                TemplateType = TextEntry.From(LookUpTemplateType(item.TemplateType, ItemType.ComponentTemplate, client), Resources.LabelTemplateType)
            };

            if (item.IsRepositoryPublishable == true)
            {
                string dynamicTemplate = Resources.DynamicTemplateNotAllowedOnPage;
                if (item.AllowOnPage == true)
                {
                    dynamicTemplate = Resources.DynamicTemplateAllowedOnPage;
                }
                result.DynamicTemplateInfo = TextEntry.From(dynamicTemplate, Resources.LabelDynamicTemplateInfo);
            }

            if (item.Priority != null)
            {
                string priority = Resources.PriorityNeverLink;
                switch (item.Priority.Value)
                {
                case 300: priority = Resources.PriorityHigh; break;

                case 200: priority = Resources.PriorityMedium; break;

                case 100: priority = Resources.PriorityLow; break;
                }
                result.Priority = TextEntry.From(priority, Resources.LabelPriority);
            }

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #3
0
        public static PageResult From(PageData item, ISessionAwareCoreService client, string currentUserId)
        {
            var    template  = (PageTemplateData)client.Read(item.PageTemplate.IdRef, new ReadOptions());
            string extension = template.FileExtension;

            var result = new PageResult
            {
                Template = LinkEntry.From(item.PageTemplate, Resources.LabelTemplate, currentUserId),
                FileName = TextEntry.From(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", item.FileName, extension), Resources.LabelFileName),
            };

            if (result.FileName != null)
            {
                result.PathOnWebsite = GetPublishPath(item.LocationInfo as PublishLocationInfo, result.FileName.Value);
            }

            string componentPresentations = Resources.None;

            if (item.ComponentPresentations.Any())
            {
                int count         = item.ComponentPresentations.Count();
                int templateCount = item.ComponentPresentations.DistinctBy(cp => cp.ComponentTemplate.IdRef).Count();
                componentPresentations = (templateCount == 1)
                    ? string.Format(CultureInfo.InvariantCulture, Resources.ComponentPresentationSummarySameTemplate, count)
                    : string.Format(CultureInfo.InvariantCulture, Resources.ComponentPresentationSummary, count, templateCount);
            }

            result.ComponentPresentations = TextEntry.From(componentPresentations, Resources.LabelComponentPresentations);

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #4
0
        protected static void AddPropertiesForRepositoryLocalObject(RepositoryLocalObjectData rlo, PeekResult result, string currentUserId)
        {
            if (rlo == null)
            {
                return;
            }

            result.LockedBy       = LinkEntry.From(rlo.LockInfo.LockUser, Resources.LabelLockedBy, currentUserId);
            result.MetadataSchema = LinkEntry.From(rlo.MetadataSchema, Resources.LabelMetadataSchema, currentUserId);

            if (rlo.LocationInfo != null)
            {
                result.WebDavUrl = TextEntry.From(rlo.LocationInfo.WebDavUrl, Resources.LabelWebDavUrl);
            }

            FullVersionInfo versionInfo = rlo.VersionInfo as FullVersionInfo;

            if (versionInfo != null)
            {
                if (result.CreationDate != null)
                {
                    result.CreationDate.User = GetUserTitle(versionInfo.Creator, currentUserId);
                }

                if (result.RevisionDate != null)
                {
                    result.RevisionDate.User = GetUserTitle(versionInfo.Revisor, currentUserId);
                }

                if (versionInfo.LastVersion != null && versionInfo.LastVersion.Value > 1)
                {
                    result.Versions = NumberEntry.From(versionInfo.LastVersion.Value, Resources.LabelVersions);
                }
            }
        }
        public static TargetTypeResult From(TargetTypeData item)
        {
            var result = new TargetTypeResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription)
            };

            AddCommonProperties(item, result);
            return(result);
        }
        public static MultimediaTypeResult From(MultimediaTypeData item)
        {
            var result = new MultimediaTypeResult
            {
                MimeType = TextEntry.From(item.MimeType, Resources.LabelMimeType),
                FileExtensions = TextEntry.From(string.Join(", ", item.FileExtensions), Resources.LabelFileExtensions)
            };

            AddCommonProperties(item, result);
            return result;
        }
예제 #7
0
        public static VirtualFolderResult From(VirtualFolderData item, string currentUserId)
        {
            var result = new VirtualFolderResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
        public static PageTemplateResult From(PageTemplateData item, ISessionAwareCoreService client, string currentUserId)
        {
            var result = new PageTemplateResult
            {
                Extension    = TextEntry.From(item.FileExtension, Resources.LabelExtension),
                TemplateType = TextEntry.From(LookUpTemplateType(item.TemplateType, ItemType.PageTemplate, client), Resources.LabelTemplateType)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #9
0
        public static TemplateBuildingBlockResult From(TemplateBuildingBlockData item, ISessionAwareCoreService client, string currentUserId)
        {
            var result = new TemplateBuildingBlockResult
            {
                ParametersSchema = LinkEntry.From(item.ParameterSchema, Resources.LabelParametersSchema, currentUserId),
                MetadataSchema   = LinkEntry.From(item.MetadataSchema, Resources.LabelMetadataSchema, currentUserId),
                TemplateType     = TextEntry.From(LookUpTemplateType(item.TemplateType, ItemType.TemplateBuildingBlock, client), Resources.LabelTemplateType)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
        public static TargetGroupResult From(TargetGroupData item, string currentUserId)
        {
            int count  = item.Conditions.Count();
            var result = new TargetGroupResult
            {
                Description    = TextEntry.From(item.Description, Resources.LabelDescription),
                MetadataSchema = LinkEntry.From(item.MetadataSchema, Resources.LabelMetadataSchema, currentUserId),
                Conditions     = TextEntry.From(count > 0 ? count.ToString(CultureInfo.InvariantCulture) : Resources.None, Resources.LabelConditions)
            };

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #11
0
        protected static TextEntry GetPublishPath(PublishLocationInfo publishInfo, string appendText)
        {
            if (publishInfo != null)
            {
                string path = publishInfo.PublishPath.Replace(@"\", "/");
                if (!string.IsNullOrWhiteSpace(appendText))
                {
                    path = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", path.TrimEnd('/'), appendText);
                }
                return(TextEntry.From(path, Resources.LabelPathOnWebsite));
            }

            return(null);
        }
예제 #12
0
        public static SchemaResult From(SchemaData item, string currentUserId)
        {
            var result = new SchemaResult
            {
                Description     = TextEntry.From(item.Description, Resources.LabelDescription),
                Namespace       = TextEntry.From(item.NamespaceUri, Resources.LabelNamespace),
                RootElementName = TextEntry.From(item.RootElementName, Resources.LabelRootElementName)
            };

            AddFieldsSummary(item, result);
            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
        public static PublicationTargetResult From(PublicationTargetData item)
        {
            var result = new PublicationTargetResult
            {
                Description    = TextEntry.From(item.Description, Resources.LabelDescription),
                TargetLanguage = TextEntry.From(item.TargetLanguage, Resources.LabelTargetLanguage)
            };

            if (item.DefaultCodePage != null)
            {
                string codePage = "System Default";
                if (item.DefaultCodePage > 0)
                {
                    var encoding = Encoding.GetEncodings().FirstOrDefault(e => e.CodePage == item.DefaultCodePage);
                    if (encoding != null)
                    {
                        codePage = encoding.DisplayName;
                    }
                }
                result.DefaultCodePage = TextEntry.From(codePage, Resources.LabelDefaultCodePage);
            }

            if (item.Priority != null)
            {
                string priority = Resources.PriorityMedium;

                switch (item.Priority.Value)
                {
                case PublishPriority.High:
                    priority = Resources.PriorityHigh;
                    break;

                case PublishPriority.Low:
                    priority = Resources.PriorityLow;
                    break;
                }

                result.Priority = TextEntry.From(priority, Resources.LabelPriority);
            }

            var destinations = item.Destinations.Select(
                destination => string.Format(Resources.PublicationTargetDestination, destination.Title, destination.ProtocolSchema.Title)
                ).ToList();

            result.Destinations = TextEntry.From(string.Join(", ", destinations), Resources.LabelDestinations);

            AddCommonProperties(item, result);
            return(result);
        }
예제 #14
0
        public static PublicationResult From(PublicationData item, string currentUserId)
        {
            var result = new PublicationResult
            {
                Key             = TextEntry.From(item.Key, Resources.LabelKey),
                PublicationPath = TextEntry.From(item.PublicationPath, Resources.LabelPublicationPath),
                PublicationUrl  = TextEntry.From(item.PublicationUrl, Resources.LabelPublicationUrl),
                MultimediaPath  = TextEntry.From(item.MultimediaPath, Resources.LabelMultimediaPath),
                MultimediaUrl   = TextEntry.From(item.MultimediaUrl, Resources.LabelMultimediaUrl),
                WebDavUrl       = TextEntry.From(item.LocationInfo.WebDavUrl, Resources.LabelWebDavUrl)
            };

            AddCommonProperties(item, result);
            return(result);
        }
예제 #15
0
        public static KeywordResult From(KeywordData item, string currentUserId)
        {
            var result = new KeywordResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription),
                Key         = TextEntry.From(item.Key, Resources.LabelKey)
            };

            if (item.IsAbstract == true)
            {
                result.IsAbstract = TextEntry.From(Resources.Yes, Resources.LabelIsAbstract);
            }


            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #16
0
        public static ComponentResult From(ComponentData item, string currentUserId)
        {
            var result = new ComponentResult {
                Schema = LinkEntry.From(item.Schema, Resources.LabelSchema, currentUserId)
            };

            if (item.ComponentType == ComponentType.Multimedia)
            {
                if (item.BinaryContent.FileSize != null)
                {
                    result.FileSize = TextEntry.From(FormatFileSize((long)item.BinaryContent.FileSize), Resources.LabelFileSize);
                }
                result.FileName = TextEntry.From(item.BinaryContent.Filename, Resources.LabelFileName);
            }

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #17
0
        public static GroupResult From(GroupData item)
        {
            var result = new GroupResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription)
            };


            if (item.GroupMemberships != null)
            {
                result.GroupMemberships = TextEntry.From(GetGroupMembershipSummary(item.GroupMemberships), Resources.LabelGroupMemberships);
            }

            string scope = item.Scope.Length > 0
                ? Resources.GroupScopeSpecificPublications
                : Resources.GroupScopeAllPublications;

            result.Scope = TextEntry.From(scope, Resources.LabelScope);

            AddCommonProperties(item, result);
            return(result);
        }
예제 #18
0
        public static StructureGroupResult From(StructureGroupData item, string currentUserId)
        {
            var result = new StructureGroupResult
            {
                Directory     = TextEntry.From(string.IsNullOrWhiteSpace(item.Directory) ? Resources.EmptyLabel : item.Directory, Resources.LabelDirectory),
                Template      = LinkEntry.From(item.DefaultPageTemplate, Resources.LabelTemplate, currentUserId),
                PathOnWebsite = GetPublishPath(item.LocationInfo as PublishLocationInfo, item.Directory)
            };

            if (item.IsActiveResolvedValue == false)
            {
                string publishable = Resources.CannotBePublished;
                if (item.IsActive == true)
                {
                    publishable = Resources.CannotBePublishedDueToAncestor;
                }
                result.Publishable = TextEntry.From(publishable, Resources.LabelPublishable);
            }

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }
예제 #19
0
        private static void AddFieldsSummary(SchemaData schema, SchemaResult result)
        {
            try
            {
                XDocument    doc      = XDocument.Parse(schema.Xsd);
                const string nameAttr = "name";

                if (!string.IsNullOrWhiteSpace(schema.RootElementName))
                {
                    var rootElement = doc.Descendants(schemaFields).FirstOrDefault(e => e.Attribute(nameAttr) != null && e.Attribute(nameAttr).Value == schema.RootElementName);
                    result.FieldsSummary = TextEntry.From(GetFieldSummary(rootElement, Resources.None), Resources.LabelFieldsSummary);
                }

                bool expectFields = (schema.Purpose == SchemaPurpose.Metadata ||
                                     schema.Purpose == SchemaPurpose.Multimedia ||
                                     schema.Purpose == SchemaPurpose.Bundle);

                var metadataRoot = doc.Descendants(schemaFields).FirstOrDefault(e => e.Attribute(nameAttr) != null && e.Attribute(nameAttr).Value == "Metadata");
                result.MetadataFieldsSummary = TextEntry.From(GetFieldSummary(metadataRoot, expectFields ? Resources.None : null), Resources.LabelMetadataFieldsSummary);
            }
            catch (System.Xml.XmlException)
            {
            }
        }
예제 #20
0
        public static CategoryResult From(CategoryData item, ISessionAwareCoreService client, string currentUserId)
        {
            var result = new CategoryResult
            {
                Description = TextEntry.From(item.Description, Resources.LabelDescription),
                XmlName     = TextEntry.From(item.XmlName, Resources.LabelXmlName)
            };

            if (item.UseForNavigation == false)
            {
                result.Publishable = TextEntry.From(Resources.CannotBePublished, Resources.LabelPublishable);
            }

            if (item.UseForIdentification == true)
            {
                result.UseForIdentification = TextEntry.From(Resources.Yes, Resources.LabelUseForIdentification);
            }

            result.LinkedSchema = LinkEntry.From(item.KeywordMetadataSchema, Resources.LabelLinkedSchema, currentUserId);

            AddCommonProperties(item, result);
            AddPropertiesForRepositoryLocalObject(item, result, currentUserId);
            return(result);
        }