protected override void ActivateInternal()
        {
            var schedulingService = Resolver.GetInstance <ISchedulingService>();
            var job = Resolver.CreateConcreteInstanceWithDependencies <TankpreiseJob>();

            schedulingService.AddJob(job, new PollingPlan(new TimeSpan(0, 6, 23)));
        }
Ejemplo n.º 2
0
        private void SetupMqttClient()
        {
            var solarEdgeSetting = Resolver.CreateConcreteInstanceWithDependencies <SolarEdgeSetting>();


            var lwtMessage = new MqttApplicationMessageBuilder()
                             .WithRetainFlag(true)
                             .WithTopic("tele/solaredge/LWT")
                             .WithPayload("offline")
                             .Build();
            var clientOptions = new MqttClientOptionsBuilder().WithClientId("SolarEdge")
                                .WithTcpServer(solarEdgeSetting.MqttAddress)
                                .WithWillMessage(lwtMessage);

            if (!string.IsNullOrWhiteSpace(solarEdgeSetting.MqttUsername))
            {
                clientOptions.WithCredentials(solarEdgeSetting.MqttUsername, solarEdgeSetting.MqttPassword);
            }

            var options = new ManagedMqttClientOptionsBuilder().WithAutoReconnectDelay(TimeSpan.FromSeconds(5))
                          .WithClientOptions(clientOptions.Build())
                          .Build();

            var mqttClient = new MqttFactory().CreateManagedMqttClient();

            mqttClient.StartAsync(options).Wait();

            ConfigurationResolver.AddRegistration(new SingletonRegistration <IManagedMqttClient>(mqttClient));
        }
Ejemplo n.º 3
0
        private void SetupDatabase()
        {
            var solarEdgeSetting = Resolver.CreateConcreteInstanceWithDependencies <SolarEdgeSetting>();
            var influxManagement = Resolver.CreateConcreteInstanceWithDependencies <IInfluxDbManagement>();

            influxManagement.EnsureDatabase(solarEdgeSetting.TargetDatabase);

            influxManagement.EnsureRetentionPolicy(solarEdgeSetting.TargetDatabase, new InfluxDbRetentionPolicyDefinition("week_one", TimeSpan.FromDays(7), false));
            //influxManagement.EnsureRetentionPolicy(solarEdgeSetting.TargetDatabase, new InfluxDbRetentionPolicyDefinition("infinite", TimeSpan.MinValue, true));
        }
Ejemplo n.º 4
0
        protected override void ActivateInternal()
        {
            var loader        = Resolver.CreateConcreteInstanceWithDependencies <ConfigurationLoader>();
            var envLloader    = Resolver.CreateConcreteInstanceWithDependencies <EnvConfigurationLoader>();
            var settingValues = loader.LoadConfiguration()
                                .Concat(envLloader.LoadConfiguration()).ToList();

            LogLoadedConfiguration(settingValues);

            var settingsInitializer = Resolver.CreateConcreteInstanceWithDependencies <ConfigurationObjectInitializer>();

            settingsInitializer.Initialice(settingValues);
        }
Ejemplo n.º 5
0
        protected override void ActivateInternal()
        {
            SetupDatabase();
            SetupMqttClient();

            ConfigurationResolver.AddRegistration(new SingletonRegistration <SolarEdgeApiClient, SolarEdgeApiClient>());
            ConfigurationResolver.AddRegistration(new SingletonRegistration <SiteListRepository, SiteListRepository>());

            var historyJob   = Resolver.CreateConcreteInstanceWithDependencies <SolarEdgeHistoryJob>();
            var powerFlowJob = Resolver.CreateConcreteInstanceWithDependencies <SolaredgePowerFlowJob>();

            var scheduler = Resolver.GetInstance <ISchedulingService>();

            scheduler.AddJob(historyJob, new PollingPlan(TimeSpan.FromHours(1)));
            scheduler.AddJob(powerFlowJob, new PollingPlan(TimeSpan.FromSeconds(5)));
        }
Ejemplo n.º 6
0
        protected override void ActivateInternal()
        {
            var versionService = new WallpaperClientVersionService();
            var registration   = new SingletonRegistration <WallpaperClientVersionService>(versionService);

            ConfigurationResolver.AddRegistration(registration);

            var uiApp = Resolver.GetInstance <IUiApplication>();

            uiApp.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            var resourceDictionaryManager = Resolver.GetInstance <IResourceDictionaryManager>();
            var dir = new ResourceDictionary {
                Source = new Uri("/Plugin.Application.Wallpaper.Client;component/WallpaperClientResourceDictionary.xaml", UriKind.RelativeOrAbsolute)
            };

            resourceDictionaryManager.AddToApplication(dir);

            var result = dir["WallpaperNotifyIcon"] as TaskbarIcon;

            if (result != null)
            {
                var viewModel = Resolver.CreateConcreteInstanceWithDependencies <TaskBarIconViewModel>();

                ConfigurationResolver.AddRegistration(new ServiceInstanceRegistration <IUserInteraction>(viewModel));

                result.DataContext = viewModel;
                result.Loaded     += (s, e) => viewModel.State.OnLogin();
            }

            //Workaround for bug in NotfiyIcon library
            var tt = new ToolTip();

            tt.IsOpen = true;
            tt.IsOpen = false;
        }