Ejemplo n.º 1
0
        /// <summary>
        /// Member to create a site collection
        /// </summary>
        /// <param name="siteRequest">The SiteRequest</param>
        /// <param name="template">The Template</param>
        public void CreateSiteCollection(SiteInformation siteRequest, Template template)
        {
            _siteprovisioningService.Authentication = new AppOnlyAuthenticationTenant();
            _siteprovisioningService.Authentication.TenantAdminUrl = template.TenantAdminUrl;

            ReflectionManager rm = new ReflectionManager();

            var siteUrlProvider = rm.GetSiteUrlProvider("SiteUrlProvider");
            if(siteUrlProvider != null)
            {
                var newUrl = siteUrlProvider.GenerateSiteUrl(siteRequest, template);
                if (!String.IsNullOrEmpty(newUrl))
                {
                    Log.Info("SiteProvisioningManager.CreateSiteCollection", "Site {0} was renamed to {1}", siteRequest.Url, newUrl);

                    SiteRequestFactory.GetInstance().GetSiteRequestManager().UpdateRequestUrl(siteRequest.Url, newUrl);
                    siteRequest.Url = newUrl;

                }
                
            }
            _siteprovisioningService.CreateSiteCollection(siteRequest, template);
            if(siteRequest.EnableExternalSharing)
            {
                _siteprovisioningService.SetExternalSharing(siteRequest);
            }
           
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Member to create a site collection
        /// </summary>
        /// <param name="siteRequest">The SiteRequest</param>
        /// <param name="template">The Template</param>
        public void CreateSiteCollection(SiteInformation siteRequest, Template template)
        {
            _siteprovisioningService.Authentication = new AppOnlyAuthenticationTenant();
            _siteprovisioningService.Authentication.TenantAdminUrl = template.TenantAdminUrl;

            ReflectionManager rm = new ReflectionManager();

            var siteUrlProvider = rm.GetSiteUrlProvider("SiteUrlProvider");
            if(siteUrlProvider != null)
            {
                var newUrl = siteUrlProvider.GenerateSiteUrl(siteRequest, template);
                if (!String.IsNullOrEmpty(newUrl))
                {
                    Log.Info("SiteProvisioningManager.CreateSiteCollection", "Site {0} was renamed to {1}", siteRequest.Url, newUrl);

                    SiteRequestFactory.GetInstance().GetSiteRequestManager().UpdateRequestUrl(siteRequest.Url, newUrl);
                    siteRequest.Url = newUrl;

                }
                
            }



           // Check to see if the site already exists before attempting to create it
            bool siteExists = _siteprovisioningService.SiteExists(siteRequest.Url.ToString());

            if (!siteExists)
            {
                _siteprovisioningService.CreateSiteCollection(siteRequest, template);
                if (siteRequest.EnableExternalSharing)
                {
                    _siteprovisioningService.SetExternalSharing(siteRequest);
                }
            }
            else
            {                
                Log.Info("SiteProvisioningManager.CreateSiteCollection", "Site already exists. Moving on to next provisioning step");                
            }           
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Member to create a sub site
        /// </summary>
        /// <param name="siteRequest">The SiteRequest</param>
        /// <param name="template">The Template</param>
        public Web CreateSubSite(SiteInformation siteRequest, Template template)
        {
            Web newWeb = null;

            _siteprovisioningService.Authentication = new AppOnlyAuthenticationTenant();
            _siteprovisioningService.Authentication.TenantAdminUrl = template.TenantAdminUrl;

            ReflectionManager rm = new ReflectionManager();

            var siteUrlProvider = rm.GetSiteUrlProvider("SiteUrlProvider");
            if (siteUrlProvider != null)
            {
                var newUrl = siteUrlProvider.GenerateSiteUrl(siteRequest, template);
                if (!String.IsNullOrEmpty(newUrl))
                {
                    Log.Info("SiteProvisioningManager.CreateSiteCollection", "Site {0} was renamed to {1}", siteRequest.Url, newUrl);

                    SiteRequestFactory.GetInstance().GetSiteRequestManager().UpdateRequestUrl(siteRequest.Url, newUrl);
                    siteRequest.Url = newUrl;

                }
            }

            // Check to see if the site already exists before attempting to create it
            bool siteExists = _siteprovisioningService.SubSiteExists(siteRequest.Url.ToString());

            if (!siteExists)
            {
                newWeb = _siteprovisioningService.CreateSubSite(siteRequest, template);
               
            }
            else
            {
                Log.Info("Provisioning.Common.Office365SiteProvisioningService.CreateSubSite", PCResources.SiteCreation_Creation_Starting, siteRequest.Url);
                Uri siteUri = new Uri(siteRequest.Url);                
                string realm = TokenHelper.GetRealmFromTargetUrl(siteUri);
                string accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, siteUri.Authority, realm).AccessToken;

                using (var ctx = TokenHelper.GetClientContextWithAccessToken(siteRequest.Url, accessToken))
                {
                    newWeb = ctx.Web;
                }
            }

            return newWeb;
        }
Ejemplo n.º 4
0
        public SiteUrlCheckRequest IsSiteUrlProviderUsed([FromBody]string value)
        {
            var _request = JsonConvert.DeserializeObject<SiteUrlCheckRequest>(value);

            ReflectionManager rm = new ReflectionManager();

            var siteUrlProvider = rm.GetSiteUrlProvider("SiteUrlProvider");
            if (siteUrlProvider != null)
            {
                _request.UsesCustomProvider = false;
            }
            else
            {
                _request.UsesCustomProvider = true;
            }

            return _request;
        }