private MonitorServiceTests Setup()
        {
            Cleanup();

            options = new DbContextOptionsBuilder <DatastoreContext>()
                      .UseInMemoryDatabase(Guid.NewGuid().ToString())
                      .Options;
            using (var store = new DatastoreContext(options, StubConfig.Default))
            {
                store.Database.EnsureCreated();
            }
            SetupDataStore();
            datastoreContext = new DatastoreContext(options, StubConfig.Default);

            var mapperConfig = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile(new SettingsAutoMapper());
                cfg.AddProfile(new MonitorAutoMapper());
            });

            DatastoreRepository = Substitute.For <IDatastoreRepository>();
            var bodyStore = new StubMessageBodyRetriever(() => Stream.Null);

            monitorService = new MonitorService(datastoreContext, SetupPmodeSource(), DatastoreRepository, bodyStore, mapperConfig);

            return(this);
        }
Example #2
0
        public void Test1()
        {
            var srv = MonitorService.Create();

            try
            {
                for (int i = 0; i < 4; i++)
                {
                    srv.Collect();
                    Thread.Sleep(500);
                }

                var proList = srv.GetProccesses().OrderByDescending(p => p.Cpu);
                foreach (var n in proList)
                {
                    Console.WriteLine(n);
                }
            }
            finally
            {
                srv.Dispose();
            }

            Assert.Pass();
        }
 public HttpReportsDataController(IHttpReportsStorage storage, MonitorService monitorService, ScheduleService scheduleService, LanguageService languageService)
 {
     _storage         = storage;
     _monitorService  = monitorService;
     _scheduleService = scheduleService;
     _lang            = languageService.GetLanguage().Result;
 }
Example #4
0
 public DashboardDataHandle(IServiceProvider serviceProvider, IHttpReportsStorage storage, MonitorService monitorService, ScheduleService scheduleService, LocalizeService localizeService) : base(serviceProvider)
 {
     _storage         = storage;
     _monitorService  = monitorService;
     _scheduleService = scheduleService;
     _localizeService = localizeService;
 }
Example #5
0
    public MainViewModel(MonitorService monitorService)
    {
        _monitorService = monitorService;
        Processes       = new ReactiveList <ProcessModel>()
        {
            ChangeTrackingEnabled = true
        };
        RxApp.SupportsRangeNotifications = false;
        IObservable <bool> checkboxObservable = this.WhenAnyValue(vm => vm.ShowProcessesIsChecked);
        IObservable <long> intervalObservable = Observable.Interval(TimeSpan.FromMilliseconds(200.0));

        // Start/stop the monitoring.
        checkboxObservable
        // Skip the default unchecked state.
        .Skip(1)
        .ObserveOnDispatcher()
        .Subscribe(
            isChecked =>
        {
            if (isChecked)
            {
                Processes.AddRange(monitorService.GetProcesses());
                monitorService.Start();
            }
            else
            {
                Processes.Clear();
                monitorService.Stop();
            }
        });
        // Update the memory usage and remove processes that have exited.
        checkboxObservable
        .Select(isChecked => isChecked ? intervalObservable : Observable.Never <long>())
        // Switch disposes of the previous internal observable
        // (either intervalObservable or Never) and "switches" to the new one.
        .Switch()
        .ObserveOnDispatcher()
        .Subscribe(
            _ =>
        {
            // Loop backwards in a normal for-loop to avoid the modification errors.
            for (int i = Processes.Count - 1; i >= 0; --i)
            {
                if (Processes[i].ProcessObject.HasExited)
                {
                    Processes.RemoveAt(i);
                }
                else
                {
                    Processes[i].UpdateMemory();
                }
            }
        });
        // Add newly started processes to our reactive list.
        monitorService.NewProcessObservable
        .Where(_ => ShowProcessesIsChecked)
        .ObserveOnDispatcher()
        .Subscribe(process => Processes.Add(process));
    }
Example #6
0
        private void SetPCInfo()
        {
            var computerInfo = MonitorService.GetComputerInfo();

            OSName.Content                 = computerInfo.OSName;
            MachineName.Content            = computerInfo.MachineName;
            AmountOfProcessorsName.Content = computerInfo.ProcessorsAmount;
        }
Example #7
0
        public void Test_MonitorTimer_NoConstructor()
        {
            // Arrange.
            var monitor = new MonitorService();

            // Assert.
            monitor.AppName.Should().Be(AppDomain.CurrentDomain.FriendlyName);
        }
Example #8
0
        public async Task GetMonitorDetails_WhenCall_ShouldHaveOneRecord()
        {
            var monitorService = new MonitorService(_mockRepository.Object);

            var result = await monitorService.GetMonitorDetails();

            Assert.IsTrue(result.Count == 1);
        }
        internal void MethodTest <TRequest>(TRequest request)
        {
            var service  = new MonitorService(config);
            var response = service.GetBalance(requestKeyApi);

            Debug.WriteLine(response.Balance);
            Assert.IsTrue(response.Success);
        }
Example #10
0
        public async Task GetMonitorDetails_WhenCall_ShouldNotNull()
        {
            var monitorService = new MonitorService(_mockRepository.Object);

            var result = await monitorService.GetMonitorDetails();

            Assert.IsNotNull(result);
        }
Example #11
0
 /// <summary>
 /// Delegate for refreshing Life Tests
 /// </summary>
 /// <param name="sender"></param>
 private void OnTimerElapsed(object sender)
 {
     if (PingActivated)
     {
         LifeTestService.GetLifeTest(ref clustersLife);
         MonitorService.InsertResults(clustersLife);
         hub.Clients.All.RefreshLifeTests(model, DateTime.Now.ToString());
     }
 }
Example #12
0
        public void Test_MonitorTimer_LoggerConstructor()
        {
            // Arrange.
            var mockLogger = new Mock <ILogger <MonitorService> >();
            var monitor    = new MonitorService(mockLogger.Object);

            // Assert.
            monitor.AppName.Should().Be(AppDomain.CurrentDomain.FriendlyName);
        }
Example #13
0
        public void CanCreateInstanceOfmonitorService()
        {
            Mock <IEventDispatcher> dispatcher = new Mock <IEventDispatcher>();
            IMonitor monitor = new MonitorService(dispatcher.Object);

            Assert.IsNotNull(monitor);
            Assert.IsInstanceOf <MonitorService>(monitor);
            Assert.IsInstanceOf <IMonitor>(monitor);
        }
Example #14
0
        private void SetVCInfo()
        {
            var vcInfo = MonitorService.GetVideoControllerInfo();

            VCName.Content   = vcInfo["Name"];
            VCDriver.Content = vcInfo["DriverVersion"];
            VCProc.Content   = vcInfo["VideoProcessor"];
            VCStatus.Content = vcInfo["VideoProcessor"];
        }
Example #15
0
        public void Init( )
        {
            AddProcessWatchers( );
            AddServerMonitors( );

            MonitorService.Where(x => x.Type == ServerEventType.Offline).Subscribe(OnOffline);
            MonitorService.Where(x => x.Type == ServerEventType.Online).Subscribe(OnOnline);
            MonitorService.Where(x => x.Type == ServerEventType.Updated).Subscribe(OnUpdated);
        }
        public void CanCreateInstanceOfmonitorService()
        {
            Mock<IEventDispatcher> dispatcher = new Mock<IEventDispatcher>();
            IMonitor monitor = new MonitorService(dispatcher.Object);

            Assert.IsNotNull(monitor);
            Assert.IsInstanceOf<MonitorService>(monitor);
            Assert.IsInstanceOf<IMonitor>(monitor);
        }
Example #17
0
        private void BroadcastStatus(object state)
        {
            Status s = MonitorService.GetStatus();

            s.RequestCount           = string.Format("{0} - {1}", BaseController.CurrentRequestCount, BaseController.RequestCountLastReset);
            s.CrawlDaddyRequestCount = string.Format("{0} - {1}", BaseController.CrawlDaddyRequestCount, BaseController.RequestCountLastReset);
            s.RequestRate            = GetRequestRate(BaseController.CurrentRequestCount, BaseController.RequestCountLastReset).ToString();
            s.CrawlDaddyRequestRate  = GetRequestRatePerMin(BaseController.CrawlDaddyRequestCount, BaseController.RequestCountLastReset).ToString();
            Clients.All.showStatus(s);
        }
Example #18
0
        public ProccessesPage()
        {
            IKernel resolver = new StandardKernel();

            resolver.ConfigurateResolver();
            MonitorService = resolver.Get <IService>();
            InitializeComponent();
            Processes = MonitorService.GetAllProcesses().Take(20);
            ProcessesGridView.ItemsSource = Processes;
        }
Example #19
0
 public IndexModel(ILogger <IndexModel> logger, IOptions <DefaultPagingOptions> defaultPagingOptions,
                   IOptionsSnapshot <FeatureSettings> featureSettings, IOptions <ValidateSettings> validateSettings,
                   MonitorService monitorService)
 {
     _logger               = logger;
     _monitorService       = monitorService;
     _validateSettings     = validateSettings.Value;
     _featureSettings      = featureSettings.Value;
     _defaultPagingOptions = defaultPagingOptions.Value;
 }
Example #20
0
        // GET api/Monitor?pageIndex={pageIndex}&pageSize={pageSize}
        public IEnumerable <MonitorResultBO> Get(int pageIndex, int pageSize)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();
            IEnumerable <MonitorResultBO> ret = MonitorService.GetAllPaging(pageIndex, pageSize);

            sw.Stop();

            return(ret);
        }
        public void CanReceiveEevntsAndPassToHandlers()
        {
            Mock<IEventDispatcher> dispatcher = new Mock<IEventDispatcher>();
            dispatcher.Setup(o => o.DispatchEvent(It.IsAny<EventThatHappened>())).Verifiable();

            IMonitor monitor = new MonitorService(dispatcher.Object);

            monitor.ReceiveEvent(new EventThatHappened());

            dispatcher.Verify();
        }
Example #22
0
        public void CanReceiveEevntsAndPassToHandlers()
        {
            Mock <IEventDispatcher> dispatcher = new Mock <IEventDispatcher>();

            dispatcher.Setup(o => o.DispatchEvent(It.IsAny <EventThatHappened>())).Verifiable();

            IMonitor monitor = new MonitorService(dispatcher.Object);

            monitor.ReceiveEvent(new EventThatHappened());

            dispatcher.Verify();
        }
        public MainForm()
        {
            _activityMonitor = MonitorService.GetInstance().GetActivityMonitor();
            InitializeComponent();
            CanClose = false;

            if (_activityMonitor.Started())
            {
                startToolStripMenuItem.Enabled = false;
                stopToolStripMenuItem.Enabled  = true;
            }
        }
Example #24
0
 public MonitorBackendJob(IHttpReportsStorage storage,
                          IAlarmService alarmService,
                          MonitorService monitorService,
                          ILogger <MonitorBackendJob> logger,
                          LocalizeService localizeService)
 {
     _storage         = storage;
     _alarmService    = alarmService;
     _monitorService  = monitorService;
     _logger          = logger;
     _localizeService = localizeService;
 }
Example #25
0
        public ActionResult Index()
        {
            var configurationService = new ConfigurationService(AuthenticatedUser.SessionToken);
            var filters = new List <FilterModel>();

            ViewBag.Regions   = configurationService.GetRegionPaginatedList(filters, FilterJoin.And, true, "Name", 1, 1000000).Models;
            ViewBag.Districts = configurationService.GetDistrictPaginatedList(filters, FilterJoin.And, true, "BranchName", 1, 1000000).Models;

            var monitorService         = new MonitorService(AuthenticatedUser.SessionToken);
            var cameraStatisticsModels = monitorService.GetCameraStatistics(new FilterCameraLastStatisticsModel());

            return(View(cameraStatisticsModels));
        }
        public void GetContractTest()
        {
            var service = new MonitorService(Configuration);
            var model   = new RequestKeyApiModel();

            model.PublicKey   = "12GfsQD7peXrxTsjyNVCJmpWWBJAYA9oKy9dGZHb5mJt";
            model.NetworkIp   = "68.183.230.109";
            model.NetworkPort = "9090";

            var response = service.GetContract(model);

            Assert.IsNotNull(response);
            Console.WriteLine(JsonConvert.SerializeObject(response));
        }
Example #27
0
        public void GetLastBlockIdTest()
        {
            var service = new MonitorService(Configuration);

            var model = new RequestGetterApiModel();

            model.NetworkAlias = "MainNet";//"TestNet";
            model.AuthKey      = "87cbdd85-b2e0-4cb9-aebf-1fe87bf3afdd";
            // model.TransactionId = "26364287.1";

            var response = service.GetLastBlockId(model);

            Assert.IsNotNull(response);
        }
Example #28
0
        public async Task Test_MonitorTimer_ConfigConstructor()
        {
            // Arrange.
            var monitor = new MonitorService(new MonitorConfig(1), null);

            // Act.
            monitor.BackgroundTimerTick += (elapsed) => {
                elapsed.Should().BeGreaterOrEqualTo(TimeSpan.FromSeconds(0));
            };

            await Task.Delay(3000);

            // Assert.
            monitor.AppName.Should().Be(AppDomain.CurrentDomain.FriendlyName);
        }
Example #29
0
        public string GetDeviceLastThumbnail(long deviceID)
        {
            try
            {
                var monitorService = new MonitorService(AuthenticatedUser.SessionToken);
                var lastThumbnail  = monitorService.GetCameraLastThumbnail(deviceID);

                return("data:image/jpg;base64," + lastThumbnail.Document);
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;
                return("/Images/No_image.png");
            }
        }
Example #30
0
        public ActionResult FilterCameraStatistics(long regionID, long districtID, string cameraStatusTypes)
        {
            var filterModel = new FilterCameraLastStatisticsModel();

            filterModel.RegionID          = regionID == 0 ? default(long?) : regionID;
            filterModel.DistrictID        = districtID == 0 ? default(long?) : districtID;
            filterModel.CameraStatusTypes =
                cameraStatusTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(f => (CameraStatusType)int.Parse(f.Replace("statusChkBox_", string.Empty)))
                .ToList();

            var monitorService         = new MonitorService(AuthenticatedUser.SessionToken);
            var cameraStatisticsModels = monitorService.GetCameraStatistics(filterModel);

            return(Json(cameraStatisticsModels, JsonRequestBehavior.AllowGet));
        }
Example #31
0
        public static IDisposable Start()
        {
            // set up the creator
            Config.EventBusConfigSection.TriggerCreator();
            // start the monitor wcf service
            MonitorService.Start();

            // load up all the subscribers
            Subscribers.Current.WithSubscriberActivatedAction(new SubscriberActivatedHandler(
                                                                  delegate(ISubscriber subscriber)
            {
                MonitorService.MonitorAlertSubscriberActivated(subscriber);

                DefaultSingleton <ICreator> .Instance.Create <ILog>().Debug(string.Format("Activated '{0}' to handle '{1}'",
                                                                                          subscriber.GetEventType().Name, subscriber.GetType().Name));
            }))
            .WithSubscriberStartedAction(new SubscriberStartedExecutionHandler(
                                             delegate(ISubscriber subscriber, object target)
            {
                MonitorService.MonitorAlertSubscriberStarted(subscriber);

                DefaultSingleton <ICreator> .Instance.Create <ILog>().Debug(string.Format("Started handling '{0}' with '{1}'",
                                                                                          subscriber.GetEventType().Name, subscriber.GetType().Name));
            }))
            .WithSubscriberCompletedAction(
                new SubscriberCompletedExecutionHandler(
                    delegate(ISubscriber subscriber, object target)
            {
                MonitorService.MonitorAlertSubscriberCompleted(subscriber);

                DefaultSingleton <ICreator> .Instance.Create <ILog>().Debug(string.Format("Completed handling of '{0}' with '{1}'",
                                                                                          subscriber.GetEventType().Name, subscriber.GetType().Name));
            }))
            .WithSubscriberExceptionHandler(
                new SubscriberExecutionExceptionHandler(
                    delegate(ISubscriber subscriber, Exception exception)
            {
                MonitorService.MonitorAlertSubscriberException(subscriber);

                DefaultSingleton <ICreator> .Instance.Create <ILog>().Error(string.Format("Error handling '{0}' with '{1}'",
                                                                                          subscriber.GetEventType().Name, subscriber.GetType().Name), exception);
            }))
            .FromConfiguration();

            return(new WireSession());
        }
Example #32
0
        private void SetDriveInfo()
        {
            var drives = MonitorService.GetHardDriveInfo();

            foreach (var drive in drives)
            {
                DisksInfoList.Items.Add($"Drive {drive.Name}");
                DisksInfoList.Items.Add($"  Drive type: {drive.DriveType}");
                if (drive.IsReady == true)
                {
                    DisksInfoList.Items.Add($"  Volume label: {drive.VolumeLabel}");
                    DisksInfoList.Items.Add($"  File system: {drive.DriveFormat}");
                    DisksInfoList.Items.Add($"  Available space to current user:{drive.AvailableFreeSpace} bytes");

                    DisksInfoList.Items.Add($"  Total available space:          {drive.TotalFreeSpace} bytes");

                    DisksInfoList.Items.Add($"  Total size of drive:            {drive.TotalSize} bytes ");
                    DisksInfoList.Items.Add($"  Root directory:            {drive.RootDirectory}");
                }
            }
        }
Example #33
0
 public MonitorService getMonitorService()
 {
     if (monitorService == null)
     {
         monitorService = new MonitorServiceImpl();
     }
     return monitorService;
 }