Esempio n. 1
0
 public BotCommand(string Text, bool modOnly = false, bool subOnly = false)
 {
     typeCommand  = TypeCommand.Text;
     this.Text    = Text;
     this.modOnly = modOnly;
     this.subOnly = subOnly;
 }
Esempio n. 2
0
 public BotCommand(Action <string[], Message> CommandScript, bool modOnly = false, bool subOnly = false)
 {
     typeCommand        = TypeCommand.Action;
     this.commandScript = CommandScript;
     this.modOnly       = modOnly;
     this.subOnly       = subOnly;
 }
Esempio n. 3
0
        /*-------------------------------------------------------------------*/

        public FluentSessionRecorder In(string selector)
        {
            var command = new TypeCommand(_text, selector, false);

            _performer.Perform(command);

            return(_recorder);
        }
Esempio n. 4
0
        public async Task <bool> Send(TypeCommand typeCommand, TypeData typeData, object data)
        {
            Command command = GetCommand(typeCommand, typeData);

            DataPacket dataPacket = new DataPacket(command, data);

            return(await Task.Run(() => TrySendObject(dataPacket)));
        }
Esempio n. 5
0
        public FluentSessionRecorder In(IElement element)
        {
            var command = new TypeCommand(_text, element, false);

            _performer.Perform(command);

            return(_recorder);
        }
Esempio n. 6
0
 public StatementDAO(string pSql)
 {
     _namesParameter  = new List <string>();
     _valuesParameter = new List <object>();
     _typesParameter  = new List <Type>();
     _sql             = pSql;
     _typeCommand     = TypeCommand.StoredProcedure;
 }
Esempio n. 7
0
 public StatementDAO(string pSql, TypeCommand pTypeCommand)
 {
     _namesParameter  = new List <string>();
     _valuesParameter = new List <object>();
     _typesParameter  = new List <Type>();
     _sql             = pSql;
     _typeCommand     = pTypeCommand;
 }
        /// String SQL ou StoredProcedure
        /// Tipo de Commando (Text ou Stored Procedure
        /// Lista de parâmetros
        /// Comando a ser executado (ExecuteNonQuery, ExecuteReader, ExecuteScalar, ExecuteDataTable)
        /// Object
        public static Object executeCommand(String cmmdText, CommandType cmmdType, List<DbParameter> listParameter, TypeCommand typeCmmd, ConnectionDB.TypeDB TpDB)
        {
            // Cria comando com os dados passado por parâmetro
            DbCommand command = createCommand(cmmdText, cmmdType, listParameter, TpDB);

            // Cria objeto de retorno
            Object objRetorno = null;

            try
            {
                // Abre a Conexão com o banco de dados
                command.Connection.Open();

                switch (typeCmmd)
                {
                    case TypeCommand.ExecuteNonQuery:
                        // Retorna o número de linhas afetadas
                        objRetorno = command.ExecuteNonQuery();
                        break;
                    case TypeCommand.ExecuteReader:
                        // Retorna um DbDataReader
                        objRetorno = command.ExecuteReader(CommandBehavior.CloseConnection);
                        break;
                    case TypeCommand.ExecuteScalar:
                        // Retorna um objeto
                        objRetorno = command.ExecuteScalar();
                        break;
                    case TypeCommand.ExecuteDataTable:
                        // Cria uma tabela
                        DataTable table = new DataTable();
                        // Executa o comando e salva os dados na tabela
                        using (DbDataReader reader = command.ExecuteReader())
                        {
                            table.Load(reader);
                        }
                        // Retorna a tabela
                        objRetorno = table;

                        break;
                }
            }
            catch (Exception ex)
            {
                 throw ex;
            }
            finally
            {
                if (typeCmmd != TypeCommand.ExecuteReader)
                {
                    // Sempre fecha a conexão com o BD
                    command.Connection.Close();
                    command.Connection.Dispose();
                    command.Dispose();
                    command = null;
                }
            }
            return objRetorno;
        }
 public ArmorProficiencyViewModel()
 {
     DoStuffCommand = new RelayCommand(DoWork, param => canExecute);
     ConfirmCommand = new TypeCommand<Window>(ConfirmStuff);
     foreach (var item in AllProficiencies)
     {
         item.PropertyChanged += EnumBase_PropertyChanged;
     }
 }
Esempio n. 10
0
        public void Parse_Bool()
        {
            CommandLine          commandLine = new CommandLine($"Types -Bool");
            IDangrCommandFactory factory     = new DangrCommandFactory <TypeCommand>();

            IDangrCommand command = factory.Create(commandLine);

            Validate.Value.IsType <TypeCommand>(command, "Wrong type of command created.");
            TypeCommand typeCommand = (TypeCommand)command;

            Validate.Value.IsTrue(typeCommand.Bool, "Wrong value assigned arg.");
        }
Esempio n. 11
0
        public void Parse_Int()
        {
            const int            expected    = 12345;
            CommandLine          commandLine = new CommandLine($"Types -Int {expected}");
            IDangrCommandFactory factory     = new DangrCommandFactory <TypeCommand>();

            IDangrCommand command = factory.Create(commandLine);

            Validate.Value.IsType <TypeCommand>(command, "Wrong type of command created.");
            TypeCommand typeCommand = (TypeCommand)command;

            Validate.Value.AreEqual(expected, typeCommand.Int, "Wrong value assigned arg.");
        }
Esempio n. 12
0
        public void Execute_NoClearRequested_ClearNotCalled()
        {
            // Arrange
            var command    = new TypeCommand(DefaultText, DefaultSelector, false);
            var webDriver  = Substitute.For <IWebDriver>();
            var webElement = Substitute.For <IWebElement>();

            // Act
            IgnoreExceptions.Run(() => command.Execute(webDriver));

            // Assert
            webElement.DidNotReceive().Clear();
        }
Esempio n. 13
0
        public void Parse_String()
        {
            const string         expected    = "1234.5";
            CommandLine          commandLine = new CommandLine($"Types -String {expected}");
            IDangrCommandFactory factory     = new DangrCommandFactory <TypeCommand>();

            IDangrCommand command = factory.Create(commandLine);

            Validate.Value.IsType <TypeCommand>(command, "Wrong type of command created.");
            TypeCommand typeCommand = (TypeCommand)command;

            Validate.Value.AreEqual(expected, typeCommand.String, "Wrong value assigned arg.");
        }
Esempio n. 14
0
        public void Parse_Decimal()
        {
            const decimal        expected    = 12.345M;
            CommandLine          commandLine = new CommandLine($"Types -Decimal {expected}");
            IDangrCommandFactory factory     = new DangrCommandFactory <TypeCommand>();

            IDangrCommand command = factory.Create(commandLine);

            Validate.Value.IsType <TypeCommand>(command, "Wrong type of command created.");
            TypeCommand typeCommand = (TypeCommand)command;

            Validate.Value.AreEqual(expected, typeCommand.Decimal, "Wrong value assigned arg.");
        }
Esempio n. 15
0
        public static object ExecutarComando(string cmbText, TypeCommand tipoRetorno)
        {
            DbCommand comando    = CriarComando(cmbText, CommandType.Text, null);
            object    objRetorno = null;

            try
            {
                comando.Connection.Open();
                switch (tipoRetorno)
                {
                case TypeCommand.ExecuteNonQuery:
                    objRetorno = comando.ExecuteNonQuery();
                    break;

                case TypeCommand.ExecuteReader:
                    objRetorno = comando.ExecuteReader();
                    break;

                case TypeCommand.ExecuteScalar:
                    objRetorno = comando.ExecuteScalar();
                    break;

                case TypeCommand.ExecuteDataTable:
                    DataTable    tabela = new DataTable();
                    DbDataReader leitor = comando.ExecuteReader();
                    tabela.Load(leitor);
                    Random GeradorDeNumerosAleatorios = new Random();
                    tabela.TableName = "TABELA" + GeradorDeNumerosAleatorios.Next(1, 99999999).ToString();
                    leitor.Close();
                    objRetorno = tabela;
                    break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if ((tipoRetorno != TypeCommand.ExecuteReader))
                {
                    if ((comando.Connection.State == ConnectionState.Open))
                    {
                        comando.Connection.Close();
                        comando.Connection.Dispose();
                    }
                }
            }

            return(objRetorno);
        }
Esempio n. 16
0
        public void Execute_ClearRequested_ClearCalled()
        {
            // Arrange
            var command    = new TypeCommand(DefaultText, DefaultSelector, true);
            var webDriver  = Substitute.For <IWebDriver>();
            var webElement = Substitute.For <IWebElement>();

            webDriver.FindElementBySelector(DefaultSelector).Returns(webElement);

            // Act
            IgnoreExceptions.Run(() => command.Execute(webDriver));

            // Assert
            webElement.Received().Clear();
        }
Esempio n. 17
0
        public static bool GetSingleFlag(TypeCommand enums)
        {
            MemberInfo memberInfo = typeof(TypeCommand).GetMember(enums.ToString()).FirstOrDefault();

            if (memberInfo != null)
            {
                SingleAttribute attribute = (SingleAttribute)
                                            memberInfo.GetCustomAttributes(typeof(SingleAttribute), false).FirstOrDefault();

                if (attribute != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 18
0
        private static void ReadFile(string path, TypeCommand command, string pathToFasm = null)
        {
            if (pathToFasm != null)
            {
                ReadSource.SetPathToFasm(pathToFasm);
            }

            string source = ReadSource.ReadFile(path);

            if (source != "")
            {
                SwitcherCommand(source, command);
            }
            else
            {
                ConsoleHelper.WriteError("Исходник пустой");
            }
        }
Esempio n. 19
0
        private Command GetCommand(TypeCommand typeCommand, TypeData typeData)
        {
            switch (typeCommand)
            {
            case TypeCommand.Save:
                return(new SaveCommand(typeData));

            case TypeCommand.Search:
                return(new SearchCommand(typeData));

            case TypeCommand.Update:
                return(new UpdateCommand(typeData));

            case TypeCommand.Delete:
                return(new DeleteCommand(typeData));

            default:
                return(null);
            }
        }
        public LanguageProficiencyViewModel(ObservableCollection<EnumBase> selectedEnums)
        {
            DoStuffCommand = new RelayCommand(DoWork, param => canExecute);
            ConfirmCommand = new TypeCommand<Window>(ConfirmStuff);
            SelectedProficiencies = selectedEnums;

            foreach (var item in AllProficiencies)
            {
                item.PropertyChanged += EnumBase_PropertyChanged;
            }
            foreach (var item in SelectedProficiencies)
            {
                foreach (var item2 in AllProficiencies)
                {
                    if (item.Description == item2.Description)
                    {
                        item2.IsChecked = true;
                    }
                }
            }
        }
Esempio n. 21
0
        private static void SwitcherCommand(string source, TypeCommand command)
        {
            switch (command)
            {
            case TypeCommand.DUMP_TOKENS:
                Lexer.StartLexer(source);
                Lexer.ParseLexem();
                Lexer.ViewTokens();
                break;

            case TypeCommand.DUMP_AST:
                Lexer.StartLexer(source);
                AbstractSyntaxTree.CreateAST(true, true);
                break;

            case TypeCommand.DUMP_ASM:
                Lexer.StartLexer(source);
                AbstractSyntaxTree.CreateAST(true, true);
                ASM.CreateASM();
                ASM.RunCompileProgramm();
                break;
            }
        }
Esempio n. 22
0
 public void SetUp()
 {
     _defaultCommand = new TypeCommand(DefaultText, DefaultSelector, DefaultClear);
 }
Esempio n. 23
0
        /// <summary>
        /// Enviar dados através da Stream
        /// </summary>
        /// <param name="Command">Tipo do comando a ser enviado</param>
        /// <param name="Arguments">Argumentos do comando. Caso não tenha, deixe-o vazio</param>
        /// <returns>Informa se os dados foram enviados corretamente</returns>
        public bool SendData(TypeCommand Command, params object[] Arguments)
        {
            lock (this)
            {
                bool ReturnMethod = true;
                bool HasArguments = Arguments.Length > 0;

                ReturnMethod &= netWorkStream.WriteSpecific<ushort>((ushort)(Command));
                ReturnMethod &= netWorkStream.WriteSpecific<bool>(HasArguments);

                if (HasArguments)
                    ReturnMethod &= netWorkStream.WriteSpecific<string>(JsonConvert.SerializeObject(Arguments));

                return ReturnMethod;
            }
        }
Esempio n. 24
0
 protected virtual void OnDataSent(TypeCommand Command, params object[] Arguments)
 {
     Control control = DataSent.Target as Control;
     if (control != null && control.InvokeRequired)
     {
         control.Invoke(DataSent, Command, Arguments);
     }
     else
     {
         DataSent(Command, Arguments);
     }
 }
Esempio n. 25
0
        private void DataReceivedCore(TypeCommand Command, params object[] ArgumentsReceived)
        {
            switch (Command)
            {
                case TypeCommand.Connect:
                case TypeCommand.Login:
                case TypeCommand.Unlogin:
                    {
                        bool Sucess = (bool)ArgumentsReceived[0];
                        string MsgErro = (string)ArgumentsReceived[1];

                        if (Command == TypeCommand.Unlogin)
                            OnEventUnlogin(Sucess, MsgErro);

                        else if (Command == TypeCommand.Login)
                            OnEventLogin(Sucess, MsgErro);

                        else
                            OnEventConnect(Sucess, MsgErro);
                    }
                    break;

                case TypeCommand.HardwareInfo:
                    {
                        List<IWarning> Warnings = ArgumentsReceived[0] as List<IWarning>;
                        OnEventHardwareInfo(Warnings);
                    }
                    break;

                default:
                    ConsoleConstants.WriteInConsole(
                        "Comando recebido do servidor é desconhecido." +
                        "\nCódigo do comando: " + Convert.ToString((uint)Command, 16), Color.DarkRed);
                    break;
            }
        }
        //Constuctor

        public RaceCreationViewModel()
        {
            
            //Test Things
            AddAbilityBonusCommand = new TypeCommand<StackPanel>(AddAbility);
            TestCommand = new RelayCommand(Test, param =>canExecute);
            //Commands
            CreateRaceCommand = new RelayCommand(AddRaceToDB, param =>canExecute);
            AddArmorProficiencyCommand = new RelayCommand(AddArmorProficiencies, param=>canExecute);
            AddWeaponProficiencyCommand = new RelayCommand(AddWeaponProficiencies, param=>canExecute);
            AddToolProficiencyCommand = new RelayCommand(AddToolProficiencies, param=>canExecute);
            AddSkillProficiencyCommand = new RelayCommand(AddSkillProficiencies, param => canExecute);
            AddLanguagesProficiencyCommand = new RelayCommand(AddLanguageProficiencies, param => canExecute);
            ResetAllCommand = new RelayCommand(ResetAll);
            ParentSelectedCommand = new RelayCommand(ParentSelected, param => canExecute);
            ParentToggledCommand = new RelayCommand(ParentToggled, param => canExecute);

            //ViewModels
            WeaponProficiencyViewModel = new WeaponProficiencyViewModel(SelectedWeaponProficiencies);
            ArmorProficiencyViewModel = new ArmorProficiencyViewModel(SelectedArmorProficiencies);
            ToolProficiencyViewModel = new ToolProficiencyViewModel(SelectedToolProficiencies);
            SkillProficiencyViewModel = new SkillProficiencyViewModel(SelectedSkillProficiencies);
            LanguageProficiencyViewModel = new LanguageProficiencyViewModel(SelectedLanguageProficiencies);

            CurrentVM = WeaponProficiencyViewModel;
            PropertyChanged += SelectedParentRace_PropertyChanged;
        }
Esempio n. 27
0
 public PackCommand(TypeCommand type)
 {
     this.Type = type;
     // Args = new List<string>();
 }
Esempio n. 28
0
 public RemoteCommand(TypeCommand type, object obj)
 {
     Type    = type;
     ObjData = obj;
 }
Esempio n. 29
0
 public TarefaCommand(TypeCommand typeCommand)
 {
     this.typeCommand = typeCommand;
 }
Esempio n. 30
0
 public TarefaCommand(TypeCommand typeCommand, TarefaPageViewModel tarefaPageViewModel)
 {
     this.typeCommand         = typeCommand;
     this.tarefaPageViewModel = tarefaPageViewModel;
 }
Esempio n. 31
0
 public Command(TypeCommand type, string command)
 {
     Type          = type;
     CommandString = command;
 }
Esempio n. 32
0
        public static Object ExecuteCommand(string cmdText, CommandType cmdType, List <DbParameter> listParameter, TypeCommand typeCmd)
        {
            var    command    = CreateCommand(cmdText, cmdType, listParameter);
            Object objRetorno = null;

            try
            {
                command.Connection.Open();
                switch (typeCmd)
                {
                case TypeCommand.ExecuteNonQuery:
                    objRetorno = command.ExecuteNonQuery();
                    break;

                case TypeCommand.ExecuteReader:
                    objRetorno = command.ExecuteReader();
                    break;

                case TypeCommand.ExecuteScalar:
                    objRetorno = command.ExecuteScalar();
                    break;

                case TypeCommand.ExecuteDataTable:
                    var table  = new DataTable();
                    var reader = command.ExecuteReader();
                    table.Load(reader);
                    reader.Close();
                    objRetorno = table;
                    break;
                }
            }
            catch (Exception)
            {
                throw new Exception("Erro ao executar o ExecuteCommando");
            }
            finally
            {
                if (typeCmd != TypeCommand.ExecuteReader)
                {
                    if (command.Connection.State == ConnectionState.Open)
                    {
                        command.Connection.Close();
                    }
                    command.Connection.Dispose();
                }
            }

            return(objRetorno);
        }
 public static int executeNonQueryWithTransaction(String cmmdText, CommandType cmmdType, List<DbParameter> listParameter, TypeCommand typeCmmd, ConnectionDB.TypeDB TpDB)
 {
     using (TransactionScope ts = new TransactionScope())
     {
         int iRet = 0;
         DbCommand cmd = createCommand(cmmdText, cmmdType, listParameter, TpDB);
         try
         {
             cmd.Connection.Open();
             iRet = cmd.ExecuteNonQuery();
             ts.Complete();
             return iRet;
         }
         catch (DbException ex)
         {
             throw ex;
         }
         finally
         {
             cmd.Connection.Close();
             ts.Dispose();
         }
     }
 }