public override void DoWork() { try { //notification that the event is progressing this.Progressing(); //OPTIONAL ResourceInstaller objResourceInstaller = new ResourceInstaller(); objResourceInstaller.Install(); this.ScheduleHistoryItem.Succeeded = true; //REQUIRED this.ScheduleHistoryItem.AddLogNote( "Resource Installation Complete." ); //OPTIONAL } catch( Exception exc ) //REQUIRED { this.ScheduleHistoryItem.Succeeded = false; //REQUIRED this.ScheduleHistoryItem.AddLogNote( "Resource Installation Failed. " + exc.ToString() ); //OPTIONAL //notification that we have errored this.Errored( ref exc ); //REQUIRED //log the exception Exceptions.LogException( exc ); //OPTIONAL } }
public override void DoWork() { try { //notification that the event is progressing this.Progressing(); //OPTIONAL ResourceInstaller objResourceInstaller = new ResourceInstaller(); objResourceInstaller.Install(); this.ScheduleHistoryItem.Succeeded = true; //REQUIRED this.ScheduleHistoryItem.AddLogNote("Resource Installation Complete."); //OPTIONAL } catch (Exception exc) //REQUIRED { this.ScheduleHistoryItem.Succeeded = false; //REQUIRED this.ScheduleHistoryItem.AddLogNote("Resource Installation Failed. " + exc.ToString()); //OPTIONAL //notification that we have errored this.Errored(ref exc); //REQUIRED //log the exception Exceptions.LogException(exc); //OPTIONAL } }
/// <summary> /// InstallDNN manages the Installation of a new DotNetNuke Application /// </summary> /// <remarks> /// </remarks> /// <param name="strProviderPath">The path to the Data Provider</param> public static void InstallDNN(string strProviderPath) { string strExceptions = ""; string strHostPath = Globals.HostMapPath; XmlDocument xmlDoc = new XmlDocument(); string strVersion = ""; string strScript = ""; string strLogFile = ""; string strErrorMessage = ""; // get current App version from constant (Medium Trust) string strAssemblyVersion = Globals.glbAppVersion.Replace(".", ""); // open the Install Template XML file string installTemplate = Config.GetSetting("InstallTemplate"); try { xmlDoc.Load(Globals.ApplicationMapPath + "\\Install\\" + installTemplate); } catch // error { strErrorMessage += "Failed to load Install template.<br><br>"; } if (strErrorMessage == "") { // parse host nodes XmlNode node = xmlDoc.SelectSingleNode("//dotnetnuke"); if (node != null) { strVersion = XmlUtils.GetNodeValue(node, "version", ""); } Array arrVersion = strVersion.Split(Convert.ToChar(".")); int intMajor = Convert.ToInt32(arrVersion.GetValue(0)); int intMinor = Convert.ToInt32(arrVersion.GetValue(1)); int intBuild = Convert.ToInt32(arrVersion.GetValue(2)); ResourceInstaller objResourceInstaller = new ResourceInstaller(); //Output feedback line HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing Version: " + intMajor + "." + intMinor + "." + intBuild + "<br>"); //Parse the script nodes node = xmlDoc.SelectSingleNode("//dotnetnuke/scripts"); if (node != null) { // Get the name of the data provider to start provider specific scripts ProviderConfiguration objProviderConfiguration = ProviderConfiguration.GetProviderConfiguration("data"); // Loop through the available scripts foreach (XmlNode scriptNode in node.SelectNodes("script")) { strScript = scriptNode.InnerText + "." + objProviderConfiguration.DefaultProvider; HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing Script: " + strScript); strExceptions += ExecuteScript(strProviderPath + strScript, ""); HtmlUtils.WriteScriptSuccessError(HttpContext.Current.Response, (strExceptions == ""), strProviderPath + strScript.Replace("." + objProviderConfiguration.DefaultProvider, ".log")); } } //Optionally Install the memberRoleProvider bool installMemberRole = true; if (Config.GetSetting("InstallMemberRole") != null) { installMemberRole = bool.Parse(Config.GetSetting("InstallMemberRole")); } if (installMemberRole) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing MemberRole Provider:<br>"); strExceptions += InstallMemberRoleProvider(strProviderPath); HtmlUtils.WriteSuccessError(HttpContext.Current.Response, (strExceptions == "")); } // update the version PortalSettings.UpdateDatabaseVersion(intMajor, intMinor, intBuild); //Call Upgrade with the current DB Version to carry out any incremental upgrades UpgradeDNN(strProviderPath, strVersion.Replace(".", "")); // parse Host Settings if available node = xmlDoc.SelectSingleNode("//dotnetnuke/settings"); if (node != null) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Loading Host Settings:<br>"); ParseSettings(node); } // parse SuperUser if Available node = xmlDoc.SelectSingleNode("//dotnetnuke/superuser"); if (node != null) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Configuring SuperUser:<br>"); ParseSuperUser(node); } //TODO - This method is obsolete since the modules are now seperated from the core // parse Desktop Modules if available //node = xmlDoc.SelectSingleNode("//dotnetnuke/desktopmodules"); //if (node != null) //{ // HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing Desktop Modules:<br>"); // ParseDesktopModules(node); //} // parse File List if available node = xmlDoc.SelectSingleNode("//dotnetnuke/files"); if (node != null) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Loading Host Files:<br>"); ParseFiles(node, Null.NullInteger); } //Install modules if present HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing Modules:<br>"); objResourceInstaller.Install(true, 2, "modules"); //Run any addition scripts in the Scripts folder HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Executing Additional Scripts:<br>"); ExecuteScripts(strProviderPath); // parse portal(s) if available XmlNodeList nodes = xmlDoc.SelectNodes("//dotnetnuke/portals/portal"); foreach (XmlNode tempLoopVar_node in nodes) { node = tempLoopVar_node; if (node != null) { int intPortalId = AddPortal(node, true, 2); if (intPortalId > -1) { HtmlUtils.WriteFeedback(HttpContext.Current.Response, 2, "<font color='green'>Successfully Installed Portal " + intPortalId + ":</font><br>"); } else { HtmlUtils.WriteFeedback(HttpContext.Current.Response, 2, "<font color='red'>Portal failed to install:Error!</font><br>"); } } } //Install optional resources if present HtmlUtils.WriteFeedback(HttpContext.Current.Response, 0, "Installing Optional Resources:<br>"); objResourceInstaller.Install(true, 2); } else { // upgrade error StreamReader objStreamReader; objStreamReader = File.OpenText(HttpContext.Current.Server.MapPath("~/500.htm")); string strHTML = objStreamReader.ReadToEnd(); objStreamReader.Close(); strHTML = strHTML.Replace("[MESSAGE]", strErrorMessage); if (HttpContext.Current != null) { HttpContext.Current.Response.Write(strHTML); HttpContext.Current.Response.End(); } } }
private void InstallResources() { //Start Timer Upgrade.StartTimer(); //Write out Header HtmlUtils.WriteHeader( Response, "installResources" ); Response.Write( "<h2>Install Resources Status Report</h2>" ); Response.Flush(); // install new resources(s) ResourceInstaller resourceInstaller = new ResourceInstaller(); resourceInstaller.Install( true, 0 ); Response.Write( "<h2>Installation Complete</h2>" ); Response.Flush(); //Write out Footer HtmlUtils.WriteFooter( Response ); }
private void UpgradeApplication() { //Start Timer Upgrade.StartTimer(); //Write out Header HtmlUtils.WriteHeader( Response, "upgrade" ); Response.Write( "<h2>Current Assembly Version: " + Globals.glbAppVersion + "</h2>" ); Response.Flush(); // get path to script files string providerPath = PortalSettings.GetProviderPath(); if( ! providerPath.StartsWith( "ERROR:" ) ) { // get current database version IDataReader dr = PortalSettings.GetDatabaseVersion(); if( dr.Read() ) { //Call Upgrade with the current DB Version to upgrade an //existing DNN installation int majVersion = Convert.ToInt32( dr["Major"] ); int minVersion = Convert.ToInt32( dr["Minor"] ); int buildVersion = Convert.ToInt32( dr["Build"] ); string strDatabaseVersion = String.Format( majVersion.ToString(), "00" ) + "." + String.Format( minVersion.ToString(), "00" ) + "." + String.Format( buildVersion.ToString(), "00" ); Response.Write( "<h2>Current Database Version: " + strDatabaseVersion + "</h2>" ); Response.Flush(); string ignoreWarning = Null.NullString; string strWarning = Null.NullString; if( ( majVersion == 3 && minVersion < 3 ) || ( majVersion == 4 && minVersion < 3 ) ) { //Users and profile have not been transferred // Get the name of the data provider ProviderConfiguration providerConfiguration = ProviderConfiguration.GetProviderConfiguration( "data" ); //Execute Special Script Upgrade.ExecuteScript( providerPath + "Upgrade." + providerConfiguration.DefaultProvider ); if( ( Request.QueryString["ignoreWarning"] != null ) ) { ignoreWarning = Request.QueryString["ignoreWarning"].ToLower(); } strWarning = Upgrade.CheckUpgrade(); } else { ignoreWarning = "true"; } //Check whether Upgrade is ok if( strWarning == Null.NullString || ignoreWarning == "true" ) { Response.Write( "<br><br>" ); Response.Write( "<h2>Upgrade Status Report</h2>" ); Response.Flush(); Upgrade.UpgradeDNN( providerPath, strDatabaseVersion.Replace( ".", "" ) ); //Install Resources ResourceInstaller objResourceInstaller = new ResourceInstaller(); objResourceInstaller.Install( true, 0 ); Response.Write( "<h2>Upgrade Complete</h2>" ); Response.Write( "<br><br><h2><a href='../Default.aspx'>Click Here To Access Your Portal</a></h2><br><br>" ); } else { Response.Write( "<h2>Warning:</h2>" + strWarning.Replace( "\r\n", "<br />" ) ); Response.Write( "<br><br><a href='Install.aspx?mode=Install&ignoreWarning=true'>Click Here To Proceed With The Upgrade.</a>" ); } Response.Flush(); } dr.Close(); } else { Response.Write( "<h2>Upgrade Error: " + providerPath + "</h2>" ); Response.Flush(); } //Write out Footer HtmlUtils.WriteFooter( Response ); }