static void Main(string[] args) { // registerService = new MMIRegisterServiceImplementation(); registerService.OnAdapterRegistered += RegisterService_OnAdapterRegistered; ///Start the register server registerServer = new MMIRegisterThriftServer(RuntimeData.MMIRegisterAddress.Port, registerService); registerServer.Start(); //Setup the environment SetupEnvironment(@"..\Adapters", @"..\MMUs", @"..\Services"); System.Console.ReadLine(); Dispose(); }
/// <summary> /// Main constructor /// </summary> public MainWindow() { InitializeComponent(); this.StopButton.IsEnabled = false; //Important assign the dispatcher at the beginning UIData.Initialize(this.Dispatcher); //Register for unhandled exceptions AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; //Initialize gui related things this.adapterListView.ItemsSource = UIData.AdapterCollection; this.serviceListView.ItemsSource = UIData.ServiceCollection; this.mmuView.ItemsSource = UIData.MMUCollection; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(this.mmuView.ItemsSource); //PropertyGroupDescription groupDescription = new PropertyGroupDescription("Language"); //view.GroupDescriptions.Add(groupDescription); view.SortDescriptions.Add(new SortDescription("MotionType", ListSortDirection.Ascending)); view.SortDescriptions.Add(new SortDescription("priority", ListSortDirection.Ascending)); //Create an instance of the register service and register at events this.registerService = new MMIRegisterServiceImplementation(); this.registerService.OnAdapterRegistered += RegisterService_OnAdapterRegistered; this.registerService.OnAdapterUnregistered += RegisterService_OnAdapterUnregistered; this.registerService.OnServiceRegistered += RegisterService_OnServiceRegistered; this.registerService.OnServiceUnregistered += RegisterService_OnServiceUnregistered; //Parse the settings from file try { //Load the settings file from json settings = Serialization.FromJsonString <ServerSettings>(File.ReadAllText("settings.json")); //Check if directory exists -> if not user must provide input if (!Directory.Exists(settings.DataPath)) { ShowFolderSelectionDialog("Invalid path: "); } } catch (Exception) { //Create a new settings file settings = new ServerSettings(); //Show the folder selection dialog ShowFolderSelectionDialog("No settings file found: "); SaveSettings(); //if settings did not exist before save the default settings } //Read settings from system registry encryptionService = new Encrypt(); LoadRegistrySettings(); //Assign the port (common for loaded settings from file or settings from default settings file. RuntimeData.MMIRegisterAddress.Port = settings.RegisterPort; RuntimeData.MMIRegisterAddress.Address = settings.RegisterAddress; //Sets up the performance bar which visualizes performance stats within the main window SetupPerformanceBar(); //check if last selected adapter has the same ip address and update ip if needed NetworkAdapters = new NetworkAdapters(); if (NetworkAdapters.updatedCurrentIp(settings.RegisterInterface, settings.RegisterAddress)) { //update settings and save only if the interface or IP address has changed settings.RegisterAddress = NetworkAdapters.AvailableIp[NetworkAdapters.currentIp].IP; settings.RegisterInterface = NetworkAdapters.AvailableIp[NetworkAdapters.currentIp].Name; RuntimeData.MMIRegisterAddress.Address = settings.RegisterAddress; SaveSettings(); } UpdateTitleBar(); //Directly start all processes if autostart is enabled if (this.settings.AutoStart) { this.StartButton_Click(this, new RoutedEventArgs()); } }