Exemple #1
0
        public ResolvedVariablesContainer ResolveVariables(AppAndServerAndOverrides appAndServerAndOverrides)
        {
            var app       = appAndServerAndOverrides.Application;
            var server    = appAndServerAndOverrides.Server;
            var overrides = appAndServerAndOverrides.Overrides;

            // Hydrate the app with trusted data (ie: don't use what was sent from the browser).
            Application hydratedApp;

            using (var prestoWcf = new PrestoWcf <IApplicationService>())
            {
                hydratedApp = prestoWcf.Service.GetById(app.Id);
            }

            // Hydrate the server with trusted data (ie: don't use what was sent from the browser).
            ApplicationServer hydratedServer;

            using (var prestoWcf = new PrestoWcf <IServerService>())
            {
                hydratedServer = prestoWcf.Service.GetServerById(server.Id);
            }

            var appWithOverrides = new ApplicationWithOverrideVariableGroup();

            appWithOverrides.Application          = hydratedApp;
            appWithOverrides.CustomVariableGroups = overrides;

            return(VariableGroupResolver.Resolve(appWithOverrides, hydratedServer));
        }
Exemple #2
0
        public IEnumerable <InstallationSummaryDto> Get(AppAndServerAndOverrides appAndServerAndOverrides)
        {
            try
            {
                if (appAndServerAndOverrides.MaxResults <= 0)
                {
                    appAndServerAndOverrides.MaxResults = _defaultInstallsToRetrieve;
                }

                var installationSummaries = GetInstallationSummaries(appAndServerAndOverrides);

                var installationSummaryDtos = new List <InstallationSummaryDto>();

                // Just use this until we can give the user the flexibility to choose a different time zone.
                var timeZoneHelper = new TimeZoneHelperThisComputer();

                foreach (InstallationSummary installationSummary in installationSummaries)
                {
                    InstallationSummaryDto dto = new InstallationSummaryDto();
                    dto.ApplicationName = installationSummary.ApplicationWithOverrideVariableGroup.ToString();
                    dto.Id          = installationSummary.Id;
                    dto.Result      = installationSummary.InstallationResult.ToString();
                    dto.ServerName  = installationSummary.ApplicationServer.Name;
                    dto.Environment = installationSummary.ApplicationServer.InstallationEnvironment.ToString();
                    dto.TaskDetails = installationSummary.TaskDetails;

                    timeZoneHelper.SetStartAndEndTimes(installationSummary, dto);

                    installationSummaryDtos.Add(dto);
                }

                return(installationSummaryDtos.OrderByDescending(x => x.InstallationStart));
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                throw Helper.CreateHttpResponseException(ex, "Error Getting Installations");
            }
        }
Exemple #3
0
        private IEnumerable <InstallationSummary> GetInstallationSummaries(AppAndServerAndOverrides appAndServerAndOverrides)
        {
            if (appAndServerAndOverrides.MaxResults > _maxInstallsToRetrieve)
            {
                string message = string.Format(CultureInfo.CurrentCulture,
                                               "Cannot retrieve {0} records. The maximum allowed is {1}.",
                                               appAndServerAndOverrides.MaxResults,
                                               _maxInstallsToRetrieve);

                throw new InvalidOperationException(message);
            }

            using (var prestoWcf = new PrestoWcf <IInstallationSummaryService>())
            {
                if (appAndServerAndOverrides.Application != null & appAndServerAndOverrides.Server != null)
                {
                    return(prestoWcf.Service.GetMostRecentByStartTimeServerAndApplication(
                               appAndServerAndOverrides.MaxResults, appAndServerAndOverrides.Server.Id, appAndServerAndOverrides.Application.Id,
                               appAndServerAndOverrides.EndDate));
                }

                if (appAndServerAndOverrides.Application != null)
                {
                    return(prestoWcf.Service.GetMostRecentByStartTimeAndApplication(
                               appAndServerAndOverrides.MaxResults, appAndServerAndOverrides.Application.Id, appAndServerAndOverrides.EndDate));
                }

                if (appAndServerAndOverrides.Server != null)
                {
                    return(prestoWcf.Service.GetMostRecentByStartTimeAndServer(
                               appAndServerAndOverrides.MaxResults, appAndServerAndOverrides.Server.Id, appAndServerAndOverrides.EndDate));
                }

                // No filter; just get the most recent.
                return(prestoWcf.Service.GetMostRecentByStartTime(appAndServerAndOverrides.MaxResults, appAndServerAndOverrides.EndDate));
            }
        }