Exemplo n.º 1
0
        protected override void SaveSite(string siteId, string newTitle, SitePublishInfo info)
        {
            Site site = SiteConfiguration.FindExistingSiteByID(siteId);

            if (site == null)
            {
                throw new Exception("Unable to find site with siteId = " + siteId);
            }

            FaultContract Fault = null;

            if (!(new ApplicationBuilderHelper()).SaveConfigurationForSite(site, info, out Fault, newTitle))
            {
                throw new Exception(Fault != null ? Fault.Message : "Unable to save site");
            }

            if (!string.IsNullOrEmpty(newTitle) && site.Title != newTitle) // Update site's title in site configuration list
            {
                site.Title = newTitle;
                SiteConfiguration.SaveSite(site);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Upgrades the site with the specified ID to the current version of the product
        /// </summary>
        /// <param name="siteId"></param>
        /// <param name="templateId"></param>
        /// <returns></returns>
        protected override Site UpgradeSite(string siteId, string templateId, out FaultContract fault)
        {
            // Get the site
            Site site = SiteConfiguration.FindExistingSiteByID(siteId);

            if (site == null)
            {
                throw new Exception("Unable to find site with siteId = " + siteId);
            }

            // Do upgrade
            fault = null;
            bool upgraded = ApplicationBuilderHelper.UpgradeSite(site, templateId, out fault);

            if (upgraded)
            {
                // Upgrade successful - update the version on the site and save it to disk
                Version currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                site.ProductVersion = string.Format("{0}.{1}.{2}.0", currentVersion.Major, currentVersion.Minor,
                                                    currentVersion.Build);
                SiteConfiguration.SaveSite(site);
                return(site);
            }
            else
            {
                if (fault == null)
                {
                    fault = new FaultContract()
                    {
                        Message = "Upgrade failed"
                    }
                }
                ;
                return(null);
            }
        }
    }