コード例 #1
0
        /// <summary>
        /// GetPublishInfoData - Creates a PublishInfoData which is used to obtain a list of publishable items.
        /// </summary>
        /// <param name="parameters">PagePublisherParameters</param>
        /// <returns>GetPublishInfoData object</returns>
        private PublishInstructionData GetPublishInstructionData(PagePublisherParameters parameters)
        {
            ResolveInstructionData resolveInstruction = new ResolveInstructionData();

            resolveInstruction.IncludeChildPublications = parameters.PublishChildren;
            resolveInstruction.IncludeComponentLinks    = parameters.IncludeComponentLinks ? true : false;
            resolveInstruction.StructureResolveOption   = parameters.IncludeStructureGroups ? StructureResolveOption.ItemsAndStructure : StructureResolveOption.OnlyItems;
            resolveInstruction.IncludeWorkflow          = parameters.IncludeWorkflow ? true : false;
            resolveInstruction.Purpose = parameters.Republish ? ResolvePurpose.RePublish : ResolvePurpose.Publish;

            RenderInstructionData renderInstruction = new RenderInstructionData();

            renderInstruction.RenderMode = RenderMode.Publish;


            PublishInstructionData instruction = new PublishInstructionData();

            instruction.RollbackOnFailure             = true;
            instruction.MaximumNumberOfRenderFailures = 1;
            instruction.ResolveInstruction            = resolveInstruction;
            instruction.RenderInstruction             = renderInstruction;
            if (!string.IsNullOrEmpty(parameters.SchedulePublish))
            {
                instruction.StartAt = DateTime.Parse(parameters.SchedulePublish);
            }
            return(instruction);
        }
コード例 #2
0
        public void Publish(string[] itemIds, string targetId)
        {
            RenderInstructionData  renderInstruction  = new RenderInstructionData();
            ResolveInstructionData resolveInstruction = new ResolveInstructionData();

            PublishInstructionData publishInstruction = new PublishInstructionData
            {
                DeployAt = DateTime.Now,
                MaximumNumberOfRenderFailures = 0,
                RenderInstruction             = renderInstruction,
                ResolveInstruction            = resolveInstruction,
                StartAt = DateTime.Now
            };

            _client.PublishAsync(itemIds, publishInstruction, new[] { targetId }, PublishPriority.Normal, null);
        }
コード例 #3
0
        private void AssertItemRendersWithoutException(IdentifiableObjectData item, IdentifiableObjectData template)
        {
            string testPublicationId = TestContext.Properties["TestPublicationId"].ToString();

            string localisedItemId     = Client.GetTcmUri(item.Id, testPublicationId, null);
            string localisedTemplateId = Client.GetTcmUri(template.Id, testPublicationId, null);

            // We check if the template exists at this publication level as the schema where used query
            // might give us templates that might only exist elsewhere in the blueprint
            if (Client.IsExistingObject(localisedTemplateId) && !this.renderedTemplates.Contains(localisedTemplateId))
            {
                try
                {
                    this.renderedTemplates.Add(localisedTemplateId);
                    RenderedItemData renderedItem = new RenderedItemData();

                    RenderInstructionData renderInstruction = new RenderInstructionData();
                    renderInstruction.RenderMode = RenderMode.PreviewStatic;

                    PublishInstructionData previewInstruction = new PublishInstructionData();
                    ResolveInstructionData resolveInstruction = new ResolveInstructionData();

                    previewInstruction.RenderInstruction  = renderInstruction;
                    previewInstruction.ResolveInstruction = resolveInstruction;

                    stopwatch.Restart();
                    renderedItem = Client.RenderItem(localisedItemId, localisedTemplateId, previewInstruction, "tcm:0-1-65537");
                    long timeToRender = stopwatch.ElapsedMilliseconds;
                    if (renderedItem.Content != null)
                    {
                        string renderedContent = System.Text.Encoding.Default.GetString(renderedItem.Content);
                        this.LogMessage(String.Format("Rendering with template \"{0}\" ({1}) succeeded and took {2} milliseconds.", template.Title, localisedTemplateId, timeToRender));
                        Assert.IsNotNull(renderedContent);
                    }
                    else
                    {
                        this.LogMessage(String.Format("ALERT: Rendering with template \"{0}\" ({1}) resulted in null content and took {2} milliseconds.", template.Title, localisedTemplateId, timeToRender));
                    }
                }
                catch (System.ServiceModel.FaultException ex)
                {
                    string failMessage = String.Format("TEST FAILED! Failed when rendering item {0} ({1}) with template {2} ({3}) {4}. Exception: {5}", item.Id, item.Title, template.Id, template.Title, Environment.NewLine + Environment.NewLine, ex.Message);
                    this.LogMessage(failMessage);
                    Assert.Fail(failMessage);
                }
            }
        }
        private string RenderItem(string itemId, string templateId)
        {
            try
            {
                this.OpenSession();
                ResolveInstructionData resolveInstruction = new ResolveInstructionData()
                {
                    IncludeWorkflow          = true,
                    IncludeComponentLinks    = false,
                    IncludeChildPublications = false,
                    Purpose = ResolvePurpose.Publish,
                    StructureResolveOption = StructureResolveOption.OnlyItems
                };
                RenderInstructionData renderInstruction = new RenderInstructionData()
                {
                    RenderMode = RenderMode.PreviewDynamic
                };
                PublishInstructionData publishInstruction = new PublishInstructionData()
                {
                    MaximumNumberOfRenderFailures = 0,
                    ResolveInstruction            = resolveInstruction,
                    RenderInstruction             = renderInstruction,
                    StartAt  = DateTime.UtcNow,
                    DeployAt = DateTime.MinValue
                };


                RenderedItemData result = session.RenderItem(itemId, templateId, publishInstruction, TcmUri.UriNull.ToString());

                if (result.Content != null && result.Content.Length > 0)
                {
                    string contents = System.Text.Encoding.UTF8.GetString(result.Content);
                    return(contents);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                this.CloseSession();
            }
            return("");
        }
コード例 #5
0
        /// <summary>
        /// GetPublishInfoData - Creates a PublishInfoData which is used to obtain a list of publishable items.
        /// </summary>
        /// <param name="parameters">PagePublisherParameters</param>
        /// <returns>GetPublishInfoData object</returns>
        private PublishInstructionData GetPublishInstructionData(PagePublisherParameters parameters)
        {
            ResolveInstructionData resolveInstruction = new ResolveInstructionData();
            resolveInstruction.IncludeChildPublications = parameters.PublishChildren;
            resolveInstruction.IncludeComponentLinks = parameters.IncludeComponentLinks ? true : false;
            resolveInstruction.StructureResolveOption = parameters.IncludeStructureGroups ? StructureResolveOption.ItemsAndStructure : StructureResolveOption.OnlyItems;
            resolveInstruction.IncludeWorkflow = parameters.IncludeWorkflow ? true : false;
            resolveInstruction.Purpose = parameters.Republish ? ResolvePurpose.RePublish : ResolvePurpose.Publish;

            RenderInstructionData renderInstruction = new RenderInstructionData();
            renderInstruction.RenderMode = RenderMode.PreviewDynamic;

            PublishInstructionData instruction = new PublishInstructionData();
            instruction.RollbackOnFailure = true;
            instruction.MaximumNumberOfRenderFailures = 1;
            instruction.ResolveInstruction = resolveInstruction;
            instruction.RenderInstruction = renderInstruction;
            return instruction;
        }
コード例 #6
0
        /// <summary>
        /// GetPublishInfoData - Creates a PublishInfoData which is used to obtain a list of publishable items.
        /// </summary>
        /// <param name="parameters">PagePublisherParameters</param>
        /// <returns>GetPublishInfoData object</returns>
        private PublishInstructionData GetPublishInstructionData(PagePublisherParameters parameters)
        {
            ResolveInstructionData resolveInstruction = new ResolveInstructionData();
            resolveInstruction.IncludeChildPublications = parameters.PublishChildren;
            resolveInstruction.IncludeComponentLinks = parameters.IncludeComponentLinks ? true : false; 
            resolveInstruction.StructureResolveOption = parameters.IncludeStructureGroups ? StructureResolveOption.ItemsAndStructure : StructureResolveOption.OnlyItems;
            resolveInstruction.IncludeWorkflow = parameters.IncludeWorkflow ? true : false;
            resolveInstruction.Purpose = parameters.Republish ? ResolvePurpose.RePublish : ResolvePurpose.Publish;

            RenderInstructionData renderInstruction = new RenderInstructionData();
            renderInstruction.RenderMode = RenderMode.Publish;
 

            PublishInstructionData instruction = new PublishInstructionData();
            instruction.RollbackOnFailure = true;
            instruction.MaximumNumberOfRenderFailures = 1;
            instruction.ResolveInstruction = resolveInstruction;
            instruction.RenderInstruction = renderInstruction;
            if (!string.IsNullOrEmpty(parameters.SchedulePublish))
            {
                instruction.StartAt = DateTime.Parse(parameters.SchedulePublish);
            }
            return instruction;
        }
コード例 #7
0
        public void Publish(string[] itemIds, string targetId)
        {
            RenderInstructionData renderInstruction = new RenderInstructionData();
            ResolveInstructionData resolveInstruction = new ResolveInstructionData();

            PublishInstructionData publishInstruction = new PublishInstructionData
                                                            {
                                                                DeployAt = DateTime.Now,
                                                                MaximumNumberOfRenderFailures = 0,
                                                                RenderInstruction = renderInstruction,
                                                                ResolveInstruction = resolveInstruction,
                                                                StartAt = DateTime.Now
                                                            };
            _client.PublishAsync(itemIds, publishInstruction, new[] { targetId }, PublishPriority.Normal, null);
        }