/// <summary> /// Runs the install script. /// </summary> /// <remarks> /// This contains the boilerplate code that needs to be done for all install-type /// scripts. Implementers must override the <see cref="DoScript()"/> method to /// implement their script-specific functionality. /// </remarks> /// <param name="p_booSuppressSuccessMessage">Indicates whether to /// supress the success message. This is useful for batch installs.</param> /// <seealso cref="DoScript()"/> protected bool Run(bool p_booSuppressSuccessMessage, bool p_booSetFOModReadOnly) { bool booSuccess = false; if (CheckAlreadyDone()) booSuccess = true; if (!booSuccess) { try { //the install process modifies INI and config files. // if multiple sources (i.e., installs) try to modify // these files simultaneously the outcome is not well known // (e.g., one install changes SETTING1 in a config file to valueA // while simultaneously another install changes SETTING1 in the // file to value2 - after each install commits its changes it is // not clear what the value of SETTING1 will be). // as a result, we only allow one mod to be installed at a time, // hence the lock. lock (ModInstallerBase.objInstallLock) { using (TransactionScope tsTransaction = new TransactionScope()) { m_tfmFileManager = new TxFileManager(); using (m_misScript = CreateInstallScript()) { bool booCancelled = false; if (p_booSetFOModReadOnly && (Fomod != null)) { if (Fomod.ReadOnlyInitStepCount > 1) { using (m_bwdProgress = new BackgroundWorkerProgressDialog(BeginFOModReadOnlyTransaction)) { m_bwdProgress.OverallMessage = "Preparing FOMod..."; m_bwdProgress.ShowItemProgress = false; m_bwdProgress.OverallProgressMaximum = Fomod.ReadOnlyInitStepCount; m_bwdProgress.OverallProgressStep = 1; try { Fomod.ReadOnlyInitStepStarted += new CancelEventHandler(Fomod_ReadOnlyInitStepStarted); Fomod.ReadOnlyInitStepFinished += new CancelEventHandler(Fomod_ReadOnlyInitStepFinished); if (m_bwdProgress.ShowDialog() == DialogResult.Cancel) booCancelled = true; } finally { Fomod.ReadOnlyInitStepStarted -= new CancelEventHandler(Fomod_ReadOnlyInitStepStarted); Fomod.ReadOnlyInitStepFinished -= new CancelEventHandler(Fomod_ReadOnlyInitStepFinished); } } } else Fomod.BeginReadOnlyTransaction(); } if (!booCancelled) { booSuccess = DoScript(); if (booSuccess) tsTransaction.Complete(); } } } } } catch (Exception e) { #if TRACE Program.TraceException(e); #endif StringBuilder stbError = new StringBuilder(e.Message); if (e is FileNotFoundException) stbError.Append(" (" + ((FileNotFoundException)e).FileName + ")"); if (e is IllegalFilePathException) stbError.Append(" (" + ((IllegalFilePathException)e).Path + ")"); if (e.InnerException != null) stbError.AppendLine().AppendLine(e.InnerException.Message); if (e is RollbackException) foreach (RollbackException.ExceptedResourceManager erm in ((RollbackException)e).ExceptedResourceManagers) { stbError.AppendLine(erm.ResourceManager.ToString()); stbError.AppendLine(erm.Exception.Message); if (erm.Exception.InnerException != null) stbError.AppendLine(erm.Exception.InnerException.Message); } string strMessage = String.Format(ExceptionMessage, stbError.ToString()); System.Windows.Forms.MessageBox.Show(strMessage, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } finally { m_tfmFileManager = null; m_ilmModInstallLog = null; if (Fomod != null) Fomod.EndReadOnlyTransaction(); } } if (booSuccess && !p_booSuppressSuccessMessage && !String.IsNullOrEmpty(SuccessMessage)) System.Windows.Forms.MessageBox.Show(SuccessMessage, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); else if (!booSuccess && !String.IsNullOrEmpty(FailMessage)) System.Windows.Forms.MessageBox.Show(FailMessage, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); return booSuccess; }
/// <summary> /// A simple constructor that initializes the object with the given values. /// </summary> /// <param name="p_misInstallScript">The install script.</param> public Fallout3DependencyStateManager(ModInstallScript p_misInstallScript) : base(p_misInstallScript) {}
/// <summary> /// Creates a <see cref="DependencyStateManager"/> for the given <see cref="ModInstallScript"/>. /// </summary> /// <param name="p_misInstallScript">The <see cref="ModInstallScript"/> for which the /// <see cref="DependencyStateManager"/> is being created.</param> /// <returns>A <see cref="DependencyStateManager"/> for the given <see cref="ModInstallScript"/>.</returns> public abstract DependencyStateManager CreateDependencyStateManager(ModInstallScript p_misInstallScript);