コード例 #1
0
ファイル: Install.aspx.cs プロジェクト: xiaopohou/cuyahoga
 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();
         }
     }
 }
コード例 #2
0
ファイル: Install.aspx.cs プロジェクト: xiaopohou/cuyahoga
        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());
            }
        }
コード例 #3
0
 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"));
 }
コード例 #4
0
        private 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;
                }

                // Rebind modules
                BindModules();

                ShowMessage(e.CommandName + ": thao tác thành công với " + moduleName + ".");
            }
            catch (Exception ex)
            {
                ShowError(e.CommandName + ": thao tác thất bại với " + moduleName + ".<br/>" + ex.Message);
            }
        }
コード例 #5
0
        private void StartupEndpoint()
        {
            var config = new SetupConfig();

            try
            {
                LoggerCQ.LogInfo("Attempting to upgrade database.");
                var connectionStringSettings = ConfigurationManager.ConnectionStrings["DatastoreEntities"];
                var connectionStringBuilder  = new SqlConnectionStringBuilder(connectionStringSettings.ConnectionString)
                {
                    InitialCatalog = "Master"
                };

                //Make sure there are no other nHydrate installations on this database
                if (DbMaintenanceHelper.ContainsOtherInstalls(connectionStringSettings.ConnectionString))
                {
                    LoggerCQ.LogError($"The database contains another installation. This is an error condition. Database={connectionStringBuilder.InitialCatalog}");
                    throw new Exception($"The database contains another installation. This is an error condition. Database={connectionStringBuilder.InitialCatalog}");
                }

                //Even a blank database gets updated below so save if DB is blank when started
                var isBlank = DbMaintenanceHelper.IsBlank(connectionStringSettings.ConnectionString);

                var installer = new DatabaseInstaller();
                if (installer.NeedsUpdate(connectionStringSettings.ConnectionString))
                {
                    var setup = new InstallSetup
                    {
                        AcceptVersionWarningsChangedScripts = true,
                        AcceptVersionWarningsNewScripts     = true,
                        ConnectionString       = connectionStringSettings.ConnectionString,
                        InstallStatus          = InstallStatusConstants.Upgrade,
                        MasterConnectionString = connectionStringBuilder.ToString(),
                        SuppressUI             = true,
                    };
                    installer.Install(setup);
                }

                //If new database then add file split data files to reduce file locking
                if (isBlank)
                {
                    try
                    {
                        DbMaintenanceHelper.SplitDbFiles(connectionStringSettings.ConnectionString);
                        LoggerCQ.LogInfo("New database has split data files.");
                    }
                    catch
                    {
                        LoggerCQ.LogWarning("New database could not split data files.");
                    }

                    try
                    {
                        var configFile = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "setup.config");
                        if (File.Exists(configFile))
                        {
                            var barr = File.ReadAllBytes(configFile);
                            config = ServerUtilities.DeserializeObject <SetupConfig>(barr);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new Exception($"Setup configuration file is not valid.");
                    }

                    if (config != null)
                    {
                        if (!string.IsNullOrEmpty(config.ListDataPath) && !Directory.Exists(config.ListDataPath))
                        {
                            throw new Exception("The setup configuration file value 'ListDataPath' is not valid");
                        }
                        if (!string.IsNullOrEmpty(config.IndexPath) && !Directory.Exists(config.IndexPath))
                        {
                            throw new Exception("The setup configuration file value 'IndexPath' is not valid");
                        }

                        //Create a file group for List tables
                        config.ListDataPath = DbMaintenanceHelper.CreateFileGroup(connectionStringSettings.ConnectionString, config.ListDataPath, SetupConfig.YFileGroup);

                        //Create a file group for Indexes
                        config.IndexPath = DbMaintenanceHelper.CreateFileGroup(connectionStringSettings.ConnectionString, config.IndexPath, SetupConfig.IndexFileGroup);
                    }
                }
            }
            catch (Exception ex)
            {
                LoggerCQ.LogError(ex, "Failed on database upgrade.");
                throw new Exception("Failed on database upgrade.");
            }

            LoggerCQ.LogInfo("Service started begin");
            try
            {
                #region Primary Endpoint

                var service = new Gravitybox.Datastore.Server.Core.SystemCore(ConfigurationManager.ConnectionStrings["DatastoreEntities"].ConnectionString, _enableHouseKeeping);
                if (config != null)
                {
                    ConfigHelper.SetupConfig = config;
                }

                #region Determine if configured port is free
                var isPortFree = false;
                do
                {
                    try
                    {
                        //Determine if can connect to port
                        using (var p1 = new System.Net.Sockets.TcpClient("localhost", ConfigHelper.Port))
                        {
                        }
                        //If did connect successfully then there is already something on this port
                        isPortFree = false;
                        LoggerCQ.LogInfo($"Port {ConfigHelper.Port} is in use...");
                        System.Threading.Thread.Sleep(3000); //wait...
                    }
                    catch (Exception ex)
                    {
                        //If there is an error connecting then nothing is listening on that port so FREE
                        isPortFree = true;
                    }
                } while (!isPortFree);
                #endregion

                var primaryAddress = new Uri($"net.tcp://localhost:{ConfigHelper.Port}/__datastore_core");
                var primaryHost    = new ServiceHost(service, primaryAddress);

                //Initialize the service
                var netTcpBinding = new NetTcpBinding();
                netTcpBinding.MaxConnections = ThrottleMax;
                netTcpBinding.Security.Mode  = SecurityMode.None;
                primaryHost.AddServiceEndpoint(typeof(Gravitybox.Datastore.Common.ISystemCore), netTcpBinding, string.Empty);

                //Add more threads
                var stb = new ServiceThrottlingBehavior
                {
                    MaxConcurrentSessions  = ThrottleMax,
                    MaxConcurrentCalls     = ThrottleMax,
                    MaxConcurrentInstances = ThrottleMax,
                };
                primaryHost.Description.Behaviors.Add(stb);

                primaryHost.Open();

                //Create Core Listener
                var primaryEndpoint = new EndpointAddress(primaryHost.BaseAddresses.First().AbsoluteUri);
                var primaryClient   = new ChannelFactory <Gravitybox.Datastore.Common.ISystemCore>(netTcpBinding, primaryEndpoint);
                _core = primaryClient.CreateChannel();
                (_core as IContextChannel).OperationTimeout = new TimeSpan(0, 0, 120); //Timeout=2m

                #endregion

                LoadEngine(service);
                service.Manager.ResetMaster();
                LoggerCQ.LogInfo("Service started complete");
                ConfigHelper.StartUp();
            }
            catch (Exception ex)
            {
                LoggerCQ.LogError(ex);
                throw;
            }
        }
コード例 #6
0
        private static void StartupEndpoint()
        {
            try
            {
                Logger.LogInfo("Attempting to execute database upgrade.");
                var connectionStringSettings = ConfigurationManager.ConnectionStrings["gFileSystemEntities"];
                var connectionStringBuilder  = new SqlConnectionStringBuilder(connectionStringSettings.ConnectionString)
                {
                    InitialCatalog = "Master"
                };

                var installer = new DatabaseInstaller();
                if (installer.NeedsUpdate(connectionStringSettings.ConnectionString))
                {
                    var setup = new InstallSetup
                    {
                        AcceptVersionWarningsChangedScripts = true,
                        AcceptVersionWarningsNewScripts     = true,
                        ConnectionString       = connectionStringSettings.ConnectionString,
                        InstallStatus          = InstallStatusConstants.Upgrade,
                        MasterConnectionString = connectionStringBuilder.ToString()
                    };

                    installer.Install(setup);
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "Failed to execute database upgrade.");
                throw new Exception("Failed to execute database upgrade.");
            }

            Logger.LogInfo("Services Started Begin");
            try
            {
                #region Primary Endpoint

                var service        = new SystemCore();
                var primaryAddress = new Uri("net.tcp://localhost:" + ConfigHelper.Port + "/__gfile");
                var primaryHost    = new ServiceHost(service, primaryAddress);

                //Initialize the service
                //var netTcpBinding = new CompressedNetTcpBinding();
                var netTcpBinding = new NetTcpBinding {
                    MaxBufferSize = 10 * 1024 * 1024, MaxReceivedMessageSize = 10 * 1024 * 1024, MaxBufferPoolSize = 10 * 1024 * 1024
                };
                netTcpBinding.ReaderQuotas.MaxStringContentLength = 10 * 1024 * 1024;
                netTcpBinding.ReaderQuotas.MaxBytesPerRead        = 10 * 1024 * 1024;
                netTcpBinding.ReaderQuotas.MaxArrayLength         = 10 * 1024 * 1024;
                netTcpBinding.ReaderQuotas.MaxDepth = 10 * 1024 * 1024;
                netTcpBinding.ReaderQuotas.MaxNameTableCharCount = 10 * 1024 * 1024;
                netTcpBinding.Security.Mode = SecurityMode.None;
                primaryHost.AddServiceEndpoint(typeof(ISystemCore), netTcpBinding, string.Empty);
                primaryHost.Open();

                //Create Core Listener
                var primaryEndpoint = new EndpointAddress(primaryHost.BaseAddresses.First().AbsoluteUri);
                var primaryClient   = new ChannelFactory <ISystemCore>(netTcpBinding, primaryEndpoint);
                _core = primaryClient.CreateChannel();

                #endregion

                Logger.LogInfo("Service Running on Port " + ConfigHelper.Port);
                Logger.LogInfo("Services Started End");
            }
            catch (Exception ex)
            {
                Logger.LogError(ex);
                throw;
            }
        }