Example #1
0
        private bool InstallAssemblyProvider(Package provider, Link link, string fastPath, BootstrapRequest request)
        {
            if (!Directory.Exists(request.DestinationPath))
            {
                request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.DestinationPathNotSet);
                return(false);
            }

            var targetFilename = link.Attributes[Iso19770_2.Discovery.TargetFilename];

            if (string.IsNullOrWhiteSpace(targetFilename))
            {
                request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.InvalidFilename);
                return(false);
            }

            targetFilename = Path.GetFileName(targetFilename);
            var targetFile = Path.Combine(request.DestinationPath, targetFilename);

            // download the file
            var file = request.DownloadAndValidateFile(provider.Name, provider._swidtag.Links.Where(each => each.Relationship == Iso19770_2.Relationship.InstallationMedia));

            if (file != null)
            {
                // looks good! let's keep it
                if (File.Exists(targetFile))
                {
                    request.Debug("Removing old file '{0}'", targetFile);
                    targetFile.TryHardToDelete();
                }

                // is that file still there?
                if (File.Exists(targetFile))
                {
                    request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.UnableToRemoveFile, targetFile);
                    return(false);
                }

                request.Debug("Copying file '{0}' to '{1}'", file, targetFile);
                File.Copy(file, targetFile);
                if (File.Exists(targetFile))
                {
                    // since we only installed a single assembly, we can just ask to load that specific assembly.
                    if (PackageManagementService.TryToLoadProviderAssembly(targetFile, request))
                    {
                        // looks good to me.
                        request.YieldFromSwidtag(provider, fastPath);
                        return(true);
                    }
                }
            }
            if (file != null)
            {
                file.TryHardToDelete();
            }
            return(false);
        }
Example #2
0
        private bool InstallPackageFile(Package provider, string fastPath, BootstrapRequest request)
        {
            // we can download and verify this package and get the core to install it.
            var file = request.DownloadAndValidateFile(provider.Name, provider._swidtag.Links.Where(each => each.Relationship == Iso19770_2.Relationship.InstallationMedia));

            if (file != null)
            {
                // we have a valid file.
                // run the installer
                if (request.ProviderServices.Install(file, "", request))
                {
                    // it installed ok!
                    request.YieldFromSwidtag(provider, fastPath);
                    PackageManagementService.LoadProviders(request.As <IRequest>());
                    return(true);
                }
                request.Warning(Constants.Messages.FailedProviderBootstrap, fastPath);
            }
            return(false);
        }
Example #3
0
 private bool InstallPackageFile(Package provider, string fastPath, BootstrapRequest request)
 {
     // we can download and verify this package and get the core to install it.
     var file = request.DownloadAndValidateFile(provider.Name, provider._swidtag.Links.Where(each => each.Relationship == Iso19770_2.Relationship.InstallationMedia));
     if (file != null) {
         // we have a valid file.
         // run the installer
         if (request.ProviderServices.Install(file, "", request)) {
             // it installed ok!
             request.YieldFromSwidtag(provider, fastPath);
             PackageManagementService.LoadProviders(request.As<IRequest>());
             return true;
         }
         request.Warning(Constants.Messages.FailedProviderBootstrap, fastPath);
     }
     return false;
 }
Example #4
0
        private bool InstallAssemblyProvider(Package provider, Link link, string fastPath, BootstrapRequest request)
        {
            if (!Directory.Exists(request.DestinationPath)) {
                request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.DestinationPathNotSet);
                return false;
            }

            var targetFilename = link.Attributes[Iso19770_2.Discovery.TargetFilename];

            if (string.IsNullOrWhiteSpace(targetFilename)) {
                request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.InvalidFilename);
                return false;
            }

            targetFilename = Path.GetFileName(targetFilename);
            var targetFile = Path.Combine(request.DestinationPath, targetFilename);

            // download the file
            var file = request.DownloadAndValidateFile(provider.Name, provider._swidtag.Links.Where(each => each.Relationship == Iso19770_2.Relationship.InstallationMedia));
            if (file != null) {
                // looks good! let's keep it
                if (File.Exists(targetFile)) {
                    request.Debug("Removing old file '{0}'", targetFile);
                    targetFile.TryHardToDelete();
                }

                // is that file still there?
                if (File.Exists(targetFile)) {
                    request.Error(ErrorCategory.InvalidOperation, fastPath, Constants.Messages.UnableToRemoveFile, targetFile);
                    return false;
                }

                request.Debug("Copying file '{0}' to '{1}'", file, targetFile);
                File.Copy(file, targetFile);
                if (File.Exists(targetFile)) {
                    // since we only installed a single assembly, we can just ask to load that specific assembly.
                    if (PackageManagementService.TryToLoadProviderAssembly(targetFile, request)) {
                        // looks good to me.
                        request.YieldFromSwidtag(provider, fastPath);
                        return true;
                    }
                }
            }
            if (file != null) {
                file.TryHardToDelete();
            }
            return false;
        }