本文整理汇总了C#中SPListItem.RunElevated方法的典型用法代码示例。如果您正苦于以下问题:C# SPListItem.RunElevated方法的具体用法?C# SPListItem.RunElevated怎么用?C# SPListItem.RunElevated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPListItem
的用法示例。
在下文中一共展示了SPListItem.RunElevated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
private object Execute(SPListItem i, SetRightsPluginConfig config)
{
if (i == null) throw new ArgumentNullException("i");
//polozku otevreme jako elevated a zni jiz pak vse bude elevated!!!
i.RunElevated(delegate(SPListItem item)
{
log.LogInfo("Start ExecuteSetRights from item " + item.FormUrlDisplay());
foreach (KeyValuePair<string, RightsSettings> right in config.Rights)
{
string rightsTitle = right.Key;
RightsSettings settings = right.Value;
string itemIdentification = settings.RightsFor;
//Prava primo pro polozku
if (itemIdentification == "self")
{
SetRightsForItem(item, settings.Roles, settings.Clear, settings.ExpandUsers);
}
else if (item.ParentList.ContainsFieldIntName(itemIdentification)) //Prava na lookupovanou polozku
{
try
{
SPField field = item.ParentList.OpenField(itemIdentification, true);
if (field.IsLookup())
{
item.GetItemsFromLookup(field.InternalName).ProcessItems(item.Web.Site, delegate(SPListItem lookupItem)
{
SetRightsForItem(lookupItem, settings.Roles, settings.Clear, settings.ExpandUsers);
return null;
});
}
else
{
log.LogError("Field '" + field.InternalName + "' is not lookup");
continue;
}
}
catch (Exception exc)
{
log.LogError(exc);
}
}
else if (itemIdentification.Contains('|')) ////Prava na lookupovanou polozku a lookup v ni
{
WebListItemDictionary wild = item.TraverseItemLookups(itemIdentification.Split('|').ToList());
wild.ProcessItems(item.Web.Site, delegate(SPListItem lookupItem)
{
Console.WriteLine(lookupItem.Title);
SetRightsForItem(lookupItem, settings.Roles, settings.Clear, settings.ExpandUsers);
return null;
});
}
else
{
log.LogError("Could not recognize rights for: '" + itemIdentification + "'");
}
}
return null;
});
log.LogInfo(setRightsLog);
return "OK";
}
示例2: LoadScriptFromItem
private KeyValuePair<string, FileAndDate> LoadScriptFromItem(SPListItem tempitem)
{
return (KeyValuePair<string, FileAndDate>) tempitem.RunElevated(delegate(SPListItem item)
{
string relativePath =
RemoveMatchingStringFromStart(item.DocumentUrl(), item.ParentList.AbsoluteUrl()).Replace("/", "\\");
KeyValuePair<string, FileAndDate> result = new KeyValuePair<string, FileAndDate>
(item.IsFolder() ? ".\\" + relativePath + "\\" : ".\\" + relativePath,
new FileAndDate(item.IsFolder() ? null : item.File.OpenBinaryStream().ReadAllBytes(),
(DateTime) item["Modified"]));
return result;
});
}