Example #1
0
        /// <summary>
        /// Member to handle provisioning sites
        /// </summary>
        /// <param name="siteRequests">The site request</param>
        public void ProvisionSites(ICollection<SiteInformation> siteRequests)
        {
            var _tm = this._siteTemplateFactory.GetManager();
            var _requestManager = this._requestFactory.GetSiteRequestManager();

            foreach (var siteRequest in siteRequests)
            {
                try 
                {
                    var _template = _tm.GetTemplateByName(siteRequest.Template);
              
                    if (_template == null)
                    {   
                        //NO TEMPLATE FOUND THAT MATCHES WE CANNOT PROVISION A SITE
                        var _message = string.Format("Template: {0} was not found for site {1}. Ensure that the template file exits.", siteRequest.Template, siteRequest.Url);
                        Log.Error("Provisioning.Job.SiteProvisioningJob.ProvisionSites", _message );
                        throw new ConfigurationErrorsException(_message);
                    }
                   
                    var _provisioningTemplate = _tm.GetProvisioningTemplate(_template.ProvisioningTemplate);
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.Processing);
                    SiteProvisioningManager _siteProvisioningManager = new SiteProvisioningManager(siteRequest, _template);
                    Log.Info("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Provisioning Site Request for Site Url {0}.", siteRequest.Url);
                
                    _siteProvisioningManager.CreateSiteCollection(siteRequest, _template);
                    _siteProvisioningManager.ApplyProvisioningTemplate(_provisioningTemplate, siteRequest, _template);
                    this.SendSuccessEmail(siteRequest);
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.Complete);
                }
                catch(ProvisioningTemplateException _pte)
                {
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.CompleteWithErrors, _pte.Message);
                }
                catch(Exception _ex)
                {
                    Log.Error("Provisioning.Job.SiteProvisioningJob.ProvisionSites", _ex.ToString());
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.Exception, _ex.Message);
                  this.SendFailureEmail(siteRequest, _ex.Message);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Member to handle provisioning sites
        /// </summary>
        /// <param name="siteRequests">The site request</param>
        public void ProvisionSites(ICollection<SiteInformation> siteRequests)
        {
            var _tm = this._siteTemplateFactory.GetManager();
            var _requestManager = this._requestFactory.GetSiteRequestManager();

            foreach (var siteRequest in siteRequests)
            {
                try 
                {
                    // ****************************************************
                    // Step 1 - Get Template                   
                    // ****************************************************
                    var _template = _tm.GetTemplateByName(siteRequest.Template);              
                    if (_template == null)
                    {   
                        //NO TEMPLATE FOUND THAT MATCHES WE CANNOT PROVISION A SITE
                        var _message = string.Format("Template: {0} was not found for site {1}. Ensure that the template file exits.", siteRequest.Template, siteRequest.Url);
                        Log.Error("Provisioning.Job.SiteProvisioningJob.ProvisionSites", _message );
                        throw new ConfigurationErrorsException(_message);
                    }
                    
                    // ****************************************************
                    // Step 2 - Update request status                    
                    // ****************************************************
                    var _provisioningTemplate = _tm.GetProvisioningTemplate(_template.ProvisioningTemplate);

                    //NO TEMPLATE FOUND THAT MATCHES WE CANNOT PROVISION A SITE
                    if (_template == null)
                    {
                        Log.Warning("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Template {0} was not found for Site Url {1}.", siteRequest.Template, siteRequest.Url);
                    }

                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.Processing);
                   
                    // ****************************************************
                    // Step 3 - Create the site                    
                    // ****************************************************
                    SiteProvisioningManager _siteProvisioningManager = new SiteProvisioningManager(siteRequest, _template);
                    Log.Info("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Provisioning Site Request for Site Url {0}.", siteRequest.Url);
                    _siteProvisioningManager.CreateSiteCollection(siteRequest, _template);

                    // FOR SUBSITE PROVISIONING TESTING ONLY
                    //_siteProvisioningManager.CreateSubSite(siteRequest, _template);

                    // ****************************************************
                    // Step 4 - Apply provisioning template                    
                    // ****************************************************
                    Log.Info("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Applying Provisioning Template for Site Url {0}.", siteRequest.Url);
                    _siteProvisioningManager.ApplyProvisioningTemplate(_provisioningTemplate, siteRequest, _template);
                    
                    // ****************************************************
                    // Step 5 - Update request access email                    
                    // ****************************************************
                    Log.Info("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Updating Request Access Email Address for Site Url {0}.", siteRequest.Url);
                    _siteProvisioningManager.UpdateRequestAccessEmail(siteRequest);

                    // ****************************************************
                    // Step 6 - Update site description                   
                    // ****************************************************
                    Log.Info("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Updating site description for Site Url {0}.", siteRequest.Url);
                    _siteProvisioningManager.UpdateSiteDescription(siteRequest);

                    // ****************************************************
                    // Step 7 - Send success email                    
                    // ****************************************************
                    Log.Info("Provisioning.Job.SiteProvisioningJob.ProvisionSites", "Sending Success Email for Site Url {0}.", siteRequest.Url);
                    this.SendSuccessEmail(siteRequest);
                    
                    // ****************************************************
                    // Step 8 - Set status to complete                    
                    // ****************************************************
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.Complete, "");

                }
                catch(ProvisioningTemplateException _pte)
                {
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.CompleteWithErrors, _pte.Message);
                }
                catch(Exception _ex)
                {
                    Log.Error("Provisioning.Job.SiteProvisioningJob.ProvisionSites", _ex.ToString());
                    _requestManager.UpdateRequestStatus(siteRequest.Url, SiteRequestStatus.Exception, _ex.Message);
                  this.SendFailureEmail(siteRequest, _ex.Message, true);
                }
            }
        }