private void step2CodeActivity_Install_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                PackageManagerInstallProcess packageManagerInstallProcess = this.GetBinding<PackageManagerInstallProcess>("PackageManagerInstallProcess");

                List<PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install();
                if (installResult.Count > 0)
                {
                    this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(installResult));
                }
            }
            catch (Exception ex)
            {
                this.UpdateBinding("Errors", new List<List<string>> { new List<string> { ex.Message, "" } });
            }
        }
Beispiel #2
0
        private void step3CodeActivity_DownloadAndValidate_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                PackageDescription packageDescription = GetPackageDescription();

                string packageServerSource = PackageSystemServices.GetPackageSourceNameByPackageId(packageDescription.Id, InstallationInformationFacade.InstallationId, UserSettings.CultureInfo);

                System.IO.Stream installFileStream = PackageServerFacade.GetInstallFileStream(packageDescription.PackageFileDownloadUrl);

                PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(installFileStream, false, packageServerSource);
                this.Bindings.Add("PackageManagerInstallProcess", packageManagerInstallProcess);

                this.Bindings.Add("FlushOnCompletion", packageManagerInstallProcess.FlushOnCompletion);
                this.Bindings.Add("ReloadConsoleOnCompletion", packageManagerInstallProcess.ReloadConsoleOnCompletion);

                if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0)
                {
                    this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(packageManagerInstallProcess.PreInstallValidationResult));
                }
                else
                {
                    List <PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate();

                    if (validationResult.Count > 0)
                    {
                        this.UpdateBinding("LayoutLabel", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallRemotePackage.ShowWarning.LayoutLabel"));
                        this.UpdateBinding("TableCaption", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallRemotePackage.ShowWarning.InfoTableCaption"));
                        this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(validationResult));
                    }
                    else
                    {
                        this.UpdateBinding("Uninstallable", packageManagerInstallProcess.CanBeUninstalled == false);
                    }
                }
            }
            catch (Exception ex)
            {
                this.UpdateBinding("Errors", new List <List <string> > {
                    new List <string> {
                        ex.Message, ""
                    }
                });
            }
        }
        private void step1CodeActivity_ValidateInstallation_ExecuteCode(object sender, EventArgs e)
        {
            try
            {
                UploadedFile uploadedFile = this.GetBinding <UploadedFile>("UploadedFile");

                PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(uploadedFile.FileStream, true);

                if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0)
                {
                    this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(packageManagerInstallProcess.PreInstallValidationResult));
                }
                else
                {
                    List <PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate();

                    if (validationResult.Count > 0)
                    {
                        this.UpdateBinding("LayoutLabel", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallLocalPackage.ShowWarning.LayoutLabel"));
                        this.UpdateBinding("TableCaption", StringResourceSystemFacade.GetString("Composite.Plugins.PackageElementProvider", "InstallLocalPackage.ShowWarning.InfoTableCaption"));
                        this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(validationResult));
                    }
                    else
                    {
                        this.Bindings.Add("PackageManagerInstallProcess", packageManagerInstallProcess);

                        this.Bindings.Add("FlushOnCompletion", packageManagerInstallProcess.FlushOnCompletion);
                        this.Bindings.Add("ReloadConsoleOnCompletion", packageManagerInstallProcess.ReloadConsoleOnCompletion);
                    }
                }
            }
            catch (Exception ex)
            {
                this.UpdateBinding("Errors", new List <List <string> > {
                    new List <string> {
                        ex.Message, ""
                    }
                });
            }
        }
Beispiel #4
0
        private static void InstallPackage(string packageUrl, Stream packageStream)
        {
            PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(packageStream, true);

            if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0)
            {
                throw WrapFirstValidationException(packageUrl, packageManagerInstallProcess.PreInstallValidationResult);
            }

            List <PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate();

            if (validationResult.Count > 0)
            {
                throw WrapFirstValidationException(packageUrl, validationResult);
            }

            List <PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install();

            if (installResult.Count > 0)
            {
                throw WrapFirstValidationException(packageUrl, installResult);
            }
        }
Beispiel #5
0
        private static bool InstallPackage(string packageUrl, Stream packageStream)
        {
            try
            {
                PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(packageStream, true);
                if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0)
                {
                    LogValidationResults(packageManagerInstallProcess.PreInstallValidationResult);
                    return(false);
                }

                List <PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate();

                if (validationResult.Count > 0)
                {
                    LogValidationResults(validationResult);
                    return(false);
                }

                List <PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install();
                if (installResult.Count > 0)
                {
                    LogValidationResults(installResult);
                    return(false);
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.LogCritical(LogTitle, "Error installing package: " + packageUrl);
                Log.LogCritical(LogTitle, ex);

                throw;
            }
        }
Beispiel #6
0
        private static void DoAutoInstallPackages()
        {
            if (IsReinitializingTheSystem)
            {
                return;
            }

            try
            {
                // This is not so good, unittests run and normal runs should have same semantic behavior.
                // But if this is not here, some unittests will start failing. /MRJ
                if (RuntimeInformation.IsUnittest)
                {
                    return;
                }

                var zipFiles = new List <AutoInstallPackageInfo>();

                string directory = PathUtil.Resolve(GlobalSettingsFacade.AutoPackageInstallDirectory);
                if (C1Directory.Exists(directory))
                {
                    Log.LogVerbose(LogTitle, string.Format("Installing packages from: {0}", directory));
                    zipFiles.AddRange(C1Directory.GetFiles(directory, "*.zip")
                                      .Select(f => new AutoInstallPackageInfo {
                        FilePath = f, ToBeDeleted = true
                    }));
                }
                else
                {
                    Log.LogVerbose(LogTitle, string.Format("Auto install directory not found: {0}", directory));
                }

                if (RuntimeInformation.IsDebugBuild)
                {
                    string workflowTestDir = Path.Combine(PathUtil.Resolve(GlobalSettingsFacade.AutoPackageInstallDirectory), "WorkflowTesting");
                    if (C1Directory.Exists(workflowTestDir))
                    {
                        Log.LogVerbose(LogTitle, string.Format("Installing packages from: {0}", workflowTestDir));
                        zipFiles.AddRange(C1Directory.GetFiles(workflowTestDir, "*.zip")
                                          .OrderBy(f => f)
                                          .Select(f => new AutoInstallPackageInfo {
                            FilePath = f, ToBeDeleted = false
                        }));
                    }
                }


                foreach (var zipFile in zipFiles)
                {
                    try
                    {
                        using (Stream zipFileStream = C1File.OpenRead(zipFile.FilePath))
                        {
                            Log.LogVerbose(LogTitle, "Installing package: " + zipFile.FilePath);

                            PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(zipFileStream, true);

                            if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0)
                            {
                                Log.LogError(LogTitleNormal, "Package installation failed! (Pre install validation error)");
                                LogErrors(packageManagerInstallProcess.PreInstallValidationResult);

                                continue;
                            }


                            List <PackageFragmentValidationResult> validationResults = packageManagerInstallProcess.Validate();
                            if (validationResults.Count > 0)
                            {
                                Log.LogError(LogTitleNormal, "Package installation failed! (Validation error)");
                                LogErrors(validationResults);

                                continue;
                            }


                            List <PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install();
                            if (installResult.Count > 0)
                            {
                                Log.LogError(LogTitleNormal, "Package installation failed! (Installation error)");
                                LogErrors(installResult);

                                continue;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.LogWarning(LogTitleNormal, ex);
                    }

                    if (zipFile.ToBeDeleted)
                    {
                        FileUtils.Delete(zipFile.FilePath);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.LogError(LogTitleNormal, ex);
            }
        }
Beispiel #7
0
        public static bool InstallPackage(string packageUrl)
        {
            Log.LogInformation("InstallPackage", "downloading.." + packageUrl);
            bool result = false;

            try
            {
                HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(packageUrl);
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();

                byte[] buffer = new byte[32768];
                using (Stream inputStream = response.GetResponseStream())
                {
                    using (MemoryStream outputStream = new MemoryStream())
                    {
                        int read;
                        while ((read = inputStream.Read(buffer, 0, 32768)) > 0)
                        {
                            outputStream.Write(buffer, 0, read);
                        }

                        outputStream.Seek(0, SeekOrigin.Begin);

                        PackageManagerInstallProcess packageManagerInstallProcess = PackageManager.Install(outputStream, true);
                        if (packageManagerInstallProcess.PreInstallValidationResult.Count > 0)
                        {
                            LogValidationResults(packageManagerInstallProcess.PreInstallValidationResult);
                        }
                        else
                        {
                            List <PackageFragmentValidationResult> validationResult = packageManagerInstallProcess.Validate();

                            if (validationResult.Count > 0)
                            {
                                LogValidationResults(validationResult);
                            }
                            else
                            {
                                List <PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install();
                                if (installResult.Count > 0)
                                {
                                    LogValidationResults(installResult);
                                }
                                else
                                {
                                    result = true;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.LogCritical("InstallPackage", "Error installing package: " + packageUrl);
                Log.LogCritical("InstallPackage", ex);

                throw;
            }
            Log.LogInformation("InstallPackage", "Installed package: " + packageUrl);
            return(result);
        }
Beispiel #8
0
        private void step4CodeActivity_Install_ExecuteCode(object sender, EventArgs e)
        {
            PackageDescription packageDescription = GetPackageDescription();

            PackageManagerInstallProcess packageManagerInstallProcess = this.GetBinding <PackageManagerInstallProcess>("PackageManagerInstallProcess");

            bool      installOk        = false;
            string    packageServerUrl = null;
            Exception exception        = null;

            try
            {
                packageServerUrl = PackageSystemServices.GetPackageSourceNameByPackageId(packageDescription.Id, InstallationInformationFacade.InstallationId, UserSettings.CultureInfo);

                List <PackageFragmentValidationResult> installResult = packageManagerInstallProcess.Install();
                if (installResult.Count > 0)
                {
                    this.UpdateBinding("Errors", WorkflowHelper.ValidationResultToBinding(installResult));
                }
                else
                {
                    installOk = true;
                }
            }
            catch (Exception ex)
            {
                exception = ex;

                this.UpdateBinding("Errors", new List <List <string> > {
                    new List <string> {
                        ex.Message, ""
                    }
                });
            }

            try
            {
                if (installOk)
                {
                    PackageServerFacade.RegisterPackageInstallationCompletion(packageServerUrl, InstallationInformationFacade.InstallationId, packageDescription.Id, UserSettings.Username, UserSettings.UserIPAddress.ToString());
                }
                else
                {
                    StringBuilder sb = new StringBuilder();
                    if (exception != null)
                    {
                        sb.Append(exception.ToString());
                    }
                    else
                    {
                        List <List <string> > errors = this.GetBinding <List <List <string> > >("Errors");
                        foreach (List <string> list in errors)
                        {
                            sb.AppendLine(list[0]);
                        }
                    }

                    PackageServerFacade.RegisterPackageInstallationFailure(packageServerUrl, InstallationInformationFacade.InstallationId, packageDescription.Id, UserSettings.Username, UserSettings.UserIPAddress.ToString(), sb.ToString());
                }
            }
            catch (Exception ex)
            {
                LoggingService.LogWarning("InstallRemotePackageWorkflow", ex);
            }
        }