private void PluginMessageReceived(PacketHeader header, Connection connection, string message) { string[] arguments = message.Split('|'); if (arguments[1] == "True") OSAEObjectStateManager.ObjectStateSet(arguments[0], "ON", sourceName); else if (arguments[1] == "False") OSAEObjectStateManager.ObjectStateSet(arguments[0], "OFF", sourceName); foreach (Plugin p in plugins) { if (p.PluginName == arguments[0]) { OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName); if (obj != null) { bool isSystemPlugin = false; foreach (OSAEObjectProperty p2 in obj.Properties) { if (p2.Name == "System Plugin") { if (p2.Value == "TRUE") isSystemPlugin = true; break; } } if (arguments[1] == "True" && !p.Enabled && !isSystemPlugin) { OSAEObjectManager.ObjectUpdate(p.PluginName, p.PluginName, obj.Description, obj.Type, obj.Address, obj.Container, 1); try { enablePlugin(p); logging.AddToLog("Activated plugin: " + p.PluginName, false); } catch (Exception ex) { logging.AddToLog("Error activating plugin (" + p.PluginName + "): " + ex.Message + " - " + ex.InnerException, true); } } else if (arguments[1] == "False" && p.Enabled && !isSystemPlugin) { OSAEObjectManager.ObjectUpdate(p.PluginName, p.PluginName, obj.Description, obj.Type, obj.Address, obj.Container, 0); try { disablePlugin(p); logging.AddToLog("Deactivated plugin: " + p.PluginName, false); } catch (Exception ex) { logging.AddToLog("Error stopping plugin (" + p.PluginName + "): " + ex.Message + " - " + ex.InnerException, true); } } } } } }
private void MethodMessageReceived(PacketHeader header, Connection connection, string message) { string[] items = message.Split('|'); OSAEMethod method = new OSAEMethod(items[2].Trim(), "", items[0].Trim(), items[3].Trim(), items[4].Trim(), items[5].Trim(), items[1].Trim()); if (method.ObjectName == "SERVICE-" + Common.ComputerName) { if (method.MethodName == "RESTART PLUGIN") { foreach (Plugin p in plugins) { if (p.PluginName == method.Parameter1) { OSAEObject obj = OSAEObjectManager.GetObjectByName(p.PluginName); if (obj != null) { disablePlugin(p); enablePlugin(p); } } } } } else { foreach (Plugin plugin in plugins) { if (plugin.Enabled == true && (method.Owner.ToLower() == plugin.PluginName.ToLower() || method.ObjectName.ToLower() == plugin.PluginName.ToLower())) { plugin.ExecuteCommand(method); } } } }