public HomeGenieService() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); EnableOutputRedirect(); InitializeSystem(); Reload(); backupManager = new BackupManager(this); packageManager = new PackageManager(this); updateChecker = new UpdateChecker(this); updateChecker.ArchiveDownloadUpdate += (object sender, ArchiveDownloadEventArgs args) => { RaiseEvent( Domains.HomeGenie_System, Domains.HomeGenie_UpdateChecker, SourceModule.Master, "HomeGenie Update Checker", Properties.InstallProgressMessage, "= " + args.Status + ": " + args.ReleaseInfo.DownloadUrl ); }; updateChecker.UpdateProgress += (object sender, UpdateProgressEventArgs args) => { RaiseEvent( Domains.HomeGenie_System, Domains.HomeGenie_UpdateChecker, SourceModule.Master, "HomeGenie Update Checker", Properties.InstallProgressUpdate, args.Status.ToString() ); }; updateChecker.InstallProgressMessage += (object sender, string message) => { RaiseEvent( Domains.HomeGenie_System, Domains.HomeGenie_UpdateChecker, SourceModule.Master, "HomeGenie Update Checker", Properties.InstallProgressMessage, message ); }; statisticsLogger = new StatisticsLogger(this); statisticsLogger.Start(); // Setup local UPnP device SetupUpnp(); // it will check every 24 hours updateChecker.Start(); Thread.Sleep(5000); // this is a fix for upgrading from r522 to any new release as the SchedulerItem object has changed in r523 // de-serializing new object will only work after HomeGenie.exe update and restart if (File.Exists("scheduler_update.xml")) { updateChecker.UpdateScheduler("scheduler_update.xml"); File.Delete("scheduler_update.xml"); } Start(); }
public HomeGenieService() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); InitializeSystem(); Reload(); updateChecker = new UpdateChecker(this); updateChecker.ArchiveDownloadUpdate += (object sender, ArchiveDownloadEventArgs args) => { RaiseEvent( Domains.HomeGenie_UpdateChecker, HOMEGENIE_MASTERNODE, "HomeGenie Update Checker", Properties.INSTALLPROGRESS_MESSAGE, "= " + args.Status + ": " + args.ReleaseInfo.DownloadUrl ); }; updateChecker.UpdateProgress += (object sender, UpdateProgressEventArgs args) => { RaiseEvent( Domains.HomeGenie_UpdateChecker, HOMEGENIE_MASTERNODE, "HomeGenie Update Checker", Properties.INSTALLPROGRESS_UPDATE, args.Status.ToString() ); }; updateChecker.InstallProgressMessage += (object sender, string message) => { RaiseEvent( Domains.HomeGenie_UpdateChecker, HOMEGENIE_MASTERNODE, "HomeGenie Update Checker", Properties.INSTALLPROGRESS_MESSAGE, message ); }; statisticsLogger = new StatisticsLogger(this); statisticsLogger.Start(); // Setup local UPnP device SetupUpnp(); // it will check every 24 hours updateChecker.Start(); Start(); }
public HomeGenieService() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); EnableOutputRedirect(); InitializeSystem(); Reload(); updateChecker = new UpdateChecker(this); updateChecker.ArchiveDownloadUpdate += (object sender, ArchiveDownloadEventArgs args) => { RaiseEvent( Domains.HomeGenie_System, Domains.HomeGenie_UpdateChecker, SourceModule.Master, "HomeGenie Update Checker", Properties.InstallProgressMessage, "= " + args.Status + ": " + args.ReleaseInfo.DownloadUrl ); }; updateChecker.UpdateProgress += (object sender, UpdateProgressEventArgs args) => { RaiseEvent( Domains.HomeGenie_System, Domains.HomeGenie_UpdateChecker, SourceModule.Master, "HomeGenie Update Checker", Properties.InstallProgressUpdate, args.Status.ToString() ); }; updateChecker.InstallProgressMessage += (object sender, string message) => { RaiseEvent( Domains.HomeGenie_System, Domains.HomeGenie_UpdateChecker, SourceModule.Master, "HomeGenie Update Checker", Properties.InstallProgressMessage, message ); }; statisticsLogger = new StatisticsLogger(this); statisticsLogger.Start(); // Setup local UPnP device SetupUpnp(); // it will check every 24 hours updateChecker.Start(); Thread.Sleep(2000); Start(); }
public HomeGenieService() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); // TODO: all the following initialization stuff should go async // // initialize logging SetupLogging(); #region MIG Service initialization and startup // // initialize MIGService, interfaces (hw controllers drivers), webservice migService = new MIG.MIGService(); migService.InterfaceModulesChanged += migService_InterfaceModulesChanged; migService.InterfacePropertyChanged += migService_InterfacePropertyChanged; migService.ServiceRequestPreProcess += migService_ServiceRequestPreProcess; migService.ServiceRequestPostProcess += migService_ServiceRequestPostProcess; // // load system configuration systemConfiguration = new SystemConfiguration(); systemConfiguration.HomeGenie.ServiceHost = "+"; systemConfiguration.HomeGenie.ServicePort = 8080; systemConfiguration.OnUpdate += systemConfiguration_OnUpdate; LoadSystemConfig(); // // setup web service handlers wshConfig = new Handlers.Config(this); wshAutomation = new Handlers.Automation(this); wshInterconnection = new Handlers.Interconnection(this); wshStatistics = new Handlers.Statistics(this); wshLogging = new Handlers.Logging(this); // // Try to start WebGateway, if default HTTP port is busy, then it will try from 8080 to 8090 bool serviceStarted = false; int bindAttempts = 0; string address = systemConfiguration.HomeGenie.ServiceHost; int port = systemConfiguration.HomeGenie.ServicePort; while (!serviceStarted && bindAttempts <= 10) { // TODO: this should be done like this _services.Gateways["WebService"].Configure(....) migService.ConfigureWebGateway( address, port, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "html"), "/hg/html", systemConfiguration.HomeGenie.UserPassword ); if (migService.StartGateways()) { serviceStarted = true; } else { if (port < 8080) port = 8080; else port++; bindAttempts++; } } #endregion MIG Service initialization and startup // // If we successfully bound to port, then initialize the database. if (serviceStarted) { LogBroadcastEvent( Domains.HomeAutomation_HomeGenie, HOMEGENIE_MASTERNODE, "HomeGenie service ready", Properties.SYSTEMINFO_HTTPADDRESS, systemConfiguration.HomeGenie.ServiceHost + ":" + port ); InitializeSystem(); // Update system configuration with the HTTP port the service succeed to bind on systemConfiguration.HomeGenie.ServicePort = port; } else { LogBroadcastEvent( Domains.HomeAutomation_HomeGenie, HOMEGENIE_MASTERNODE, "HTTP binding failed.", Properties.SYSTEMINFO_HTTPADDRESS, systemConfiguration.HomeGenie.ServiceHost + ":" + systemConfiguration.HomeGenie.ServicePort ); Program.Quit(false); } updateChecker = new UpdateChecker(this); updateChecker.ArchiveDownloadUpdate += (object sender, ArchiveDownloadEventArgs args) => { LogBroadcastEvent( Domains.HomeGenie_UpdateChecker, HOMEGENIE_MASTERNODE, "HomeGenie Update Checker", Properties.INSTALLPROGRESS_MESSAGE, "= " + args.Status + ": " + args.ReleaseInfo.DownloadUrl ); }; updateChecker.UpdateProgress += (object sender, UpdateProgressEventArgs args) => { LogBroadcastEvent( Domains.HomeGenie_UpdateChecker, HOMEGENIE_MASTERNODE, "HomeGenie Update Checker", Properties.INSTALLPROGRESS_UPDATE, args.Status.ToString() ); }; updateChecker.InstallProgressMessage += (object sender, string message) => { LogBroadcastEvent( Domains.HomeGenie_UpdateChecker, HOMEGENIE_MASTERNODE, "HomeGenie Update Checker", Properties.INSTALLPROGRESS_MESSAGE, message ); }; // statisticsLogger = new StatisticsLogger(this); statisticsLogger.Start(); // // Setup local UPnP device SetupUpnp(); // // it will check every 24 hours updateChecker.Start(); // Start(); }
public HomeGenieService() { Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); // // initialize recent log list recentEventsLog = new TsList<LogEntry>(); #region MIG Service initialization and startup // // initialize MIGService, interfaces (hw controllers drivers), webservice migService = new MIG.MIGService(); migService.InterfaceModulesChanged += migService_InterfaceModulesChanged; migService.InterfacePropertyChanged += migService_InterfacePropertyChanged; migService.ServiceRequestPreProcess += migService_ServiceRequestPreProcess; migService.ServiceRequestPostProcess += migService_ServiceRequestPostProcess; // // load system configuration systemConfiguration = new SystemConfiguration(); systemConfiguration.HomeGenie.ServicePort = 8080; systemConfiguration.OnUpdate += systemConfiguration_OnUpdate; LoadSystemConfig(); // // setup web service handlers wshConfig = new Handlers.Config(this); wshAutomation = new Handlers.Automation(this); wshInterconnection = new Handlers.Interconnection(this); wshStatistics = new Handlers.Statistics(this); wshLogging = new Handlers.Logging(this); // // Try to start WebGateway, at 0 < (port - ServicePort) < 10 bool serviceStarted = false; int port = systemConfiguration.HomeGenie.ServicePort; while (!serviceStarted && port <= systemConfiguration.HomeGenie.ServicePort + 10) { // TODO: this should be done like this _services.Gateways["WebService"].Configure(....) migService.ConfigureWebGateway( port, Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "html"), "/hg/html", systemConfiguration.HomeGenie.UserPassword ); if (migService.StartGateways()) { systemConfiguration.HomeGenie.ServicePort = port; serviceStarted = true; } else { port++; } } #endregion MIG Service initialization and startup // // If we successfully bound to port, then initialize the database. if (serviceStarted) { LogBroadcastEvent( Domains.HomeAutomation_HomeGenie, "SystemInfo", "HomeGenie service ready", "HTTP.PORT", port.ToString() ); systemConfiguration.HomeGenie.ServicePort = port; InitializeSystem(); } else { LogBroadcastEvent( Domains.HomeAutomation_HomeGenie, "SystemInfo", "Http port bind failed.", "HTTP.PORT", port.ToString() ); Program.Quit(false); } updateChecker = new UpdateChecker(this); updateChecker.ArchiveDownloadUpdate += (object sender, ArchiveDownloadEventArgs args) => { LogBroadcastEvent( Domains.HomeGenie_UpdateChecker, "0", "HomeGenie Update Checker", "InstallProgress.Message", "= " + args.Status + ": " + args.ReleaseInfo.DownloadUrl ); }; updateChecker.UpdateProgress += (object sender, UpdateProgressEventArgs args) => { LogBroadcastEvent( Domains.HomeGenie_UpdateChecker, "0", "HomeGenie Update Checker", "Update Check", args.Status.ToString() ); }; updateChecker.InstallProgressMessage += (object sender, string message) => { LogBroadcastEvent( Domains.HomeGenie_UpdateChecker, "0", "HomeGenie Update Checker", "InstallProgress.Message", message ); }; // it will check every 24 hours updateChecker.Start(); // statisticsLogger = new StatisticsLogger(this); statisticsLogger.Start(); // LogBroadcastEvent(Domains.HomeGenie_System, "0", "HomeGenie System", "HomeGenie", "STARTED"); // // Setup local UPnP device SetupUpnp(); }