private static void SendEmailWithInstallationSummaryProperties(InstallationSummary installationSummary) { string subject = "Presto Warning - Invalid Installation Summary"; string appName = installationSummary.ApplicationWithOverrideVariableGroup == null ? "app with override group is null" : installationSummary.ApplicationWithOverrideVariableGroup.ToString(); string summaryId = installationSummary.Id; string result = installationSummary.InstallationResult.ToString(); string serverName = installationSummary.ApplicationServer == null ? "server is null" : installationSummary.ApplicationServer.Name; string message = string.Format(CultureInfo.CurrentCulture, "An attempt was made to display an installation summary in the UI, however the installation summary was invalid." + Environment.NewLine + Environment.NewLine + "App name: {0}" + Environment.NewLine + "Installation summary ID: {1}" + Environment.NewLine + "Result: {2}" + Environment.NewLine + "Server name: {3}", appName, summaryId, result, serverName); CommonUtility.SendEmail(subject, message); }
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 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); } }
public InstallationSummary InstallCompiledPackageData( XDocument?packageXml, int userId = Constants.Security.SuperUserId) { CompiledPackage compiledPackage = GetCompiledPackageInfo(packageXml); if (compiledPackage == null) { throw new InvalidOperationException("Could not read the package file " + packageXml); } // Trigger the Importing Package Notification and stop execution if event/user is cancelling it var importingPackageNotification = new ImportingPackageNotification(compiledPackage.Name); if (_eventAggregator.PublishCancelable(importingPackageNotification)) { return(new InstallationSummary(compiledPackage.Name)); } InstallationSummary summary = _packageInstallation.InstallPackageData(compiledPackage, userId, out _); _auditService.Add(AuditType.PackagerInstall, userId, -1, "Package", $"Package data installed for package '{compiledPackage.Name}'."); // trigger the ImportedPackage event _eventAggregator.Publish(new ImportedPackageNotification(summary).WithStateFrom(importingPackageNotification)); return(summary); }
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 InstallationSummary InstallPackageData(PackageDefinition packageDefinition, CompiledPackage compiledPackage, int userId) { var installationSummary = new InstallationSummary { DataTypesInstalled = _packageDataInstallation.ImportDataTypes(compiledPackage.DataTypes.ToList(), userId), LanguagesInstalled = _packageDataInstallation.ImportLanguages(compiledPackage.Languages, userId), DictionaryItemsInstalled = _packageDataInstallation.ImportDictionaryItems(compiledPackage.DictionaryItems, userId), MacrosInstalled = _packageDataInstallation.ImportMacros(compiledPackage.Macros, userId), TemplatesInstalled = _packageDataInstallation.ImportTemplates(compiledPackage.Templates.ToList(), userId), DocumentTypesInstalled = _packageDataInstallation.ImportDocumentTypes(compiledPackage.DocumentTypes, userId) }; //we need a reference to the imported doc types to continue var importedDocTypes = installationSummary.DocumentTypesInstalled.ToDictionary(x => x.Alias, x => x); installationSummary.StylesheetsInstalled = _packageDataInstallation.ImportStylesheets(compiledPackage.Stylesheets, userId); installationSummary.ContentInstalled = _packageDataInstallation.ImportContent(compiledPackage.Documents, importedDocTypes, userId); installationSummary.Actions = CompiledPackageXmlParser.GetPackageActions(XElement.Parse(compiledPackage.Actions), compiledPackage.Name); installationSummary.MetaData = compiledPackage; installationSummary.FilesInstalled = packageDefinition.Files; //make sure the definition is up to date with everything foreach (var x in installationSummary.DataTypesInstalled) { packageDefinition.DataTypes.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.LanguagesInstalled) { packageDefinition.Languages.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.DictionaryItemsInstalled) { packageDefinition.DictionaryItems.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.MacrosInstalled) { packageDefinition.Macros.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.TemplatesInstalled) { packageDefinition.Templates.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.DocumentTypesInstalled) { packageDefinition.DocumentTypes.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.StylesheetsInstalled) { packageDefinition.Stylesheets.Add(x.Id.ToInvariantString()); } var contentInstalled = installationSummary.ContentInstalled.ToList(); packageDefinition.ContentNodeId = contentInstalled.Count > 0 ? contentInstalled[0].Id.ToInvariantString() : null; //run package actions installationSummary.ActionErrors = RunPackageActions(packageDefinition, installationSummary.Actions).ToList(); return(installationSummary); }
public void SetStartAndEndTimes(InstallationSummary installationSummary, InstallationSummaryDto dto) { if (installationSummary == null) { throw new ArgumentNullException("installationSummary"); } if (dto == null) { throw new ArgumentNullException("dto"); } dto.InstallationStart = installationSummary.InstallationStartUtc; dto.InstallationEnd = installationSummary.InstallationEndUtc; }
/// <summary> /// Saves the specified installation summary. /// </summary> /// <param name="installationSummary">The installation summary.</param> public void Save(InstallationSummary installationSummary) { if (installationSummary == null) { throw new ArgumentNullException("installationSummary"); } installationSummary.ApplicationServerId = installationSummary.ApplicationServer.Id; new GenericData().Save(installationSummary); }
public void PackagingService_Can_ImportPackage() { var packagingService = (PackagingService)ServiceContext.PackagingService; const string documentTypePickerUmb = "Document_Type_Picker_1.1.umb"; string testPackagePath = GetTestPackagePath(documentTypePickerUmb); InstallationSummary installationSummary = packagingService.InstallPackage(testPackagePath); Assert.IsNotNull(installationSummary); }
public void SetStartAndEndTimes(InstallationSummary installationSummary, InstallationSummaryDto dto) { if (installationSummary == null) { throw new ArgumentNullException("installationSummary"); } if (dto == null) { throw new ArgumentNullException("dto"); } dto.InstallationStart = TimeZone.CurrentTimeZone.ToLocalTime(installationSummary.InstallationStartUtc); dto.InstallationEnd = TimeZone.CurrentTimeZone.ToLocalTime(installationSummary.InstallationEndUtc); }
public void Install_Data() { var testPackageFile = new FileInfo(Path.Combine(HostingEnvironment.MapPathContentRoot("~/TestData/Packages"), DocumentTypePickerPackage)); using var fileStream = testPackageFile.OpenRead(); CompiledPackage package = PackageInstallation.ReadPackage(XDocument.Load(fileStream)); InstallationSummary summary = PackageInstallation.InstallPackageData(package, -1, out PackageDefinition def); Assert.AreEqual(1, summary.DataTypesInstalled.Count()); // make sure the def is updated too Assert.AreEqual(summary.DataTypesInstalled.Count(), def.DataTypes.Count); }
private static void LogAndSaveInstallationSummary(InstallationSummary installationSummary) { using (var prestoWcf = new PrestoWcf <IInstallationSummaryService>()) { prestoWcf.Service.SaveInstallationSummary(installationSummary); } Logger.LogInformation(string.Format(CultureInfo.CurrentCulture, PrestoServerResources.ApplicationInstalled, installationSummary.ApplicationWithOverrideVariableGroup.ToString(), installationSummary.ApplicationServer.Name, installationSummary.InstallationStart.ToString(CultureInfo.CurrentCulture), installationSummary.InstallationEnd.ToString(CultureInfo.CurrentCulture), installationSummary.InstallationResult)); }
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); }
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 HydrateInstallationSummary(InstallationSummary summary) { if (summary == null) { return; } summary.ApplicationServer = QuerySingleResultAndSetEtag(session => session.Load <ApplicationServer>(summary.ApplicationServerId)) as ApplicationServer; // Hydrate the environment on the server. summary.ApplicationServer.InstallationEnvironment = QuerySingleResultAndSetEtag(session => session.Load <InstallationEnvironment>(summary.ApplicationServer.InstallationEnvironmentId)) as InstallationEnvironment; summary.ApplicationWithOverrideVariableGroup.Application = QuerySingleResultAndSetEtag(session => session.Load <Application>(summary.ApplicationWithOverrideVariableGroup.ApplicationId)) as Application; if (summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds == null || summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds.Count < 1) { return; } if (summary.ApplicationWithOverrideVariableGroup.CustomVariableGroups == null) { summary.ApplicationWithOverrideVariableGroup.CustomVariableGroups = new PrestoObservableCollection <CustomVariableGroup>(); } foreach (string groupId in summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds) { summary.ApplicationWithOverrideVariableGroup.CustomVariableGroups.Add( QuerySingleResultAndSetEtag(session => { if (session.Advanced.IsLoaded(groupId)) { return(session.Load <CustomVariableGroup>(groupId)); } return(null); // Note: We can be missing a custom variable in the session because someone deleted it. ; }) as CustomVariableGroup); } }
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); }
private static void CreateInstallationSummaries(Application app, ApplicationServer server, int numberOfInstallationSummariesToCreate) { DateTime originalStartTime = DateTime.Now.AddDays(-1); for (int x = 0; x < numberOfInstallationSummariesToCreate; x++) { var appWithGroup = new ApplicationWithOverrideVariableGroup() { Application = app, ApplicationId = app.Id }; DateTime startTime = originalStartTime.AddMinutes(x); InstallationSummary summary = new InstallationSummary(appWithGroup, server, startTime); var resultContainer = new InstallationResultContainer(); resultContainer.InstallationResult = InstallationResult.Success; summary.SetResults(resultContainer, startTime.AddSeconds(4)); InstallationSummaryLogic.Save(summary); } }
public void Test() { // Arrange const string pagePath = "Test.umb"; var packageExtraction = new Mock <IPackageExtraction>(); string test; packageExtraction.Setup(a => a.ReadTextFileFromArchive(pagePath, Constants.Packaging.PackageXmlFileName, out test)).Returns(Xml); var fileService = new Mock <IFileService>(); var macroService = new Mock <IMacroService>(); var packagingService = new Mock <IPackagingService>(); var sut = new PackageInstallation(packagingService.Object, macroService.Object, fileService.Object, packageExtraction.Object); // Act InstallationSummary installationSummary = sut.InstallPackage(pagePath, -1); // Assert Assert.IsNotNull(installationSummary); //Assert.Inconclusive("Lots of more tests can be written"); }
private static void AddInstallationSummaries() { AllInstallationSummaries = new List <InstallationSummary>(); List <Application> allApps = new List <Application>(ApplicationLogic.GetAll(true)); List <ApplicationServer> allServers = new List <ApplicationServer>(ApplicationServerLogic.GetAll(true)); ApplicationWithOverrideVariableGroup appWithGroup; DateTime originalStartTime = DateTime.Now.AddDays(-1); int totalOuterLoops = TotalNumberOfInstallationSummaries / TotalNumberOfEachEntityToCreate; int runningTotal = 1; // Count of total summaries overall for (int i = 1; i <= totalOuterLoops; i++) { for (int x = 0; x < TotalNumberOfEachEntityToCreate - 1; x++) // We use "- 1" here so we have some entities without an installation summary (for testing) { appWithGroup = new ApplicationWithOverrideVariableGroup() { Application = allApps[x], ApplicationId = allApps[x].Id }; DateTime startTime = originalStartTime.AddMinutes(runningTotal); InstallationSummary summary = new InstallationSummary(appWithGroup, allServers[x], startTime); summary.InstallationEnd = startTime.AddSeconds(4); summary.InstallationResult = InstallationResult.Success; AllInstallationSummaries.Add(summary); InstallationSummaryLogic.Save(summary); runningTotal++; } } }
public InstallationSummary InstallPackageData(CompiledPackage compiledPackage, int userId, out PackageDefinition packageDefinition) { packageDefinition = new PackageDefinition { Name = compiledPackage.Name }; InstallationSummary installationSummary = _packageDataInstallation.InstallPackageData(compiledPackage, userId); // Make sure the definition is up to date with everything (note: macro partial views are embedded in macros) foreach (var x in installationSummary.DataTypesInstalled) { packageDefinition.DataTypes.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.LanguagesInstalled) { packageDefinition.Languages.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.DictionaryItemsInstalled) { packageDefinition.DictionaryItems.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.MacrosInstalled) { packageDefinition.Macros.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.TemplatesInstalled) { packageDefinition.Templates.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.DocumentTypesInstalled) { packageDefinition.DocumentTypes.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.MediaTypesInstalled) { packageDefinition.MediaTypes.Add(x.Id.ToInvariantString()); } foreach (var x in installationSummary.StylesheetsInstalled) { packageDefinition.Stylesheets.Add(x.Path); } foreach (var x in installationSummary.ScriptsInstalled) { packageDefinition.Scripts.Add(x.Path); } foreach (var x in installationSummary.PartialViewsInstalled) { packageDefinition.PartialViews.Add(x.Path); } packageDefinition.ContentNodeId = installationSummary.ContentInstalled.FirstOrDefault()?.Id.ToInvariantString(); foreach (var x in installationSummary.MediaInstalled) { packageDefinition.MediaUdis.Add(x.GetUdi()); } return(installationSummary); }
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); }
public ImportedPackageNotification(InstallationSummary installationSummary) { InstallationSummary = installationSummary; }
public InstallationSummary InstallPackage(string packageFile, int userId) { XElement dataTypes; XElement languages; XElement dictionaryItems; XElement macroes; XElement files; XElement templates; XElement documentTypes; XElement styleSheets; XElement documentSet; XElement documents; XElement actions; MetaData metaData; InstallationSummary installationSummary; try { XElement rootElement = GetConfigXmlElement(packageFile); PackageSupportedCheck(rootElement); PackageStructureSanetyCheck(packageFile, rootElement); dataTypes = rootElement.Element(Constants.Packaging.DataTypesNodeName); languages = rootElement.Element(Constants.Packaging.LanguagesNodeName); dictionaryItems = rootElement.Element(Constants.Packaging.DictionaryItemsNodeName); macroes = rootElement.Element(Constants.Packaging.MacrosNodeName); files = rootElement.Element(Constants.Packaging.FilesNodeName); templates = rootElement.Element(Constants.Packaging.TemplatesNodeName); documentTypes = rootElement.Element(Constants.Packaging.DocumentTypesNodeName); styleSheets = rootElement.Element(Constants.Packaging.StylesheetsNodeName); documentSet = rootElement.Element(Constants.Packaging.DocumentSetNodeName); documents = rootElement.Element(Constants.Packaging.DocumentsNodeName); actions = rootElement.Element(Constants.Packaging.ActionsNodeName); metaData = GetMetaData(rootElement); installationSummary = new InstallationSummary { MetaData = metaData }; } catch (Exception e) { throw new Exception("Error reading " + packageFile, e); } try { var dataTypeDefinitions = EmptyEnumerableIfNull <IDataType>(dataTypes) ?? InstallDataTypes(dataTypes, userId); installationSummary.DataTypesInstalled = dataTypeDefinitions; var languagesInstalled = EmptyEnumerableIfNull <ILanguage>(languages) ?? InstallLanguages(languages, userId); installationSummary.LanguagesInstalled = languagesInstalled; var dictionaryInstalled = EmptyEnumerableIfNull <IDictionaryItem>(dictionaryItems) ?? InstallDictionaryItems(dictionaryItems); installationSummary.DictionaryItemsInstalled = dictionaryInstalled; var macros = EmptyEnumerableIfNull <IMacro>(macroes) ?? InstallMacros(macroes, userId); installationSummary.MacrosInstalled = macros; var keyValuePairs = EmptyEnumerableIfNull <string>(packageFile) ?? InstallFiles(packageFile, files); installationSummary.FilesInstalled = keyValuePairs; var templatesInstalled = EmptyEnumerableIfNull <ITemplate>(templates) ?? InstallTemplats(templates, userId); installationSummary.TemplatesInstalled = templatesInstalled; var documentTypesInstalled = EmptyEnumerableIfNull <IContentType>(documentTypes) ?? InstallDocumentTypes(documentTypes, userId); installationSummary.ContentTypesInstalled = documentTypesInstalled; var stylesheetsInstalled = EmptyEnumerableIfNull <IFile>(styleSheets) ?? InstallStylesheets(styleSheets); installationSummary.StylesheetsInstalled = stylesheetsInstalled; var documentsInstalled = documents != null?InstallDocuments(documents, userId) : EmptyEnumerableIfNull <IContent>(documentSet) ?? InstallDocuments(documentSet, userId); installationSummary.ContentInstalled = documentsInstalled; var packageActions = EmptyEnumerableIfNull <PackageAction>(actions) ?? GetPackageActions(actions, metaData.Name); installationSummary.Actions = packageActions; installationSummary.PackageInstalled = true; return(installationSummary); } catch (Exception e) { throw new Exception("Error installing package " + packageFile, e); } }
public void SaveInstallationSummary(InstallationSummary installationSummary) { Invoke(() => InstallationSummaryLogic.Save(installationSummary)); }
public InstallationSummary GetMostRecentByServerAppAndGroup(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { if (appWithGroup == null) { throw new ArgumentNullException("appWithGroup"); } Expression <Func <InstallationSummary, bool> > whereClause; if (appWithGroup.CustomVariableGroups == null || appWithGroup.CustomVariableGroups.Count < 1) { whereClause = summary => summary.ApplicationServerId == appServer.Id && summary.ApplicationWithOverrideVariableGroup.ApplicationId == appWithGroup.Application.Id && summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupId == null && (summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds == null || summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds.Count < 1); return(ExecuteQuery <InstallationSummary>(() => { InstallationSummary installationSummary = QuerySingleResultAndSetEtag(session => session.Query <InstallationSummary>() .Include(x => x.ApplicationServerId) .Include(x => x.ApplicationWithOverrideVariableGroup.ApplicationId) .Include(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds) .Customize(x => x.WaitForNonStaleResults()) .Where(whereClause) .OrderByDescending(x => x.InstallationStart) .FirstOrDefault()) as InstallationSummary; HydrateInstallationSummary(installationSummary); return installationSummary; })); } // The where clause used to be generated in a private method, but RavenDB can't handle this last line: // summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds.All(appWithGroup.CustomVariableGroupIds.Contains); // So now just get more installation summaries from RavenDB than we need, and implement that last line in memory. whereClause = summary => summary.ApplicationServerId == appServer.Id && summary.ApplicationWithOverrideVariableGroup.ApplicationId == appWithGroup.Application.Id && summary.ApplicationWithOverrideVariableGroup != null && summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds != null && summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds.Count == appWithGroup.CustomVariableGroupIds.Count; return(ExecuteQuery <InstallationSummary>(() => { var installationSummaries = QueryAndSetEtags(session => session.Query <InstallationSummary>() .Include(x => x.ApplicationServerId) .Include(x => x.ApplicationWithOverrideVariableGroup.ApplicationId) .Include(x => x.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds) .Customize(x => x.WaitForNonStaleResults()) .Where(whereClause) .OrderByDescending(x => x.InstallationStart) as IQueryable <EntityBase>); // Loop through the installation summaries to find the one that has the exact same CVG IDs // as appWithGroup.CustomVariableGroupIds. InstallationSummary theInstallationSummary = null; foreach (var summary in installationSummaries.ToList().Cast <InstallationSummary>()) { if (summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupIds.All(appWithGroup.CustomVariableGroupIds.Contains)) { theInstallationSummary = summary; } } HydrateInstallationSummary(theInstallationSummary); return theInstallationSummary; })); }
public static void Save(InstallationSummary installationSummary) { DataAccessFactory.GetDataInterface <IInstallationSummaryData>().Save(installationSummary); }