public static void CreateComputerObject(string sourceName) { Logging.GetLogger().AddToLog("Creating Computer object", true); string computerIp = Common.GetComputerIP(); if (OSAEObjectManager.GetObjectByName(Common.ComputerName) == null) { OSAEObject obj = OSAEObjectManager.GetObjectByAddress(computerIp); if (obj == null) { OSAEObjectManager.ObjectAdd(Common.ComputerName, Common.ComputerName, Common.ComputerName, "COMPUTER", computerIp, string.Empty, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); } else if (obj.Type == "COMPUTER") { OSAEObjectManager.ObjectUpdate(obj.Name, Common.ComputerName, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); } else { OSAEObjectManager.ObjectAdd(Common.ComputerName + "." + computerIp, Common.ComputerName, Common.ComputerName, "COMPUTER", computerIp, string.Empty, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName + "." + computerIp, "Host Name", Common.ComputerName, sourceName); } } else { OSAEObject obj = OSAEObjectManager.GetObjectByName(Common.ComputerName); OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Host Name", Common.ComputerName, sourceName); } }
public static void CheckComputerObject(string sourceName) { Logging.GetLogger().AddToLog("Checking for Computer object", true); string computerIp = Common.GetComputerIP(); if (OSAEObjectManager.GetObjectByName(Common.ComputerName) == null) { OSAEObject obj = OSAEObjectManager.GetObjectByAddress(computerIp); if (obj == null) { Logging.GetLogger().AddToLog("Computer Object not found, creating it...", true); OSAEObjectManager.ObjectAdd(Common.ComputerName, "", Common.ComputerName, "COMPUTER", computerIp, "", 30, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); Logging.GetLogger().AddToLog("Computer Object created called: " + Common.ComputerName, true); } else if (obj.Type == "COMPUTER") { Logging.GetLogger().AddToLog("Computer Object found under a different name, updating it...", true); OSAEObjectManager.ObjectUpdate(obj.Name, Common.ComputerName, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.MinTrustLevel, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName, "Host Name", Common.ComputerName, sourceName); } else { Logging.GetLogger().AddToLog("Computer Object found under a different Name and Object Type, updating it...", true); OSAEObjectManager.ObjectAdd(Common.ComputerName, "", Common.ComputerName, "COMPUTER", computerIp, string.Empty, obj.MinTrustLevel, true); OSAEObjectPropertyManager.ObjectPropertySet(Common.ComputerName + "." + computerIp, "Host Name", Common.ComputerName, sourceName); } } else { Logging.GetLogger().AddToLog("Computer Object found, updating it...", true); OSAEObject obj = OSAEObjectManager.GetObjectByName(Common.ComputerName); OSAEObjectManager.ObjectUpdate(obj.Name, obj.Name, obj.Alias, obj.Description, "COMPUTER", computerIp, obj.Container, obj.MinTrustLevel, obj.Enabled); OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Host Name", Common.ComputerName, sourceName); } }