public string FindValueInAllCommunitities(string ip, string oid) { var value = Utils.Common; foreach (var community in Utils.LoadCommunities()) { try { var result = Messenger.Get( VersionCode.V2, new IPEndPoint(IPAddress.Parse(ip), 161), new OctetString(community), new List <Variable> { new Variable(new ObjectIdentifier(oid)) }, 6000); value = result.FirstOrDefault()?.Data.ToString(); if (!string.IsNullOrEmpty(value) && !value.Equals(Utils.Common)) { var args = new RcdFndEventArgs { Value = value, IpAddress = ip }; OnValueFound(args); break; } } catch (Exception) { value = Utils.Common; } } OnValueFound(new RcdFndEventArgs { Value = value, IpAddress = ip }); return(value); }
protected virtual void OnValueFound(RcdFndEventArgs e) => ValueFound?.Invoke(this, e);