private async void DoConnect() { if (AddressIdentifier.IsIpAddressIdentifier(ServerAddress)) { session.TryConnect(new Address(Protocol, AddressIdentifier.GetIpAddressIdentifierFromString(ServerAddress)), new Address(Protocol, AddressIdentifier.GetIpAddressIdentifierFromString(ClientAddress)), errorMessage => { Application.Current.Dispatcher.Invoke(async() => { var dialog = new UserDialogBox( "", $"Es kann keine Verbindung mit {ServerAddress} hergestellt werden", MessageBoxButton.OK ); await dialog.ShowMahAppsDialog(); }); }); } else { var dialog = new UserDialogBox("", $"{ServerAddress} ist keine gültige Ip-Adresse", MessageBoxButton.OK); await dialog.ShowMahAppsDialog(); } SetAutoConnectToSettings(); }
private void SetAutoConnectToSettings() { if (AutoConnectOnNextStart) { localSettingsRepository.IsAutoConnectionEnabled = true; localSettingsRepository.AutoConnectionServerAddress = AddressIdentifier.GetIpAddressIdentifierFromString(ServerAddress); localSettingsRepository.AutoConnectionClientAddress = AddressIdentifier.GetIpAddressIdentifierFromString(ClientAddress); } else { localSettingsRepository.IsAutoConnectionEnabled = false; localSettingsRepository.AutoConnectionClientAddress = new IpV4AddressIdentifier(127, 0, 0, 1); localSettingsRepository.AutoConnectionServerAddress = new IpV4AddressIdentifier(127, 0, 0, 1); } }
public static IReadOnlyList <Address> GetAllAvailableLocalIpAddresses() { var hostName = Dns.GetHostName(); var addressList = new List <Address>(); var protocol = new TcpIpProtocol(); Dns.GetHostEntry(hostName).AddressList .Select(address => address.ToString()) .Where(AddressIdentifier.IsIpAddressIdentifier) .Select(address => new Address(protocol, AddressIdentifier.GetIpAddressIdentifierFromString(address))) .Do(addressList.Add); if (addressList.Count == 0) { addressList.Add(new Address(protocol, new IpV4AddressIdentifier(127, 0, 0, 1))); } return(addressList); }
private void DoActivateConnection() { ActiveConnection = SelectedIpAddress; connectionService.InitiateCommunication(new Address(new TcpIpProtocol(), AddressIdentifier.GetIpAddressIdentifierFromString(SelectedIpAddress))); }
public LocalSettingsData Load() { if (!File.Exists(filename)) { return(LocalSettingsData.CreateDefaultSettings()); } bool isAutoConnectionEnabled = false; AddressIdentifier autoConnectionClientAddress = new IpV4AddressIdentifier(127, 0, 0, 1); AddressIdentifier autoConnectionServerAddress = new IpV4AddressIdentifier(127, 0, 0, 1); Guid lastUsedMedicalPracticeId = Guid.Empty; Guid lastLoggedInUserId = Guid.Empty; var reader = XmlReader.Create(filename); while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element || reader.Name != XmlRoot) { continue; } while (reader.Read()) { if (reader.NodeType != XmlNodeType.Element) { continue; } switch (reader.Name) { case AutoConnection: { while (reader.MoveToNextAttribute()) { switch (reader.Name) { case IsAutoConnectionEnabledAttribute: isAutoConnectionEnabled = bool.Parse(reader.Value); break; case AutoConnectionClientAddressAttribute: autoConnectionClientAddress = AddressIdentifier.GetIpAddressIdentifierFromString(reader.Value); break; case AutoConnectionServerAddressAttribute: autoConnectionServerAddress = AddressIdentifier.GetIpAddressIdentifierFromString(reader.Value); break; } } break; } case LastSession: { while (reader.MoveToNextAttribute()) { switch (reader.Name) { case LastUsedMedicalPracticeIdAttribute: lastUsedMedicalPracticeId = Guid.Parse(reader.Value); break; case LastLoggedInUserIdAttribute: lastLoggedInUserId = Guid.Parse(reader.Value); break; } } break; } } } } reader.Close(); return(new LocalSettingsData(isAutoConnectionEnabled, autoConnectionClientAddress, autoConnectionServerAddress, lastUsedMedicalPracticeId, lastLoggedInUserId)); }
public static BeginConnectionRequest Parse(string s) { var clientAddress = AddressIdentifier.GetIpAddressIdentifierFromString(s); return(new BeginConnectionRequest(clientAddress)); }