コード例 #1
0
        /// <exclude />
        public static PackageManagerUninstallProcess Uninstall(Guid id)
        {
            try
            {
                string absolutePath = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.PackageDirectory), id.ToString());

                InstalledPackageInformation installedPackageInformation =
                    (from package in GetInstalledPackages()
                     where package.Id == id
                     select package).SingleOrDefault();

                if (installedPackageInformation == null)
                {
                    return(new PackageManagerUninstallProcess(new List <PackageFragmentValidationResult> {
                        new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format(GetText("PackageManager.MissingPackageDirectory"), absolutePath))
                    }));
                }

                Log.LogVerbose("PackageManager", "Uninstalling package: {0}, Id = {1}", installedPackageInformation.Name, installedPackageInformation.Id);

                if (installedPackageInformation.CanBeUninstalled == false)
                {
                    return(new PackageManagerUninstallProcess(new List <PackageFragmentValidationResult> {
                        new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, GetText("PackageManager.Uninstallable"))
                    }));
                }

                string zipFilePath = Path.Combine(absolutePath, PackageSystemSettings.ZipFilename);
                if (C1File.Exists(zipFilePath) == false)
                {
                    return(new PackageManagerUninstallProcess(new List <PackageFragmentValidationResult> {
                        new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format(GetText("PackageManager.MissingZipFile"), zipFilePath))
                    }));
                }

                string uninstallFilePath = Path.Combine(absolutePath, PackageSystemSettings.UninstallFilename);
                if (C1File.Exists(uninstallFilePath) == false)
                {
                    return(new PackageManagerUninstallProcess(new List <PackageFragmentValidationResult> {
                        new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format(GetText("PackageManager.MissingUninstallFile"), uninstallFilePath))
                    }));
                }

                PackageInformation packageInformation = new PackageInformation
                {
                    Id                        = installedPackageInformation.Id,
                    Name                      = installedPackageInformation.Name,
                    GroupName                 = installedPackageInformation.GroupName,
                    Author                    = installedPackageInformation.Author,
                    Website                   = installedPackageInformation.Website,
                    Description               = installedPackageInformation.Description,
                    Version                   = installedPackageInformation.Version,
                    CanBeUninstalled          = installedPackageInformation.CanBeUninstalled,
                    SystemLockingType         = installedPackageInformation.SystemLockingType,
                    FlushOnCompletion         = installedPackageInformation.FlushOnCompletion,
                    ReloadConsoleOnCompletion = installedPackageInformation.ReloadConsoleOnCompletion,
                };


                PackageUninstaller packageUninstaller = new PackageUninstaller(zipFilePath, uninstallFilePath, absolutePath, TempDirectoryFacade.CreateTempDirectory(), installedPackageInformation.FlushOnCompletion, installedPackageInformation.ReloadConsoleOnCompletion, true, packageInformation);

                PackageManagerUninstallProcess packageManagerUninstallProcess = new PackageManagerUninstallProcess(packageUninstaller, absolutePath, installedPackageInformation.SystemLockingType);
                return(packageManagerUninstallProcess);
            }
            catch (Exception ex)
            {
                return(new PackageManagerUninstallProcess(new List <PackageFragmentValidationResult> {
                    new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex)
                }));
            }
        }
コード例 #2
0
ファイル: PackageManager.cs プロジェクト: DBailey635/C1-CMS
        /// <exclude />
        public static PackageManagerUninstallProcess Uninstall(Guid id)
        {
            try
            {
                string absolutePath = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.PackageDirectory), id.ToString());

                InstalledPackageInformation installedPackageInformation =
                    (from package in GetInstalledPackages()
                     where package.Id == id
                     select package).SingleOrDefault();

                if (installedPackageInformation == null) return new PackageManagerUninstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format(GetText("PackageManager.MissingPackageDirectory"), absolutePath)) });

                Log.LogVerbose("PackageManager", "Uninstalling package: {0}, Id = {1}", installedPackageInformation.Name, installedPackageInformation.Id);

                if (installedPackageInformation.CanBeUninstalled == false) return new PackageManagerUninstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, GetText("PackageManager.Uninstallable")) });

                string zipFilePath = Path.Combine(absolutePath, PackageSystemSettings.ZipFilename);
                if (C1File.Exists(zipFilePath) == false) return new PackageManagerUninstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format(GetText("PackageManager.MissingZipFile"), zipFilePath)) });

                string uninstallFilePath = Path.Combine(absolutePath, PackageSystemSettings.UninstallFilename);
                if (C1File.Exists(uninstallFilePath) == false) return new PackageManagerUninstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, string.Format(GetText("PackageManager.MissingUninstallFile"), uninstallFilePath)) });

                PackageInformation packageInformation = new PackageInformation
                {
                    Id = installedPackageInformation.Id,
                    Name = installedPackageInformation.Name,
                    GroupName = installedPackageInformation.GroupName,
                    Author = installedPackageInformation.Author,
                    Website = installedPackageInformation.Website,
                    Description = installedPackageInformation.Description,
                    Version = installedPackageInformation.Version,
                    CanBeUninstalled = installedPackageInformation.CanBeUninstalled,
                    SystemLockingType = installedPackageInformation.SystemLockingType,
                    FlushOnCompletion = installedPackageInformation.FlushOnCompletion,
                    ReloadConsoleOnCompletion = installedPackageInformation.ReloadConsoleOnCompletion,
                };


                PackageUninstaller packageUninstaller = new PackageUninstaller(zipFilePath, uninstallFilePath, absolutePath, TempDirectoryFacade.CreateTempDirectory(), installedPackageInformation.FlushOnCompletion, installedPackageInformation.ReloadConsoleOnCompletion, true, packageInformation);

                PackageManagerUninstallProcess packageManagerUninstallProcess = new PackageManagerUninstallProcess(packageUninstaller, absolutePath, installedPackageInformation.SystemLockingType);
                return packageManagerUninstallProcess;
            }
            catch (Exception ex)
            {
                return new PackageManagerUninstallProcess(new List<PackageFragmentValidationResult> { new PackageFragmentValidationResult(PackageFragmentValidationResultType.Fatal, ex) });
            }
        }