Beispiel #1
0
        private void btnUpgradeDatabase_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.Upgrade();
                if (modulesDbInstaller.CanUpgrade)
                {
                    modulesDbInstaller.Upgrade();
                }
                this.pnlIntro.Visible = false;
                this.pnlFinished.Visible = true;

                // Remove the IsUpgrading flag, so users can view the pages again.
                HttpContext.Current.Application.Lock();
                HttpContext.Current.Application["IsUpgrading"] = false;
                HttpContext.Current.Application.UnLock();
            }
            catch (Exception ex)
            {
                ShowError("An error occured while installing the database tables: <br/>" + ex.ToString());
            }
        }
        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);
            }
        }
        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);
            }
        }