public ActionResult Install(string moduleName) { try { string moduleInstallDirectory = GetPhysicalModuleInstallDirectory(moduleName); DatabaseInstaller dbInstaller = new DatabaseInstaller(moduleInstallDirectory, null); dbInstaller.Install(); ModuleType moduleType = this._moduleTypeService.GetModuleByName(moduleName); moduleType.AutoActivate = true; this._moduleTypeService.SaveOrUpdateModuleType(moduleType); this._moduleLoader.ActivateModule(moduleType); Messages.AddFlashMessageWithParams("ModuleInstalledAndActivatedMessage", moduleName); } catch (Exception ex) { Messages.AddFlashException(ex); } return RedirectToAction("Index"); }
private void rptModules_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e) { string[] commandArguments = e.CommandArgument.ToString().Split(':'); string moduleName = commandArguments[0]; string assemblyName = commandArguments[1]; Assembly assembly = null; if (assemblyName.Length > 0) { assembly = Assembly.Load(assemblyName); } string moduleInstallDirectory = Path.Combine(Server.MapPath("~/Modules/" + moduleName), "Install"); DatabaseInstaller dbInstaller = new DatabaseInstaller(moduleInstallDirectory, assembly); try { switch (e.CommandName.ToLower()) { case "install": dbInstaller.Install(); break; case "upgrade": dbInstaller.Upgrade(); break; case "uninstall": dbInstaller.Uninstall(); break; } // Rebind modules BindModules(); ShowMessage(e.CommandName + ": operation succeeded for " + moduleName + "."); } catch (Exception ex) { ShowError(e.CommandName + ": operation failed for " + moduleName + ".<br/>" + ex.Message); } }
private void btnInstallDatabase_Click(object sender, EventArgs e) { DatabaseInstaller dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), Assembly.Load("Cuyahoga.Core")); DatabaseInstaller modulesDbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Modules"), Assembly.Load("Cuyahoga.Modules")); try { dbInstaller.Install(); modulesDbInstaller.Install(); this.pnlIntro.Visible = false; this.pnlModules.Visible = true; BindOptionalModules(); ShowMessage("Database tables successfully created."); } catch (Exception ex) { ShowError("An error occured while installing the database tables: <br/>" + ex.ToString()); } }
private void InstallOptionalModules() { foreach (RepeaterItem ri in this.rptModules.Items) { CheckBox chkInstall = ri.FindControl("chkInstall") as CheckBox; if (chkInstall != null && chkInstall.Checked) { Literal litModuleName = (Literal) ri.FindControl("litModuleName"); string moduleName = litModuleName.Text; DatabaseInstaller moduleInstaller = new DatabaseInstaller(Path.Combine(Server.MapPath("~/Modules/" + moduleName), "Install"), null); moduleInstaller.Install(); } } }
protected void rptModules_ItemCommand(object source, RepeaterCommandEventArgs e) { string[] commandArguments = e.CommandArgument.ToString().Split(':'); string moduleName = commandArguments[0]; string assemblyName = commandArguments[1]; Assembly assembly = null; if (assemblyName.Length > 0) { assembly = Assembly.Load(assemblyName); } string moduleInstallDirectory = Path.Combine(Server.MapPath("~/Modules/" + moduleName), "Install"); DatabaseInstaller dbInstaller = new DatabaseInstaller(moduleInstallDirectory, assembly); try { switch (e.CommandName.ToLower()) { case "install": dbInstaller.Install(); break; case "upgrade": dbInstaller.Upgrade(); break; case "uninstall": dbInstaller.Uninstall(); break; case "delete": string moduleFolder = Server.MapPath("~/Modules/" + moduleName); string dllFile = string.Format("{0}Cuyahoga.Modules.{1}.dll", Server.MapPath("~/bin/"), moduleName); // Maybe add to a service and use a transaction if (Directory.Exists(moduleFolder)) _fileService.DeleteDirectory(moduleFolder); if (File.Exists(dllFile)) _fileService.DeleteFile(dllFile); break; } // Rebind modules BindModules(); ShowMessage(e.CommandName + ": operation succeeded for " + moduleName + "."); } catch (Exception ex) { ShowError(e.CommandName + ": operation failed for " + moduleName + ".<br/>" + ex.Message); } }