本文整理汇总了C#中Package.CreateTridionItem方法的典型用法代码示例。如果您正苦于以下问题:C# Package.CreateTridionItem方法的具体用法?C# Package.CreateTridionItem怎么用?C# Package.CreateTridionItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package.CreateTridionItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform
public void Transform(Engine engine, Package package)
{
_log = TemplatingLogger.GetLogger(GetType());
_engine = engine;
string itemName = string.Empty;
if (package.GetByName(Package.ComponentName) != null) itemName = Package.ComponentName;
if (package.GetByName(Package.PageName) != null) itemName = Package.PageName;
if (string.IsNullOrEmpty(itemName))
{
_log.Debug("Could not determine template type, exiting");
return;
}
VersionedItem item = (VersionedItem)engine.GetObject(package.GetByName(itemName));
if (item.LockType.HasFlag(LockType.InWorkflow))
{
CurrentMode mode = GetCurrentMode();
VersionedItem w = item.GetVersion(0);
switch (mode)
{
case CurrentMode.CmePreview:
case CurrentMode.TemplateBuilder:
case CurrentMode.SessionPreview:
// return workflow object without comparing to Publication Target Minimum Approval Status
package.Remove(package.GetByName(itemName));
if (itemName.Equals(Package.ComponentName))
{
package.PushItem(Package.ComponentName, package.CreateTridionItem(ContentType.Component, w));
}
else if (itemName.Equals(Package.PageName))
{
package.PushItem(Package.PageName, package.CreateTridionItem(ContentType.Page, w));
}
break;
case CurrentMode.Publish:
PublicationTarget target = _engine.PublishingContext.PublicationTarget;
ApprovalStatus targetStatus = target.MinApprovalStatus;
ApprovalStatus contentStatus = null;
if (w is Component)
{
contentStatus = ((Component)w).ApprovalStatus;
}
else if (w is Page)
{
contentStatus = ((Page)w).ApprovalStatus;
}
if (contentStatus == null)
{
_log.Debug("Could not determine approval status of content. Exiting.");
return;
}
bool mustUpdate = false;
if (targetStatus == null)
mustUpdate = true;
else
{
if (contentStatus.Position > targetStatus.Position)
mustUpdate = true;
}
if (mustUpdate)
{
package.Remove(package.GetByName(itemName));
if (itemName.Equals(Package.ComponentName))
{
package.PushItem(Package.ComponentName, package.CreateTridionItem(ContentType.Component, w));
}
else if (itemName.Equals(Package.PageName))
{
package.PushItem(Package.PageName, package.CreateTridionItem(ContentType.Page, w));
}
}
break;
}
}
}