Пример #1
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            log.Debug("Upgrade.aspx.Page_Load: Start");

             ErrorPanel.Visible = false;

             if (!IsPostBack)
             {
            try
            {
               // Check upgradable state. Check both Cuyahoga.Core and Cuyahoga.Modules.
               bool canUpgrade = false;
               StringBuilder sb = new StringBuilder();
               DatabaseInstaller dbInstaller;

               // get a list of all arashi assemblies
               AppDomain arashiDomain = AppDomain.CurrentDomain;
               var arashiLoadedAssemblies = from a in arashiDomain.GetAssemblies()
                                            where a.FullName.StartsWith("Arashi.")
                                            select a;

               IList<AssemblyInfo> infos = new List<AssemblyInfo>();

               foreach (Assembly assembly in arashiLoadedAssemblies)
               {
                  log.DebugFormat("Loaded Assembly Version: {0} {1}", assembly.FullName, assembly.GetName().Version);

                  // Check upgradability for each assembly
                  dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), assembly);

                  if (dbInstaller.CanUpgrade)
                     canUpgrade = true;

                  AssemblyInfo info = new AssemblyInfo();
                  info.AssemblyName = assembly.GetName().Name;
                  info.CurrentVersion = dbInstaller.CurrentVersionInDatabase;
                  info.NewVersion = dbInstaller.NewAssemblyVersion;
                  info.CanUpgrade = dbInstaller.CanUpgrade;
                  infos.Add(info);
               }

               UpgradeInforepeater.DataSource = infos;
               UpgradeInforepeater.DataBind();

               //// Core
               //DatabaseInstaller dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), Assembly.Load("Arashi.Core"));

               //if (dbInstaller.CanUpgrade)
               //{
               //   canUpgrade = true;
               //   lblCoreAssemblyCurrent.Text = "Arashi Core Domain" + dbInstaller.CurrentVersionInDatabase.ToString(3);
               //   lblCoreAssemblyNew.Text = "Arashi Core Domain" + dbInstaller.NewAssemblyVersion.ToString(3);
               //   // Core modules
               //   //DatabaseInstaller moduleDbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Modules"), Assembly.Load("Cuyahoga.Modules"));
               //   //lblModulesAssemblyCurrent.Text = "Cuyahoga Core Modules " + moduleDbInstaller.CurrentVersionInDatabase.ToString(3);
               //   //if (moduleDbInstaller.CanUpgrade)
               //   //{
               //   //   lblModulesAssemblyNew.Text = "Cuyahoga Core Modules " + moduleDbInstaller.NewAssemblyVersion.ToString(3);
               //   //}
               //   //else
               //   //{
               //   //   lblModulesAssemblyNew.Text = "Cuyahoga Core Modules - no upgrade available";
               //   //}
               //}

               if (canUpgrade)
               {
                  IntroPanel.Visible = true;
               }
               else
               {
                  ShowError("Nothing to upgrade.");
               }

               log.Debug("Upgrade.Page_Load: End");
            }
            catch (Exception ex)
            {
               log.Error(ex.ToString());
               ShowError("An error occurred: <br/><br/>" + ex.ToString());
            }
             }

             log.Debug("Upgrade.Page_Load: End");
        }
Пример #2
0
        /// <summary>
        /// Start the upgrade
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void StartUpgradeButton_Click(object sender, EventArgs e)
        {
            DatabaseInstaller dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), Assembly.Load("Arashi.Core"));

            try
            {
                dbInstaller.Upgrade();
            //if (modulesDbInstaller.CanUpgrade)
            //{
            //   modulesDbInstaller.Upgrade();
            //}
            IntroPanel.Visible = false;
            UpgradeCompletedPanel.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)
            {
               log.Error(ex.ToString());
            ShowError("An error occured while upgrading the database tables: <br/>" + ex.ToString());
            }
        }
Пример #3
0
        /// <summary>
        /// Page Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            log.Debug("Install.aspx.Page_Load: Start");

             ErrorPanel.Visible = false;

             if (!IsPostBack)
             {
            try
            {
               // Check installable state. Check Arashi.Core.Domain
               bool canInstall = false;

               // Core
               DatabaseInstaller dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), Assembly.Load("Arashi.Core"));

               if (dbInstaller.CanInstall)
               {
                  lblCoreAssembly.Text = "<ul><li>Arashi Core " + dbInstaller.NewAssemblyVersion.ToString(3) + "</li></ul>";

                  //// Core cms
                  //DatabaseInstaller coreCmsInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Cms"), Assembly.Load("Arashi.Core.Cms"));
                  //if (coreCmsInstaller.CanInstall)
                  //{
                  canInstall = true;
                  //   lblModulesAssembly.Text = "Arashi Core Cms " + coreCmsInstaller.NewAssemblyVersion.ToString(3);
                  //}
               }

               if (canInstall)
               {
                  //DatabasePanel.Visible = true;
                  IntroPanel.Visible = true;
               }
               else
               {
                  // Check if we perhaps need to add an admin
                  if (userService.CountAllUsersForAllSites() == 0)
                     AdminPanel.Visible = true;
                  else
                     ShowError("Can't install Arashi. Check if the install.sql file exists in the /Install/Core|Modules/Database/DATABASE_TYPE/ directory and that there isn't already a version installed.");
               }

               log.Debug("Install.Page_Load: End");
            }
            catch (Exception ex)
            {
               log.Error(ex.ToString());
               ShowError("An error occurred: <br/><br/>" + ex.ToString());
            }
             }

             log.Debug("Install.aspx.Page_Load: End");
        }
Пример #4
0
        protected void PrerequisitesCheckButton_Click(object sender, EventArgs e)
        {
            log.Debug("Install.PrerequisitesCheckButton_Click: Start");

             string siteDataRoot = Server.MapPath("~/Sites/");
             DirectoryInfo di = new DirectoryInfo(siteDataRoot);
             bool isFSPermissionOk = fileService.CheckIfDirectoryIsWritable(di.Parent.FullName);

             DatabaseInstaller dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), Assembly.Load("Arashi.Core"));
             bool isDbOk = dbInstaller.TestDatabaseConnection();

             if (isDbOk && isFSPermissionOk)
             {
            lblCheckResults.Text = "The prerequisites check is successfull, please proceed to the next step.";
            GoToStep2Button.Enabled = true;
            PrerequisitesCheckButton.Visible = false;
             }
             else
             {
            string results = "";

            if (!isDbOk)
               results = "<p class=\"field-validation-error\">There is a problem trying to connect to the database, please check the connection string in the web.config file!</p>";

            if (!isFSPermissionOk)
               results = "<p class=\"field-validation-error\">The identity used by the application, as configured in the application pool under IIS, doesn't have the write permissions!</p>";

            lblCheckResults.Text = results;
             }

             log.Debug("Install.PrerequisitesCheckButton_Click: End");
        }
Пример #5
0
        protected void InstallDatabaseButton_Click(object sender, EventArgs e)
        {
            log.Debug("Install.InstallDatabaseButton_Click: Start");

             DatabaseInstaller dbInstaller = new DatabaseInstaller(Server.MapPath("~/Install/Core"), Assembly.Load("Arashi.Core"));
             log.Debug("Install.InstallDatabaseButton_Click: DatabaseInstaller initialized");

             try
             {

            dbInstaller.Install();
            log.Debug("Install.InstallDatabaseButton_Click: Database installed successfully");

            DatabasePanel.Visible = false;
            CreateSitePanel.Visible = true;

            ShowMessage("Database successfully created.");

            log.Debug("Install.InstallDatabaseButton_Click: End");
             }
             catch (Exception ex)
             {
            log.Error(ex.ToString());
            ShowError("An error occurred while installing the database tables: <br/>" + ex.ToString());
             }
        }