Exemplo n.º 1
0
        public UserUsageSummary CreateUserUsageSummary(DateTime period, IReportingClient client)
        {
            bool showDisclaimer = false;

            var gs = _provider.Data.GlobalSetting.GetGlobalSetting("ShowUserUsageSummaryDisclaimer");

            if (gs != null)
            {
                showDisclaimer = bool.Parse(gs.SettingValue);
            }

            string disclaimer = showDisclaimer ? string.Format("Please note: The data for {0:MMMM} usage has not yet been finalized.", period) : null;

            //var usage = UserUsageCharge.SelectByUser(client.ClientID, period).ToList();

            var result = new UserUsageSummary()
            {
                ClientID       = client.ClientID,
                UserName       = client.UserName,
                LName          = client.LName,
                FName          = client.FName,
                Period         = period,
                Created        = DateTime.Now,
                Disclaimer     = disclaimer,
                AggregateByOrg = CreateAggregateByOrg(client.ClientID, period)
            };

            return(result);
        }
        public async Task StartContainersForScenarioRun(String scenarioName)
        {
            String testFolder = scenarioName;

            Logging.Enabled();

            Guid testGuid = Guid.NewGuid();

            this.TestId = testGuid;
            // Setup the container names
            this.ManagementAPIContainerName       = $"rest{testGuid:N}";
            this.EventStoreContainerName          = $"eventstore{testGuid:N}";
            this.SecurityServiceContainerName     = $"auth{testGuid:N}";
            this.SubscriberServiceId              = testGuid;
            this.SubscriptionServiceContainerName = $"subService{testGuid:N}";
            this.MessagingServiceContainerName    = $"messaging{testGuid:N}";

            this.EventStoreConnectionString =
                $"EventStoreSettings:ConnectionString=ConnectTo=tcp://admin:changeit@{this.EventStoreContainerName}:1113;VerboseLogging=true;";
            this.SecurityServiceAddress = $"AppSettings:SecurityService=http://{this.SecurityServiceContainerName}:5001";
            this.AuthorityAddress       = $"SecurityConfiguration:Authority=http://{this.SecurityServiceContainerName}:5001";
            this.SubscriptionServiceConnectionString =
                $"\"ConnectionStrings:SubscriptionServiceConfigurationContext={Setup.GetConnectionString("SubscriptionServiceConfiguration")}\"";
            this.ManagementAPIReadModelConnectionString = $"\"ConnectionStrings:ManagementAPIReadModel={Setup.GetConnectionString($"ManagementAPIReadModel{testGuid:N}")}\"";
            this.ManagementAPISeedingType = "SeedingType=IntegrationTest";
            this.MessagingServiceAddress  = $"ServiceAddresses:MessagingService=http://{this.MessagingServiceContainerName}:5002";

            this.SetupTestNetwork();
            this.SetupManagementAPIContainer(testFolder);
            this.SetupSecurityServiceContainer(testFolder);
            this.SetupEventStoreContainer(testFolder);
            this.SetupSubscriptionServiceContainer(testFolder);
            this.SetupMessagingService(testFolder);

            // Cache the ports
            this.ManagementApiPort    = this.ManagementAPIContainer.ToHostExposedEndpoint("5000/tcp").Port;
            this.EventStorePort       = this.EventStoreContainer.ToHostExposedEndpoint("2113/tcp").Port;
            this.SecurityServicePort  = this.SecurityServiceContainer.ToHostExposedEndpoint("5001/tcp").Port;
            this.MessagingServicePort = this.MessagingServiceContainer.ToHostExposedEndpoint("5002/tcp").Port;

            await this.SetupSubscriptionServiceConfig(CancellationToken.None).ConfigureAwait(false);

            await this.SetupSecurityServiceConfig(CancellationToken.None).ConfigureAwait(false);

            // Setup the base address resolver
            Func <String, String> baseAddressResolver = api => $"http://127.0.0.1:{this.ManagementApiPort}";

            HttpClient httpClient = new HttpClient();


            this.GolfClubAdministratorClient = new GolfClubAdministratorClient(baseAddressResolver, httpClient);
            this.GolfClubClient         = new Service.Client.v2.GolfClubClient(baseAddressResolver, httpClient);
            this.PlayerClient           = new Service.Client.v2.PlayerClient(baseAddressResolver, httpClient);
            this.ReportingClient        = new Service.Client.v2.ReportingClient(baseAddressResolver, httpClient);
            this.HttpClient             = new HttpClient();
            this.HttpClient.BaseAddress = new Uri(baseAddressResolver(String.Empty));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiClient" /> class.
 /// </summary>
 /// <param name="golfClubClient">The golf club client.</param>
 /// <param name="tournamentClient">The tournament client.</param>
 /// <param name="reportingClient">The reporting client.</param>
 /// <param name="modelFactory">The model factory.</param>
 public ApiClient(IGolfClubClient golfClubClient,
                  ITournamentClient tournamentClient,
                  IReportingClient reportingClient,
                  IModelFactory modelFactory)
 {
     this.GolfClubClient   = golfClubClient;
     this.TournamentClient = tournamentClient;
     this.ReportingClient  = reportingClient;
     this.ModelFactory     = modelFactory;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiClient" /> class.
 /// </summary>
 /// <param name="playerClient">The player client.</param>
 /// <param name="golfClubClient">The golf club client.</param>
 /// <param name="tournamentClient">The tournament client.</param>
 /// <param name="reportingClient">The reporting client.</param>
 public ApiClient(IPlayerClient playerClient,
                  IGolfClubClient golfClubClient,
                  ITournamentClient tournamentClient,
                  IReportingClient reportingClient)
 {
     this.PlayerClient     = playerClient;
     this.GolfClubClient   = golfClubClient;
     this.TournamentClient = tournamentClient;
     this.ReportingClient  = reportingClient;
 }
Exemplo n.º 5
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral              = taskInstance.GetDeferral();
            taskInstance.Canceled += TaskInstance_Canceled;

            try
            {
                _logger = new SyslogLogger();
                _logger.Info("Starting weather station service");
            }
            catch (Exception ex)
            {
                throw ex;
            }

            try
            {
                _sensorsClient   = new RinsenOneWireClient();
                _reportingClient = new WebReportingClient(_logger);

                if (_reportingClient.SupportsSensorsUpdate)
                {
                    _logger.Info("Sending sensors info is allowed, updating sensors info");

                    var sensorIds = _sensorsClient.ListSensors();
                    await _reportingClient.UpdateSensors(sensorIds);
                }

                _logger.Info("Initializing sensors reading timer");
                _timer = new Timer(TemperatureCallback, null, 0, 5 * 60 * 1000);
                _logger.Info("Timer successfully initialized");
            }
            catch (Exception ex)
            {
                _logger.Critical(ex.ToString());

                _logger.Info("Critical exception occured while reporting sensors, closing");
                _deferral.Complete();
                return;
            }

            _logger.Info("Entering service loop");

            while (!_isClosing)
            {
                Task.Delay(2000).Wait();
            }

            _logger.Info("Exiting service loop");
        }
Exemplo n.º 6
0
        private void TaskInstance_Canceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
        {
            _logger.Info("Task was cancelled, reason: " + reason);

            _isClosing = true;

            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }

            if (_sensorsClient != null)
            {
                var disposable = _sensorsClient as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
                _sensorsClient = null;
            }

            if (_reportingClient != null)
            {
                var disposable = _reportingClient as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
                _reportingClient = null;
            }

            if (_logger != null)
            {
                var disposable = _logger as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
                _logger = null;
            }

            if (_deferral != null)
            {
                _deferral.Complete();
                _deferral = null;
            }
        }
Exemplo n.º 7
0
        private IList<string> DataSourcesForReport(IReportingClient reportingClient, Report report)
        {
            var path = IsCustomReport(report.Id) ? _customReportsPath : _cannedReportsPath;
            var reports = reportingClient.GetReports(path);

            String baseReportName = string.Join("/", SplitReportId(report.Id), 0, DataSourcePartIndex);

            return (from reportInfo in reports
                    where reportInfo.Id.StartsWith(baseReportName, StringComparison.OrdinalIgnoreCase)
                    select SplitReportId(reportInfo.Id)[DataSourcePartIndex]).ToList();
        }
Exemplo n.º 8
0
        private static ReportSchedulerModel CreateReportSchedulerModel(IReportingClient reportingClient, string reportUiCulture,
                                                                       Report report, SubscriptionDetails subscriptionDetails)
        {
            var subscriptionParameters = reportingClient.GetParameters(report.Id, DefaultReportDataSouce, subscriptionDetails.Parameters);
            bool endDateSpecified = subscriptionDetails.EndDateTime != DateTime.MinValue;
            var model = new ReportSchedulerModel
            {
                ReportId = report.Id,
                ScheduleId = subscriptionDetails.ScheduleId,
                ReportUiCulture = reportUiCulture,
                ReportName = report.Name,
                Description = subscriptionDetails.Description,
                Parameters = new ReportParameters(subscriptionParameters, true),
                ParametersView = DynamicParameters,
                ReportOutputType =
                    ReportOutputTypeFromDeliverySettings(
                        subscriptionDetails.DeliverySettings),
                ReportFrequency = ReportFrequencyFromScheduleDefinition(subscriptionDetails.ScheduleDefinition),
                ScheduledTime = subscriptionDetails.StartDateTime.ToShortTimeString(),
                StartDate = subscriptionDetails.StartDateTime.ToShortDateString(),
                EndDateSpecified = endDateSpecified,
                ReportDestination =
                    ReportDestinationFromDeliverySettings(
                        subscriptionDetails.DeliverySettings)
            };

            if (model.ReportFrequency == ReportFrequency.Weekly)
            {
                model.Weekday = WeeklyRecurrencePatternFromScheduleDefintion(subscriptionDetails.ScheduleDefinition);
            }

            if (endDateSpecified) model.EndDate = subscriptionDetails.EndDateTime.ToShortDateString();

            if (subscriptionDetails.DeliverySettings.ReportDestination == ReportDestination.FileShare)
            {
                LoadModelWithFileShareValues(model, subscriptionDetails.DeliverySettings.ToFileShareSettings());
            }
            else
            {
                LoadModelWithEmailValues(model, subscriptionDetails.DeliverySettings.ToEmailSettings());
            }

            return model;
        }
Exemplo n.º 9
0
        private Report RetrieveReportForReportId(IReportingClient reportingClient, string reportId, string dataSource, out string reportUiCulture)
        {
            reportUiCulture = CultureInfo.CurrentCulture.Name;
            Report report = reportingClient.GetReport(reportId, dataSource, LanguageParameterArrayForCulture(reportUiCulture));

            if (report != null)
            {
                ReportInfo reportInfo;
                string reportName;
                string reportDescription;
                List<ItemParameter> parameters = report.Parameters.ToList();

                if (TryGetReportInfo(reportId, out reportInfo))
                {
                    // Attempt to identify a CannedReport with the specified reportId,
                    // to use the Name and Description from Resources
                    reportName = reportInfo.Name;
                    reportDescription = reportInfo.Description;
                }
                else
                {
                    // If the reportId does not match a CannedReport, then use the
                    // Name and Description from the report itself (not localized)
                    reportName = GetCustomReportName(report.Id);
                    reportDescription = report.Description;
                }

                if (!IsRequestedLanguageSupported(parameters))
                {
                    // fall back to English (United States)
                    reportUiCulture = "en-US";
                    parameters = reportingClient.GetParameters(report.Id, dataSource,
                                                               LanguageParameterArrayForCulture(reportUiCulture)).ToList();
                }

                report = new Report(report.Id, reportName, reportDescription, parameters);
            }

            return report;
        }
Exemplo n.º 10
0
        private IEnumerable<ReportInfo> GetCustomReports(IReportingClient reportingClient)
        {
            ICollection<ReportInfo> filteredCustomReports = new Collection<ReportInfo>();
            IEnumerable<ReportInfo> customReports = reportingClient.GetReports(_customReportsPath);

            foreach (ReportInfo reportInfo in customReports)
            {
                if (reportInfo.Id.Contains("/History/Standard"))
                {
                    filteredCustomReports.Add(new ReportInfo(reportInfo.Id, GetCustomReportName(reportInfo.Id), reportInfo.Description));
                }
            }

            return filteredCustomReports;
        }
Exemplo n.º 11
0
 public ReportingTest()
 {
     _reportingClient = new ReportingClient(new ReportServerConfiguration("http://10.10.93.87/ReportServer", "P20003", "administrator", "").CloneWithNewPassword("control01!"), new BasicHttpBinding("ReportingServicesSoap"));
 }
Exemplo n.º 12
0
 public HomeController(IReportingClient reportingClient)
 {
     _reportingClient = reportingClient;
 }
Exemplo n.º 13
0
 public ManagerUsageSummary CreateManagerUsageSummary(DateTime period, IReportingClient manager, IEnumerable <ManagerUsageSummaryItem> items)
 {
     return(CreateManagerUsageSummary(period, manager.ClientID, manager.UserName, manager.LName, manager.FName, items));
 }
Exemplo n.º 14
0
 public ManagerUsageSummary CreateManagerUsageSummary(DateTime period, IReportingClient manager, bool includeRemote)
 {
     return(CreateManagerUsageSummary(period, manager.ClientID, manager.UserName, manager.LName, manager.FName, includeRemote));
 }
Exemplo n.º 15
0
 public GraphClientReportingTests(TestClientFixture fixture)
 {
     _fixture         = fixture;
     _reportingClient = fixture.Client.Reporting;
 }