Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
        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;
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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;
        }
        public void Open(string endPoint, NetworkCredential credentials)
        {
            EndpointAddress endpointAddress =
                new EndpointAddress($"net.tcp://{endPoint}:2660/CoreService/2013/netTcp" ??
                                    "CoreService");
            var netTcpBinding = new NetTcpBinding
            {
                Name                   = "netTcp_2013",
                TransactionFlow        = true,
                TransactionProtocol    = TransactionProtocol.OleTransactions,
                MaxReceivedMessageSize = 10485760,
                ReaderQuotas           = new XmlDictionaryReaderQuotas
                {
                    MaxStringContentLength = 10485760,
                    MaxArrayLength         = 10485760
                }
            };

            //_client = new SessionAwareCoreServiceClient(netTcpBinding, endpointAddress);

            //if (credentials != null)
            //{
            //    _client.ChannelFactory.Credentials.Windows.ClientCredential = credentials;
            //}

            ChannelFactory <ISessionAwareCoreService> factory = new ChannelFactory <ISessionAwareCoreService>(netTcpBinding, endpointAddress);

            factory.Credentials.Windows.ClientCredential = credentials; //new System.Net.NetworkCredential(username, password);

            _client  = factory.CreateChannel();
            _factory = factory;
        }
Exemplo n.º 8
0
        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;
        }
        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);
        }
Exemplo n.º 10
0
        private static string GetLanguageById(int languageId, ISessionAwareCoreService client)
        {
            if (languageId > 0)
            {
                var languages = client.GetTridionLanguages();
                if (languages != null)
                {
                    var language = languages.FirstOrDefault(l => l.LanguageId == languageId);
                    if (language != null)
                    {
                        return(language.NativeName);
                    }
                }
            }

            return(Resources.NotSet);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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;
        }
Exemplo n.º 13
0
        protected static string LookUpTemplateType(string templateType, ItemType itemType, ISessionAwareCoreService client)
        {
            var templateTypes = client.GetListTemplateTypes(itemType);
            var found         = templateTypes != null?templateTypes.FirstOrDefault(t => t.Name == templateType) : null;

            return(found != null ? found.Title : templateType);
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        private static string GetLanguageById(int languageId, ISessionAwareCoreService client)
        {
            if (languageId > 0)
            {
                var languages = client.GetTridionLanguages();
                if (languages != null)
                {
                    var language = languages.FirstOrDefault(l => l.LanguageId == languageId);
                    if (language != null)
                    {
                        return language.NativeName;
                    }
                }
            }

            return Resources.NotSet;
        }
 public ElevatedPrivilegesScope(ISessionAwareCoreService client, Privileges privileges)
 {
     this._client = client;
     this._client.ElevatePrivileges(privileges);
 }
Exemplo n.º 17
0
 protected static string LookUpTemplateType(string templateType, ItemType itemType, ISessionAwareCoreService client)
 {
     var templateTypes = client.GetListTemplateTypes(itemType);
     var found = templateTypes != null ? templateTypes.FirstOrDefault(t => t.Name == templateType) : null;
     return found != null ? found.Title : templateType;
 }