当前位置: 首页>>代码示例>>C#>>正文


C# Tenant.DeleteSiteCollectionFromRecycleBin方法代码示例

本文整理汇总了C#中Tenant.DeleteSiteCollectionFromRecycleBin方法的典型用法代码示例。如果您正苦于以下问题:C# Tenant.DeleteSiteCollectionFromRecycleBin方法的具体用法?C# Tenant.DeleteSiteCollectionFromRecycleBin怎么用?C# Tenant.DeleteSiteCollectionFromRecycleBin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tenant的用法示例。


在下文中一共展示了Tenant.DeleteSiteCollectionFromRecycleBin方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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());
                    }
                }
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:39,代码来源:TenantExtensionsTests.cs

示例2: CreateDeleteSiteCollectionTest

        public void CreateDeleteSiteCollectionTest()
        {
            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");
            }
        }
开发者ID:xaviayala,项目名称:Birchman,代码行数:22,代码来源:TenantExtensionsTests.cs

示例3: DeleteSiteCollectionFromRecycleBinTenant

 public static bool DeleteSiteCollectionFromRecycleBinTenant(this Web web, string siteUrl)
 {
     Tenant tenant = new Tenant(web.Context);
     return tenant.DeleteSiteCollectionFromRecycleBin(siteUrl);
 }
开发者ID:JohnKozell,项目名称:PnP,代码行数:5,代码来源:WebExtensions.cs

示例4: CreateDeleteCreateSiteCollectionTest

        public void CreateDeleteCreateSiteCollectionTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);

                //Create site collection test
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 1");
                string siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 1.1");
                var siteExists = tenant.SiteExists(siteToCreateUrl);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 1.1");
                Assert.IsTrue(siteExists, "Site collection creation failed");

                //Delete site collection test: move to recycle bin
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 2");
                tenant.DeleteSiteCollection(siteToCreateUrl, true);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 2.1");
                bool recycled = tenant.CheckIfSiteExists(siteToCreateUrl, "Recycled");
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 2.2");
                Assert.IsTrue(recycled, "Site collection recycling failed");

                //Remove from recycle bin
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 3");
                tenant.DeleteSiteCollectionFromRecycleBin(siteToCreateUrl, true);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 3.1");
                var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 3.2");
                Assert.IsFalse(siteExists2, "Site collection deletion from recycle bin failed");

                //Create a site collection using the same url as the previously deleted site collection
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 4");
                siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 4.1");
                siteExists = tenant.SiteExists(siteToCreateUrl);
                Console.WriteLine("CreateDeleteCreateSiteCollectionTest: step 4.2");
                Assert.IsTrue(siteExists, "Second site collection creation failed");
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:39,代码来源:TenantExtensionsTests.cs


注:本文中的Tenant.DeleteSiteCollectionFromRecycleBin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。