本文整理汇总了C#中SPSite.RunElevated方法的典型用法代码示例。如果您正苦于以下问题:C# SPSite.RunElevated方法的具体用法?C# SPSite.RunElevated怎么用?C# SPSite.RunElevated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPSite
的用法示例。
在下文中一共展示了SPSite.RunElevated方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadAllScripts
private Dictionary<string, FileAndDate> LoadAllScripts(string siteUrl)
{
if (siteUrl == null) throw new ArgumentNullException("siteUrl");
var output = new Dictionary<string, FileAndDate>();
using (SPSite tempsite = new SPSite(siteUrl))
{
return (Dictionary<string, FileAndDate>) tempsite.RunElevated(delegate(SPSite site)
{
this._currentSiteUrl = site.Url;
SPWeb rootWeb = site.RootWeb;
SPList sList = rootWeb.OpenList("SiteScripts", true);
sList.ProcessItems(delegate(SPListItem script)
{
KeyValuePair<string, FileAndDate> scriptItem = LoadScriptFromItem(script);
output[scriptItem.Key] = scriptItem.Value;
return null;
});
return output;
});
}
}
示例2: Reload
public void Reload(string siteUrl, string fileNamePath)
{
string totalUrl = null;
try
{
using (SPSite tempsite = new SPSite(siteUrl))
{
tempsite.RunElevated(delegate(SPSite site)
{
this._currentSiteUrl = siteUrl;
SPWeb rootWeb = site.RootWeb;
SPList sList = rootWeb.OpenList("SiteScripts", true);
// url seznamu spojit s dodanou cestou a jmenem souboru
totalUrl =
(sList.AbsoluteUrl() +
RepoServiceClient.NormalizedFilePath(fileNamePath).Replace('\\', '/').Substring(2)).Replace
("/Forms/", "/");
SPListItem script = rootWeb.GetItemByUrl(totalUrl);
KeyValuePair<string, FileAndDate> scriptItem = LoadScriptFromItem(script);
_files[site.Url][scriptItem.Key] = scriptItem.Value;
return null;
});
}
}
catch (FileNotFoundException f)
{
throw new FileNotFoundException("RepoService failed to open file " + ( totalUrl ?? "-" ) + "\n" + f);
}
}