public NetworkNodeConfigDto ReadHostConfig() { var config = new NetworkNodeConfigDto(); var lines = File.ReadAllLines(_filePath); config.Neighbors = new List <Neighbor>(); foreach (var line in lines) { var parts = line.Split(' '); if (line.StartsWith("NAME")) { config.Name = parts[1]; } else if (line.StartsWith("CLOUDIP")) { config.CloudIp = parts[1]; } else if (line.StartsWith("CLOUDPORT")) { config.CloudPort = int.Parse(parts[1]); } else if (line.StartsWith("MANAGEMENTIP")) { config.ManagementIp = parts[1]; } else if (line.StartsWith("MANAGEMENTPORT")) { config.ManagementPort = int.Parse(parts[1]); } else if (line.StartsWith("CCRCPORT")) { config.CCRCPort = int.Parse(parts[1]); } else if (line.StartsWith("DOMAINCCRCPORT")) { config.DomainCCRCPort = int.Parse(parts[1]); } else if (line.StartsWith("NEIGHBOR")) { config.Neighbors.Add(new Neighbor { Name = parts[1], Port = int.Parse(parts[2]) }); } } return(config); }
public MainViewModel(ICableCloudConnectionService cableCloudConnectionService, IManagementAgentService managementAgentService, IConfigReaderService configReaderService, ILogService logService, IRoutingService routingService, ILRMService lrmService) { _cableCloudConnectionService = cableCloudConnectionService; _cableCloudConnectionService.PackageReceived += OnPackageReceived; _cableCloudConnectionService.MessageReceived += OnMessageReceived; _managementAgentService = managementAgentService; //_managementAgentService.RowInfoReceived += OnRowInfoReceived; _logService = logService; _routingService = routingService; _lrmService = lrmService; _lrmService.RowInfoReceived += OnRowInfoReceived; _lrmService.MessageReceived += OnMessageReceived; NetworkNodeConfig = configReaderService.ReadHostConfig(); try { NetworkNodeConfig = configReaderService.ReadHostConfig(); } catch (Exception e) { _logService.LogError("WRONG CONFIG: " + e.Message); } BindingOperations.EnableCollectionSynchronization(Logs, _lock); StartClients(); Task.Run(async() => { while (true) { await CheckList(); Thread.Sleep(50); } }); }