private void UpdateSystemInformationOfTarget(IDocumentSession session, CollectRequest collectRequest, FamilyEnumeration plataform, ExecutionLogBuilder executionLog)
 {
     if (!collectRequest.Target.IsSystemInformationDefined())
     {
         executionLog.CollectSystemInformation();
         ISystemInformationService systemInformationService = ProbeManager.GetSystemInformationService(plataform);
         if (systemInformationService != null)
         {
             try
             {
                 this.GetSystemInformationFromTarget(collectRequest, systemInformationService);
                 session.SaveChanges();
             }
             catch (RecoverableProbeException ex)
             {
                 CollectExecution collectExecution = this.CreateCollectExecution(session, collectRequest);
                 collectExecution.SetDateStartCollect();
                 this.ConfigureTheCollectRequestWithAnErrorProbeExecute(collectRequest, "SystemInformation", collectExecution, ex, executionLog);
                 session.SaveChanges();
                 throw new SystemInformationException(ex.Message, ex);
             }
             catch (Exception ex)
             {
                 CreateCollectionExcutionWithError(session, collectRequest, "SystemInformation", ex, executionLog);
                 session.SaveChanges();
                 throw new SystemInformationException(ex.Message, ex);
             }
         }
     }
 }
Example #2
0
        public ComponentService(
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiService apiService,
            ISettingsService settingsService)
        {
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }

            _systemInformationService = systemInformationService;
            _apiService      = apiService;
            _settingsService = settingsService;

            apiService.StatusRequested += HandleApiStatusRequest;
        }
        private void GetSystemInformationFromTarget(CollectRequest collectRequest, ISystemInformationService systemInformationService)
        {
            SystemInformation systemInformation = systemInformationService.GetSystemInformationFrom(Target);
            SystemInfo        systemInfo        = new SystemInfoFactory().CreateSystemInfo(systemInformation);

            collectRequest.Target.SystemInformation = systemInfo;
        }
Example #4
0
        public AutomationService(
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiService apiService)
        {
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Automations/Count", _automations.GetAll().Count);
            };

            apiService.StatusRequested += HandleApiStatusRequest;
        }
        public MainFormPresenter(IMainFormView mainFormView,
                                 IDataListView employeesDataListView,
                                 IDataListView tasksDataListView,
                                 IDataListView assignedTasksDataListView,
                                 ISystemInformationService systemInformationService,
                                 IMenuCommand[] commands)
        {
            this.mainFormView = mainFormView;
            this.commands     = commands;

            menuView = mainFormView.MenuView;
            menuView.SetCommands(commands);

            employeesDataListView = mainFormView.EmployeesDataListView;
            employeesDataListView.SetTitle(MenuOption.Employees.GetAttribute <MenuOptionAttribute>().Name);
            employeesDataListView.SetTag(MenuOption.Employees);
            employeesDataListView.OnDataGridViewCellClick += OnDataGridViewCellClick;

            tasksDataListView = mainFormView.TasksDataListView;
            tasksDataListView.SetTitle(MenuOption.Tasks.GetAttribute <MenuOptionAttribute>().Name);
            tasksDataListView.SetTag(MenuOption.Tasks);
            tasksDataListView.OnDataGridViewCellClick += OnDataGridViewCellClick;

            assignedTasksDataListView = mainFormView.AssignedTasksDataListView;
            assignedTasksDataListView.SetTitle(MenuOption.AssignedTasks.GetAttribute <MenuOptionAttribute>().Name);
            assignedTasksDataListView.SetTag(MenuOption.AssignedTasks);
            assignedTasksDataListView.OnDataGridViewCellClick += OnDataGridViewCellClick;

            mainFormView.KeyUp += MainFormViewOnKeyUp;

            if (!systemInformationService.IsHighContrastColourScheme)
            {
                mainFormView.BackColor = Color.White;
            }
        }
Example #6
0
        public MainFormPresenter(IMainFormView mainFormView,
                                 IPodcastLoader podcastLoader,
                                 ISubscriptionManager subscriptionManager,
                                 IPodcastPlayer podcastPlayer,
                                 IMessageBoxDisplayService messageBoxDisplayService,
                                 ISettingsService settingsService,
                                 ISystemInformationService systemInformationService,
                                 IToolbarCommand[] commands)
        {
            mainFormView.Load          += MainFormViewOnLoad;
            mainFormView.FormClosed    += MainFormViewOnFormClosed;
            mainFormView.HelpRequested += OnHelpRequested;
            mainFormView.KeyUp         += MainFormViewOnKeyUp;

            this.subscriptionManager      = subscriptionManager;
            this.podcastLoader            = podcastLoader;
            this.podcastPlayer            = podcastPlayer;
            this.messageBoxDisplayService = messageBoxDisplayService;
            this.settingsService          = settingsService;
            this.commands = commands;

            if (!systemInformationService.IsHighContrastColourScheme)
            {
                mainFormView.BackColor = Color.White;
            }

            EventAggregator.Instance.Subscribe <EpisodeSelectedMessage>(m => mainFormView.ShowEpisodeView());
            EventAggregator.Instance.Subscribe <PodcastSelectedMessage>(m => mainFormView.ShowPodcastView());
        }
Example #7
0
        public RemoteSocketService(
            IConfigurationService configurationService,
            IDeviceRegistryService deviceRegistryService,
            ISchedulerService schedulerService,
            ISystemInformationService systemInformationService,
            ILogService logService)
        {
            _configurationService  = configurationService ?? throw new ArgumentNullException(nameof(configurationService));
            _deviceRegistryService = deviceRegistryService ?? throw new ArgumentNullException(nameof(deviceRegistryService));
            if (schedulerService == null)
            {
                throw new ArgumentNullException(nameof(schedulerService));
            }
            _systemInformationService = systemInformationService ?? throw new ArgumentNullException(nameof(systemInformationService));
            if (logService == null)
            {
                throw new ArgumentNullException(nameof(logService));
            }

            // Ensure that the state of the remote switch is restored if the original remote is used
            // or the switch has been removed from the socket and plugged in at another place.
            schedulerService.Register("RCSocketStateSender", TimeSpan.FromMinutes(1), () => RefreshStates());

            _log = logService.CreatePublisher(nameof(RemoteSocketService));
        }
Example #8
0
        private FileProber GetMockedFileProber(file_item fakeItem)
        {
            IList <String> fakeValues        = new List <String>(new string[] { "FakeValue" });
            CollectedItem  fakeCollectedItem = ProbeHelper.CreateFakeCollectedItem(fakeItem);

            MockRepository            mocks                 = new MockRepository();
            IConnectionManager        fakeConnection        = mocks.DynamicMock <IConnectionManager>();
            ISystemInformationService fakeSystemInformation = mocks.DynamicMock <ISystemInformationService>();
            FileConnectionProvider    fakeProvider          = mocks.DynamicMock <FileConnectionProvider>();
            WmiDataProvider           fakeWmiProvider       = mocks.DynamicMock <WmiDataProvider>();
            FileObjectCollector       fakeDataCollector     = mocks.DynamicMock <FileObjectCollector>();

            fakeDataCollector.WmiDataProvider = fakeWmiProvider;

            //Expect.Call(fakeConnection.Connect<FileConnectionProvider>(null, null)).IgnoreArguments().Repeat.Any().Return(fakeProvider);
            Expect.Call(fakeDataCollector.CollectDataForSystemItem(fakeItem)).IgnoreArguments().Repeat.Any().Return(new List <CollectedItem>()
            {
                fakeCollectedItem
            });
            Expect.Call(fakeDataCollector.GetValues(null)).IgnoreArguments().Repeat.Any().Return(fakeValues);
            Expect.Call(fakeSystemInformation.GetSystemInformationFrom(null)).IgnoreArguments().Return(SystemInformationFactory.GetExpectedSystemInformation());
            mocks.ReplayAll();

            return(new FileProber()
            {
                ConnectionManager = fakeConnection, ObjectCollector = fakeDataCollector
            });
        }
Example #9
0
 public static Deposit ToDeposit(this DepositModel deposit, ISystemInformationService SystemInformationService)
 {
     Mapper.Initialize(e =>
     {
         e.CreateMap <ClientModel, Client>();
         e.CreateMap <PlanOfDepositModel, PlanOfDeposit>();
         e.CreateMap <DepositModel, Deposit>()
         .ForMember(t => t.CurrentPercentAmount, t => t.MapFrom(r => r.PercentAccount.Balance))
         .ForMember(t => t.PercentAmountForDay,
                    t => t.MapFrom(r => (double)r.Amount * r.PlanOfDeposit.Percent / 100 / SystemInformationService.CountDaysInYear))
         .ForMember(t => t.StartDate,
                    t => t.MapFrom(r => r.StartDate))
         .ForMember(t => t.EndDate,
                    t => t.MapFrom(r => r.EndDate))
         .ForMember(t => t.IsCanCloseToday,
                    t =>
                    t.MapFrom(
                        r =>
                        (r.PlanOfDeposit.Revocable || r.EndDate < SystemInformationService.CurrentBankDay) &&
                        r.Amount > 0))
         .ForMember(t => t.IsCanWithdrawPercentsToday,
                    t =>
                    t.MapFrom(
                        r =>
                        !r.PlanOfDeposit.Revocable &&
                        (SystemInformationService.CurrentBankDay - r.StartDate).TotalDays % SystemInformationService.CountDaysInMonth == 0 &&
                        r.Amount > 0));
     });
     return(Mapper.Map <DepositModel, Deposit>(deposit));
 }
Example #10
0
 public static Credit ToCredit(this CreditModel credit, ISystemInformationService SystemInformationService)
 {
     Mapper.Initialize(e =>
     {
         e.CreateMap <ClientModel, Client>();
         e.CreateMap <PlanOfCreditModel, PlanOfCredit>();
         e.CreateMap <CreditModel, Credit>()
         .ForMember(t => t.Balance,
                    t => t.MapFrom(r => r.MainAccount.Balance))
         .ForMember(t => t.StartDate,
                    t => t.MapFrom(r => r.StartDate))
         .ForMember(t => t.EndDate,
                    t => t.MapFrom(r => r.EndDate))
         .ForMember(t => t.CurrentPercentAmount, t => t.MapFrom(r => Math.Abs(r.PercentAccount.Balance)))
         .ForMember(t => t.IsCanCloseToday,
                    t =>
                    t.MapFrom(
                        r =>
                        (r.EndDate <= SystemInformationService.CurrentBankDay) &&
                        r.Amount > 0))
         .ForMember(t => t.IsCanPayPercentToday,
                    t =>
                    t.MapFrom(
                        r =>
                        (SystemInformationService.CurrentBankDay - r.StartDate).TotalDays % SystemInformationService.CountDaysInMonth == 0 &&
                        r.Amount > 0));
     });
     return(Mapper.Map <CreditModel, Credit>(credit));
 }
Example #11
0
        public HealthService(
            ControllerOptions controllerOptions,
            IPi2GpioService pi2GpioService,
            ITimerService timerService,
            ISystemInformationService systemInformationService)
        {
            if (controllerOptions == null)
            {
                throw new ArgumentNullException(nameof(controllerOptions));
            }
            if (timerService == null)
            {
                throw new ArgumentNullException(nameof(timerService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }

            _systemInformationService = systemInformationService;

            if (controllerOptions.StatusLedNumber.HasValue)
            {
                _led = pi2GpioService.GetOutput(controllerOptions.StatusLedNumber.Value);
                _ledTimeout.Start(TimeSpan.FromMilliseconds(1));
            }

            timerService.Tick += Tick;
        }
Example #12
0
        public AreaRegistryService(
            IComponentRegistryService componentService,
            IAutomationRegistryService automationService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService,
            IScriptingService scriptingService)
        {
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (scriptingService == null)
            {
                throw new ArgumentNullException(nameof(scriptingService));
            }

            _componentService  = componentService ?? throw new ArgumentNullException(nameof(componentService));
            _automationService = automationService ?? throw new ArgumentNullException(nameof(automationService));
            _settingsService   = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            apiService.ConfigurationRequested += HandleApiConfigurationRequest;

            systemInformationService.Set("Areas/Count", () => _areas.Count);

            scriptingService.RegisterScriptProxy(s => new AreaRegistryScriptProxy(this));
        }
Example #13
0
        public OpenWeatherMapService(
            IOutdoorTemperatureService outdoorTemperatureService,
            IOutdoorHumidityService outdoorHumidityService,
            IDaylightService daylightService,
            IWeatherService weatherService,
            IDateTimeService dateTimeService,
            ISchedulerService schedulerService,
            ISystemInformationService systemInformationService,
            ISettingsService settingsService,
            IStorageService storageService,
            ILogService logService)
        {
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            _schedulerService          = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService));
            _outdoorTemperatureService = outdoorTemperatureService ?? throw new ArgumentNullException(nameof(outdoorTemperatureService));
            _outdoorHumidityService    = outdoorHumidityService ?? throw new ArgumentNullException(nameof(outdoorHumidityService));
            _daylightService           = daylightService ?? throw new ArgumentNullException(nameof(daylightService));
            _weatherService            = weatherService ?? throw new ArgumentNullException(nameof(weatherService));
            _dateTimeService           = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));
            _systemInformationService  = systemInformationService ?? throw new ArgumentNullException(nameof(systemInformationService));
            _storageService            = storageService ?? throw new ArgumentNullException(nameof(storageService));

            _log = logService?.CreatePublisher(nameof(OpenWeatherMapService)) ?? throw new ArgumentNullException(nameof(logService));

            settingsService.CreateSettingsMonitor <OpenWeatherMapServiceSettings>(s => Settings = s.NewSettings);
        }
        public SRDebugService()
        {
            SRServiceManager.RegisterService <IDebugService>(this);

            // Load profiler
            SRServiceManager.GetService <IProfilerService>();

            // Setup trigger service
            _debugTrigger = SRServiceManager.GetService <IDebugTriggerService>();

            _informationService = SRServiceManager.GetService <ISystemInformationService>();

            _pinnedUiService = SRServiceManager.GetService <IPinnedUIService>();
            _pinnedUiService.OptionsCanvasCreated += transform =>
            {
                if (PinnedUiCanvasCreated == null)
                {
                    return;
                }
                try
                {
                    PinnedUiCanvasCreated(transform);
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
                }
            };

            _optionsService = SRServiceManager.GetService <IOptionsService>();

            // Create debug panel service (this does not actually load any UI resources until opened)
            _debugPanelService = SRServiceManager.GetService <IDebugPanelService>();

            // Subscribe to visibility changes to provide API-facing event for panel open/close
            _debugPanelService.VisibilityChanged += DebugPanelServiceOnVisibilityChanged;

            _debugTrigger.IsEnabled = Settings.EnableTrigger == Settings.TriggerEnableModes.Enabled ||
                                      Settings.EnableTrigger == Settings.TriggerEnableModes.MobileOnly && Application.isMobilePlatform ||
                                      Settings.EnableTrigger == Settings.TriggerEnableModes.DevelopmentBuildsOnly && Debug.isDebugBuild;

            _debugTrigger.Position = Settings.TriggerPosition;

            if (Settings.EnableKeyboardShortcuts)
            {
                SRServiceManager.GetService <KeyboardShortcutListenerService>();
            }

            _entryCodeEnabled = Settings.Instance.RequireCode && Settings.Instance.EntryCode.Count == 4;

            if (Settings.Instance.RequireCode && !_entryCodeEnabled)
            {
                Debug.LogError("[SRDebugger] RequireCode is enabled, but pin is not 4 digits");
            }

            // Ensure that root object cannot be destroyed on scene loads
            var srDebuggerParent = Hierarchy.Get("SRDebugger");

            Object.DontDestroyOnLoad(srDebuggerParent.gameObject);
        }
Example #15
0
        public AreaRegistryService(
            IComponentRegistryService componentService,
            IAutomationRegistryService automationService,
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService)
        {
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }

            _componentService  = componentService ?? throw new ArgumentNullException(nameof(componentService));
            _automationService = automationService ?? throw new ArgumentNullException(nameof(automationService));
            _settingsService   = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Areas/Count", _areas.Count);
            };

            apiService.ConfigurationRequested += HandleApiConfigurationRequest;
        }
        /// <summary>Initializes a new instance of the <see cref="ShellViewPresenter"/> class.</summary>
        /// <param name="shell">The shell.</param>
        /// <param name="msgBoxService">The msg Box Service.</param>
        /// <param name="fileBrowserService">The file Browser Service.</param>
        /// <param name="eventAggregator">The event Aggregator.</param>
        /// <param name="systemInformationService">The system Information Service.</param>
        public ShellViewPresenter(
            IShellView shell, 
            IMessageBoxService msgBoxService, 
            IFileBrowserService fileBrowserService, 
            IEventAggregator eventAggregator, 
            ISystemInformationService systemInformationService)
        {
            // Wire up our services
            this.msgBoxService = msgBoxService;
            this.fileBrowserService = fileBrowserService;
            this.eventAggregator = eventAggregator;
            this.systemInformationService = systemInformationService;

            // Wire up our view
            this.view = shell;

            // Wire up view our events
            shell.FormClosed += this.ViewOnFormClosed;
            shell.Load += this.ViewOnLoad;
            shell.KeyUp += this.ViewOnKeyUp;
            shell.HelpRequested += this.ViewOnHelpRequested;

            // WindowHandle high contrast
            if (!this.systemInformationService.IsHighContrastColourScheme)
            {
                shell.BackColor = Color.White;
            }
        }
Example #17
0
        public ComponentRegistryService(
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService,
            ISettingsService settingsService,
            IScriptingService scriptingService,
            ILogService logService)
        {
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (scriptingService == null)
            {
                throw new ArgumentNullException(nameof(scriptingService));
            }

            _log             = logService.CreatePublisher(nameof(ComponentRegistryService));
            _apiService      = apiService ?? throw new ArgumentNullException(nameof(apiService));
            _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService));

            apiService.StatusRequested += HandleApiStatusRequest;

            systemInformationService.Set("Components/Count", () => _components.Count);

            scriptingService.RegisterScriptProxy(s => new ComponentRegistryScriptProxy(this, s));
        }
Example #18
0
        public AreaService(
            IComponentService componentService,
            IAutomationService automationService,
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiService apiService,
            ISettingsService settingsService)
        {
            if (componentService == null) throw new ArgumentNullException(nameof(componentService));
            if (automationService == null) throw new ArgumentNullException(nameof(automationService));
            if (systemEventsService == null) throw new ArgumentNullException(nameof(systemEventsService));
            if (systemInformationService == null) throw new ArgumentNullException(nameof(systemInformationService));
            if (apiService == null) throw new ArgumentNullException(nameof(apiService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));

            _componentService = componentService;
            _automationService = automationService;
            _apiService = apiService;
            _settingsService = settingsService;

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Areas/Count", _areas.GetAll().Count);
            };

            apiService.ConfigurationRequested += HandleApiConfigurationRequest;
        }
        public OpenWeatherMapService(
            IOutdoorTemperatureService outdoorTemperatureService,
            IOutdoorHumidityService outdoorHumidityService,
            IDaylightService daylightService,
            IWeatherService weatherService,
            IDateTimeService dateTimeService, 
            ISchedulerService schedulerService, 
            ISystemInformationService systemInformationService,
            ISettingsService settingsService, 
            IStorageService storageService)
        {
            if (outdoorTemperatureService == null) throw new ArgumentNullException(nameof(outdoorTemperatureService));
            if (outdoorHumidityService == null) throw new ArgumentNullException(nameof(outdoorHumidityService));
            if (daylightService == null) throw new ArgumentNullException(nameof(daylightService));
            if (weatherService == null) throw new ArgumentNullException(nameof(weatherService));
            if (dateTimeService == null) throw new ArgumentNullException(nameof(dateTimeService));
            if (systemInformationService == null) throw new ArgumentNullException(nameof(systemInformationService));
            if (settingsService == null) throw new ArgumentNullException(nameof(settingsService));
            if (storageService == null) throw new ArgumentNullException(nameof(storageService));

            _outdoorTemperatureService = outdoorTemperatureService;
            _outdoorHumidityService = outdoorHumidityService;
            _daylightService = daylightService;
            _weatherService = weatherService;
            _dateTimeService = dateTimeService;
            _systemInformationService = systemInformationService;
            _storageService = storageService;

            settingsService.CreateSettingsMonitor<OpenWeatherMapServiceSettings>(s => Settings = s);

            LoadPersistedData();

            schedulerService.RegisterSchedule("OpenWeatherMapServiceUpdater", TimeSpan.FromMinutes(5), Refresh);
        }
        public AutomationRegistryService(
            ISettingsService settingsService,
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService,
            IApiDispatcherService apiService)
        {
            _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService));
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }
            if (apiService == null)
            {
                throw new ArgumentNullException(nameof(apiService));
            }

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Automations/Count", _automations.Count);
            };

            apiService.StatusRequested += HandleApiStatusRequest;
        }
Example #21
0
        public OpenWeatherMapService(
            IOutdoorService outdoorService,
            IDaylightService daylightService,
            IDateTimeService dateTimeService,
            ISchedulerService schedulerService,
            ISystemInformationService systemInformationService,
            ISettingsService settingsService,
            IStorageService storageService,
            ILogService logService)
        {
            if (schedulerService == null)
            {
                throw new ArgumentNullException(nameof(schedulerService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            _outdoorService           = outdoorService ?? throw new ArgumentNullException(nameof(outdoorService));
            _daylightService          = daylightService ?? throw new ArgumentNullException(nameof(daylightService));
            _dateTimeService          = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService));
            _systemInformationService = systemInformationService ?? throw new ArgumentNullException(nameof(systemInformationService));

            _log = logService?.CreatePublisher(nameof(OpenWeatherMapService)) ?? throw new ArgumentNullException(nameof(logService));

            settingsService.CreateSettingsMonitor <OpenWeatherMapServiceSettings>(s => Settings = s.NewSettings);

            schedulerService.Register("OpenWeatherMapServiceUpdater", TimeSpan.FromMinutes(5), RefreshAsync);
        }
        /// <summary>Initializes a new instance of the <see cref="ShellViewPresenter"/> class.</summary>
        /// <param name="shell">The shell.</param>
        /// <param name="eventAggregator">The event aggregator.</param>
        /// <param name="msgBoxService">The msg Box Service.</param>
        /// <param name="systemInformationService">The system Information Service.</param>
        public ShellViewPresenter(
            IShellView shell,
            IEventAggregator eventAggregator,
            IMessageBoxService msgBoxService,
            ISystemInformationService systemInformationService)
        {
            this.eventAggregator = eventAggregator;
            this.msgBoxService   = msgBoxService;

            this.systemInformationService = systemInformationService;

            // Wire up our view
            this.view = shell;

            // Wire up view our events
            shell.FormClosed    += this.ViewOnFormClosed;
            shell.Load          += this.ViewOnLoad;
            shell.KeyUp         += this.ViewOnKeyUp;
            shell.HelpRequested += this.ViewOnHelpRequested;

            // WindowHandle high contrast
            if (!this.systemInformationService.IsHighContrastColourScheme)
            {
                shell.BackColor = Color.White;
            }
        }
Example #23
0
        public TelegramBotService(
            ISettingsService settingsService,
            IPersonalAgentService personalAgentService,
            ISystemInformationService systemInformationService,
            ILogService logService,
            IScriptingService scriptingService)
        {
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (scriptingService == null)
            {
                throw new ArgumentNullException(nameof(scriptingService));
            }

            _personalAgentService = personalAgentService ?? throw new ArgumentNullException(nameof(personalAgentService));

            _log = logService.CreatePublisher(nameof(TelegramBotService));

            settingsService.CreateSettingsMonitor <TelegramBotServiceSettings>(s => Settings = s.NewSettings);
            systemInformationService.Set("TelegramBotService/IsConnected", () => _isConnected);

            scriptingService.RegisterScriptProxy(s => new TelegramBotScriptProxy(this));
        }
        public CollectExecutionManager CreateExecutionManagerForTheSuccessScenario(ProbeResult resultForRegistry, ProbeResult resultForFamily)
        {
            MockRepository mocks = new MockRepository();

            probeManager             = mocks.DynamicMock <IProbeManager>();
            probe                    = mocks.DynamicMock <IProbe>();
            familyProbe              = mocks.DynamicMock <IProbe>();
            dataProvider             = mocks.DynamicMock <IDataProvider>();
            systemInformationService = mocks.DynamicMock <ISystemInformationService>();
            connectionContext        = this.CreateConnectionContext();

            CollectInfo collectInfo = new CollectInfo()
            {
                ObjectTypes = ovalObjects
            };

            Expect.Call(probeManager.GetProbesFor(null, FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(this.GetSelectedProbes());
            Expect.Call(probeManager.GetSystemInformationService(FamilyEnumeration.windows)).IgnoreArguments().Repeat.Any().Return(systemInformationService);
            Expect.Call(probe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForRegistry);
            Expect.Call(familyProbe.Execute(connectionContext, target, collectInfo)).IgnoreArguments().Repeat.Any().Return(resultForFamily);
            Expect.Call(dataProvider.GetSession()).Repeat.Any().Return(session).IgnoreArguments();
            Expect.Call(dataProvider.GetTransaction(session)).Repeat.Any().Return(new Transaction(session)).IgnoreArguments();
            Expect.Call(systemInformationService.GetSystemInformationFrom(target)).IgnoreArguments().Return(this.GetExpectedSystemInformation());

            mocks.ReplayAll();

            return(new CollectExecutionManager(probeManager)
            {
                Target = target, connectionContext = connectionContext
            });
        }
Example #25
0
        public OpenWeatherMapService(
            IOutdoorTemperatureService outdoorTemperatureService,
            IOutdoorHumidityService outdoorHumidityService,
            IDaylightService daylightService,
            IWeatherService weatherService,
            IDateTimeService dateTimeService,
            ISchedulerService schedulerService,
            ISystemInformationService systemInformationService,
            ISettingsService settingsService,
            IStorageService storageService)
        {
            if (outdoorTemperatureService == null)
            {
                throw new ArgumentNullException(nameof(outdoorTemperatureService));
            }
            if (outdoorHumidityService == null)
            {
                throw new ArgumentNullException(nameof(outdoorHumidityService));
            }
            if (daylightService == null)
            {
                throw new ArgumentNullException(nameof(daylightService));
            }
            if (weatherService == null)
            {
                throw new ArgumentNullException(nameof(weatherService));
            }
            if (dateTimeService == null)
            {
                throw new ArgumentNullException(nameof(dateTimeService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }
            if (settingsService == null)
            {
                throw new ArgumentNullException(nameof(settingsService));
            }
            if (storageService == null)
            {
                throw new ArgumentNullException(nameof(storageService));
            }

            _outdoorTemperatureService = outdoorTemperatureService;
            _outdoorHumidityService    = outdoorHumidityService;
            _daylightService           = daylightService;
            _weatherService            = weatherService;
            _dateTimeService           = dateTimeService;
            _systemInformationService  = systemInformationService;
            _storageService            = storageService;

            settingsService.CreateSettingsMonitor <OpenWeatherMapServiceSettings>(s => Settings = s);

            LoadPersistedData();

            schedulerService.RegisterSchedule("OpenWeatherMapServiceUpdater", TimeSpan.FromMinutes(5), Refresh);
        }
        /// <summary>
        /// Creates a new <see cref="ReviewPromptSubPageViewModel"/> instance
        /// </summary>
        /// <param name="emailService">The <see cref="IEmailService"/> instance to use</param>
        /// <param name="storeService">The <see cref="IStoreService"/> instance to use</param>
        /// <param name="systemInformationService">The <see cref="ISystemInformationService"/> instance to use</param>
        public ReviewPromptSubPageViewModel(IEmailService emailService, IStoreService storeService, ISystemInformationService systemInformationService)
        {
            EmailService             = emailService;
            StoreService             = storeService;
            SystemInformationService = systemInformationService;

            ReviewCommand        = new AsyncRelayCommand(StoreService.RequestReviewAsync);
            FeedbackEmailCommand = new AsyncRelayCommand(SendFeedbackEmailAsync);
        }
Example #27
0
 public LicenseController(IApplicationUsersService applicationUsersService, ITraceManager traceManager, IAPIHttpClient apiHttpClient, ISystemInformationService systemInformationService,
                          ILocalizationManager localizationManager)
     : base(localizationManager)
 {
     _applicationUsersService  = applicationUsersService;
     _apiHttpClient            = apiHttpClient;
     _systemInformationService = systemInformationService;
     _traceManager             = traceManager;
 }
Example #28
0
        private FileEffectiveRightsProber createMockedFileEffectiveRightsProber(IEnumerable <CollectedItem> fakeCollectedItems)
        {
            MockRepository                     mocks = new MockRepository();
            IConnectionManager                 fakeConnectionManager = mocks.DynamicMock <IConnectionManager>();
            ISystemInformationService          fakeSysInfoService    = mocks.DynamicMock <ISystemInformationService>();
            FileConnectionProvider             fakeProvider          = mocks.DynamicMock <FileConnectionProvider>();
            FileEffectiveRightsObjectCollector fakeSystemDataSource  = mocks.DynamicMock <FileEffectiveRightsObjectCollector>();

            Expect.Call(fakeSystemDataSource.CollectDataForSystemItem(null)).IgnoreArguments().Return(fakeCollectedItems);
            mocks.ReplayAll();

            return(new FileEffectiveRightsProber()
            {
                ConnectionManager = fakeConnectionManager, ObjectCollector = fakeSystemDataSource
            });
        }
Example #29
0
        public MainFormPresenter(IMainFormView mainFormView,
                                 IPodcastLoader podcastLoader,
                                 ISubscriptionManager subscriptionManager,
                                 IPodcastPlayer podcastPlayer,
                                 IMessageBoxDisplayService messageBoxDisplayService,
                                 ISettingsService settingsService,
                                 ISystemInformationService systemInformationService,
                                 IToolbarCommand[] commands)
        {
            this.podcastPlayer            = podcastPlayer;
            this.subscriptionManager      = subscriptionManager;
            this.podcastLoader            = podcastLoader;
            this.messageBoxDisplayService = messageBoxDisplayService;
            this.settingsService          = settingsService;
            this.commands = commands;


            subscriptionView = mainFormView.SubscriptionView;
            episodeView      = mainFormView.EpisodeView;
            podcastView      = mainFormView.PodcastView;

            this.mainFormView           = mainFormView;
            mainFormView.Load          += MainFormViewOnLoad;
            mainFormView.FormClosed    += MainFormViewOnFormClosed;
            mainFormView.HelpRequested += OnHelpRequested;
            mainFormView.KeyUp         += MainFormViewOnKeyUp;
            mainFormView.ToolbarView.SetCommands(commands);

            timer          = new Timer();
            timer.Interval = 100;
            timer.Tick    += TimerOnTick;
            timer.Start();

            episodeView.Title                  = "";
            episodeView.Description            = "";
            episodeView.PubDate                = "";
            subscriptionView.SelectionChanged += OnSelectedEpisodeChanged;
            if (!systemInformationService.IsHighContrastColourScheme)
            {
                mainFormView.BackColor = System.Drawing.Color.White;
            }
            subscriptionManager.LoadPodcasts();

            episodeView.PositionChanged += (s, a) => podcastPlayer.PositionInSeconds = episodeView.PositionInSeconds;
            episodeView.NoteCreated     += EpisodeViewOnNoteCreated;
        }
        public MainFormPresenter(IMainFormView mainFormView,
                                 ISubscriptionManager subscriptionManager,
                                 IPodcastLoader podcastLoader,
                                 IPodcastPlayer podcastPlayer,
                                 IMessageBoxDisplayService messageBoxDisplayService,
                                 ISettingsService settingsService,
                                 ISystemInformationService systemInformationService,
                                 INewSubscriptionService newSubscriptionService)
        {
            _subscriptionView = mainFormView.SubscriptionView;
            _episodeView      = mainFormView.EpisodeView;
            _podcastView      = mainFormView.PodcastView;

            _timer          = new Timer();
            _timer.Interval = 100;
            _timer.Tick    += TimerOnTick;
            _timer.Start();

            _mainFormView            = mainFormView;
            mainFormView.Load       += OnMainFormLoad;
            mainFormView.FormClosed += OnMainFormClosed;
            mainFormView.KeyUp      += MainFormViewOnKeyUp;

            _subscriptionView.AddPodcastClicked    += OnButtonAddClick;
            _subscriptionView.RemovePodcastClicked += OnButtonRemoveClick;
            _subscriptionView.SelectionChanged     += OnSelectedEpisodeChanged;

            _episodeView.PlayClicked += OnButtonPlayClick;
            _episodeView.StopClicked += OnButtonStopClick;

            _subscriptionManager = subscriptionManager;
            _podcastLoader       = podcastLoader;
            _podcastPlayer       = podcastPlayer;
            _podcasts            = _subscriptionManager.LoadPodcasts();

            _settingsService          = settingsService;
            _newSubscriptionService   = newSubscriptionService;
            _messageBoxDisplayService = messageBoxDisplayService;

            if (systemInformationService.IsHighContrastColorScheme)
            {
                mainFormView.BackColor = Color.White;
            }

            _episodeView.PositionChanged += (s, a) => _podcastPlayer.PositionInSeconds = _episodeView.PositionInSeconds;
        }
Example #31
0
        public DialogFormPresenter(
            IDialogFormView dialogFormView,
            IService <Task> taskService,
            IService <Employee> employeeService,
            IService <AssignedTask> assignedTaskService,
            ISystemInformationService systemInformationService,
            IValidateAssignment validateAssignment,
            IMenuCommand[] commands)
        {
            this.dialogFormView = dialogFormView;

            this.taskDialogView = dialogFormView.TaskDialogView;
            this.taskDialogView.SetTitle(MenuOption.Tasks.GetAttribute <MenuOptionAttribute>().Name);

            this.employeeDialogView = dialogFormView.EmployeeDialogView;
            this.employeeDialogView.SetTitle(MenuOption.Employees.GetAttribute <MenuOptionAttribute>().Name);

            this.assignedTaskDialogView = dialogFormView.AssignedTaskDialogView;
            this.assignedTaskDialogView.SetTitle(MenuOption.AssignedTasks.GetAttribute <MenuOptionAttribute>().Name);

            this.taskDialogView.OnCancelButtonClick += OnCancelButtonClick;
            this.taskDialogView.OnSaveButtonClick   += TaskDialogView_OnSaveButtonClick;

            this.employeeDialogView.OnCancelButtonClick += OnCancelButtonClick;;
            this.employeeDialogView.OnSaveButtonClick   += EmployeeDialogView_OnSaveButtonClick;;

            this.assignedTaskDialogView.OnCancelButtonClick += OnCancelButtonClick;;
            this.assignedTaskDialogView.OnSaveButtonClick   += AssignedTaskDialogView_OnSaveButtonClick;;

            this.taskService         = taskService;
            this.employeeService     = employeeService;
            this.assignedTaskService = assignedTaskService;

            this.assignedTaskDialogView.LoadEmployees(employeeService.Get(e => !e.IsDeleted));
            this.assignedTaskDialogView.LoadTasks(taskService.Get(t => !t.IsDeleted));

            this.validateAssignment = validateAssignment;

            this.commands = commands;

            if (!systemInformationService.IsHighContrastColourScheme)
            {
                dialogFormView.BackColor = Color.White;
            }
        }
Example #32
0
        public DeviceRegistryService(
            ISystemEventsService systemEventsService,
            ISystemInformationService systemInformationService)
        {
            if (systemEventsService == null)
            {
                throw new ArgumentNullException(nameof(systemEventsService));
            }
            if (systemInformationService == null)
            {
                throw new ArgumentNullException(nameof(systemInformationService));
            }

            systemEventsService.StartupCompleted += (s, e) =>
            {
                systemInformationService.Set("Devices/Count", _devices.Count);
            };
        }
        public MainFormPresenter(IMainFormView mainFormView,
                                 IPodcastLoader podcastLoader,
                                 ISubscriptionManager subscriptionManager,
                                 IPodcastPlayer podcastPlayer,
                                 IMessageBoxDisplayService messageBoxDisplayService,
                                 ISettingsService settingsService,
                                 ISystemInformationService systemInformationService,
                                 INewSubscriptionService newSubscriptionService)
        {
            subscriptionView = mainFormView.SubscriptionView;
            episodeView      = mainFormView.EpisodeView;
            podcastView      = mainFormView.PodcastView;
            toolbarView      = mainFormView.ToolbarView;

            this.mainFormView           = mainFormView;
            mainFormView.Load          += MainFormViewOnLoad;
            mainFormView.FormClosed    += MainFormViewOnFormClosed;
            mainFormView.HelpRequested += OnHelpRequested;
            mainFormView.KeyUp         += MainFormViewOnKeyUp;

            toolbarView.PlayClicked          += OnButtonPlayClick;
            toolbarView.StopClicked          += OnButtonStopClick;
            toolbarView.PauseClicked         += OnButtonPauseClick;
            toolbarView.RemovePodcastClicked += OnButtonRemovePodcastClick;
            toolbarView.AddPodcastClicked    += OnButtonAddSubscriptionClick;
            toolbarView.FavouriteChanged     += OnButtonFavouriteCheckStateChanged;

            episodeView.Description            = "";
            episodeView.Title                  = "";
            episodeView.PublicationDate        = "";
            subscriptionView.SelectionChanged += OnSelectedEpisodeChanged;
            this.subscriptionManager           = subscriptionManager;
            this.podcastLoader                 = podcastLoader;
            this.podcastPlayer                 = podcastPlayer;
            this.messageBoxDisplayService      = messageBoxDisplayService;
            this.settingsService               = settingsService;
            this.newSubscriptionService        = newSubscriptionService;
            podcasts = subscriptionManager.LoadPodcasts();

            if (!systemInformationService.IsHighContrastColourScheme)
            {
                mainFormView.BackColor = Color.White;
            }
        }
        public HealthService(
            ControllerOptions controllerOptions, 
            IPi2GpioService pi2GpioService,
            ITimerService timerService, 
            ISystemInformationService systemInformationService)
        {
            if (controllerOptions == null) throw new ArgumentNullException(nameof(controllerOptions));
            if (timerService == null) throw new ArgumentNullException(nameof(timerService));
            if (systemInformationService == null) throw new ArgumentNullException(nameof(systemInformationService));

            _systemInformationService = systemInformationService;

            if (controllerOptions.StatusLedNumber.HasValue)
            {
                _led = pi2GpioService.GetOutput(controllerOptions.StatusLedNumber.Value);
                _ledTimeout.Start(TimeSpan.FromMilliseconds(1));
            }

            timerService.Tick += Tick;
        }
 private void GetSystemInformationFromTarget(CollectRequest collectRequest, ISystemInformationService systemInformationService)
 {
     SystemInformation systemInformation = systemInformationService.GetSystemInformationFrom(Target);
     SystemInfo systemInfo = new SystemInfoFactory().CreateSystemInfo(systemInformation);
     collectRequest.Target.SystemInformation = systemInfo;
 }