public void SetResults(InstallationResultContainer resultContainer, DateTime endTime)
        {
            if (resultContainer == null)
            {
                throw new ArgumentNullException("resultContainer");
            }

            this.InstallationResult = resultContainer.InstallationResult;
            this.TaskDetails        = resultContainer.TaskDetails;
            this.InstallationEnd    = endTime;
            this.InstallationEndUtc = TimeZoneInfo.ConvertTimeToUtc(endTime);
        }
Exemple #2
0
        private static InstallationResultContainer FinalInstallationResultContainer(
            InstallationResultContainer container, InstallationResult result, int numberOfSuccessfulTasks, bool atLeastOneTaskFailed)
        {
            if (_atLeastOneTaskFailedWhereFailureCausesAllStop || numberOfSuccessfulTasks < 1)
            {
                container.InstallationResult = InstallationResult.Failure;
                return(container);
            }

            if (atLeastOneTaskFailed)
            {
                container.InstallationResult = InstallationResult.PartialSuccess;
                return(container);
            }

            container.InstallationResult = result;
            return(container);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
            }
        }
Exemple #5
0
        /// <summary>
        /// Installs this instance.
        /// </summary>
        public InstallationResultContainer Install(ApplicationServer applicationServer, DateTime installationStartTime, bool calledFromAppInstaller)
        {
            SetInstallationStartTimestamp(installationStartTime);

            // Before 23-Jun-2014, the only caller to this method was the AppInstaller. Since a new task (TaskApp) was added, it
            // also calls this method now. We only want to initialize a new container when called by AppInstaller. TaskApp will
            // call this method, but it won't do anything with the result. So, we just want to capture all of the task details
            // here, including the ones generated by TaskApp, then return the whole thing to AppInstaller.
            if (calledFromAppInstaller)
            {
                _installationResultContainer = new InstallationResultContainer();
            }

            bool atLeastOneTaskFailed    = false;
            int  numberOfSuccessfulTasks = 0;

            try
            {
                // Note: We do a ToList() here because we get a "collection was modified" exception otherwise. The reason we
                //       get the exception is because, somewhere else in this processing, we make this call:
                //       CustomVariableGroupLogic.Get(application.Name)
                //       That method does a refresh on the CustomVariableGroup, which contains an app, which contains the tasks.
                //       Good times.
                foreach (TaskBase taskBase in this.Application.MainAndPrerequisiteTasks.ToList().OrderBy(task => task.Sequence))
                {
                    DateTime taskStartTime = DateTime.Now;

                    PossiblyAddTaskAppStartToInstallationResults(taskBase, taskStartTime);

                    taskBase.Execute(applicationServer, this);

                    _installationResultContainer.TaskDetails.Add(new TaskDetail(taskStartTime, DateTime.Now, taskBase.TaskDetails));

                    if (taskBase.TaskSucceeded == true)
                    {
                        numberOfSuccessfulTasks++;
                    }

                    // The reason this is here is because we're trying to detect when failures occur within the TaskApp types.
                    if (_atLeastOneTaskFailedWhereFailureCausesAllStop)
                    {
                        break;
                    }

                    if (taskBase.TaskSucceeded == false)
                    {
                        atLeastOneTaskFailed = true;
                        if (taskBase.FailureCausesAllStop == 1)
                        {
                            _atLeastOneTaskFailedWhereFailureCausesAllStop = true;
                            break;  // No more processing.
                        }
                    }
                }

                return(FinalInstallationResultContainer(_installationResultContainer, InstallationResult.Success, numberOfSuccessfulTasks, atLeastOneTaskFailed));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(FinalInstallationResultContainer(_installationResultContainer, InstallationResult.Failure, numberOfSuccessfulTasks, atLeastOneTaskFailed));
            }
            finally
            {
                // Clear this so we don't keep things hanging around in memory unnecessarily.
                if (calledFromAppInstaller)
                {
                    _installationResultContainer = null;
                }
                if (calledFromAppInstaller)
                {
                    _atLeastOneTaskFailedWhereFailureCausesAllStop = false;
                }                                                                                       // Reset for the next call
            }
        }