private void InitializeData(ApplicationWithOverrideVariableGroup originalAppWithGroup) { PossiblyHydrateOriginalAppWithGroup(originalAppWithGroup); InitializeWorkingCopy(originalAppWithGroup); this._originalAppWithGroup = originalAppWithGroup; }
private static void CannotImportGroup(ApplicationWithOverrideVariableGroup importedGroup) { ViewModelUtility.MainWindowViewModel.AddUserMessage(string.Format(CultureInfo.CurrentCulture, "{0} could not be imported because the application ({1}) with which it is associated does not exist.", importedGroup.ToString(), importedGroup.Application.Name)); }
private static void LoadAppGroupCustomVariableGroups(ApplicationWithOverrideVariableGroup appGroup) { if (appGroup.CustomVariableGroupId == null && (appGroup.CustomVariableGroupIds == null || appGroup.CustomVariableGroupIds.Count < 1)) { return; } // Since both properties, CustomVariableGroupId (singular) and CustomVariableGroupIds (plural) can have data, // we'll put everything in CustomVariableGroupIds first. if (appGroup.CustomVariableGroupIds == null) { appGroup.CustomVariableGroupIds = new List <string>(); } if (appGroup.CustomVariableGroupId != null && !appGroup.CustomVariableGroupIds.Contains(appGroup.CustomVariableGroupId)) { appGroup.CustomVariableGroupIds.Add(appGroup.CustomVariableGroupId); } appGroup.CustomVariableGroups = new PrestoObservableCollection <CustomVariableGroup>(); // Now that we have the IDs in one property, loop through the IDs and load the groups. foreach (var groupId in appGroup.CustomVariableGroupIds) { var groupLoadedFromSession = QuerySingleResultAndSetEtag(session => session.Load <CustomVariableGroup>(groupId)) as CustomVariableGroup; appGroup.CustomVariableGroups.Add(groupLoadedFromSession); } appGroup.CustomVariableGroupId = null; // No longer need this property now that we have CustomVariableGroupIds (plural) }
public ResolvedVariablesContainer ResolveVariables(AppAndServerAndOverrides appAndServerAndOverrides) { var app = appAndServerAndOverrides.Application; var server = appAndServerAndOverrides.Server; var overrides = appAndServerAndOverrides.Overrides; // Hydrate the app with trusted data (ie: don't use what was sent from the browser). Application hydratedApp; using (var prestoWcf = new PrestoWcf <IApplicationService>()) { hydratedApp = prestoWcf.Service.GetById(app.Id); } // Hydrate the server with trusted data (ie: don't use what was sent from the browser). ApplicationServer hydratedServer; using (var prestoWcf = new PrestoWcf <IServerService>()) { hydratedServer = prestoWcf.Service.GetServerById(server.Id); } var appWithOverrides = new ApplicationWithOverrideVariableGroup(); appWithOverrides.Application = hydratedApp; appWithOverrides.CustomVariableGroups = overrides; return(VariableGroupResolver.Resolve(appWithOverrides, hydratedServer)); }
private void EditApplication() { ApplicationWithOverrideVariableGroup selectedAppWithGroup = GetSelectedAppWithGroupWhereOnlyOneIsSelected(); if (selectedAppWithGroup == null) { return; } // If the user changes the enabled property, we need to log that. bool originalEnabledValue = selectedAppWithGroup.Enabled; TaskAppViewModel viewModel = new TaskAppViewModel(selectedAppWithGroup); MainWindowViewModel.ViewLoader.ShowDialog(viewModel); if (viewModel.UserCanceled) { return; } if (originalEnabledValue != selectedAppWithGroup.Enabled) { string message = string.Format(CultureInfo.CurrentCulture, "For {0}, the enabled property was changed from {1} to {2} on {3}", selectedAppWithGroup.ToString(), originalEnabledValue, selectedAppWithGroup.Enabled, this.SelectedApplicationServer.Name); using (var prestoWcf = new PrestoWcf <IBaseService>()) { prestoWcf.Service.SaveLogMessage(message); } } SaveServer(); }
private static bool ForceInstallationShouldHappenBasedOnTimeAndEnvironment( ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { // Note: To even get to this method, a force installation exists. DateTime now = DateTime.Now; // Get the list of InstallationStatus entities for this server. InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(appServer, appWithGroup); bool shouldForce; if (mostRecentInstallationSummary == null) { shouldForce = now > appWithGroup.Application.ForceInstallation.ForceInstallationTime && appWithGroup.Application.ForceInstallation.ForceInstallEnvironment.Id == appServer.InstallationEnvironment.Id; LogForceInstallExistsWithNoInstallationSummaries(appServer, appWithGroup, now, shouldForce); return(shouldForce); } // Check the latest installation. If it's before ForceInstallationTime, then we need to install shouldForce = (mostRecentInstallationSummary.InstallationStart <appWithGroup.Application.ForceInstallation.ForceInstallationTime && now> appWithGroup.Application.ForceInstallation.ForceInstallationTime && appWithGroup.Application.ForceInstallation.ForceInstallEnvironment.Id == appServer.InstallationEnvironment.Id); LogForceInstallBasedOnInstallationSummary(appServer, appWithGroup, now, mostRecentInstallationSummary, shouldForce); return(shouldForce); }
public static ApplicationWithOverrideVariableGroup GetAppWithGroup( IEnumerable <ApplicationWithOverrideVariableGroup> appWithGroupList, ApplicationWithOverrideVariableGroup appWithGroupToFind) { if (appWithGroupList == null) { throw new ArgumentNullException("appWithGroupList"); } if (appWithGroupToFind == null) { throw new ArgumentNullException("appWithGroupToFind"); } // To find the matching appWithGroup, the app IDs need to match AND one of these two things must be true: // 1. Both custom variable groups are null, or // 2. Both custom variable groups are the same. if (appWithGroupToFind.CustomVariableGroups == null || appWithGroupToFind.CustomVariableGroups.Count < 1) { return(appWithGroupList.FirstOrDefault(groupFromList => groupFromList.Application.Id == appWithGroupToFind.Application.Id && (groupFromList.CustomVariableGroups == null || groupFromList.CustomVariableGroups.Count < 1))); } return(appWithGroupList.FirstOrDefault(groupFromList => groupFromList.Application.Id == appWithGroupToFind.Application.Id && groupFromList.CustomVariableGroups != null && groupFromList.CustomVariableGroups.Count == appWithGroupToFind.CustomVariableGroups.Count && groupFromList.CustomVariableGroups.Select(x => x.Id).All(appWithGroupToFind.CustomVariableGroups.Select(x => x.Id).Contains))); }
public void ApplicationShouldBeInstalledTest_UseCase6() { // Use Case #6 -- app does not exist in the server's ApplicationWithGroupToForceInstallList, // but the custom variable does. string rootName = "UseCase06"; TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, 0); ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName)); appServer.ApplicationsWithOverrideGroup[0].CustomVariableGroups[0] = TestHelper.CreateCustomVariableGroup(rootName); ApplicationServerLogic.Save(appServer); // To save with a valid group. // Create a new app group with a new app, but an existing group var appWithValidGroup = new ApplicationWithOverrideVariableGroup(); appWithValidGroup.Application = TestHelper.CreateApp(rootName + " " + Guid.NewGuid().ToString()); appWithValidGroup.CustomVariableGroups[0] = appServer.ApplicationsWithOverrideGroup[0].CustomVariableGroups[0]; // Set the app to something that doesn't already exist within the server... // Leave the group alone because it already exists. ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithValidGroup)); SetGlobalFreeze(false); ApplicationServerLogic.InstallApplications(appServer); _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(), It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never()); }
private static bool FinalInstallationChecksPass(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { GlobalSetting globalSetting = GlobalSettingLogic.GetItem(); string warning = string.Empty; if (globalSetting == null) { warning = string.Format(CultureInfo.CurrentCulture, PrestoServerResources.GlobalSettingNullSoNoInstallation, appWithGroup.ToString(), appServer.Name); Logger.LogWarning(warning); LogMessageLogic.SaveLogMessage(warning); return(false); } if (globalSetting.FreezeAllInstallations) { warning = string.Format(CultureInfo.CurrentCulture, PrestoServerResources.FreezeAllInstallationsTrueSoNoInstallation, appWithGroup.ToString(), appServer.Name); Logger.LogWarning(warning); LogMessageLogic.SaveLogMessage(warning); return(false); } return(true); }
public void ApplicationShouldBeInstalledTest_UseCase5() { // Use Case #5 -- app exists in the server's ApplicationWithGroupToForceInstallList, // but the custom variable is different string rootName = "UseCase05"; TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, 0); ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName)); ApplicationWithOverrideVariableGroup appWithDifferentGroup = new ApplicationWithOverrideVariableGroup(); appWithDifferentGroup.Application = appServer.ApplicationsWithOverrideGroup[0].Application; // Set the group to something that doesn't already exist within the server... appWithDifferentGroup.CustomVariableGroups[0] = TestHelper.CreateCustomVariableGroup(rootName + " " + Guid.NewGuid().ToString()); ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithDifferentGroup)); SetGlobalFreeze(false); ApplicationServerLogic.InstallApplications(appServer); _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(), It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never()); }
private static bool IndividualChecksPass(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { if (AppGroupEnabled(appServer, appWithGroup) == false) { return(false); } // This is forcing an APPLICATION SERVER / APP GROUP instance if (ForceInstallIsThisAppWithGroup(appServer, appWithGroup)) { return(true); } // This is forcing an APPLICATION // If there is no force installation time, then no need to install. if (!ForceInstallationExists(appServer, appWithGroup)) { return(false); } if (ForceInstallationShouldHappenBasedOnTimeAndEnvironment(appServer, appWithGroup)) { return(true); } return(false); }
private static void AddManyInstallationSummariesForOneServerAndApp() { string serverName = "server4"; ApplicationServer server = ApplicationServerLogic.GetByName(serverName); string appName = "app8"; Application app = ApplicationLogic.GetByName(appName); ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = app; // Save many installation summaries, for one server, to test Raven's 128 or 1024 limit. DateTime originalStartTime = DateTime.Now.AddDays(-1); for (int i = 1; i <= NumberOfExtraInstallationSummariesForServer4AndApp8; i++) { DateTime startTime = originalStartTime.AddMinutes(i); InstallationSummary summary = new InstallationSummary(appWithGroup, server, startTime); summary.InstallationEnd = startTime.AddSeconds(4); summary.InstallationResult = InstallationResult.Success; AllInstallationSummaries.Add(summary); InstallationSummaryLogic.Save(summary); } }
private static void TestInstallationSummaryData() { var server = new ApplicationServer(); server.Id = "ApplicationServers/10"; var appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = new Application(); appWithGroup.Application.Id = "applications/5"; appWithGroup.CustomVariableGroups = new PrestoObservableCollection <CustomVariableGroup>(); appWithGroup.CustomVariableGroups.Add(new CustomVariableGroup()); appWithGroup.CustomVariableGroupIds = new List <string>(); appWithGroup.CustomVariableGroupIds.Add("CustomVariableGroups/296"); appWithGroup.CustomVariableGroupIds.Add("CustomVariableGroups/302"); appWithGroup.CustomVariableGroupIds.Add("CustomVariableGroups/268"); var data = new InstallationSummaryData(); data.SetAsInitialDalInstanceAndCreateSession(); var installationSummary = data.GetMostRecentByServerAppAndGroup(server, appWithGroup); Debug.WriteLine(installationSummary == null); }
public void GetByServerAppAndGroupTest() { string serverName = "server4"; ApplicationServer server = ApplicationServerLogic.GetByName(serverName); string appName = "app8"; Application app = ApplicationLogic.GetByName(appName); ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = app; InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(server, appWithGroup); InstallationSummary mostRecentSummaryInMemory = TestUtility.AllInstallationSummaries .Where(summary => summary.ApplicationServer.Id == server.Id && summary.ApplicationWithOverrideVariableGroup.ApplicationId == appWithGroup.Application.Id && summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupId == null) .OrderByDescending(x => x.InstallationStart) .First(); Assert.AreEqual(mostRecentSummaryInMemory.InstallationStart, mostRecentInstallationSummary.InstallationStart); Assert.AreEqual(serverName, mostRecentInstallationSummary.ApplicationServer.Name); Assert.AreEqual(appName, mostRecentInstallationSummary.ApplicationWithOverrideVariableGroup.Application.Name); }
private static bool AppGroupEnabled(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { Logger.LogDebug(string.Format(CultureInfo.CurrentCulture, "Checking if app should be installed. ApplicationWithOverrideVariableGroup enabled: {0}.", appWithGroup.Enabled), appServer.EnableDebugLogging); return(appWithGroup.Enabled); }
public static ServerForceInstallation GetForceInstallationContainingAppWithGroup( IEnumerable <ServerForceInstallation> forceInstallationsToDo, ApplicationWithOverrideVariableGroup appWithGroupToFind) { if (forceInstallationsToDo == null) { throw new ArgumentNullException("forceInstallationsToDo"); } if (appWithGroupToFind == null) { throw new ArgumentNullException("appWithGroupToFind"); } if (forceInstallationsToDo.Count() < 1) { return(null); } // To find the matching appWithGroup, the app IDs need to match AND one of these two things must be true: // 1. Both custom variable groups are null, or // 2. Both custom variable groups are the same. try { if (appWithGroupToFind.CustomVariableGroups == null || appWithGroupToFind.CustomVariableGroups.Count < 1) { return(forceInstallationsToDo.FirstOrDefault(forceInstallationToDo => forceInstallationToDo.ApplicationWithOverrideGroup.Application.Id == appWithGroupToFind.ApplicationId && (forceInstallationToDo.ApplicationWithOverrideGroup.CustomVariableGroups == null || forceInstallationToDo.ApplicationWithOverrideGroup.CustomVariableGroups.Count < 1))); } return(forceInstallationsToDo.FirstOrDefault(forceInstallationToDo => forceInstallationToDo.ApplicationWithOverrideGroup.Application.Id == appWithGroupToFind.ApplicationId && forceInstallationToDo.ApplicationWithOverrideGroup.CustomVariableGroups != null && forceInstallationToDo.ApplicationWithOverrideGroup.CustomVariableGroups.Count == appWithGroupToFind.CustomVariableGroups.Count && forceInstallationToDo.ApplicationWithOverrideGroup.CustomVariableGroups.Select(x => x.Id).All(appWithGroupToFind.CustomVariableGroups.Select(x => x.Id).Contains))); // Note: The LINQ extension All() (above): Determines whether all elements of a sequence satisfy a condition. And we're // passing the Contains() method from the other list as a delegate. // Since we're making sure the counts are the same, the order of those lists (which one calls All()) doesn't // matter.) // Also, the order of the elements within each list doesn't matter. } catch { try { Logger.LogObjectDump(forceInstallationsToDo, "forceInstallationsToDo"); Logger.LogObjectDump(appWithGroupToFind, "appWithGroupToFind"); } catch { // Eat it. We don't want logging object dumps to stop us from throwing the initial exception. } throw; } }
private static void HydrateTaskApps(ApplicationWithOverrideVariableGroup appWithGroupBundle) { // See ReadMe_AppWithGroupMapping.docx, in the same folder as this class, for a diagram overview. // When this method is complete, the innermost appWithGroup should have all of the CVGs in it, // because that is what gets passed to the tasks that execute. When a taskApp runs, it calls // this.AppWithGroup.Install(...). That means the tasks don't have access to the bundle; just // the appWithGroup within it. // The override CVGs will go here: innermostAppWithGroup.CVGs // All other CVGs will go here: innermostAppWithGroup.App.CVGs // TaskApp tasks are stored with only the IDs for the Application and CustomVariableGroup properties. // Hydrate those before installing. foreach (var task in appWithGroupBundle.Application.Tasks.Where(x => x.PrestoTaskType == TaskType.App)) { var taskApp = task as TaskApp; if (taskApp.AppWithGroup.Application == null) { using (var prestoWcf = new PrestoWcf <IApplicationService>()) { taskApp.AppWithGroup.Application = prestoWcf.Service.GetById(taskApp.AppWithGroup.ApplicationId); } } /*********************************************************************************************************** * Normal CVGs * ***********************************************************************************************************/ // Add the bundle's app's CVGs to the taskApp appWithGroupBundle.Application.CustomVariableGroups.ForEach(x => taskApp.AppWithGroup.Application.CustomVariableGroups.Add(x)); // For each task app in the bundle, add its CVGs to the taskApp. if (taskApp.AppWithGroup.CustomVariableGroups != null) { foreach (var cvg in taskApp.AppWithGroup.CustomVariableGroups) { taskApp.AppWithGroup.Application.CustomVariableGroups.Add(cvg); } } /*********************************************************************************************************** * OVERRIDES * ***********************************************************************************************************/ // It's not possible to have overrides on taskApp.AppWithGroup.CustomVariableGroups because the overrides // are set with the bundle. So let's initialize the CVGs so we can store the bundle's overrides here. taskApp.AppWithGroup.CustomVariableGroups = new PrestoObservableCollection <CustomVariableGroup>(); // These are the overrides. if (appWithGroupBundle.CustomVariableGroups != null) { taskApp.AppWithGroup.CustomVariableGroups.AddRange(appWithGroupBundle.CustomVariableGroups); } } }
/// <summary> /// Initializes a new instance of the <see cref="TaskAppViewModel"/> class. /// </summary> /// <param name="originalAppWithGroup">The app with group.</param> public TaskAppViewModel(ApplicationWithOverrideVariableGroup originalAppWithGroup) { if (DesignMode.IsInDesignMode) { return; } InitializeCommands(); InitializeData(originalAppWithGroup); }
/// <summary> /// Initializes a new instance of the <see cref="TaskAppViewModel"/> class. /// </summary> public TaskAppViewModel() { if (DesignMode.IsInDesignMode) { return; } this._originalAppWithGroup = new ApplicationWithOverrideVariableGroup(); InitializeCommands(); }
private static void RemoveForceInstallation(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { // If this was a force install, remove it, so we don't keep trying to install it repeatedly. ServerForceInstallation forceInstallation = appServer.GetFromForceInstallList(appWithGroup); if (forceInstallation != null) { appServer.ForceInstallationsToDo.Remove(forceInstallation); // Remove so we don't install again. ApplicationServerLogic.RemoveForceInstallation(forceInstallation); } }
private static string ForceInstallationTimeAsString(ApplicationWithOverrideVariableGroup appWithGroup) { if (appWithGroup.Application == null || appWithGroup.Application.ForceInstallation == null || appWithGroup.Application.ForceInstallation.ForceInstallationTime == null) { return("n/a"); } return(appWithGroup.Application.ForceInstallation.ForceInstallationTime.ToString()); }
private static bool ForceInstallationExists(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { bool forceInstallationExists = (appWithGroup.Application.ForceInstallation != null && appWithGroup.Application.ForceInstallation.ForceInstallationTime != null); Logger.LogDebug(string.Format(CultureInfo.CurrentCulture, "Checking if app should be installed. ApplicationWithOverrideVariableGroup.Application.ForceInstallation exists: {0}. " + "ForceInstallationTime={1}", forceInstallationExists, ForceInstallationTimeAsString(appWithGroup)), appServer.EnableDebugLogging); return(forceInstallationExists); }
private TestEntityContainer CreateTestEntityContainer(string rootName, Func <InstallationSummary, DateTime> forceInstallationTimeFunc, bool forceInstallEnvironmentShouldMatch, bool freezeAllInstallations, int numberOfInstallationSummariesToCreate) { // Creates all of the entities for a particular use case and stores them in a container. This is done // because many of the methods in this class do this same thing. SetGlobalFreeze(freezeAllInstallations); TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, numberOfInstallationSummariesToCreate); ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName)); // So we can check the event log and see that this test passed/failed for the right reason. appServer.EnableDebugLogging = _enableAppServerDebugLogging; // Use this app and group string appName = TestHelper.GetAppName(rootName); ApplicationWithOverrideVariableGroup appWithGroup = appServer.ApplicationsWithOverrideGroup.Where(x => x.Application.Name == appName).First(); // Get the most recent InstallationSummary for this server. InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(appServer, appWithGroup); ForceInstallation forceInstallation = new ForceInstallation(); forceInstallation.ForceInstallationTime = forceInstallationTimeFunc.Invoke(mostRecentInstallationSummary); if (forceInstallEnvironmentShouldMatch) { forceInstallation.ForceInstallEnvironment = appServer.InstallationEnvironment; } else { forceInstallation.ForceInstallEnvironment = InstallationEnvironmentLogic.GetAll().Where(x => x.LogicalOrder != appServer.InstallationEnvironment.LogicalOrder).First(); } appWithGroup.Application.ForceInstallation = forceInstallation; TestEntityContainer container = new TestEntityContainer(); container.ApplicationServer = appServer; container.AppWithGroup = appWithGroup; container.ForceInstallation = forceInstallation; container.MostRecentInstallationSummary = mostRecentInstallationSummary; return(container); }
private static void LogForceInstallExistsWithNoInstallationSummaries( ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup, DateTime now, bool shouldForce) { Logger.LogDebug(string.Format(CultureInfo.CurrentCulture, "{0} should be installed on {1}: {2}. A force installation exists, there are no installation summaries, " + "**AND** now ({3}) > appWithGroup.Application.ForceInstallation.ForceInstallationTime ({4}) " + "**AND** appWithGroup.Application.ForceInstallation.ForceInstallationEnvironment ({5}) == this.DeploymentEnvironment ({6}).", appWithGroup.ToString(), appServer.Name, shouldForce, now.ToString(CultureInfo.CurrentCulture), appWithGroup.Application.ForceInstallation.ForceInstallationTime.ToString(), appWithGroup.Application.ForceInstallation.ForceInstallEnvironment, appServer.InstallationEnvironment), appServer.EnableDebugLogging); }
public void GetByServerAppAndGroupWithManyInstallationSummariesTest() { string serverName = "server4"; ApplicationServer server = ApplicationServerLogic.GetByName(serverName); string appName = "app8"; Application app = ApplicationLogic.GetByName(appName); ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup(); appWithGroup.Application = app; InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(server, appWithGroup); Assert.AreEqual(serverName, mostRecentInstallationSummary.ApplicationServer.Name); Assert.AreEqual(appName, mostRecentInstallationSummary.ApplicationWithOverrideVariableGroup.Application.Name); }
private static void LogForceInstallBasedOnInstallationSummary(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup, DateTime now, InstallationSummary mostRecentInstallationSummary, bool shouldForce) { Logger.LogDebug(string.Format(CultureInfo.CurrentCulture, "Checking if app should be installed. Force installation should happen: {0}. If true, the following is true: " + "mostRecentInstallationSummary.InstallationStart ({1}) < appWithGroup.Application.ForceInstallation.ForceInstallationTime ({2}) " + "**AND** now ({3}) > appWithGroup.Application.ForceInstallation.ForceInstallationTime ({4}) " + "**AND** appWithGroup.Application.ForceInstallation.ForceInstallationEnvironment ({5}) == this.DeploymentEnvironment ({6}).", shouldForce, mostRecentInstallationSummary.InstallationStart.ToString(CultureInfo.CurrentCulture), appWithGroup.Application.ForceInstallation.ForceInstallationTime.ToString(), now.ToString(CultureInfo.CurrentCulture), appWithGroup.Application.ForceInstallation.ForceInstallationTime.ToString(), appWithGroup.Application.ForceInstallation.ForceInstallEnvironment, appServer.InstallationEnvironment), appServer.EnableDebugLogging); }
private void InstallPrestoUpdater(ApplicationWithOverrideVariableGroup appWithGroup) { try { using (var prestoWcf = new PrestoWcf <IServerService>()) { // So just run it locally. new AppInstaller().InstallApplication(this.SelectedApplicationServer, appWithGroup); } } catch (Exception ex) { CommonUtility.ProcessException(ex); ViewModelUtility.MainWindowViewModel.AddUserMessage(string.Format(CultureInfo.CurrentCulture, ViewModelResources.PrestoUpdaterCouldNotBeInstalled)); } }
public void ApplicationShouldBeInstalledTest_UseCase2() { // Use Case #2 -- app group exists in the server's ApplicationWithGroupToForceInstallList // -- with *null* custom variable group ApplicationServer appServer = GetAppServerWithInstallationSummariesFromDb(); // Use this app ApplicationWithOverrideVariableGroup appWithNullGroup = appServer.ApplicationsWithOverrideGroup[0]; ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithNullGroup)); SetGlobalFreeze(false); ApplicationServerLogic.InstallApplications(appServer); _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(), It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Once()); }
public void InstallApplication(ApplicationServer server, ApplicationWithOverrideVariableGroup appWithGroup) { if (appWithGroup == null) { throw new ArgumentNullException("appWithGroup"); } DateTime installationStartTime = DateTime.Now; var installationSummary = new InstallationSummary(appWithGroup, server, installationStartTime); HydrateTaskApps(appWithGroup); InstallationResultContainer resultContainer = appWithGroup.Install(server, installationStartTime, true); installationSummary.SetResults(resultContainer, DateTime.Now); LogAndSaveInstallationSummary(installationSummary); }
public void ApplicationShouldBeInstalledTest_UseCase1() { // Use Case #1 -- app group is not enabled ApplicationServer appServer = GetAppServerWithInstallationSummariesFromDb(); // If disabled, don't install. ApplicationWithOverrideVariableGroup appWithNullGroup = appServer.ApplicationsWithOverrideGroup[0]; appWithNullGroup.Enabled = false; ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithNullGroup)); SetGlobalFreeze(false); ApplicationServerLogic.InstallApplications(appServer); _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(), It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never()); }