本文整理汇总了C#中Tenant.CheckIfSiteExists方法的典型用法代码示例。如果您正苦于以下问题:C# Tenant.CheckIfSiteExists方法的具体用法?C# Tenant.CheckIfSiteExists怎么用?C# Tenant.CheckIfSiteExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tenant
的用法示例。
在下文中一共展示了Tenant.CheckIfSiteExists方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDeleteCreateSiteCollectionTest
public void CreateDeleteCreateSiteCollectionTest()
{
using (var tenantContext = TestCommon.CreateTenantClientContext())
{
var tenant = new Tenant(tenantContext);
//Create site collection test
string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
var siteExists = tenant.SiteExists(siteToCreateUrl);
Assert.IsTrue(siteExists, "Site collection creation failed");
//Delete site collection test: move to recycle bin
tenant.DeleteSiteCollection(siteToCreateUrl, true);
bool recycled = tenant.CheckIfSiteExists(siteToCreateUrl, "Recycled");
Assert.IsTrue(recycled, "Site collection recycling failed");
//Remove from recycle bin
tenant.DeleteSiteCollectionFromRecycleBin(siteToCreateUrl, true);
var siteExists2 = tenant.SiteExists(siteToCreateUrl);
Assert.IsFalse(siteExists2, "Site collection deletion from recycle bin failed");
//Create a site collection using the same url as the previously deleted site collection
siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
siteExists = tenant.SiteExists(siteToCreateUrl);
Assert.IsTrue(siteExists, "Second site collection creation failed");
}
}
示例2: CheckIfSiteExistsTest
public void CheckIfSiteExistsTest()
{
using (var tenantContext = TestCommon.CreateTenantClientContext()) {
var tenant = new Tenant(tenantContext);
var siteCollections = tenant.GetSiteCollections();
var site = siteCollections.First();
var siteExists1 = tenant.CheckIfSiteExists(site.Url, "Active");
Assert.IsTrue(siteExists1);
try {
var siteExists2 = tenant.CheckIfSiteExists(site.Url + "sites/aaabbbccc", "Active");
Assert.IsFalse(siteExists2, "Invalid site returned as valid.");
}
catch (ServerException) { }
}
}
示例3: CleanupAllTestSiteCollections
private static void CleanupAllTestSiteCollections(ClientContext tenantContext)
{
var tenant = new Tenant(tenantContext);
var siteCols = tenant.GetSiteCollections();
foreach (var siteCol in siteCols)
{
if (siteCol.Url.Contains(sitecollectionNamePrefix))
{
try
{
// Drop the site collection from the recycle bin
if (tenant.CheckIfSiteExists(siteCol.Url, "Recycled"))
{
tenant.DeleteSiteCollectionFromRecycleBin(siteCol.Url, false);
}
else
{
// Eat the exceptions: would occur if the site collection is already in the recycle bin.
try
{
// ensure the site collection in unlocked state before deleting
tenant.SetSiteLockState(siteCol.Url, SiteLockState.Unlock);
}
catch { }
// delete the site collection, do not use the recyle bin
tenant.DeleteSiteCollection(siteCol.Url, false);
}
}
catch (Exception ex)
{
// eat all exceptions
Console.WriteLine(ex.ToString());
}
}
}
}
示例4: CheckIfSiteExistsInTenant
public static bool CheckIfSiteExistsInTenant(this Web web, string siteUrl, string status)
{
Tenant tenant = new Tenant(web.Context);
return tenant.CheckIfSiteExists(siteUrl, status);
}
示例5: CreateDeleteSiteCollectionTest
public void CreateDeleteSiteCollectionTest()
{
using (var tenantContext = TestCommon.CreateTenantClientContext())
{
var tenant = new Tenant(tenantContext);
//Create site collection test
Console.WriteLine("CreateDeleteSiteCollectionTest: step 1");
string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
Console.WriteLine("CreateDeleteSiteCollectionTest: step 1.1");
var siteExists = tenant.SiteExists(siteToCreateUrl);
Console.WriteLine("CreateDeleteSiteCollectionTest: step 1.2");
Assert.IsTrue(siteExists, "Site collection creation failed");
//Delete site collection test: move to recycle bin
Console.WriteLine("CreateDeleteSiteCollectionTest: step 2");
tenant.DeleteSiteCollection(siteToCreateUrl, true);
Console.WriteLine("CreateDeleteSiteCollectionTest: step 2.1");
bool recycled = tenant.CheckIfSiteExists(siteToCreateUrl, "Recycled");
Console.WriteLine("CreateDeleteSiteCollectionTest: step 2.2");
Assert.IsTrue(recycled, "Site collection recycling failed");
//Remove from recycle bin
Console.WriteLine("CreateDeleteSiteCollectionTest: step 3");
tenant.DeleteSiteCollectionFromRecycleBin(siteToCreateUrl, true);
Console.WriteLine("CreateDeleteSiteCollectionTest: step 3.1");
var siteExists2 = tenant.SiteExists(siteToCreateUrl);
Console.WriteLine("CreateDeleteSiteCollectionTest: step 3.2");
Assert.IsFalse(siteExists2, "Site collection deletion from recycle bin failed");
}
}