示例#1
0
        protected override void Process(InstallArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var defaultConnectionString = args.ConnectionString;

            Assert.IsNotNull(defaultConnectionString, "SQL Connection String isn't set in the Settings dialog");

            var instance = args.Instance;

            Assert.IsNotNull(instance, "instance");

            var controller = this.Controller;

            foreach (ConnectionString connectionString in instance.Configuration.ConnectionStrings)
            {
                if (this.done.Contains(connectionString.Name))
                {
                    continue;
                }

                AttachDatabasesHelper.AttachDatabase(connectionString, defaultConnectionString, args.Name, args.DatabasesFolderPath, instance.Name, controller);

                if (controller != null)
                {
                    controller.IncrementProgress(AttachDatabasesHelper.StepsCount / args.ConnectionString.Count);
                }

                this.done.Add(connectionString.Name);
            }
        }
示例#2
0
        protected override void Process(ReinstallArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            var defaultConnectionString = args.ConnectionString;

            Assert.IsNotNull(defaultConnectionString, "SQL Connection String isn't set in the Settings dialog");

            var instanceName = args.instanceName;
            var instance     = InstanceManager.GetInstance(instanceName);
            var controller   = this.Controller;

            var sqlPrefix = args.SqlPrefix;

            foreach (ConnectionString connectionString in instance.Configuration.ConnectionStrings)
            {
                if (this.done.Contains(connectionString.Name))
                {
                    continue;
                }

                AttachDatabasesHelper.AttachDatabase(connectionString, defaultConnectionString, args.Name, sqlPrefix, true, args.DatabasesFolderPath, args.InstanceName, controller);

                if (controller != null)
                {
                    controller.IncrementProgress(AttachDatabasesHelper.StepsCount / args.ConnectionString.Count);
                }

                this.done.Add(connectionString.Name);
            }
        }
示例#3
0
        public ReinstallArgs(Instance instance, SqlConnectionStringBuilder connectionString, string license, string webServerIdentity, bool serverSideRedirect)
        {
            ConnectionString    = connectionString;
            Name                = instance.Name;
            _Bindings           = instance.Bindings;
            Product             = instance.Product;
            WebRootPath         = instance.WebRootPath;
            RootPath            = instance.RootPath;
            DataFolderPath      = instance.DataFolderPath;
            DatabasesFolderPath = Path.Combine(RootPath, "Databases");
            WebServerIdentity   = webServerIdentity;
            LicenseFilePath     = license;
            _Modules            = new Product[0];
            IsClassic           = instance.IsClassic;
            Is32Bit             = instance.Is32Bit;
            ForceNetFramework4  = instance.IsNetFramework4;
            ServerSideRedirect  = serverSideRedirect;
            TempFolder          = Path.Combine(RootPath, "Temp");
            _InstanceDatabases  = instance.AttachedDatabases;
            instanceName        = instance.Name;
            _StopInstance       = instance.Stop;
            WebsiteID           = instance.ID;
            SqlPrefix           = AttachDatabasesHelper.GetSqlPrefix(instance);

            var executionTimeout = UpdateWebConfigHelper.GetHttpRuntime(instance.GetWebResultConfig()).GetAttribute("executionTimeout");

            IncreaseExecutionTimeout = string.IsNullOrEmpty(executionTimeout) || executionTimeout != "600";
        }
        private static void Process(Instance instance)
        {
            var firstDatabase = instance.AttachedDatabases?.FirstOrDefault();

            Assert.IsNotNull(firstDatabase, "The databases information is not available");

            var databaseFilePath = firstDatabase.FileName.EmptyToNull();

            Assert.IsNotNull(databaseFilePath, nameof(databaseFilePath));

            var databasesFolderPath = Path.GetDirectoryName(databaseFilePath);

            Assert.IsNotNull(databasesFolderPath, nameof(databasesFolderPath));

            var reportingCstr = instance.Configuration.ConnectionStrings.FirstOrDefault(x => x.Name == "reporting");

            if (reportingCstr != null)
            {
                var sqlName  = new SqlConnectionStringBuilder(reportingCstr.Value).InitialCatalog;
                var database = instance.AttachedDatabases.FirstOrDefault(x => x.RealName.Equals(sqlName));
                var fileName = database?.FileName;
                if (fileName != null)
                {
                    var file = new FileInfo(fileName);
                    Assert.IsTrue(!file.Exists, $"The {file.FullName} reporting database file already exist");
                }

                reportingCstr.Delete();
            }

            var reportingFile = new FileInfo(Path.Combine(databasesFolderPath, "Sitecore.Reporting.mdf"));

            if (reportingFile.Exists)
            {
                reportingFile.Delete();
            }

            AttachDatabasesHelper.ExtractReportingDatabase(instance, reportingFile);

            var sqlPrefix        = AttachDatabasesHelper.GetSqlPrefix(instance);
            var reportingSqlName = sqlPrefix + "_reporting";

            var mgmtText  = Profile.Read().ConnectionString;
            var mgmtValue = new SqlConnectionStringBuilder(mgmtText);

            SqlServerManager.Instance.AttachDatabase(reportingSqlName, reportingFile.FullName, mgmtValue);

            var reportingValue = new SqlConnectionStringBuilder(mgmtText)
            {
                InitialCatalog = reportingSqlName
            };

            instance.Configuration.ConnectionStrings.Add("reporting", reportingValue);
        }
        protected override void Process(InstallArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            var defaultConnectionString = args.ConnectionString;

            Assert.IsNotNull(defaultConnectionString, "SQL Connection String isn't set in the Settings dialog");

            var instance = args.Instance;

            Assert.IsNotNull(instance, nameof(instance));

            var sqlPrefix = args.InstanceSqlPrefix;

            Assert.IsNotNull(sqlPrefix, nameof(sqlPrefix));

            var controller = Controller;

            foreach (ConnectionString connectionString in instance.Configuration.ConnectionStrings)
            {
                var connectionStringName = connectionString.Name;
                if (_Done.Contains(connectionStringName))
                {
                    continue;
                }

                if (connectionStringName.Contains("apikey"))
                {
                    _Done.Add(connectionStringName);
                    continue;
                }

                AttachDatabasesHelper.AttachDatabase(connectionString, defaultConnectionString, args.Name, sqlPrefix, args.InstanceAttachSql, args.DatabasesFolderPath, instance.Name, controller);

                if (controller != null)
                {
                    controller.IncrementProgress(AttachDatabasesHelper.StepsCount / args.ConnectionString.Count);
                }

                _Done.Add(connectionStringName);
            }
        }
示例#6
0
        protected override void Process(ReinstallArgs args)
        {
            var databasesFolderPath = args.DatabasesFolderPath;

            AttachDatabasesHelper.MoveDatabases(databasesFolderPath);
        }
示例#7
0
 protected override bool IsRequireProcessing(ReinstallArgs args)
 {
     return(AttachDatabasesHelper.IsRemoteSqlServer());
 }
        private static void Process(Instance instance)
        {
            var database = instance.AttachedDatabases?.FirstOrDefault();

            Assert.IsNotNull(database, "The databases information is not available");

            var databaseFilePath = database.FileName.EmptyToNull();

            Assert.IsNotNull(databaseFilePath, nameof(databaseFilePath));

            var databasesFolderPath = Path.GetDirectoryName(databaseFilePath);

            Assert.IsNotNull(databasesFolderPath, nameof(databasesFolderPath));

            var primaryCstr = instance.Configuration.ConnectionStrings.FirstOrDefault(x => x.Name == "reporting");

            Assert.IsNotNull(primaryCstr, "reporting connection string is missing");

            var primarySqlName  = new SqlConnectionStringBuilder(primaryCstr.Value).InitialCatalog;
            var primaryDatabase = instance.AttachedDatabases.FirstOrDefault(x => x.RealName.Equals(primarySqlName));

            Assert.IsNotNull(primaryDatabase, nameof(primaryDatabase));

            var primaryFile = new FileInfo(primaryDatabase.FileName);

            Assert.IsTrue(primaryFile.Exists, $"The {primaryFile.FullName} reporting database file does not exist");

            var secondaryCstr = instance.Configuration.ConnectionStrings.FirstOrDefault(x => x.Name == "reporting.secondary");
            var mgmtCstr      = new SqlConnectionStringBuilder(Profile.Read().ConnectionString);

            if (secondaryCstr != null)
            {
                var name = new SqlConnectionStringBuilder(secondaryCstr.Value).InitialCatalog;
                if (SqlServerManager.Instance.DatabaseExists(name, mgmtCstr))
                {
                    SqlServerManager.Instance.DeleteDatabase(name, mgmtCstr);
                }

                secondaryCstr.Delete();
            }

            var primaryIsSecondary = primaryFile.Name.EndsWith("secondary.mdf", StringComparison.OrdinalIgnoreCase);
            var secondaryFile      = new FileInfo(Path.Combine(databasesFolderPath, primaryIsSecondary ? "Sitecore.Reporting.mdf" : "Sitecore.Reporting.Secondary.mdf"));

            if (secondaryFile.Exists)
            {
                secondaryFile.Delete();
            }

            AttachDatabasesHelper.ExtractReportingDatabase(instance, secondaryFile);

            var sqlPrefix = AttachDatabasesHelper.GetSqlPrefix(instance);
            var sqlName   = sqlPrefix + "_reporting";

            if (sqlName.EqualsIgnoreCase(primarySqlName))
            {
                sqlName += "_secondary";
            }

            SqlServerManager.Instance.AttachDatabase(sqlName, secondaryFile.FullName, mgmtCstr);
            var secondaryBuilder = new SqlConnectionStringBuilder(mgmtCstr.ToString())
            {
                InitialCatalog = sqlName
            };

            instance.Configuration.ConnectionStrings.Add("reporting.secondary", secondaryBuilder);
        }