本文整理汇总了C#中System.Item.GetProviderPath方法的典型用法代码示例。如果您正苦于以下问题:C# Item.GetProviderPath方法的具体用法?C# Item.GetProviderPath怎么用?C# Item.GetProviderPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Item
的用法示例。
在下文中一共展示了Item.GetProviderPath方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditItem
protected override void EditItem(Item item)
{
if (!ShouldProcess(item.GetProviderPath(), "Lock Item")) return;
var itemLock = item.Locking;
if (itemLock.GetOwner().Is(Identity.Name))
{
return;
}
if (itemLock.IsLocked())
{
if (Force)
{
itemLock.Unlock();
}
else
{
WriteError(typeof(SecurityException), $"Cannot modify item '{item.Name}' because it is locked by '{item.Locking.GetOwner()}' - Use the -Force parameter to transfet lock to the new user.",
ErrorIds.InsufficientSecurityRights, ErrorCategory.InvalidData,item);
return;
}
}
item.Locking.Lock();
}
示例2: ProcessItem
protected override void ProcessItem(Item item)
{
if (ShouldProcess(item.GetProviderPath(), string.Format("Set layout '{0}'", Layout.GetProviderPath())))
{
LayoutField layoutField = item.Fields[LayoutFieldId];
if (layoutField == null)
{
return;
}
var layout = LayoutDefinition.Parse(layoutField.Value);
var device = layout.GetDevice(Device.ID.ToString());
if (string.Equals(device.Layout, Layout.ID.ToString(), StringComparison.OrdinalIgnoreCase))
{
//same layout as already set - no point in setting it again
return;
}
device.Layout = Layout.ID.ToString();
item.Edit(p =>
{
var outputXml = layout.ToXml();
layoutField.Value = outputXml;
});
}
}
示例3: ProcessItem
protected override void ProcessItem(Item item)
{
if (!item.IsItemClone)
{
WriteError(typeof(ArgumentException), "The specified item is not a clone.", ErrorIds.InvalidItemType, ErrorCategory.InvalidArgument, null);
return;
}
if (ShouldProcess(item.GetProviderPath(), "Convert item clone to full item"))
{
var clone = new CloneItem(item);
WriteItem(clone.Unclone());
}
}
示例4: ProcessItem
protected override void ProcessItem(Item item)
{
if (ShouldProcess(item.GetProviderPath(), "Reset layout"))
{
Field layoutField = item.Fields[LayoutFieldId];
if (layoutField == null)
{
return;
}
item.Edit(p =>
{
layoutField.Reset();
});
}
}
示例5: ProcessItem
protected override void ProcessItem(Item item)
{
if (ShouldProcess(item.GetProviderPath(), "Expand tokens"))
{
Item.Editing.BeginEdit();
try
{
tokenReplacer.ReplaceItem(Item);
Item.Editing.EndEdit();
}
catch (Exception ex)
{
Item.Editing.CancelEdit();
WriteError(new ErrorRecord(ex, "sitecore_token_expander_error", ErrorCategory.NotSpecified, Item));
}
WriteItem(Item);
}
}
示例6: PublishToTarget
private void PublishToTarget(Item item, Database source, Database target)
{
if (PublishMode == PublishMode.Unknown)
{
PublishMode = PublishMode.Smart;
}
var language = item.Language;
if (ShouldProcess(item.GetProviderPath(),
string.Format("{3}ublishing language '{0}', version '{1}' to target '{2}'.", language, item.Version,
target.Name, Recurse.IsPresent ? "Recursively p" : "P")))
{
WriteVerbose(
String.Format(
"Publishing item '{0}' in language '{1}', version '{2}' to target '{3}'. (Recurse={4}).",
item.Name, language, item.Version, target.Name, Recurse.IsPresent));
var options = new PublishOptions(source, target, PublishMode, language, DateTime.Now)
{
Deep = Recurse.IsPresent,
RootItem = item
};
var optionsArgs = new PublishOptions[1];
optionsArgs[0] = options;
var handle = PublishManager.Publish(optionsArgs);
if (handle != null)
{
var publishStatus = PublishManager.GetStatus(handle) ?? new PublishStatus();
WriteVerbose(String.Format("Publish Job submitted, current state={0}.",
publishStatus.State));
}
}
}
示例7: ProcessItem
protected override void ProcessItem(Item item)
{
if (ShouldProcess(item.GetProviderPath(),
string.Format("Add language '{0}' version(s){1}",
TargetLanguage.Aggregate((seed, curr) => seed + ", " + curr), (Recurse ? " recursively" : ""))))
{
foreach (var targetLanguage in TargetLanguage)
{
var lang = LanguageManager.GetLanguage(targetLanguage);
if (lang == null)
{
var error = String.Format("Cannot find target language '{0}' or it is not enabled.",
targetLanguage);
WriteError(new ErrorRecord(new ObjectNotFoundException(error), error,
ErrorCategory.ObjectNotFound,
item));
}
else
{
var latestVersion = item.Versions.GetLatestVersion(lang);
if (IfExist != ActionIfExists.Skip || (latestVersion.Versions.Count == 0))
{
CopyFields(item, latestVersion, false);
}
if (Recurse)
{
foreach (Item childItem in item.Children)
{
ProcessItem(childItem);
}
}
}
}
}
}
示例8: ProcessItem
protected override void ProcessItem(Item item)
{
if (!ShouldProcess(item.GetProviderPath(),
$"Add language '{TargetLanguage.Aggregate((seed, curr) => seed + ", " + curr)}' version(s){(Recurse ? " recursively" : "")}"))
return;
foreach (var targetLanguage in TargetLanguage)
{
var lang = LanguageManager.GetLanguage(targetLanguage);
if (lang == null)
{
WriteError(typeof(ObjectNotFoundException), $"Cannot find target language '{targetLanguage}' or it is not enabled.",
ErrorIds.LanguageNotFound, ErrorCategory.ObjectNotFound, item);
}
else
{
var latestVersion = item.Versions.GetLatestVersion(lang);
if (IfExist != ActionIfExists.Skip || (latestVersion.Versions.Count == 0))
{
CopyFields(item, latestVersion, false);
}
if (Recurse)
{
foreach (Item childItem in item.Children)
{
ProcessItem(childItem);
}
}
}
}
}
示例9: SetExecutedScript
public void SetExecutedScript(Item scriptItem)
{
if (scriptItem != null)
{
SetVariable("PSScriptRoot", scriptItem.Parent.GetProviderPath());
SetVariable("PSCommandPath", scriptItem.GetProviderPath());
SetVariable("PSScript", scriptItem);
}
}