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


C# Tenant.SetSiteLockState方法代码示例

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


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

示例1: Get

 public OperationResult Get()
 {
     var siteUrl = Request.GetQueryNameValuePairs().FirstOrDefault(p => p.Key == "siteUrl").Value;
     var ret = new OperationResult()
     {
         IsSuccess = true
     };
     UsingTenantContext(context => {                
         try
         {
             var tenant = new Tenant(context);
             tenant.SetSiteLockState(siteUrl, SiteLockState.Unlock, wait: true);
         }
         catch (Exception e)
         {
             ret.IsSuccess = false;
             ret.Message = e.Message;
             return;
         }
     });
     if (ret.IsSuccess)
     {
         DbRepository.UsingContext(dbContext => {
             var site = dbContext.GetSite(siteUrl);
             if (site != null)
                 site.ComplianceState.IsLocked = false;
             dbContext.SaveChanges();
         });
     }
     return ret;
 }
开发者ID:nishantpunetha,项目名称:PnP,代码行数:31,代码来源:UnlockController.cs

示例2: Enforce

        public virtual void Enforce(SiteInformation site, bool supressEmail)
        {
            var state = site.ComplianceState;

            //If site is locked, then will not send any lock notification email, instead of sending delete email.
            if (site.ComplianceState.IsLocked && !site.ComplianceState.DeleteNotificationSent)
                SetNotifyDeleteState(site);
            if (GovernanceWorkflowHelper.NeedNotifyLock(state.LockedDate, state))
            {
                ExtendOutdatedLockedDate(site); //Extend the LockedDate if it is earlier than current date
            }
            else if (GovernanceWorkflowHelper.NeedNotifyDelete(state.LockedDate, state))
            {
                ExtendOutdatedDeleteDate(site); //Extend the DeleteDate if it is earlier than current date
            }
            if (state.IsCompliant)
                ChangeComplianceStateToDefault(site);

            var tenant = new Tenant(TenentClientContext);
            if (GovernanceWorkflowHelper.NeedNotifyLock(state.LockedDate, state))
            {
                Notifiy(site, TenentClientContext, supressEmail);
                Log.Info(GetType().Name, "Notify Lock for site {0}", site.Url);
            }
            else if (GovernanceWorkflowHelper.NeedLock(state.LockedDate, state))
            {
                tenant.SetSiteLockState(site.Url, SiteLockState.NoAccess, true);
                site.ComplianceState.IsLocked = true;
                Log.Info(GetType().Name, "Site {0} was locked", site.Url);
            }
            else if (GovernanceWorkflowHelper.NeedNotifyDelete(state.LockedDate, state))
            {
                Notifiy(site, TenentClientContext, supressEmail);                
                Log.Info(GetType().Name, "Notify Delete for site {0}", site.Url);
            }
            else if (GovernanceWorkflowHelper.NeedDelete(state.LockedDate))
            {
                //set a flag to let us know that the site is deleted by Governance Job
                //site.DeletedBy = AutoSiteDeleteBy.GovernanceJob;
                tenant.DeleteSiteCollection(site.Url, true);
                //Set a value to indicate that the site was just deleted
                site.ComplianceState.DeleteDate = DateTime.MaxValue;
                Log.Info(GetType().Name, "Site {0} was deleted", site.Url);
            }
            TenentClientContext.ExecuteQueryRetry();
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:46,代码来源:GovernanceWorkflowExecutor.cs

示例3: CleanupAllTestSiteCollections

 private static void CleanupAllTestSiteCollections(ClientContext tenantContext)
 {
     var tenant = new Tenant(tenantContext);
     for (int i = 0; i <= 9; i++)
     {
         try
         {
             string site = string.Format("TestPnPSC_123456789_{0}", i);
             site = GetTestSiteCollectionName(ConfigurationManager.AppSettings["SPODevSiteUrl"], site);
             // ensure the site collection in unlocked state before deleting
             tenant.SetSiteLockState(site, SiteLockState.Unlock);
             // delete the site collection, do not use the recyle bin
             tenant.DeleteSiteCollection(site, false);
         }
         catch (Exception ex)
         {
             // eat all exceptions
             Console.WriteLine(ex.ToString());
         }
     }
 }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:21,代码来源:TenantExtensionsTests.cs

示例4: 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

示例5: SetSiteLockStateTest

        public void SetSiteLockStateTest()
        {
            try
            {
                using (var tenantContext = TestCommon.CreateTenantClientContext())
                {
                    tenantContext.RequestTimeout = Timeout.Infinite;

                    var tenant = new Tenant(tenantContext);
                    string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                    string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                    Console.WriteLine("SetSiteLockStateTest: step 1");
                    if (!tenant.SiteExists(siteToCreateUrl))
                    {
                        siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                        Console.WriteLine("SetSiteLockStateTest: step 1.1");
                        var siteExists = tenant.SiteExists(siteToCreateUrl);
                        Console.WriteLine("SetSiteLockStateTest: step 1.2");
                        Assert.IsTrue(siteExists, "Site collection creation failed");
                    }

                    Console.WriteLine("SetSiteLockStateTest: step 2");
                    // Set Lockstate NoAccess test
                    tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.NoAccess, true);

                    Console.WriteLine("SetSiteLockStateTest: step 2.1");
                    var siteProperties = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                    Console.WriteLine("SetSiteLockStateTest: step 2.1");
                    tenantContext.Load(siteProperties);
                    tenantContext.ExecuteQueryRetry();
                    Assert.IsTrue(siteProperties.LockState == SiteLockState.NoAccess.ToString(), "LockState wasn't set to NoAccess");

                    // Set Lockstate NoAccess test
                    Console.WriteLine("SetSiteLockStateTest: step 3");
                    tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.Unlock, true);
                    Console.WriteLine("SetSiteLockStateTest: step 3.1");
                    var siteProperties2 = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                    Console.WriteLine("SetSiteLockStateTest: step 3.2");
                    tenantContext.Load(siteProperties2);
                    tenantContext.ExecuteQueryRetry();
                    Assert.IsTrue(siteProperties2.LockState == SiteLockState.Unlock.ToString(), "LockState wasn't set to UnLock");

                    //Delete site collection, also
                    Console.WriteLine("SetSiteLockStateTest: step 4");
                    tenant.DeleteSiteCollection(siteToCreateUrl, false);
                    Console.WriteLine("SetSiteLockStateTest: step 4.1");
                    var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                    Console.WriteLine("SetSiteLockStateTest: step 4.2");
                    Assert.IsFalse(siteExists2, "Site collection deletion, including from recycle bin, failed");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:58,代码来源:TenantExtensionsTests.cs

示例6: SetSiteLockStateTest

        public void SetSiteLockStateTest()
        {
            using (var tenantContext = TestCommon.CreateTenantClientContext())
            {
                var tenant = new Tenant(tenantContext);
                string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                if (!tenant.SiteExists(siteToCreateUrl))
                {
                    siteToCreateUrl = CreateTestSiteCollection(tenant, sitecollectionName);
                    var siteExists = tenant.SiteExists(siteToCreateUrl);
                    Assert.IsTrue(siteExists, "Site collection creation failed");
                }

                // Set Lockstate NoAccess test
                tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.NoAccess, true);
                var siteProperties = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                tenantContext.Load(siteProperties);
                tenantContext.ExecuteQueryRetry();
                Assert.IsTrue(siteProperties.LockState == SiteLockState.NoAccess.ToString(), "LockState wasn't set to NoAccess");

                // Set Lockstate NoAccess test
                tenant.SetSiteLockState(siteToCreateUrl, SiteLockState.Unlock, true);
                var siteProperties2 = tenant.GetSitePropertiesByUrl(siteToCreateUrl, true);
                tenantContext.Load(siteProperties2);
                tenantContext.ExecuteQueryRetry();
                Assert.IsTrue(siteProperties2.LockState == SiteLockState.Unlock.ToString(), "LockState wasn't set to UnLock");

                //Delete site collection, also
                tenant.DeleteSiteCollection(siteToCreateUrl, false);
                var siteExists2 = tenant.SiteExists(siteToCreateUrl);
                Assert.IsFalse(siteExists2, "Site collection deletion, including from recycle bin, failed");
            }
        }
开发者ID:xaviayala,项目名称:Birchman,代码行数:35,代码来源:TenantExtensionsTests.cs

示例7: 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
                    {// ensure the site collection in unlocked state before deleting
                        tenant.SetSiteLockState(siteCol.Url, SiteLockState.Unlock);
                        // 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:rroman81,项目名称:PnP-Sites-Core,代码行数:24,代码来源:TenantExtensionsTests.cs


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