/// <summary>
        /// Initializes a new instance of the <see cref="TemplateBuildingBlock"/> class.
        /// </summary>
        /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
        /// <param name="templateData"><see cref="T:Tridion.ContentManager.CoreService.Client.TemplateBuildingBlockData" /></param>
        protected TemplateBuildingBlock(Client client, TemplateBuildingBlockData templateBuildingBlockData)
            : base(client, templateBuildingBlockData)
        {
            if (templateBuildingBlockData == null)
                throw new ArgumentNullException("templateBuildingBlockData");

            mTemplateBuildingBlockData = templateBuildingBlockData;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TemplateBuildingBlock"/> class.
        /// </summary>
        /// <param name="client"><see cref="T:TcmCoreService.Client" /></param>
        /// <param name="templateData"><see cref="T:Tridion.ContentManager.CoreService.Client.TemplateBuildingBlockData" /></param>
        protected TemplateBuildingBlock(Client client, TemplateBuildingBlockData templateBuildingBlockData) : base(client, templateBuildingBlockData)
        {
            if (templateBuildingBlockData == null)
            {
                throw new ArgumentNullException("templateBuildingBlockData");
            }

            mTemplateBuildingBlockData = templateBuildingBlockData;
        }
        /// <summary>
        /// Reload the <see cref="TemplateBuildingBlock" /> with the specified <see cref="T:Tridion.ContentManager.CoreService.Client.TemplateBuildingBlockData" />
        /// </summary>
        /// <param name="templateBuildingBlockData"><see cref="T:Tridion.ContentManager.CoreService.Client.TemplateBuildingBlockData" /></param>
        protected void Reload(TemplateBuildingBlockData templateBuildingBlockData)
        {
            if (templateBuildingBlockData == null)
            {
                throw new ArgumentNullException("templateBuildingBlockData");
            }

            mTemplateBuildingBlockData = templateBuildingBlockData;
            base.Reload(templateBuildingBlockData);

            mApprovalStatus = null;
            mWorkflow       = null;
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public static ImportItem CreateTBB(TemplateBuildingBlockData templateBuildingBlockData)
        {
            var importItem = new ImportItem()
            {
                ItemType     = ItemType.TemplateBuildingBlock,
                Name         = templateBuildingBlockData.Title,
                Content      = templateBuildingBlockData.Content,
                TemplateType = templateBuildingBlockData.TemplateType,
                SourceId     = templateBuildingBlockData.Id
            };

            if (templateBuildingBlockData.BinaryContent?.Filename.ToLowerInvariant().Contains("dyndle.templates.merged") ?? false)
            {
                importItem.IsDyndleMergedDll = true;
            }

            if (templateBuildingBlockData.ParameterSchema != null && templateBuildingBlockData.ParameterSchema.IdRef != "tcm:0-0-0")
            {
                importItem.ParameterSchemaId = templateBuildingBlockData.ParameterSchema.IdRef;
            }
            return(importItem);
        }
        public static bool SaveRazorLayoutTbb(MappingInfo mapping, string title, string code, string tcmContainer, out string stackTraceMessage)
        {
            stackTraceMessage = "";

            if (!EnsureValidClient(mapping))
                return false;

            if (ExistsItem(mapping, tcmContainer, title))
            {
                string id = GetItemTcmId(mapping, tcmContainer, title);
                if (String.IsNullOrEmpty(id))
                    return false;

                return SaveRazorLayoutTbb(mapping, id, code, out stackTraceMessage);
            }

            try
            {
                TemplateBuildingBlockData tbbData = new TemplateBuildingBlockData
                {
                    Content = code,
                    Title = title,
                    LocationInfo = new LocationInfo { OrganizationalItem = new LinkToOrganizationalItemData { IdRef = tcmContainer } },
                    Id = "tcm:0-0-0",
                    TemplateType = "RazorTemplate"
                };

                tbbData = Client.Save(tbbData, new ReadOptions()) as TemplateBuildingBlockData;
                if (tbbData == null)
                    return false;

                Client.CheckIn(tbbData.Id, true, "Saved from TridionVSRazorExtension", new ReadOptions());
                return true;
            }
            catch (Exception ex)
            {
                stackTraceMessage = ex.Message;
                return false;
            }
        }
        /// <summary>
        /// Reload the <see cref="TemplateBuildingBlock" /> with the specified <see cref="T:Tridion.ContentManager.CoreService.Client.TemplateBuildingBlockData" />
        /// </summary>
        /// <param name="templateBuildingBlockData"><see cref="T:Tridion.ContentManager.CoreService.Client.TemplateBuildingBlockData" /></param>
        protected void Reload(TemplateBuildingBlockData templateBuildingBlockData)
        {
            if (templateBuildingBlockData == null)
                throw new ArgumentNullException("templateBuildingBlockData");

            mTemplateBuildingBlockData = templateBuildingBlockData;
            base.Reload(templateBuildingBlockData);

            mApprovalStatus = null;
            mWorkflow = null;
        }