using System; namespace SanSystem.Einstellungen { class SoftwareConfiguration : Settings { long IPToLong(string addr) { System.Net.IPAddress ip; if (System.Net.IPAddress.TryParse(addr, out ip)) return (((long)ip.GetAddressBytes()[0] << 24) | ((int)ip.GetAddressBytes()[1] << 16) | ((int)ip.GetAddressBytes()[2] << 8) | ip.GetAddressBytes()[3]); else return 0; } string LongToIP(long addr) { System.Net.IPAddress tmpIp; if (System.Net.IPAddress.TryParse(addr.ToString(), out tmpIp)) { return tmpIp.ToString(); /*try { Byte[] bytes = tmpIp.GetAddressBytes(); long addrs = (long)BitConverter.ToInt32(bytes, 0); return new System.Net.IPAddress(addrs).ToString(); } */ //catch (Exception e) { return e.Message; } } else return String.Empty; } internal void SetAnlageIP(string text) { setConfig("ANLAGEIP",IPToLong(text)); } public SoftwareConfiguration() : base("SoftwareConfiguration") { } public string GetAnlageIP() { long ip = getConfiguration("ANLAGEIP"); if (ip <= 0) throw new Exception("Something went wrong"); return LongToIP(ip); } public override void InitDevValues() { configuration.Add("ANLAGEIP", IPToLong("192.168.2.248")); } } }