Exemple #1
0
        private void SendMessageToHostCallBack(string command)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(new SendMessageToHost(SendMessageToHostCallBack), command);
            }
            else
            {
                CommandsActions commandAction =
                    ListCommandsActions.Find(delegate(CommandsActions c)
                {
                    return(c.Command.Equals(command));
                });

                if (commandAction != null)
                {
                    if (commandAction.CommandType.Equals(COMMANDTYPE_MSG))
                    {
                        string msg = commandAction.Message;
                        //MessageBox.Show(msg);
                        CommandsAPI2.send_MessageToEmulator(msg);
                    }
                    else if (commandAction.CommandType.Equals(COMMANDTYPE_UC))
                    {
                        pnlMiddle.Controls.Clear();
                        pnlMiddle.Controls.Add(Loader.GetReferenceUserControl(commandAction.ModuleSrc));
                    }
                }
                else
                {
                    if (command.Contains("§"))
                    {
                        CommandsAPI2.send_MessageToEmulator("FORMATO NO DISPONIBLE");
                    }
                }
            }
        }
Exemple #2
0
        public int tempSabreMarkupHandler(int messageType, string message, string properties)
        {
            int retcode = 0;

            try
            {
                if (message.Length > 30 && message.Substring(0, 3) == "EM<")
                {
                }
                else
                {
                    if (messageType.Equals(1))
                    {
                        //ValidateMarkups por default es true, cuando se ejecuta del lado
                        //de la aplicación es false
                        if (CommandsAPI.ValidateMarkups)
                        {
                            retcode = 2;
                            //Busca que el comando empiece con el que está registrado en la base de datos
                            CommandsActions commandAction =
                                ListCommandsActions.Find(delegate(CommandsActions c)
                            {
                                return(message.StartsWith(c.Command));
                            });
                            //Si Allow = false se valida el comando tal cual
                            if (commandAction != null)
                            {
                                if (!commandAction.Allow)
                                {
                                    retcode = 2;
                                }
                                else
                                {
                                    //Busca que el comando no contenga comandos restringidos
                                    string commandRestricted =
                                        commandAction.CommandsRestricted.Find(delegate(string c)
                                                                              { return(message.Contains(c)); });

                                    //si el comando contiene un comando restringido busca también que contenga comandos permitidos
                                    if (!string.IsNullOrEmpty(commandRestricted))
                                    {
                                        message = message.Replace(commandRestricted, string.Empty);
                                        string commandsAllowd = commandAction.CommandsAllowed.Find(delegate(string c)
                                                                                                   { return(message.Contains(c)); });

                                        if (!string.IsNullOrEmpty(commandsAllowd))
                                        {
                                            retcode = 0;
                                        }
                                    }
                                    else
                                    {
                                        string commandsAllowd = commandAction.CommandsAllowed.Find(delegate(string c)
                                                                                                   { return(message.Contains(c)); });

                                        if (!string.IsNullOrEmpty(commandsAllowd))
                                        {
                                            retcode = 0;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                retcode = (message.Contains("§")) ? 2 : 0;
                            }

                            if (retcode.Equals(2))
                            {
                                ReceiverParams(message);
                            }
                        }
                    }

                    if (messageType.Equals(2))
                    {
                        retcode = 0;
                    }
                }
                return(retcode);
            }
            catch (Exception)
            {
            }

            return(retcode);
        }