private void RunSetup() { #region setup mojoportal-core if (!schemaHasBeenCreated) { if (canAlterSchema) { CreateInitialSchema("mojoportal-core"); schemaHasBeenCreated = DatabaseHelper.SchemaHasBeenCreated(); if (schemaHasBeenCreated) { //recheck needSchemaUpgrade = mojoSetup.UpgradeIsNeeded(); } } } if ( (schemaHasBeenCreated) && (needSchemaUpgrade) && (canAlterSchema) ) { needSchemaUpgrade = UpgradeSchema("mojoportal-core"); } if (!CoreSystemIsReady()) { return; } existingSiteCount = DatabaseHelper.ExistingSiteCount(); if (existingSiteCount == 0) { CreateSiteAndAdminUser(); } // look for new features or settings to install SetupFeatures("mojoportal-core"); #endregion #region setup other applications // install other apps String pathToApplicationsFolder = HttpContext.Current.Server.MapPath( "~/Setup/applications/"); if (!Directory.Exists(pathToApplicationsFolder)) { WritePageContent( pathToApplicationsFolder + " " + SetupResource.ScriptFolderNotFoundAddendum, false); return; } DirectoryInfo appRootFolder = new DirectoryInfo(pathToApplicationsFolder); DirectoryInfo[] appFolders = appRootFolder.GetDirectories(); foreach (DirectoryInfo appFolder in appFolders) { if ( (!string.Equals(appFolder.Name, "mojoportal-core", StringComparison.InvariantCultureIgnoreCase)) && (appFolder.Name.ToLower() != ".svn") && (appFolder.Name.ToLower() != "_svn") ) { CreateInitialSchema(appFolder.Name); UpgradeSchema(appFolder.Name); SetupFeatures(appFolder.Name); } } #endregion WritePageContent(SetupResource.EnsuringFeaturesInAdminSites, true); ModuleDefinition.EnsureInstallationInAdminSites(); SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings != null) { if (PageSettings.GetCountOfPages(siteSettings.SiteId) == 0) { WritePageContent(SetupResource.CreatingDefaultContent); //SetupContentPages(siteSettings); mojoSetup.SetupDefaultContentPages(siteSettings); } try { int userCount = SiteUser.UserCount(siteSettings.SiteId); if (userCount == 0) { mojoSetup.EnsureRolesAndAdminUser(siteSettings); } } catch (Exception ex) { log.Error("EnsureAdminUserAndRoles", ex); } mojoSetup.EnsureSkins(siteSettings.SiteId); } // in case control type controlsrc, regex or sort changed on the definition // update instance properties to match //ThreadPool.QueueUserWorkItem(new WaitCallback(SyncDefinitions), null); //ModuleDefinition.SyncDefinitions(); SiteSettings.EnsureExpandoSettings(); mojoSetup.EnsureAdditionalSiteFolders(); // added 2013-10-18 if (WebConfigSettings.TryEnsureCustomMachineKeyOnSetup) { try { WebConfigSettings.EnsureCustomMachineKey(); } catch (Exception ex) { log.Error("tried to ensure a custom machinekey in Web.config but an error occurred.", ex); } } }