/// <summary>
        /// 
        /// </summary>
        public void LoadPlugins()
        {
            this.Log.Info("Loading Plugins...");

            OSAEPluginCollection newPlugins = new OSAEPluginCollection();
            var pluginAssemblies = new List<OSAEPluginBase>();
            var types = PluginFinder.FindPlugins();

            foreach (var type in types)
            {
                this.Log.Debug("type.TypeName: " + type.TypeName);
                this.Log.Debug("type.AssemblyName: " + type.AssemblyName);

                var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService));
                domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions);

                Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location);
                if (!pluginLoaded(p.PluginType))
                {
                    newPlugins.Add(p);
                }
            }

            this.Log.Info("Found " + newPlugins.Count.ToString() + " Assemblies");
            MySqlConnection connection = new MySqlConnection(Common.ConnectionString);

            foreach (Plugin plugin in newPlugins)
            {
                try
                {
                    if (plugin.PluginName != "")
                    {
                        this.Log.Info("----------------------------------------------------");
                        if (!goodConnection)
                        {
                            try
                            {
                                connection.Open();
                                goodConnection = true;
                            }
                            catch
                            {
                            }
                        }
                        this.Log.Info(plugin.PluginName + ":  Connection Passed (" + goodConnection + ")");
                        if (goodConnection)
                        {
                            if (plugin.PluginName != "")
                            {
                                OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);

                                if (obj == null)
                                {
                                    OSAEObjectManager.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginName + " plugin's Object", plugin.PluginType, "", "", true);
                                    obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);
                                }

                                if (obj != null)
                                {
                                    this.Log.Info(obj.Name + ":  Plugin Object found.  Plugin Object Enabled = " + obj.Enabled.ToString());
                                    if (obj.Enabled == 1)
                                    {
                                        enablePlugin(plugin);
                                    }
                                    else
                                        plugin.Enabled = false;

                                    this.Log.Info(obj.Name + ":  Plugin Enabled =  " + plugin.Enabled.ToString());
                                    this.Log.Info(obj.Name + ":  Plugin Version = " + plugin.PluginVersion);
                                }
                            }
                            else
                            {
                                //add code to create the object.  We need the plugin to specify the type though

                                MySqlDataAdapter adapter;
                                DataSet dataset = new DataSet();
                                DataSet dataset2 = new DataSet();
                                MySqlCommand command = new MySqlCommand();

                                command.Connection = connection;
                                command.CommandText = "SELECT * FROM osae_object_type_property p inner join osae_object_type t on p.object_type_id = t.object_type_id WHERE object_type=@type AND property_name='Computer Name'";
                                command.Parameters.AddWithValue("@type", plugin.PluginType);
                                adapter = new MySqlDataAdapter(command);
                                adapter.Fill(dataset);

                                command.CommandText = "SELECT * FROM osae_v_object WHERE object_type=@type";
                                command.Parameters.AddWithValue("@type", plugin.PluginType);
                                adapter = new MySqlDataAdapter(command);
                                adapter.Fill(dataset2);

                                if (dataset.Tables[0].Rows.Count > 0 && dataset2.Tables[0].Rows.Count > 0)
                                {
                                    plugin.PluginName = plugin.PluginType + "-" + Common.ComputerName;
                                }
                                else
                                {
                                    plugin.PluginName = plugin.PluginType;
                                }

                                this.Log.Info(plugin.PluginName + ":  Plugin object does not exist in DB!");
                                OSAEObjectManager.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginName, plugin.PluginType, "", "System", false);
                                OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Computer Name", Common.ComputerName, sourceName);
                                this.Log.Info(plugin.PluginName + ":  Plugin added to DB.");
                                UDPConnection.SendObject("Plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
                            }
                            plugins.Add(plugin);
                            masterPlugins.Add(plugin);
                        }
                    }
                    else
                    {
                        this.Log.Info(plugin.PluginType + " Skipped! (Not Loaded due to missing Object or other issue)");
                    }
                }
                catch (Exception ex)
                {
                    this.Log.Error("Error loading plugin: " + ex.Message, ex);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        public void LoadPlugins(string serviceName)
        {
            Log = new General.OSAELog(serviceName);
            Log.Info("Loading Plugins...");

            OSAEPluginCollection newPlugins = new OSAEPluginCollection();
            var pluginAssemblies            = new List <OSAEPluginBase>();
            var types = PluginFinder.FindPlugins();

            foreach (var type in types)
            {
                Log.Debug("TypeName: " + type.TypeName + ", AssemblyName: " + type.AssemblyName);

                var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService));
                domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions);

                Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location);
                if (!pluginLoaded(p.PluginType))
                {
                    newPlugins.Add(p);
                }
            }

            Log.Info("Found " + newPlugins.Count.ToString() + " Assemblies");
            MySqlConnection connection = new MySqlConnection(Common.ConnectionString);

            foreach (Plugin plugin in newPlugins)
            {
                try
                {
                    Log.Info("----------------------------------------------------");
                    if (plugin.PluginName != "")
                    {
                        OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);
                        if (obj == null)
                        {
                            bool found = OSAEObjectTypeManager.ObjectTypeExists(plugin.PluginType);
                            if (found)
                            {
                                OSAEObjectManager.ObjectAdd(plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, "", serviceName, 50, false);

                                obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);
                                if (obj == null)
                                {
                                    Log.Info(plugin.PluginName + ":  I failed to create the Plugin Object!");
                                }
                                else
                                {
                                    Log.Info(obj.Name + ":  Plugin Object was Not found, so I created a new Plugin Object.");
                                }
                            }
                            else
                            {
                                Log.Info(":  Plugin Object Type Not found for: " + plugin.PluginType + ".  Plugin Object Cannot be Created.");
                            }
                        }

                        if (obj != null)
                        {
                            Log.Info(obj.Name + ":  Plugin Object found.  Plugin Object Enabled = " + obj.Enabled.ToString());
                            //No idea why the following line would run
                            //OSAEObjectManager.ObjectUpdate(plugin.PluginName,plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, "", serviceName, 50, true);
                            if (obj.Enabled == true)
                            {
                                plugin.Enabled = true;
                                startPlugin(serviceObject, plugin);
                            }
                            else
                            {
                                plugin.Enabled = false;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", serviceObject);
                            }

                            Log.Info(obj.Name + ":  Plugin Enabled = " + plugin.Enabled.ToString());
                            Log.Info(obj.Name + ":  Plugin Version = " + plugin.PluginVersion);
                            OSAEObjectManager.ObjectUpdate(plugin.PluginName, plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, obj.Address, serviceName, 50, plugin.Enabled);
                            OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Version", plugin.PluginVersion, serviceName);
                            OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Author", plugin.PluginAuthor, serviceName);
                        }
                    }
                    else
                    {
                        bool found = OSAEObjectTypeManager.ObjectTypeExists(plugin.PluginType);
                        if (found)
                        {
                            plugin.PluginName = plugin.PluginType;
                            Log.Info(plugin.PluginName + ":  Plugin object does not exist in DB!");
                            OSAEObjectManager.ObjectAdd(plugin.PluginName, "", plugin.PluginName, plugin.PluginType, "", "System", 50, false);
                            OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Version", plugin.PluginVersion, serviceName);
                            OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Author", plugin.PluginAuthor, serviceName);
                            Log.Info(plugin.PluginName + ":  Plugin added to DB.");
                            //Uh, this still looks wrong below.   I don't think it is needed, besides, any new plugin is disabled...
                            //UDPConnection.SendObject("Plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
                        }
                        else
                        {
                            Log.Info(":  Plugin Object Type Not found for: " + plugin.PluginType + ".  Plugin Object Cannot be Created!");
                        }
                    }
                    plugins.Add(plugin);
                    masterPlugins.Add(plugin);
                }
                catch (Exception ex)
                { Log.Error("Error loading plugin: " + ex.Message, ex); }
            }
            OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);
        }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        public void LoadPlugins()
        {
            this.Log.Info("Loading Plugins...");

            OSAEPluginCollection newPlugins = new OSAEPluginCollection();
            var pluginAssemblies            = new List <OSAEPluginBase>();
            var types = PluginFinder.FindPlugins();

            foreach (var type in types)
            {
                this.Log.Debug("type.TypeName: " + type.TypeName);
                this.Log.Debug("type.AssemblyName: " + type.AssemblyName);

                var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService));
                domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions);

                Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location);
                if (!pluginLoaded(p.PluginType))
                {
                    newPlugins.Add(p);
                }
            }

            this.Log.Info("Found " + newPlugins.Count.ToString() + " Assemblies");
            MySqlConnection connection = new MySqlConnection(Common.ConnectionString);

            foreach (Plugin plugin in newPlugins)
            {
                try
                {
                    if (plugin.PluginName != "")
                    {
                        this.Log.Info("----------------------------------------------------");
                        if (!goodConnection)
                        {
                            try
                            {
                                connection.Open();
                                goodConnection = true;
                            }
                            catch
                            {
                            }
                        }
                        this.Log.Info(plugin.PluginName + ":  Connection Passed (" + goodConnection + ")");
                        if (goodConnection)
                        {
                            if (plugin.PluginName != "")
                            {
                                OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);

                                if (obj == null)
                                {
                                    OSAEObjectManager.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginName + " plugin's Object", plugin.PluginType, "", "", true);
                                    obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);
                                }

                                if (obj != null)
                                {
                                    this.Log.Info(obj.Name + ":  Plugin Object found.  Plugin Object Enabled = " + obj.Enabled.ToString());
                                    if (obj.Enabled == 1)
                                    {
                                        enablePlugin(plugin);
                                    }
                                    else
                                    {
                                        plugin.Enabled = false;
                                    }

                                    this.Log.Info(obj.Name + ":  Plugin Enabled =  " + plugin.Enabled.ToString());
                                    this.Log.Info(obj.Name + ":  Plugin Version = " + plugin.PluginVersion);
                                }
                            }
                            else
                            {
                                //add code to create the object.  We need the plugin to specify the type though

                                MySqlDataAdapter adapter;
                                DataSet          dataset  = new DataSet();
                                DataSet          dataset2 = new DataSet();
                                MySqlCommand     command  = new MySqlCommand();

                                command.Connection  = connection;
                                command.CommandText = "SELECT * FROM osae_object_type_property p inner join osae_object_type t on p.object_type_id = t.object_type_id WHERE object_type=@type AND property_name='Computer Name'";
                                command.Parameters.AddWithValue("@type", plugin.PluginType);
                                adapter = new MySqlDataAdapter(command);
                                adapter.Fill(dataset);

                                command.CommandText = "SELECT * FROM osae_v_object WHERE object_type=@type";
                                command.Parameters.AddWithValue("@type", plugin.PluginType);
                                adapter = new MySqlDataAdapter(command);
                                adapter.Fill(dataset2);

                                if (dataset.Tables[0].Rows.Count > 0 && dataset2.Tables[0].Rows.Count > 0)
                                {
                                    plugin.PluginName = plugin.PluginType + "-" + Common.ComputerName;
                                }
                                else
                                {
                                    plugin.PluginName = plugin.PluginType;
                                }

                                this.Log.Info(plugin.PluginName + ":  Plugin object does not exist in DB!");
                                OSAEObjectManager.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginName, plugin.PluginType, "", "System", false);
                                OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Computer Name", Common.ComputerName, sourceName);
                                this.Log.Info(plugin.PluginName + ":  Plugin added to DB.");
                                UDPConnection.SendObject("Plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
                            }
                            plugins.Add(plugin);
                            masterPlugins.Add(plugin);
                        }
                    }
                    else
                    {
                        this.Log.Info(plugin.PluginType + " Skipped! (Not Loaded due to missing Object or other issue)");
                    }
                }
                catch (Exception ex)
                {
                    this.Log.Error("Error loading plugin: " + ex.Message, ex);
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        public void LoadPlugins()
        {
            OSAEPluginCollection newPlugins = new OSAEPluginCollection();
            var pluginAssemblies            = new List <OSAEPluginBase>();
            var types = PluginFinder.FindPlugins();

            logging.AddToLog("Loading Plugins", true);

            foreach (var type in types)
            {
                logging.AddToLog("type.TypeName: " + type.TypeName, false);
                logging.AddToLog("type.AssemblyName: " + type.AssemblyName, false);

                var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService));
                domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions);

                Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location);
                if (!pluginLoaded(p.PluginType))
                {
                    newPlugins.Add(p);
                }
            }

            logging.AddToLog("Found " + plugins.Count.ToString() + " plugins", true);
            MySqlConnection connection = new MySqlConnection(Common.ConnectionString);

            foreach (Plugin plugin in newPlugins)
            {
                try
                {
                    logging.AddToLog("---------------------------------------", true);
                    logging.AddToLog("Plugin name: " + plugin.PluginName, true);
                    logging.AddToLog("Testing connection", true);
                    if (!goodConnection)
                    {
                        try
                        {
                            connection.Open();
                            goodConnection = true;
                        }
                        catch
                        {
                        }
                    }

                    if (goodConnection)
                    {
                        if (plugin.PluginName != "")
                        {
                            OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);

                            if (obj != null)
                            {
                                logging.AddToLog("Plugin Object found: " + obj.Name + " - Enabled: " + obj.Enabled.ToString(), true);
                                if (obj.Enabled == 1)
                                {
                                    enablePlugin(plugin);
                                }
                                else
                                {
                                    plugin.Enabled = false;
                                }

                                logging.AddToLog("Status: " + plugin.Enabled.ToString(), true);
                                logging.AddToLog("PluginVersion: " + plugin.PluginVersion, true);
                            }
                        }
                        else
                        {
                            //add code to create the object.  We need the plugin to specify the type though

                            MySqlDataAdapter adapter;
                            DataSet          dataset = new DataSet();
                            MySqlCommand     command = new MySqlCommand();

                            command.Connection  = connection;
                            command.CommandText = "SELECT * FROM osae_object_type_property p inner join osae_object_type t on p.object_type_id = t.object_type_id WHERE object_type=@type AND property_name='Computer Name'";
                            command.Parameters.AddWithValue("@type", plugin.PluginType);
                            adapter = new MySqlDataAdapter(command);
                            adapter.Fill(dataset);

                            if (dataset.Tables[0].Rows.Count > 0)
                            {
                                plugin.PluginName = plugin.PluginType + "-" + Common.ComputerName;
                            }
                            else
                            {
                                plugin.PluginName = plugin.PluginType;
                            }

                            logging.AddToLog("Plugin object does not exist in DB: " + plugin.PluginName, true);
                            OSAEObjectManager.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginType, "", "System", false);
                            OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Computer Name", Common.ComputerName, sourceName);

                            logging.AddToLog("Plugin added to DB: " + plugin.PluginName, true);
                            sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName);
                        }
                        plugins.Add(plugin);
                        masterPlugins.Add(plugin);
                    }
                }
                catch (Exception ex)
                {
                    logging.AddToLog("Error loading plugin: " + ex.Message, true);
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public void LoadPlugins()
        {
            OSAEPluginCollection newPlugins = new OSAEPluginCollection();
            var pluginAssemblies = new List<OSAEPluginBase>();
            var types = PluginFinder.FindPlugins();

            logging.AddToLog("Loading Plugins", true);

            foreach (var type in types)
            {
                logging.AddToLog("type.TypeName: " + type.TypeName, false);
                logging.AddToLog("type.AssemblyName: " + type.AssemblyName, false);

                var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService));
                domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions);

                Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location);
                if (!pluginLoaded(p.PluginType))
                {
                    newPlugins.Add(p);
                }
            }

            logging.AddToLog("Found " + plugins.Count.ToString() + " plugins", true);
            MySqlConnection connection = new MySqlConnection(Common.ConnectionString);

            foreach (Plugin plugin in newPlugins)
            {
                try
                {
                    logging.AddToLog("---------------------------------------", true);
                    logging.AddToLog("Plugin name: " + plugin.PluginName, true);
                    logging.AddToLog("Testing connection", true);
                    if (!goodConnection)
                    {
                        try
                        {
                            connection.Open();
                            goodConnection = true;
                        }
                        catch
                        {
                        }
                    }

                    if (goodConnection)
                    {
                        if (plugin.PluginName != "")
                        {
                            OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);

                            if (obj != null)
                            {
                                logging.AddToLog("Plugin Object found: " + obj.Name + " - Enabled: " + obj.Enabled.ToString(), true);
                                if (obj.Enabled == 1)
                                {
                                    enablePlugin(plugin);
                                }
                                else
                                    plugin.Enabled = false;

                                logging.AddToLog("Status: " + plugin.Enabled.ToString(), true);
                                logging.AddToLog("PluginVersion: " + plugin.PluginVersion, true);
                            }
                        }
                        else
                        {
                            //add code to create the object.  We need the plugin to specify the type though

                            MySqlDataAdapter adapter;
                            DataSet dataset = new DataSet();
                            MySqlCommand command = new MySqlCommand();

                            command.Connection = connection;
                            command.CommandText = "SELECT * FROM osae_object_type_property p inner join osae_object_type t on p.object_type_id = t.object_type_id WHERE object_type=@type AND property_name='Computer Name'";
                            command.Parameters.AddWithValue("@type", plugin.PluginType);
                            adapter = new MySqlDataAdapter(command);
                            adapter.Fill(dataset);

                            if (dataset.Tables[0].Rows.Count > 0)
                            {
                                plugin.PluginName = plugin.PluginType + "-" + Common.ComputerName;
                            }
                            else
                            {
                                plugin.PluginName = plugin.PluginType;
                            }

                            logging.AddToLog("Plugin object does not exist in DB: " + plugin.PluginName, true);
                            OSAEObjectManager.ObjectAdd(plugin.PluginName, plugin.PluginName, plugin.PluginType, "", "System", false);
                            OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Computer Name", Common.ComputerName, sourceName);

                            logging.AddToLog("Plugin added to DB: " + plugin.PluginName, true);
                            sendMessageToClients(WCF.OSAEWCFMessageType.PLUGIN, plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName);

                        }
                        plugins.Add(plugin);
                        masterPlugins.Add(plugin);
                    }
                }
                catch (Exception ex)
                {
                    logging.AddToLog("Error loading plugin: " + ex.Message, true);
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public void LoadPlugins(string serviceName)
        {
            Log = new General.OSAELog(serviceName);
            Log.Info("Loading Plugins...");

            OSAEPluginCollection newPlugins = new OSAEPluginCollection();
            var pluginAssemblies = new List<OSAEPluginBase>();
            var types = PluginFinder.FindPlugins();

            foreach (var type in types)
            {
                Log.Debug("TypeName: " + type.TypeName + ", AssemblyName: " + type.AssemblyName);

                var domain = Common.CreateSandboxDomain("Sandbox Domain", type.Location, SecurityZone.Internet, typeof(OSAEService));
                domain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledPluginExceptions);

                Plugin p = new Plugin(type.AssemblyName, type.TypeName, domain, type.Location);
                if (!pluginLoaded(p.PluginType)) newPlugins.Add(p);
            }

            Log.Info("Found " + newPlugins.Count.ToString() + " Assemblies");
            MySqlConnection connection = new MySqlConnection(Common.ConnectionString);

            foreach (Plugin plugin in newPlugins)
            {
                try
                {
                    Log.Info("----------------------------------------------------");
                    if (plugin.PluginName != "")
                    {
                        OSAEObject obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);
                        if (obj == null)
                        {
                            bool found = OSAEObjectTypeManager.ObjectTypeExists(plugin.PluginType);
                            if (found)
                            {
                                OSAEObjectManager.ObjectAdd(plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, "", serviceName, 50, false);

                                obj = OSAEObjectManager.GetObjectByName(plugin.PluginName);
                                if (obj == null)
                                    Log.Info(plugin.PluginName + ":  I failed to create the Plugin Object!");
                                else
                                    Log.Info(obj.Name + ":  Plugin Object was Not found, so I created a new Plugin Object.");
                            }
                            else
                                Log.Info(":  Plugin Object Type Not found for: " + plugin.PluginType + ".  Plugin Object Cannot be Created.");
                        }

                        if (obj != null)
                        {
                            Log.Info(obj.Name + ":  Plugin Object found.  Plugin Object Enabled = " + obj.Enabled.ToString());
                            //No idea why the following line would run
                            //OSAEObjectManager.ObjectUpdate(plugin.PluginName,plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, "", serviceName, 50, true);
                            if (obj.Enabled == true)
                            {
                                plugin.Enabled = true;
                                startPlugin(serviceObject, plugin);
                            }
                            else
                            {
                                plugin.Enabled = false;
                                OSAEObjectStateManager.ObjectStateSet(obj.Name, "OFF", serviceObject);
                            }

                            Log.Info(obj.Name + ":  Plugin Enabled = " + plugin.Enabled.ToString());
                            Log.Info(obj.Name + ":  Plugin Version = " + plugin.PluginVersion);
                            OSAEObjectManager.ObjectUpdate(plugin.PluginName, plugin.PluginName, "", plugin.PluginName + " plugin's Object", plugin.PluginType, obj.Address, serviceName, 50, plugin.Enabled);
                            OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Version", plugin.PluginVersion, serviceName);
                            OSAEObjectPropertyManager.ObjectPropertySet(obj.Name, "Author", plugin.PluginAuthor, serviceName);
                        }
                    }
                    else
                    {
                        bool found = OSAEObjectTypeManager.ObjectTypeExists(plugin.PluginType);
                        if (found)
                        {
                            plugin.PluginName = plugin.PluginType;
                            Log.Info(plugin.PluginName + ":  Plugin object does not exist in DB!");
                            OSAEObjectManager.ObjectAdd(plugin.PluginName, "", plugin.PluginName, plugin.PluginType, "", "System", 50, false);
                            OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Version", plugin.PluginVersion, serviceName);
                            OSAEObjectPropertyManager.ObjectPropertySet(plugin.PluginName, "Author", plugin.PluginAuthor, serviceName);
                            Log.Info(plugin.PluginName + ":  Plugin added to DB.");
                            //Uh, this still looks wrong below.   I don't think it is needed, besides, any new plugin is disabled...
                            //UDPConnection.SendObject("Plugin", plugin.PluginName + " | " + plugin.Enabled.ToString() + " | " + plugin.PluginVersion + " | Stopped | " + plugin.LatestAvailableVersion + " | " + plugin.PluginType + " | " + Common.ComputerName, new IPEndPoint(IPAddress.Broadcast, 10051));
                        }
                        else
                            Log.Info(":  Plugin Object Type Not found for: " + plugin.PluginType + ".  Plugin Object Cannot be Created!");
                    }
                    plugins.Add(plugin);
                    masterPlugins.Add(plugin);
                }
                catch (Exception ex)
                { Log.Error("Error loading plugin: " + ex.Message, ex); }
            }
            OSAEObjectStateManager.ObjectStateSet(serviceObject, "ON", serviceObject);
        }