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


C# Tenant.CreateSiteCollection方法代码示例

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


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

示例1: ProcessSiteCreationRequest

        public string ProcessSiteCreationRequest(ClientContext ctx, SiteCollectionRequest siteRequest)
        {
            // Resolve full URL 
            var webFullUrl = String.Format("https://{0}.sharepoint.com/{1}/{2}", siteRequest.TenantName, siteRequest.ManagedPath, siteRequest.Url);

            // Resolve the actual SP template to use
            string siteTemplate = SolveActualTemplate(siteRequest);

            Tenant tenant = new Tenant(ctx);
            if (tenant.SiteExists(webFullUrl))
            {
                // Abort... can't proceed, URL taken.
                throw new InvalidDataException(string.Format("site already existed with same URL as {0}. Process aborted.", webFullUrl));
            }
            else
            {
                // Create new site collection with storage limits and settings from the form
                tenant.CreateSiteCollection(webFullUrl,
                                            siteRequest.Title,
                                            siteRequest.Owner,
                                            siteTemplate,
                                            (int)siteRequest.StorageMaximumLevel,
                                            (int)(siteRequest.StorageMaximumLevel * 0.75),
                                            siteRequest.TimeZoneId,
                                            0,
                                            0,
                                            siteRequest.Lcid);

                return webFullUrl;
            }
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:31,代码来源:SiteManager.cs

示例2: DeployNewSite

        private static void DeployNewSite(string newSiteUrl, Tuple<string, string> creds)
        {
            using (ClientContext context = new ClientContext(AdminUrl))
            {
                SharePointOnlineCredentials adminCredentials = new SharePointOnlineCredentials(creds.Item1, creds.Item2.ToSecureString());
                context.Credentials = adminCredentials;

                var tenant = new Tenant(context);

                // Create new site collection with storage limits and settings from the form
                tenant.CreateSiteCollection(newSiteUrl,
                                            "Outlook Meeting Workspace",
                                            creds.Item1,
                                            "STS#0",
                                            (int) 20,
                                            (int) 10,
                                            3, // 3 is the timezone for Stockholm
                                            0,
                                            0,
                                            1033);

            }
        }
开发者ID:bluemini,项目名称:OutlookMeetingWorkspaceAddin,代码行数:23,代码来源:Functions.cs

示例3: CreateTestSiteCollection

        private string CreateTestSiteCollection(Tenant tenant, string sitecollectionName)
        {
            string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];

            string siteOwnerLogin = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["OnPremDomain"], ConfigurationManager.AppSettings["OnPremUserName"]);
            if (TestCommon.AppOnlyTesting())
            {
                using (var clientContext = TestCommon.CreateClientContext())
                {
                    List<UserEntity> admins = clientContext.Web.GetAdministrators();
                    siteOwnerLogin = admins[0].LoginName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)[1];
                }
            }

            string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
            SiteEntity siteToCreate = new SiteEntity()
            {
                Url = siteToCreateUrl,
                Template = "STS#0",
                Title = "Test",
                Description = "Test site collection",
                SiteOwnerLogin = siteOwnerLogin,
            };

            tenant.CreateSiteCollection(siteToCreate);
            return siteToCreateUrl;
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:27,代码来源:Tenant15ExtensionsTests.cs

示例4: CreateSiteCollection

        private static void CreateSiteCollection(string template, string siteUrl)
        {
            // check if site exists
            using (var tenantCtx = TestCommon.CreateTenantClientContext())
            {
                Tenant tenant = new Tenant(tenantCtx);

                if (tenant.SiteExists(siteUrl))
                {
                    Console.WriteLine("Deleting existing site {0}", siteUrl);
                    tenant.DeleteSiteCollection(siteUrl, false);
                }
                Console.WriteLine("Creating new site {0}", siteUrl);
                tenant.CreateSiteCollection(new Entities.SiteEntity()
                {
                    Lcid = 1033,
                    TimeZoneId = 4,
                    SiteOwnerLogin = (TestCommon.Credentials as SharePointOnlineCredentials).UserName,
                    Title = "Template Site",
                    Template = template,
                    Url = siteUrl,
                }, true, true);

            }
        }
开发者ID:LiyeXu,项目名称:PnP-Sites-Core,代码行数:25,代码来源:BaseTemplateTests.cs

示例5: CreateTestSiteCollection

        private string CreateTestSiteCollection(Tenant tenant, string sitecollectionName)
        {
            try
            {
                string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
                string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);

                string siteOwnerLogin = ConfigurationManager.AppSettings["SPOUserName"];
                if (TestCommon.AppOnlyTesting())
                {
                    using (var clientContext = TestCommon.CreateClientContext())
                    {
                        List<UserEntity> admins = clientContext.Web.GetAdministrators();
                        siteOwnerLogin = admins[0].LoginName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)[2];
                    }
                }

                SiteEntity siteToCreate = new SiteEntity()
                {
                    Url = siteToCreateUrl,
                    Template = "STS#0",
                    Title = "Test",
                    Description = "Test site collection",
                    SiteOwnerLogin = siteOwnerLogin,
                };

                Console.WriteLine(String.Format("!!Before creating site collection {0}", siteToCreateUrl));
                tenant.CreateSiteCollection(siteToCreate, false, true);
                Console.WriteLine(String.Format("!!Site collection created {0}", siteToCreateUrl));
                return siteToCreateUrl;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
开发者ID:stijnbrouwers,项目名称:PnP-Sites-Core,代码行数:37,代码来源:TenantExtensionsTests.cs

示例6: CreateTestSiteCollection

        private string CreateTestSiteCollection(Tenant tenant, string sitecollectionName)
        {
            string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
            string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
            SiteEntity siteToCreate = new SiteEntity()
            {
                Url = siteToCreateUrl,
                Template = "STS#0",
                Title = "Test",
                Description = "Test site collection",
                SiteOwnerLogin = ConfigurationManager.AppSettings["SPOUserName"],
            };

            tenant.CreateSiteCollection(siteToCreate, false, true);
            return siteToCreateUrl;
        }
开发者ID:xaviayala,项目名称:Birchman,代码行数:16,代码来源:TenantExtensionsTests.cs

示例7: CreateSiteCollection

        private void CreateSiteCollection(SiteCollectionProvisioningJob job)
        {
            Console.WriteLine("Creating Site Collection \"{0}\".", job.RelativeUrl);

            // Define the full Site Collection URL
            String siteUrl = String.Format("{0}{1}",
                PnPPartnerPackSettings.InfrastructureSiteUrl.Substring(0, PnPPartnerPackSettings.InfrastructureSiteUrl.IndexOf("sharepoint.com/") + 14),
                job.RelativeUrl);

            using (var adminContext = PnPPartnerPackContextProvider.GetAppOnlyTenantLevelClientContext())
            {
                // Configure the Site Collection properties
                SiteEntity newSite = new SiteEntity();
                newSite.Description = job.Description;
                newSite.Lcid = (uint)job.Language;
                newSite.Title = job.SiteTitle;
                newSite.Url = siteUrl;
                newSite.SiteOwnerLogin = job.PrimarySiteCollectionAdmin;
                newSite.StorageMaximumLevel = job.StorageMaximumLevel;
                newSite.StorageWarningLevel = job.StorageWarningLevel;
                newSite.Template = PnPPartnerPackSettings.DefaultSiteTemplate;
                newSite.TimeZoneId = job.TimeZone;
                newSite.UserCodeMaximumLevel = job.UserCodeMaximumLevel;
                newSite.UserCodeWarningLevel = job.UserCodeWarningLevel;

                // Create the Site Collection and wait for its creation (we're asynchronous)
                var tenant = new Tenant(adminContext);
                tenant.CreateSiteCollection(newSite, true, true); // TODO: Do we want to empty Recycle Bin?

                Site site = tenant.GetSiteByUrl(siteUrl);
                Web web = site.RootWeb;

                adminContext.Load(site, s => s.Url);
                adminContext.Load(web, w => w.Url);
                adminContext.ExecuteQueryRetry();

                // Enable Secondary Site Collection Administrator
                if (!String.IsNullOrEmpty(job.SecondarySiteCollectionAdmin))
                {
                    Microsoft.SharePoint.Client.User secondaryOwner = web.EnsureUser(job.SecondarySiteCollectionAdmin);
                    secondaryOwner.IsSiteAdmin = true;
                    secondaryOwner.Update();

                    web.SiteUsers.AddUser(secondaryOwner);
                    adminContext.ExecuteQueryRetry();
                }

                Console.WriteLine("Site \"{0}\" created.", site.Url);

                // Check if external sharing has to be enabled
                if (job.ExternalSharingEnabled)
                {
                    EnableExternalSharing(tenant, site);

                    // Enable External Sharing
                    Console.WriteLine("Enabled External Sharing for site \"{0}\".",
                        site.Url);
                }
            }

            // Move to the context of the created Site Collection
            using (ClientContext clientContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(siteUrl))
            {
                Site site = clientContext.Site;
                Web web = site.RootWeb;

                clientContext.Load(site, s => s.Url);
                clientContext.Load(web, w => w.Url);
                clientContext.ExecuteQueryRetry();

                // Check if we need to enable PnP Partner Pack overrides
                if (job.PartnerPackExtensionsEnabled)
                {
                    // Enable Responsive Design
                    PnPPartnerPackUtilities.EnablePartnerPackOnSite(site.Url);

                    Console.WriteLine("Enabled PnP Partner Pack Overrides on site \"{0}\".",
                        site.Url);
                }

                // Check if the site has to be responsive
                if (job.ResponsiveDesignEnabled)
                {
                    // Enable Responsive Design
                    PnPPartnerPackUtilities.EnableResponsiveDesignOnSite(site.Url);

                    Console.WriteLine("Enabled Responsive Design Template to site \"{0}\".",
                        site.Url);
                }

                // Apply the Provisioning Template
                Console.WriteLine("Applying Provisioning Template \"{0}\" to site.",
                    job.ProvisioningTemplateUrl);

                // Determine the reference URLs and file names
                String templatesSiteUrl = PnPPartnerPackUtilities.GetSiteCollectionRootUrl(job.ProvisioningTemplateUrl);
                String templateFileName = job.ProvisioningTemplateUrl.Substring(job.ProvisioningTemplateUrl.LastIndexOf("/") + 1);

                using (ClientContext repositoryContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(templatesSiteUrl))
                {
//.........这里部分代码省略.........
开发者ID:comblox,项目名称:PnP-Partner-Pack,代码行数:101,代码来源:SiteCollectionProvisioningJobHandler.cs

示例8: CreateTestSiteCollection

        private static string CreateTestSiteCollection(Tenant tenant, string sitecollectionName, bool isNoScriptSite = false)
        {
            string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];

            string siteOwnerLogin = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["OnPremDomain"], ConfigurationManager.AppSettings["OnPremUserName"]);
            if (TestCommon.AppOnlyTesting())
            {
                using (var clientContext = TestCommon.CreateClientContext())
                {
                    List<UserEntity> admins = clientContext.Web.GetAdministrators();
                    siteOwnerLogin = admins[0].LoginName.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries)[1];
                }
            }

            string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
            SiteEntity siteToCreate = new SiteEntity()
            {
                Url = siteToCreateUrl,
                Template = "STS#0",
                Title = "Test",
                Description = "Test site collection",
                SiteOwnerLogin = siteOwnerLogin,
                Lcid = 1033,
            };

            tenant.CreateSiteCollection(siteToCreate);

            // Create the default groups
            using (ClientContext cc = new ClientContext(siteToCreateUrl))
            {
                var owners = cc.Web.AddGroup("Test Owners", "", true, false);
                var members = cc.Web.AddGroup("Test Members", "", true, false);
                var visitors = cc.Web.AddGroup("Test Visitors", "", true, true);

                cc.Web.AssociateDefaultGroups(owners, members, visitors);
            }

            return siteToCreateUrl;
        }
开发者ID:OfficeDev,项目名称:PnP-Sites-Core,代码行数:39,代码来源:FunctionalTestBase.cs

示例9: ProcessBaseTemplates

        private void ProcessBaseTemplates(List<BaseTemplate> templates, bool deleteSites, bool createSites)
        {
            using (var tenantCtx = TestCommon.CreateTenantClientContext())
            {
                tenantCtx.RequestTimeout = Timeout.Infinite;
                Tenant tenant = new Tenant(tenantCtx);

#if !CLIENTSDKV15
                if (deleteSites)
                {
                    // First delete all template site collections when in SPO
                    foreach (var template in templates)
                    {
                        string siteUrl = GetSiteUrl(template);

                        try
                        {
                            Console.WriteLine("Deleting existing site {0}", siteUrl);
                            tenant.DeleteSiteCollection(siteUrl, false);
                        }
                        catch{ }
                    }
                }

                if (createSites)
                {
                    // Create site collections
                    foreach (var template in templates)
                    {
                        string siteUrl = GetSiteUrl(template);

                        Console.WriteLine("Creating site {0}", siteUrl);

                        bool siteExists = false;
                        if (template.SubSiteTemplate.Length > 0)
                        {
                            siteExists = tenant.SiteExists(siteUrl);
                        }

                        if (!siteExists)
                        {
                            tenant.CreateSiteCollection(new Entities.SiteEntity()
                            {
                                Lcid = 1033,
                                TimeZoneId = 4,
                                SiteOwnerLogin = (TestCommon.Credentials as SharePointOnlineCredentials).UserName,
                                Title = "Template Site",
                                Template = template.Template,
                                Url = siteUrl,
                            }, false, true);
                        }

                        if (template.SubSiteTemplate.Length > 0)
                        {
                            using (ClientContext ctx = TestCommon.CreateClientContext())
                            {
                                using (var sitecolCtx = ctx.Clone(siteUrl))
                                {
                                    sitecolCtx.Web.Webs.Add(new WebCreationInformation()
                                    {
                                        Title = string.Format("template{0}", template.SubSiteTemplate),
                                        Language = 1033,
                                        Url = string.Format("template{0}", template.SubSiteTemplate.Replace("#", "")),
                                        UseSamePermissionsAsParentSite = true
                                    });
                                    sitecolCtx.ExecuteQueryRetry();
                                }
                            }
                        }
                    }
                }
#endif
            }

            // Export the base templates
            using (ClientContext ctx = TestCommon.CreateClientContext())
            {
                foreach (var template in templates)
                {
                    string siteUrl = GetSiteUrl(template, false);

                    // Export the base templates
                    using (ClientContext cc = ctx.Clone(siteUrl))
                    {
                        // Specify null as base template since we do want "everything" in this case
                        ProvisioningTemplateCreationInformation creationInfo = new ProvisioningTemplateCreationInformation(cc.Web);
                        creationInfo.BaseTemplate = null;
                        // Do not extract the home page for the base templates
                        creationInfo.HandlersToProcess ^= Handlers.PageContents;

                        // Override the save name. Case is online site collection provisioned using blankinternetcontainer#0 which returns
                        // blankinternet#0 as web template using CSOM/SSOM API
                        string templateName = template.Template;
                        if (template.SaveAsTemplate.Length > 0)
                        {
                            templateName = template.SaveAsTemplate;
                        }

                        ProvisioningTemplate p = cc.Web.GetProvisioningTemplate(creationInfo);
                        if (template.SubSiteTemplate.Length > 0)
//.........这里部分代码省略.........
开发者ID:arangas,项目名称:PnP-Sites-Core,代码行数:101,代码来源:BaseTemplateTests.cs

示例10: btnCreateSite_Click

        protected void btnCreateSite_Click(object sender, EventArgs e)
        {
            User currUser = ResolveCurrentUser();

            //get the base tenant admin urls
            var tenantStr = Page.Request["SPHostUrl"].ToLower().Replace("-my", "").Substring(8);
            tenantStr = tenantStr.Substring(0, tenantStr.IndexOf("."));

            // Let's resolve the admin URL and wanted new site URL
            var webUrl = String.Format("https://{0}.sharepoint.com/{1}/{2}", tenantStr, "sites", txtUrl.Text);
            var tenantAdminUri = new Uri(String.Format("https://{0}-admin.sharepoint.com", tenantStr));

            // Creating new app only context for the operation
            string accessToken = TokenHelper.GetAppOnlyAccessToken(
                TokenHelper.SharePointPrincipal,
                tenantAdminUri.Authority,
                TokenHelper.GetRealmFromTargetUrl(tenantAdminUri)).AccessToken;

            using (var ctx = TokenHelper.GetClientContextWithAccessToken(tenantAdminUri.ToString(), accessToken))
            {
                Tenant tenant = new Tenant(ctx);

                if (tenant.SiteExists(webUrl))
                {
                    lblStatus1.Text = string.Format("Site already existed. Used URL - {0}", webUrl);
                }
                else
                {
                    // Create new site collection with some storage limts and English locale
                    tenant.CreateSiteCollection(webUrl, txtName.Text, currUser.Email, drpContentTypes.SelectedValue, 500, 400, 7, 7, 1, 1033);

                    // Let's get instance to the newly added site collection using URLs
                    var siteUri = new Uri(webUrl);
                    string token = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, siteUri.Authority, TokenHelper.GetRealmFromTargetUrl(new Uri(webUrl))).AccessToken;
                    using (var newWebContext = TokenHelper.GetClientContextWithAccessToken(siteUri.ToString(), token))
                    {
                        // Let's modify the web slightly
                        var newWeb = newWebContext.Web;
                        newWebContext.Load(newWeb);
                        newWebContext.ExecuteQuery();

                        // Let's add two document libraries to the site 
                        newWeb.CreateDocumentLibrary("Specifications"); 
                        newWeb.CreateDocumentLibrary("Presentations");

                        // Let's also apply theme to the site to demonstrate how easy this is
                        newWeb.SetComposedLookByUrl("Characters");
                    }

                    lblStatus1.Text = string.Format("Created a new site collection to address <a href='{0}'>{1}</a>", webUrl, webUrl);
                }
            }
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:53,代码来源:Scenario2.aspx.cs

示例11: AddSiteCollectionTenant

 public static Guid AddSiteCollectionTenant(this Web web, SiteEntity properties, bool removeFromRecycleBin = false, bool wait = true)
 {
     Tenant tenant = new Tenant(web.Context);
     return tenant.CreateSiteCollection(properties, removeFromRecycleBin, wait);
 }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:5,代码来源:WebExtensions.deprecated.cs

示例12: AddSiteCollection

        /// <summary>
        /// Launches a site collection creation and waits for the creation to finish
        /// </summary>
        /// <param name="properties">Describes the site collection to be created</param>
        public void AddSiteCollection(SharePointProvisioningData properties)
        {
            if (this.CreateOnPremises)
            {
                this.SiteProvisioningOnPremises.CreateSiteCollectionOnPremises(this.SharePointProvisioningData);
                this.createdSiteContext = this.SiteProvisioningOnPremises.SpOnPremiseAuthentication(this.SharePointProvisioningData.Url);
            }
            else
            {
                SiteEntity newSite = new SiteEntity
                {
                    Description = properties.Description,
                    Title = properties.Title,
                    Url = properties.Url,
                    Template = properties.Template,
                    Lcid = properties.Lcid,
                    SiteOwnerLogin = properties.SiteOwner.Login,
                    StorageMaximumLevel = properties.StorageMaximumLevel,
                    StorageWarningLevel = properties.StorageWarningLevel,
                    TimeZoneId = properties.TimeZoneId,
                    UserCodeMaximumLevel = properties.UserCodeMaximumLevel,
                    UserCodeWarningLevel = properties.UserCodeWarningLevel,
                };

                Tenant tenant = new Tenant(this.AppOnlyClientContext);
                tenant.CreateSiteCollection(newSite);
                InstantiateCreatedSiteClientContext(newSite.Url);
            }
        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:33,代码来源:SiteProvisioningBase.cs

示例13: CreateSiteCollection

        private void CreateSiteCollection(SiteCollectionProvisioningJob job)
        {
            Console.WriteLine("Creating Site Collection \"{0}\".", job.RelativeUrl);

            // Define the full Site Collection URL
            String siteUrl = String.Format("{0}{1}",
                PnPPartnerPackSettings.InfrastructureSiteUrl.Substring(0, PnPPartnerPackSettings.InfrastructureSiteUrl.IndexOf("sharepoint.com/") + 14),
                job.RelativeUrl);

            // Load the template from the source Templates Provider
            if (!String.IsNullOrEmpty(job.TemplatesProviderTypeName))
            {
                ProvisioningTemplate template = null;

                var templatesProvider = PnPPartnerPackSettings.TemplatesProviders[job.TemplatesProviderTypeName];
                if (templatesProvider != null)
                {
                    template = templatesProvider.GetProvisioningTemplate(job.ProvisioningTemplateUrl);
                }

                if (template != null)
                {
                    using (var adminContext = PnPPartnerPackContextProvider.GetAppOnlyTenantLevelClientContext())
                    {
                        adminContext.RequestTimeout = Timeout.Infinite;

                        // Configure the Site Collection properties
                        SiteEntity newSite = new SiteEntity();
                        newSite.Description = job.Description;
                        newSite.Lcid = (uint)job.Language;
                        newSite.Title = job.SiteTitle;
                        newSite.Url = siteUrl;
                        newSite.SiteOwnerLogin = job.PrimarySiteCollectionAdmin;
                        newSite.StorageMaximumLevel = job.StorageMaximumLevel;
                        newSite.StorageWarningLevel = job.StorageWarningLevel;

                        // Use the BaseSiteTemplate of the template, if any, otherwise
                        // fallback to the pre-configured site template (i.e. STS#0)
                        newSite.Template = !String.IsNullOrEmpty(template.BaseSiteTemplate) ?
                            template.BaseSiteTemplate :
                            PnPPartnerPackSettings.DefaultSiteTemplate;

                        newSite.TimeZoneId = job.TimeZone;
                        newSite.UserCodeMaximumLevel = job.UserCodeMaximumLevel;
                        newSite.UserCodeWarningLevel = job.UserCodeWarningLevel;

                        // Create the Site Collection and wait for its creation (we're asynchronous)
                        var tenant = new Tenant(adminContext);
                        tenant.CreateSiteCollection(newSite, true, true); // TODO: Do we want to empty Recycle Bin?

                        Site site = tenant.GetSiteByUrl(siteUrl);
                        Web web = site.RootWeb;

                        adminContext.Load(site, s => s.Url);
                        adminContext.Load(web, w => w.Url);
                        adminContext.ExecuteQueryRetry();

                        // Enable Secondary Site Collection Administrator
                        if (!String.IsNullOrEmpty(job.SecondarySiteCollectionAdmin))
                        {
                            Microsoft.SharePoint.Client.User secondaryOwner = web.EnsureUser(job.SecondarySiteCollectionAdmin);
                            secondaryOwner.IsSiteAdmin = true;
                            secondaryOwner.Update();

                            web.SiteUsers.AddUser(secondaryOwner);
                            adminContext.ExecuteQueryRetry();
                        }

                        Console.WriteLine("Site \"{0}\" created.", site.Url);

                        // Check if external sharing has to be enabled
                        if (job.ExternalSharingEnabled)
                        {
                            EnableExternalSharing(tenant, site);

                            // Enable External Sharing
                            Console.WriteLine("Enabled External Sharing for site \"{0}\".",
                                site.Url);
                        }
                    }

                    // Move to the context of the created Site Collection
                    using (ClientContext clientContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(siteUrl))
                    {
                        clientContext.RequestTimeout = Timeout.Infinite;

                        Site site = clientContext.Site;
                        Web web = site.RootWeb;

                        clientContext.Load(site, s => s.Url);
                        clientContext.Load(web, w => w.Url);
                        clientContext.ExecuteQueryRetry();

                        // Check if we need to enable PnP Partner Pack overrides
                        if (job.PartnerPackExtensionsEnabled)
                        {
                            // Enable Responsive Design
                            PnPPartnerPackUtilities.EnablePartnerPackOnSite(site.Url);

                            Console.WriteLine("Enabled PnP Partner Pack Overrides on site \"{0}\".",
//.........这里部分代码省略.........
开发者ID:OfficeDev,项目名称:PnP-Partner-Pack,代码行数:101,代码来源:SiteCollectionProvisioningJobHandler.cs

示例14: CreateTestSiteCollection

        private string CreateTestSiteCollection(Tenant tenant, string sitecollectionName)
        {
            string devSiteUrl = ConfigurationManager.AppSettings["SPODevSiteUrl"];
            string siteToCreateUrl = GetTestSiteCollectionName(devSiteUrl, sitecollectionName);
            SiteEntity siteToCreate = new SiteEntity()
            {
                Url = siteToCreateUrl,
                Template = "STS#0",
                Title = "Test",
                Description = "Test site collection",
                SiteOwnerLogin = string.Format("{0}\\{1}", ConfigurationManager.AppSettings["OnPremDomain"], ConfigurationManager.AppSettings["OnPremUserName"]),
            };

            tenant.CreateSiteCollection(siteToCreate);
            return siteToCreateUrl;
        }
开发者ID:AaronSaikovski,项目名称:PnP,代码行数:16,代码来源:Tenant15ExtensionsTests.cs


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