コード例 #1
0
        /// <summary>
        /// Returns a Dataset of all objects of specified type
        /// </summary>
        /// <param name="ObjectType"></param>
        /// <returns></returns>
        public static OSAEObjectCollection GetObjectsByType(string ObjectType)
        {
            DataSet              dataset = new DataSet();
            OSAEObject           obj     = new OSAEObject();
            OSAEObjectCollection objects = new OSAEObjectCollection();

            using (MySqlCommand command = new MySqlCommand())
            {
                try
                {
                    command.CommandText = "SELECT object_name, object_alias, object_description, object_type, address, container_name, enabled, state_name, base_type, coalesce(time_in_state, 0) as time_in_state, last_updated FROM osae_v_object WHERE object_type=@ObjectType";
                    command.Parameters.AddWithValue("@ObjectType", ObjectType);
                    dataset = OSAESql.RunQuery(command);

                    if (dataset.Tables[0].Rows.Count > 0)
                    {
                        foreach (DataRow dr in dataset.Tables[0].Rows)
                        {
                            obj                   = new OSAEObject(dr["object_name"].ToString(), dr["object_alias"].ToString(), dr["object_description"].ToString(), dataset.Tables[0].Rows[0]["object_type"].ToString(), dr["address"].ToString(), dr["container_name"].ToString(), int.Parse(dr["enabled"].ToString()));
                            obj.State.Value       = dr["state_name"].ToString();
                            obj.State.TimeInState = Convert.ToInt64(dr["time_in_state"]);
                            obj.BaseType          = dr["base_type"].ToString();
                            obj.LastUpd           = dr["last_updated"].ToString();
                            obj.Properties        = OSAEObjectPropertyManager.GetObjectProperties(obj.Name);
                            obj.Methods           = OSAEObjectManager.GetObjectMethods(obj.Name);
                            objects.Add(obj);
                        }
                        return(objects);
                    }
                    return(objects);
                }
                catch (Exception ex)
                {
                    Logging.GetLogger().AddToLog("API - GetObjectsByType error: " + ex.Message, true);
                    return(objects);
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 public void Delete()
 {
     OSAEObjectManager.ObjectDelete(Name);
 }
コード例 #4
0
        //public Boolean AddScript(string objName, string objEvent, string script)
        //{
        //    OSAEScriptManager.ObjectEventScriptAdd(objName, objEvent, script);
        //    return true;
        //}
        //public Boolean UpdateScript(string objName, string objEvent, string script)
        //{
        //    OSAEScriptManager.ObjectEventScriptUpdate(objName, objEvent, script);
        //    return true;
        //}
        public OSAEObjectCollection GetPlugins()
        {
            OSAEObjectManager objectManager = new OSAEObjectManager();

            // lookup objects of the requested type
            OSAEObjectCollection objects = OSAEObjectManager.GetObjectsByBaseType("plugin");
            return objects;
        }