本文整理汇总了C#中Tenant.RemoveDeletedSite方法的典型用法代码示例。如果您正苦于以下问题:C# Tenant.RemoveDeletedSite方法的具体用法?C# Tenant.RemoveDeletedSite怎么用?C# Tenant.RemoveDeletedSite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tenant
的用法示例。
在下文中一共展示了Tenant.RemoveDeletedSite方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteSite
/// <summary>
/// Delete the SiteCollection at the given Uri, also removes it from the recycle bin.
/// Checks whether the site exists before deletion.
/// </summary>
/// <param name="siteUrl"><see cref="Uri"/> of the site to delete</param>
public void DeleteSite(Uri siteUrl)
{
if (siteUrl == null) throw new ArgumentNullException("siteUrl");
var tenant = new Tenant(_client);
string siteToRemoveUrl = siteUrl.ToString().ToLowerInvariant();
// Check whether the site exists.
SPOSitePropertiesEnumerable sitePropEnumerable = tenant.GetSiteProperties(0, true);
_client.Load(sitePropEnumerable);
_client.ExecuteQuery();
bool siteExists = Enumerable.Any(sitePropEnumerable,
property => property.Url.ToLowerInvariant() == siteToRemoveUrl);
if (siteExists)
{
SpoOperation spo = tenant.RemoveSite(siteUrl.ToString());
ExecuteAndWaitForCompletion(tenant, spo);
spo = tenant.RemoveDeletedSite(siteUrl.ToString());
ExecuteAndWaitForCompletion(tenant, spo);
}
}
示例2: DeleteSiteCollectionTenant
/// <summary>
/// Deletes a site collection
/// </summary>
/// <param name="web">Site to be processed - can be root web or sub site</param>
/// <param name="siteUrl">Url of the site collection to delete</param>
/// <param name="useRecycleBin">Leave the deleted site collection in the site collection recycle bin</param>
/// <returns>True if deleted</returns>
public static bool DeleteSiteCollectionTenant(this Web web, string siteUrl, bool useRecycleBin)
{
bool ret = false;
Tenant tenant = new Tenant(web.Context);
SpoOperation op = tenant.RemoveSite(siteUrl);
web.Context.Load(tenant);
web.Context.Load(op, i => i.IsComplete, i => i.PollingInterval);
web.Context.ExecuteQuery();
//check if site creation operation is complete
while (!op.IsComplete)
{
System.Threading.Thread.Sleep(op.PollingInterval);
op.RefreshLoad();
if (!op.IsComplete)
{
try
{
web.Context.ExecuteQuery();
}
catch (WebException webEx)
{
// Context connection gets closed after action completed.
// Calling ExecuteQuery again returns an error which can be ignored
LoggingUtility.LogWarning(MSG_CONTEXT_CLOSED, webEx, EventCategory.Site);
}
}
}
if (useRecycleBin)
{
return true;
}
// To delete Site collection completely, (may take a longer time)
op = tenant.RemoveDeletedSite(siteUrl);
web.Context.Load(op, i => i.IsComplete, i => i.PollingInterval);
web.Context.ExecuteQuery();
while (!op.IsComplete)
{
System.Threading.Thread.Sleep(op.PollingInterval);
op.RefreshLoad();
if (!op.IsComplete)
{
try
{
web.Context.ExecuteQuery();
}
catch (WebException webEx)
{
// Context connection gets closed after action completed.
// Calling ExecuteQuery again returns an error which can be ignored
LoggingUtility.LogWarning(MSG_CONTEXT_CLOSED, webEx, EventCategory.Site);
}
}
}
ret = true;
return ret;
}