Exemplo n.º 1
0
 public WebhooksController(IQueue <string> payloadQueue,
                           ISignatureVerifier signatureVerifier,
                           ILogger <WebhooksController> logger,
                           IEmployeeService employeeService,
                           ILiveDataService service)
 {
     _signatureVerifier = signatureVerifier;
     _logger            = logger;
     _employeeService   = employeeService;
     _contactObservable = service.RecentActivity as ContactObservable;
 }
Exemplo n.º 2
0
        public MockLiveDataService(IEmployeeService employeeService, ILogger <MockLiveDataService> logger)
        {
            _logger  = logger;
            Download = Observable
                       .Interval(TimeSpan.FromMilliseconds(900))
                       .StartWith(0)
                       .Select(_ => $"{Math.Round(_random.Next(15, 30) + _random.NextDouble(), 1)} Mb/s");

            Upload = Observable
                     .Interval(TimeSpan.FromMilliseconds(800))
                     .StartWith(0)
                     .Select(_ => $"{Math.Round(_random.Next(5, 7) + _random.NextDouble(), 1)} Mb/s");

            Latency = Observable
                      .Interval(TimeSpan.FromSeconds(1))
                      .StartWith(0)
                      .Select(_ => $"{_random.Next(50, 200)} ms");

            Users = Observable
                    .Interval(TimeSpan.FromMilliseconds(1200))
                    .StartWith(0)
                    .Select(_ => _random.Next(200, 300));

            Traffic = Observable
                      .Interval(TimeSpan.FromMilliseconds(600))
                      .StartWith(0)
                      .Select(_ => Enumerable.Range(1, 7).Select(i => _random.Next(1000, 10000)).ToArray());

            ServerUsage = Observable
                          .Interval(TimeSpan.FromMilliseconds(400))
                          .StartWith(0)
                          .Select(_ => Enumerable.Range(1, 10).Select(i => _random.Next(1, 100)).ToArray());

            Utilization = Observable
                          .Interval(TimeSpan.FromMilliseconds(800))
                          .StartWith(0)
                          .Select(_ => Enumerable.Range(1, 3).Select(i => _random.Next(1, 100)).ToArray());

            var contactObservable = new ContactObservable();

            contactObservable.Subscribe(new ContactObserver("console notification"));

            RecentActivity =
                contactObservable
                .Populate(employeeService.GetAll()
                          .Select(employee => new Activity
            {
                Id         = employee.Id,
                PersonName = employee.FullName,
                Status     = _activities[1],
            }));
            // .StartWith(
            //    employeeService.GetAll()
            //       .Select(employee => new Activity
            //       {
            //          Id = employee.Id,
            //          PersonName = employee.FullName,
            //          Status = _activities[1],
            //       })
            //       .ToArray());



            // .Interval(TimeSpan.FromSeconds(30))
            // .Select(s => GetChanges(employeeService))
            // .Select(employee => new Activity
            // {
            //    Id = employee.Id,
            //    PersonName = employee.FullName,
            //    Status = _activities[_random.Next(1, 3)],
            // })
            // .SelectMany(_ => employeeService.GetAll())
            // .Select(employee => new Activity
            // {
            //    Id = employee.Id,
            //    PersonName = employee.FullName,
            //    Status = _activities[_random.Next(1, 6)]
            // })



            Observable
            .Empty <Activity>()
            .StartWith(
                employeeService.GetAll()
                .Select(employee => new Activity
            {
                Id         = employee.Id,
                PersonName = employee.FullName,
                Status     = _activities[1],
            })
                .ToArray());

            // RecentActivity.Subscribe(new ContactReporter("console notification"));

            // (RecentActivity as ContactTracer)?.Populate(employeeService.GetAll()
            //    .Select(employee => new Activity
            //    {
            //       Id = employee.Id,
            //       PersonName = employee.FullName,
            //       Status = _activities[1],
            //    }));
        }