public void OnMessageReceived(OSAEWCFMessage request) { }
public void OnMessageReceived(OSAEWCFMessage message) { }
public void OnMessageReceived(OSAEWCFMessage message) { logging.AddToLog("Message received: " + message.Type + " - " + message.Message, false); //this.Invoke((MethodInvoker)delegate //{ switch (message.Type) { case OSAEWCFMessageType.PLUGIN: string[] split = message.Message.Split('|'); bool enabled = false; if (split[1].Trim() == "True") { enabled = true; } foreach (PluginDescription plugin in pluginList) { if ((plugin.Type == split[5].Trim() && Common.ComputerName == split[6].Trim()) || plugin.Name == split[0].Trim()) { if (split[3].Trim() == "ON") { plugin.Status = "Running"; } else if (split[3].Trim() == "OFF") { plugin.Status = "Stopped"; } else { plugin.Status = split[3].Trim(); } plugin.Enabled = enabled; plugin.Name = split[0].Trim(); if (split[4].Trim() != "") { plugin.Upgrade = split[4].Trim(); } else { plugin.Upgrade = string.Empty; } logging.AddToLog("updated plugin: " + plugin.Name + "|" + plugin.Version + "|" + plugin.Upgrade + "|" + plugin.Status + "| " + plugin.Enabled.ToString(), true); break; } } break; case OSAEWCFMessageType.CMDLINE: string[] param = message.Message.Split('|'); if (param[2].Trim() == Common.ComputerName) { logging.AddToLog("CMDLINE received: " + param[0].Trim() + " - " + param[1].Trim(), true); Process pr = new Process(); pr.StartInfo.FileName = param[0].Trim(); pr.StartInfo.Arguments = param[1].Trim(); pr.Start(); } break; } //}); }
public void OnMessageReceived(OSAEWCFMessage message) { logging.AddToLog("received message: " + message.Type + " | " + message, false); switch (message.Type) { case OSAEWCFMessageType.PLUGIN: string[] arguments = message.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); } } } } } break; case OSAEWCFMessageType.METHOD: string[] items = message.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); } } } break; } }