protected override void ExecuteStage([NotNull] ReportBundle reportBundle)
        {
            if (reportBundle == null)
            {
                throw new ArgumentNullException(nameof(reportBundle));
            }

            var parameterValues = reportBundle.ParameterValues?.ToDictionary(_ => _.Key, _ => _.Value)
                                  ?? new Dictionary <string, object>();

            parameterValues.Add(DefaultReportParameters.CurrentDate, _timeService.GetUtc().ToString(CultureInfo.CurrentCulture));

            parameterValues.Add(DefaultReportParameters.ReportName, reportBundle.Report.DisplayName);

            parameterValues.Add(DefaultReportParameters.ReportTitle, reportBundle.Title);

            parameterValues.Add(DefaultReportParameters.SystemVersion, _systemVersionProvider.GetSystemVersion());

            parameterValues.Add(DefaultReportParameters.UiHost, _userInterfaceProvider.GetLatest().Host);

            reportBundle.ParameterValues = parameterValues;
        }
Пример #2
0
        private void CheckVersion()
        {
            var request = new ApiRequest
            {
                SourceId      = null,
                SourceType    = SourceTypes.Sa,
                RequestMethod = ScanAgentRequests.CheckVersion
            };

            request.SetData(
                new ScanAgentInfoDto
            {
                AssemblyVersion = _systemVersionProvider.GetSystemVersion(),
                Uid             = _scanAgentIdProvider.Get(),
                Version         = Settings.Default.Version,
                MachineName     = Environment.MachineName
            });

            var response = _apiService.Handle(request);

            if (!response.Success)
            {
                _logger.Fatal(response.Message);

                // TODO: typed exception
                throw new Exception($"Failed to check service version compability. Message='{response.Message}'");
            }

            var checkVersion = response.GetData <ScanAgentSettingsDto>();

            if (!checkVersion.IsCompatible)
            {
                // TODO: typed exception
                throw new Exception(Resources.SAIsNotCompatible.FormatWith(Settings.Default.Version));
            }
        }