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);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="packageDataInstallation"></param>
 /// <param name="packageFileInstallation"></param>
 /// <param name="parser"></param>
 /// <param name="packageActionRunner"></param>
 /// <param name="applicationRootFolder">
 /// The root folder of the application
 /// </param>
 public PackageInstallation(PackageDataInstallation packageDataInstallation, PackageFileInstallation packageFileInstallation, CompiledPackageXmlParser parser, IPackageActionRunner packageActionRunner,
                            DirectoryInfo applicationRootFolder)
 {
     _packageExtraction       = new PackageExtraction();
     _packageFileInstallation = packageFileInstallation ?? throw new ArgumentNullException(nameof(packageFileInstallation));
     _packageDataInstallation = packageDataInstallation ?? throw new ArgumentNullException(nameof(packageDataInstallation));
     _parser = parser ?? throw new ArgumentNullException(nameof(parser));
     _packageActionRunner   = packageActionRunner ?? throw new ArgumentNullException(nameof(packageActionRunner));
     _applicationRootFolder = applicationRootFolder ?? throw new ArgumentNullException(nameof(applicationRootFolder));
 }
Exemplo n.º 3
0
        /// <inheritdoc />
        public UninstallationSummary UninstallPackage(PackageDefinition package, int userId)
        {
            //running this will update the PackageDefinition with the items being removed
            var summary = _packageDataInstallation.UninstallPackageData(package, userId);

            summary.Actions = CompiledPackageXmlParser.GetPackageActions(XElement.Parse(package.Actions), package.Name);

            //run actions before files are removed
            summary.ActionErrors = UndoPackageActions(package, summary.Actions).ToList();

            var filesRemoved = _packageFileInstallation.UninstallFiles(package);

            summary.FilesUninstalled = filesRemoved;

            return(summary);
        }
Exemplo n.º 4
0
        public InstallationSummary InstallPackageData(PackageDefinition packageDefinition, CompiledPackage compiledPackage, int userId)
        {
            var installationSummary = _packageDataInstallation.InstallPackageData(compiledPackage, 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);
        }
Exemplo n.º 5
0
 public PackageFileInstallation(CompiledPackageXmlParser parser, IProfilingLogger logger)
 {
     _parser            = parser;
     _logger            = logger;
     _packageExtraction = new PackageExtraction();
 }