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


C# Tenant.RemoveDeletedSite方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:gavinbarron,项目名称:o365-provisioning-samples,代码行数:29,代码来源:SiteProvisioner.cs

示例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;
        }
开发者ID:BNATENSTEDT,项目名称:PnP,代码行数:68,代码来源:SiteExtensions.cs


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