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


C# Tenant.GetSiteProperties方法代码示例

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


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

示例1: GetTenantSiteCollectionsRecursive

        private List<SiteProperties> GetTenantSiteCollectionsRecursive(Tenant tenant, List<SiteProperties> siteProperties, int startPosition) 
        {
            Logger.Verbose($"Fetching tenant site collections starting from position {startPosition}");
            var tenantSiteCollections = tenant.GetSiteProperties(startPosition, true);
            tenant.Context.Load(tenantSiteCollections);
            tenant.Context.ExecuteQuery();

            var newSiteProperties = siteProperties.Concat(tenantSiteCollections).ToList();

            return tenantSiteCollections.NextStartIndex == -1
                ? newSiteProperties
                : GetTenantSiteCollectionsRecursive(tenant, newSiteProperties, tenantSiteCollections.NextStartIndex);
        }
开发者ID:ronnieholm,项目名称:Bugfree.Spo.Cqrs,代码行数:13,代码来源:GetTenantSiteCollections.cs

示例2: TenantAPIJob_TimerJobRun

        void TenantAPIJob_TimerJobRun(object sender, TimerJobRunEventArgs e)
        {
            Tenant t = new Tenant(e.TenantClientContext);
            var sites = t.GetSiteProperties(0, true);
            e.TenantClientContext.Load(sites);
            e.TenantClientContext.ExecuteQueryRetry();

            foreach(var site in sites)
            {
                Console.WriteLine(site.Template);
            }

        }
开发者ID:Calisto1980,项目名称:PnP,代码行数:13,代码来源:TenantAPIJob.cs

示例3: SiteURLAlreadyInUse

 public bool SiteURLAlreadyInUse(ClientContext adminCtx, string fullSiteUrl)
 {
     var tenant = new Tenant(adminCtx);
     SPOSitePropertiesEnumerable spp = tenant.GetSiteProperties(0, true);
     adminCtx.Load(spp);
     adminCtx.ExecuteQuery();
     foreach (SiteProperties sp in spp)
     {
         if (sp.Url.ToLowerInvariant() == fullSiteUrl.ToLowerInvariant())
         {
             return true;
         }
     }
     return false;
 }
开发者ID:CherifSy,项目名称:PnP,代码行数:15,代码来源:SiteRequestManager.cs

示例4: Execute

        public void Execute(ClientContext ctx, Uri url, string template, string owner, string title, int sizeInMb, uint languageId)
        {
            Logger.Verbose($"Started executing {nameof(CreateSiteCollection)} for url '{url}'");

            var tenant = new Tenant(ctx);
            ctx.Load(tenant);

            var siteCollections = tenant.GetSiteProperties(0, true);
            ctx.Load(siteCollections);
            ctx.ExecuteQuery();
            var siteCollection = siteCollections.SingleOrDefault(sc => sc.Url == url.ToString());

            if (siteCollection != null)
            {
                Logger.Warning($"Site collection at url '{url}' already exist");
                return;
            }

            var operation = tenant.CreateSite(new SiteCreationProperties
            {
                Url = url.ToString(),
                Owner = owner,
                Template = template,
                StorageMaximumLevel = sizeInMb,
                UserCodeMaximumLevel = 0,
                UserCodeWarningLevel = 0,
                // level is in absolute MBs, not percent
                StorageWarningLevel = (long)(sizeInMb * 0.9),
                Title = title,
                CompatibilityLevel = 15,
                TimeZoneId = 3,
                Lcid = languageId
            });

            ctx.Load(operation);
            ctx.ExecuteQuery();

            while (!operation.IsComplete)
            {
                System.Threading.Thread.Sleep(15000);
                ctx.Load(operation);
                ctx.ExecuteQuery();
                var status = operation.IsComplete ? "complete" : "waiting";
                Logger.Verbose($"Site creation status: {status}");
            }
        }
开发者ID:ronnieholm,项目名称:Bugfree.Spo.Cqrs,代码行数:46,代码来源:CreateSiteCollection.cs

示例5: Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                using (var ctx = GetAdminContext())
                {
                    // get site collections.
                    Tenant tenant = new Tenant(ctx);
                    SPOSitePropertiesEnumerable sites = tenant.GetSiteProperties(0, true);
                    ctx.Load(tenant);
                    ctx.Load(sites);
                    ctx.ExecuteQuery();

                    SharingCapabilities tenantSharing = tenant.SharingCapability;
                    switch (tenantSharing)
                    {
                        case SharingCapabilities.Disabled:
                            lblStatus.Text = "External sharing is disabled at tenant level.";
                            break;
                        case SharingCapabilities.ExternalUserSharingOnly:
                            lblStatus.Text = "External sharing at tenant level is set only for authenticated users.";
                            break;
                        case SharingCapabilities.ExternalUserAndGuestSharing:
                            lblStatus.Text = "External sharing at tenant level is for authenticated and guest users.";
                            break;
                        default:
                            break;
                    }

                    if (tenantSharing != SharingCapabilities.Disabled)
                    {
                        // List site collections
                        foreach (var item in sites)
                        {
                            sitecollections.Items.Add(new System.Web.UI.WebControls.ListItem(item.Url, item.Url));
                        }
                    }
                }

            }
        }
开发者ID:tandis,项目名称:PnP,代码行数:41,代码来源:ExternalSettingsAtSiteCollectionLevel.aspx.cs

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

示例7: Settings

        public ActionResult Settings()
        {
            SettingsViewModel model = new SettingsViewModel();

            using (var adminContext = PnPPartnerPackContextProvider.GetAppOnlyTenantLevelClientContext())
            {
                var tenant = new Tenant(adminContext);

                // TODO: Here we could add paging capabilities
                var siteCollections = tenant.GetSiteProperties(0, true);
                adminContext.Load(siteCollections);
                adminContext.ExecuteQueryRetry();

                model.SiteCollections =
                    (from site in siteCollections
                     select new SiteCollectionSettings {
                         Title = site.Title,
                         Url = site.Url,
                         PnPPartnerPackEnabled = false, // PnPPartnerPackUtilities.IsPartnerPackEnabledOnSite(site.Url),
                     }).ToArray();
            }

            return View(model);
        }
开发者ID:briankinsella,项目名称:PnP-Partner-Pack,代码行数:24,代码来源:HomeController.cs

示例8: GetSiteCollectionsInPath

        private List<string> GetSiteCollectionsInPath(string path)
        {
            var siteUri = "https://rdoyle-admin.sharepoint.com/";
            var baseUri = "https://rdoyle.sharepoint.com/";

            var results = new List<string>();

            using (var context = this.contextFactory.GetContext(siteUri))
            {

                var tenant = new Tenant(context);
                var spp = tenant.GetSiteProperties(0, true);

                context.Load(spp);
                context.ExecuteQuery();

                foreach (var site in spp)
                {
                    var uri = site.Url.ToString();
                    if (!uri.StartsWith(baseUri))
                    {
                        continue;
                    }

                    uri = uri.Remove(0, baseUri.Length);
                    var uriParts = uri.Split('/').ToArray();
                    if (uriParts.Any() && uriParts[0] == path)
                    {
                        results.Add(site.Url.ToString());
                    }
                }
            }

            return results;
        }
开发者ID:richard-doyle,项目名称:sharepoint-examples,代码行数:35,代码来源:SiteSearch.cs

示例9: GetSiteCollectionStatusByUrl

        public static string GetSiteCollectionStatusByUrl(ClientContext clientContext, string url)
        {
            var tenant = new Tenant(clientContext);
            var sitePropertiesColl = tenant.GetSiteProperties(0, true);

            var q = clientContext.LoadQuery(sitePropertiesColl.Where(n => n.Url == url));
            clientContext.ExecuteQuery();

            if (q.Count() > 0)
            {
                SiteProperties prop = q.FirstOrDefault() as SiteProperties;
                return prop.Status;
            }
            else
            {
                return "None";
            }
        }
开发者ID:TBag,项目名称:Property-Inspection-Code-Sample,代码行数:18,代码来源:CSOMUtil.cs

示例10: UpdateTemplates

        private void UpdateTemplates(RefreshSitesJob job)
        {
            // For each Site Collection in the tenant
            using (var adminContext = PnPPartnerPackContextProvider.GetAppOnlyTenantLevelClientContext())
            {
                var tenant = new Tenant(adminContext);

                var siteCollections = tenant.GetSiteProperties(0, true);
                adminContext.Load(siteCollections);
                adminContext.ExecuteQueryRetry();

                foreach (var site in siteCollections)
                {
                    // Exclude Microsoft NextGen Portals
                    if (!site.Url.ToLower().Contains("/portals/")
                        && !site.Url.ToLower().Contains("-public.sharepoint.com")
                        && !site.Url.ToLower().Contains("-my.sharepoint.com"))
                    {
                        using (var siteContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(site.Url))
                        {
                            // Get a reference to the target web
                            var targetWeb = siteContext.Site.RootWeb;

                            // Update the root web of the site collection
                            UpdateTemplateOnWeb(targetWeb, job);
                        }
                    }
                }
            }
        }
开发者ID:OfficeDev,项目名称:PnP-Partner-Pack,代码行数:30,代码来源:RefreshSitesJobHandler.cs

示例11: Main

        static void Main(string[] args)
        {
            using (var context = new ClientContext(uri))
            {
            context.Credentials = new System.Net.NetworkCredential(user, securedPassword, domain);
            var tenant = new Tenant(context);

            int startIndex = 0;

            SPOSitePropertiesEnumerable tenantSiteProperties = null;

            while (tenantSiteProperties == null || startIndex > 0)
            {
            tenantSiteProperties = tenant.GetSiteProperties(startIndex, true);
            context.Load(tenantSiteProperties);
            context.ExecuteQuery();

            foreach (SiteProperties sp in tenantSiteProperties)
            {
            //get site title here.
            }

            startIndex = tenantSiteProperties.NextStartIndex;
            }
            }

            // Request Office365 site from the user
            string siteUrl = GetSite();

            /* Prompt for Credentials */
            Console.WriteLine("Enter Credentials for {0}", siteUrl);

            string userName = GetUserName();
            SecureString pwd = GetPassword();

            using (var context = new ClientContext(siteUrl))
            {
                context.AuthenticationMode = ClientAuthenticationMode.Default;
                context.Credentials = new SharePointOnlineCredentials(userName, pwd);
                var tenant = new Tenant(context);

                int startIndex = 0;

                SPOSitePropertiesEnumerable tenantSiteProperties = null;

                while (tenantSiteProperties == null || startIndex > 0)
                {
                    tenantSiteProperties = tenant.GetSiteProperties(startIndex, true);
                    context.Load(tenantSiteProperties);
                    context.ExecuteQuery();

                    foreach (SiteProperties sp in tenantSiteProperties)
                    {
                        String siteurl = sp.Url;
                        Console.WriteLine(siteurl);

                    }

                    startIndex = tenantSiteProperties.NextStartIndex;
                }
            }

            /* End Program if no Credentials */
            if (string.IsNullOrEmpty(userName) || (pwd == null))
                return;

            // Get access to source site
            using (var ctx = new ClientContext(siteUrl))
            {
                ctx.AuthenticationMode = ClientAuthenticationMode.Default;
                ctx.Credentials = new SharePointOnlineCredentials(userName, pwd);

                Web web = ctx.Web;
                var allProperties = web.AllProperties;

                ctx.Load(web);
                ctx.Load(allProperties);
                ctx.ExecuteQuery();

                UploadAssetsToHostWeb(web);

                // Actual code for operations
                // Set the properties accordingly
                // Notice that these are new properties in 2014 April CU of 15 hive CSOM and July release of MSO CSOM
                web.AlternateCssUrl = ctx.Web.ServerRelativeUrl + "/SiteAssets/Coso-Css.css";

                // Ensure proper meta tag for viewport is set
                // Make sure that hardware devices scale CSS definitions properly
                // More details can be found http://www.n8d.at/blog/how-to-add-viewport-meta-without-editing-the-master-page/

                // Check if SEO is enabled and property for custom meta tags exists
                // This can be enabled on any team site based site collection by enabling
                // the site collection feature "Publishing Infastructure"
                // No other publishing related feature needs to be activated
                // Enable custom meta tags
                if (allProperties.FieldValues.ContainsKey("seoincludecustommetatagpropertyname")) {
                    allProperties["seoincludecustommetatagpropertyname"] = true.ToString();
                }
                // Add value of custom meta tag
                if (allProperties.FieldValues.ContainsKey("seocustommetatagpropertyname"))
//.........这里部分代码省略.........
开发者ID:CorpSoftCH,项目名称:EvolutionDay2015,代码行数:101,代码来源:Program.cs

示例12: DeleteSiteCollection

        /// <summary>
        /// Method for deleting site collections
        /// </summary>
        /// <param name="clientContext">SharePoint Client Context</param>
        /// <param name="clientUrl">Url for Site Collection</param>
        internal static void DeleteSiteCollection(ClientContext clientContext, string clientUrl)
        {
            try
            {
                Tenant tenant = new Tenant(clientContext);
                clientContext.Load(tenant);
                clientContext.ExecuteQuery(); //login into SharePoint online

                SPOSitePropertiesEnumerable spSiteProperties = tenant.GetSiteProperties(0, true);
                clientContext.Load(spSiteProperties);
                clientContext.ExecuteQuery();

                SiteProperties siteProperties = (from properties in spSiteProperties
                                                 where properties.Url.ToString().ToUpper() == clientUrl.ToUpper()
                                                 select properties).FirstOrDefault();

                if (null != siteProperties)
                {
                    // site exists
                    // delete the site
                    SpoOperation spoOperation = tenant.RemoveSite(clientUrl);
                    clientContext.Load(spoOperation, operation => operation.IsComplete);
                    clientContext.ExecuteQuery();

                    while (!spoOperation.IsComplete)
                    {
                        Console.Write(".");
                        //Wait for 30 seconds and then try again
                        System.Threading.Thread.Sleep(30000);
                        spoOperation.RefreshLoad();
                        clientContext.ExecuteQuery();
                    }
                    Console.WriteLine("Site Collection: " + clientUrl + " is deleted successfully");
                }
                else
                {
                    // site does not exists
                    return;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception occurred while deleting site collection: " + exception.Message);
            }
        }
开发者ID:RMSATS,项目名称:mattercenter,代码行数:50,代码来源:Program.cs

示例13: CreateSiteCollections

        /// <summary>
        /// Method to create site collections
        /// </summary>
        /// <param name="clientContext">SharePoint Client Context</param>
        /// <param name="configVal">Values in Config sheet</param>
        /// <param name="clientUrl">Url for Site Collection</param>
        /// <param name="clientTitle">Name of Site Collection</param>
        internal static void CreateSiteCollections(ClientContext clientContext, Dictionary<string, string> configVal, string clientUrl, string clientTitle)
        {
            try
            {
                Tenant tenant = new Tenant(clientContext);
                clientContext.Load(tenant);
                clientContext.ExecuteQuery(); //login into SharePoint Online

                SPOSitePropertiesEnumerable spoSiteProperties = tenant.GetSiteProperties(0, true);
                clientContext.Load(spoSiteProperties);
                clientContext.ExecuteQuery();
                SiteProperties siteProperties = (from properties in spoSiteProperties
                                                 where properties.Url.ToString().ToUpper() == clientUrl.ToUpper()
                                                 select properties).FirstOrDefault();

                if (null != siteProperties)
                {
                    // site exists
                    Console.WriteLine(clientUrl + " already exists...");
                    return;
                }
                else
                {
                    // site does not exists
                    SiteCreationProperties newSite = new SiteCreationProperties()
                    {
                        Url = clientUrl,
                        Owner = configVal["Username"],
                        Template = ConfigurationManager.AppSettings["template"], //using the team site template, check the MSDN if you want to use other template
                        StorageMaximumLevel = Convert.ToInt64(ConfigurationManager.AppSettings["storageMaximumLevel"], CultureInfo.InvariantCulture), //1000
                        UserCodeMaximumLevel = Convert.ToDouble(ConfigurationManager.AppSettings["userCodeMaximumLevel"], CultureInfo.InvariantCulture), //300
                        Title = clientTitle,
                        CompatibilityLevel = 15, //15 means SharePoint online 2013, 14 means SharePoint online 2010
                    };
                    SpoOperation spo = tenant.CreateSite(newSite);
                    clientContext.Load(tenant);
                    clientContext.Load(spo, operation => operation.IsComplete);

                    clientContext.ExecuteQuery();

                    Console.WriteLine("Creating site collection at " + clientUrl);
                    Console.WriteLine("Loading.");
                    //Check if provisioning of the SiteCollection is complete.
                    while (!spo.IsComplete)
                    {
                        Console.Write(".");
                        //Wait for 30 seconds and then try again
                        System.Threading.Thread.Sleep(30000);
                        spo.RefreshLoad();
                        clientContext.ExecuteQuery();
                    }
                    Console.WriteLine("Site Collection: " + clientUrl + " is created successfully");
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception occurred while creating site collection: " + exception.Message);
            }
        }
开发者ID:RMSATS,项目名称:mattercenter,代码行数:66,代码来源:Program.cs

示例14: ApplyBranding

        private void ApplyBranding(BrandingJob job)
        {
            // Use the infrastructural site collection to temporary store the template with color palette and font files
            using (var repositoryContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(
                    PnPPartnerPackSettings.InfrastructureSiteUrl))
            {
                var brandingSettings = PnPPartnerPackUtilities.GetTenantBrandingSettings();
                ProvisioningTemplate template = PrepareBrandingTemplate(repositoryContext, brandingSettings);

                // For each Site Collection in the tenant
                using (var adminContext = PnPPartnerPackContextProvider.GetAppOnlyTenantLevelClientContext())
                {
                    var tenant = new Tenant(adminContext);

                    var siteCollections = tenant.GetSiteProperties(0, true);
                    adminContext.Load(siteCollections);
                    adminContext.ExecuteQueryRetry();

                    foreach (var site in siteCollections)
                    {
                        if (!site.Url.ToLower().Contains("/portals/")
                            && !site.Url.ToLower().Contains("-public.sharepoint.com")
                            && !site.Url.ToLower().Contains("-my.sharepoint.com"))
                        {
                            // Clean-up the template
                            template.WebSettings.MasterPageUrl = null;

                            using (var siteContext = PnPPartnerPackContextProvider.GetAppOnlyClientContext(site.Url))
                            {
                                // Get a reference to the target web
                                var targetWeb = siteContext.Site.RootWeb;

                                // Update the root web of the site collection
                                ApplyBrandingOnWeb(targetWeb, brandingSettings, template);
                            }
                        }
                    }
                }
            }
        }
开发者ID:OfficeDev,项目名称:PnP-Partner-Pack,代码行数:40,代码来源:BrandingJobHandler.cs


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