Пример #1
0
        private static void AddInstallationEnvironment(string name, int logicalOrder)
        {
            InstallationEnvironment env = new InstallationEnvironment();

            env.Name         = name;
            env.LogicalOrder = logicalOrder;
            InstallationEnvironmentLogic.Save(env);
        }
Пример #2
0
        public static bool UserCanAccessEnvironment(InstallationEnvironment environment)
        {
            if (AdInfo == null || AdInfo.SecurityEnabled == false)
            {
                return(true);
            }                                                                       // Security not enabled, so let it fly.

            return(AllowedEnvironments.Exists(x => x.Name == environment.Name));
        }
Пример #3
0
        public void Save(InstallationEnvironment env)
        {
            if (env == null)
            {
                throw new ArgumentNullException("env");
            }

            new GenericData().Save(env);
        }
Пример #4
0
        static TestHelper()
        {
            TestUtility.PossiblyAddInstallationEnvironments();
            _defaultEnv = InstallationEnvironmentLogic.GetAll().First();

            // Create some generic apps so our servers can have more than one app assigned to them.
            for (int i = 1; i <= 5; i++)
            {
                var app = CreateApp("Generic" + i);
                _genericApps.Add(app);
            }
        }
Пример #5
0
        public bool Install(
            string rootFolder, string packagePath, string version, string executableName, string componentDisplayName, string webApiUrl, string certificateSubject,
            ILogger logger = null)
        {
            var transactionStore = new NoTransactionStore();
            var selfControl      = new NoSelfControl();

            var workingDirectory = Path.Combine(rootFolder, "temp");

            try
            {
                Directory2.CreateIfNotExists(workingDirectory);

                var environment = new InstallationEnvironment(
                    workingDirectory,
                    Path.Combine(rootFolder, "wwwroot"),
                    new CertificateSubjectMatcher(certificateSubject));

                var componentPath = Path.Combine(rootFolder, $"Shell_{version}");
                var packageData   = new Package {
                    Id = 0, Path = packagePath
                };
                var componentData = new Component
                {
                    Myself = false,
                    InitialInstallation = true,
                    CurrentVersion      = null,
                    ServiceName         = null,
                    NewServiceName      = $"Acr_SiteServer_Shell_{version.Replace(".", "_")}",
                    DistrPath           = null,
                    NewDistrPath        = componentPath,
                    Executable          = null,
                    NewExecutable       = executableName,
                    WwwPath             = $"Shell_{version}",
                    NewWwwPath          = $"Shell_{version}",
                    DisplayName         = $"ACR Site Server: {componentDisplayName} (version {version})",
                    Args = new Dictionary <string, string>
                    {
                        { "webapi", webApiUrl },
                    },
                    AdditionalWebFiles = null,
                };

                return(FlowBuilder.Install(componentData, packageData, environment, selfControl)
                       .WithDefaultManifestHashAlgorithm("SHA1")
                       .Build()
                       .Execute(logger, transactionStore));
            }
            finally
            {
                Directory2.DeleteIfExists(workingDirectory);
            }
        }
Пример #6
0
        public bool Uninstall(string rootFolder, string currentVersion, string executableName, string webApiUrl,
                              ILogger logger = null)
        {
            var transactionStore = new NoTransactionStore();

            var workingDirectory = Path.Combine(rootFolder, "temp");

            try
            {
                Directory2.CreateIfNotExists(workingDirectory);
                var environment = new InstallationEnvironment(
                    Directory.GetCurrentDirectory(),
                    Path.Combine(rootFolder, "wwwroot"),
                    new CertificateSubjectMatcher(""));

                var componentPath = Path.Combine(rootFolder, $"Shell_{currentVersion}");
                var serviceName   = $"Acr_SiteServer_Shell_{currentVersion.Replace(".", "_")}";

                var serviceController = GetService(serviceName);

                var componentData = new Component
                {
                    CurrentVersion = null,
                    ServiceName    = serviceName,
                    DistrPath      = componentPath,
                    Executable     = executableName,
                    WwwPath        = $"Shell_{currentVersion}",
                    DisplayName    = serviceController != null ? serviceController.DisplayName : $"ACR Site Server: Shell (version {currentVersion})",
                    Args           = new Dictionary <string, string>
                    {
                        { "webapi", webApiUrl },
                    },
                    AdditionalWebFiles = null,
                };

                var uninstalled = FlowBuilder.Uninstall(componentData, environment)
                                  .Build()
                                  .Execute(logger, transactionStore);
                if (uninstalled)
                {
                    Directory2.DeleteIfExists(Path.Combine(rootFolder, "wwwroot"));
                    Directory2.DeleteIfExists(Path.Combine(rootFolder, "Acr_SiteServer_ShellDb"));
                    Directory2.DeleteIfExists(Path.Combine(rootFolder, "ShellDb"));
                }
                return(uninstalled);
            }
            finally
            {
                Directory2.DeleteIfExists(workingDirectory);
            }
        }
        private void Initialize()
        {
            if (AllowedEnvironments.Count > 0)
            {
                this.SelectedDeploymentEnvironment = AllowedEnvironments[0];
            }

            this.ForceInstallation = new ForceInstallation();
            this.ForceInstallation.ForceInstallationTime = DateTime.Now; // default

            this.UserCanceled = true;                                    // default

            this.OkCommand     = new RelayCommand(Save, UserCanSave);
            this.CancelCommand = new RelayCommand(Cancel);
            this.ForceInstallationNowCommand = new RelayCommand(ForceInstallationNow);
        }
Пример #8
0
        private static void AddInstallationEnvironment(string name, int logicalOrder)
        {
            InstallationEnvironment env = new InstallationEnvironment();

            env.Name         = name;
            env.LogicalOrder = logicalOrder;

            using (var prestoWcf = new PrestoWcf <IInstallationEnvironmentService>())
            {
                prestoWcf.Service.Save(env);
            }

            string logMessage = string.Format(CultureInfo.CurrentCulture,
                                              "Created environment [{0}] with logical order of [{1}]",
                                              env.Name,
                                              env.LogicalOrder);

            using (var prestoWcf = new PrestoWcf <IBaseService>())
            {
                prestoWcf.Service.SaveLogMessage(logMessage);
            }
        }
Пример #9
0
 public void Save(InstallationEnvironment environment)
 {
     Invoke(() => InstallationEnvironmentLogic.Save(environment));
 }
 public static void Save(InstallationEnvironment environment)
 {
     DataAccessFactory.GetDataInterface <IInstallationEnvironmentData>().Save(environment);
 }
Пример #11
0
 private static bool UserHasEnvironmentRights(InstallationEnvironment installationEnvironment)
 {
     return(ViewModelUtility.UserCanAccessEnvironment(installationEnvironment));
 }