protected override void ExcuteCommand() { if (string.IsNullOrEmpty(this.CommandText)) { throw new ArgumentNullException("CommandText"); } string[] cmd = CommandText.Split('|'); if (cmd.Length < 2) { throw new CommandParametersException("CommandText Less than two parameters"); } else if ((cmd[0].ToLower()) != "close") { throw new CommandParametersException("The command is not 'Close'"); } try { Process[] processes = Process.GetProcesses(); foreach (Process p in processes) { if (p.ProcessName.ToLower() == cmd[1].ToLower()) { p.Kill(); } } } catch { throw; } }
protected override void ExcuteCommand() { if (string.IsNullOrEmpty(this.CommandText)) { throw new ArgumentNullException("CommandText"); } string[] cmd = CommandText.Split('|'); if (cmd.Length < 2) { throw new CommandParametersException("CommandText Less than two parameters"); } else if ((cmd[0].ToLower()) != "open") { throw new CommandParametersException("The command is not 'Open'"); } try { if (cmd.Length < 3) { Process.Start(cmd[1]); } else { Process.Start(cmd[1], cmd[2]); } } catch { throw; } }
protected override void ExcuteCommand() { if (string.IsNullOrEmpty(this.CommandText)) { throw new ArgumentNullException("CommandText"); } string[] cmd = CommandText.Split('|'); if (cmd.Length < 4) { throw new CommandParametersException("CommandText Less than four parameters"); } else if ((cmd[0].ToLower()) != "at") { throw new CommandParametersException("The command is not 'At'"); } try { } catch { throw; } }
private void SplitMultipleCommands() { var commands = CommandText.Split(new[] { SplitCommandsToken }, StringSplitOptions.RemoveEmptyEntries).Where(x => !IsNullOrWhiteSpace(x)).ToArray(); if (commands.Length <= 0) { return; } for (int index = 0, total = commands.Length - 1; index < total; index++) { CommandText = commands[index]; HandleExecuteScalar(); ExecuteNonQuery(); } CommandText = commands[commands.Length - 1]; }
/// <summary> /// /// </summary> protected virtual void InternalExecute() { var command = GetSqlCommand(); var commandTexts = CommandText.Split(Separator, StringSplitOptions.RemoveEmptyEntries); foreach (var commandText in commandTexts) { if (string.IsNullOrEmpty(commandText)) { continue; } command.CommandText = commandText; command.ExecuteNonQuery(); } Transaction.Commit(); command.Connection?.Close(); command.Dispose(); }
internal async Task <DbDataReader> ExecuteReaderAsync(CommandBehavior behavior, IOBehavior ioBehavior, CancellationToken cancellationToken) { // MyCAT: Split statements var statements = CommandText.Split(';'); if (statements.Count() <= 1) { return(await m_commandExecutor.ExecuteReaderAsync(CommandText, m_parameterCollection, behavior, ioBehavior, cancellationToken).ConfigureAwait(false)); } else { for (var i = 0; i < statements.Count(); i++) { var reader = await m_commandExecutor.ExecuteReaderAsync(statements[i], m_parameterCollection, behavior, ioBehavior, cancellationToken).ConfigureAwait(false); if (i == statements.Count() - 1) { return(reader); } } } return(null); }
private Boolean CheckFunctionNeedsColumnDefinitionList() { // If and only if a function returns "record" and has no OUT ("o" in proargmodes), INOUT ("b"), or TABLE // ("t") return arguments to characterize the result columns, we must provide a column definition list. // See http://pgfoundry.org/forum/forum.php?thread_id=1075&forum_id=519 // We would use our Output and InputOutput parameters to construct that column definition list. If we have // no such parameters, skip the check: we could only construct "AS ()", which yields a syntax error. // Updated after 0.99.3 to support the optional existence of a name qualifying schema and allow for case insensitivity // when the schema or procedure name do not contain a quote. // The hard-coded schema name 'public' was replaced with code that uses schema as a qualifier, only if it is provided. String returnRecordQuery; StringBuilder parameterTypes = new StringBuilder(""); // Process parameters Boolean seenDef = false; foreach (NpgsqlParameter p in Parameters) { if ((p.Direction == ParameterDirection.Input) || (p.Direction == ParameterDirection.InputOutput)) { parameterTypes.Append(Connection.Connector.OidToNameMapping[p.TypeInfo.Name].OID.ToString() + " "); } if ((p.Direction == ParameterDirection.Output) || (p.Direction == ParameterDirection.InputOutput)) { seenDef = true; } } if (!seenDef) { return(false); } // Process schema name. String schemaName = String.Empty; String procedureName = String.Empty; String[] fullName = CommandText.Split('.'); String predicate = "prorettype = ( select oid from pg_type where typname = 'record' ) " + "and proargtypes=:proargtypes and proname=:proname " // proargmodes && array['o','b','t']::"char"[] performs just as well, but it requires PostgreSQL 8.2. + "and ('o' = any (proargmodes) OR 'b' = any (proargmodes) OR 't' = any (proargmodes)) is not true"; if (fullName.Length == 2) { returnRecordQuery = "select count(*) > 0 from pg_proc p left join pg_namespace n on p.pronamespace = n.oid where " + predicate + " and n.nspname=:nspname"; schemaName = (fullName[0].IndexOf("\"") != -1) ? fullName[0] : fullName[0].ToLower(); procedureName = (fullName[1].IndexOf("\"") != -1) ? fullName[1] : fullName[1].ToLower(); } else { // Instead of defaulting don't use the nspname, as an alternative, query pg_proc and pg_namespace to try and determine the nspname. //schemaName = "public"; // This was removed after build 0.99.3 because the assumption that a function is in public is often incorrect. returnRecordQuery = "select count(*) > 0 from pg_proc p where " + predicate; procedureName = (CommandText.IndexOf("\"") != -1) ? CommandText : CommandText.ToLower(); } bool ret; using (NpgsqlCommand c = new NpgsqlCommand(returnRecordQuery, Connection)) { c.Parameters.Add(new NpgsqlParameter("proargtypes", NpgsqlDbType.Oidvector)); c.Parameters.Add(new NpgsqlParameter("proname", NpgsqlDbType.Name)); c.Parameters[0].Value = parameterTypes.ToString(); c.Parameters[1].Value = procedureName; if (schemaName != null && schemaName.Length > 0) { c.Parameters.Add(new NpgsqlParameter("nspname", NpgsqlDbType.Name)); c.Parameters[2].Value = schemaName; } ret = (Boolean)c.ExecuteScalar(); } return(ret); }
protected override void ExcuteCommand() { if (string.IsNullOrEmpty(this.CommandText)) { throw new ArgumentNullException("CommandText"); } string[] cmd = CommandText.Split('|'); if (cmd.Length < 2) { throw new CommandParametersException("CommandText Less than 2 parameters"); } else { switch (cmd[0].ToLower()) { case "mousemove": mouseEvent(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mouseadmove": System.Drawing.Point p = System.Windows.Forms.Cursor.Position; int index = 0; index = cmd[1].IndexOf(','); if (index > 0) { try { int x = int.Parse(cmd[1].Substring(0, index)); int y = int.Parse(cmd[1].Substring(index + 1)); mouse_event(MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE, (p.X + x) * 65535 / ScreenWidth, (p.Y + y) * 65535 / ScreenHeight, 0, 0); } catch { throw; } } break; case "mouselbdown": mouseEvent(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mouserbdown": mouseEvent(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mouselbup": mouseEvent(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mouserbup": mouseEvent(MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mouselbpress": mouseEvent(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_ABSOLUTE, cmd[1]); mouseEvent(MOUSEEVENTF_LEFTUP | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mouserbpress": mouseEvent(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_ABSOLUTE, cmd[1]); mouseEvent(MOUSEEVENTF_RIGHTUP | MOUSEEVENTF_ABSOLUTE, cmd[1]); break; case "mousescrollup": mouseEvent(MOUSEEVENTF_WHEEL, cmd[1], WHEEL_DELTA); break; case "mousescrolldown": mouseEvent(MOUSEEVENTF_WHEEL, cmd[1], -WHEEL_DELTA); break; } } }
protected override void ExcuteCommand() { if (string.IsNullOrEmpty(this.CommandText)) { throw new ArgumentNullException("CommandText"); } string[] cmd = CommandText.Split('|'); if (cmd.Length < 2) { throw new CommandParametersException("CommandText Less than 2 parameters"); } else { if (cmd.Length >= 3) { if (int.TryParse(cmd[2], out times) && times != 0) { timer = new Timer(); timer.Elapsed += timer_Elapsed; timer.Interval = 1000; } } try { vk = byte.Parse(cmd[1]); switch (cmd[0].ToLower()) { case "keydown": keyhandel = new DelegateKeyEvent(keyDown); break; case "keyup": keyhandel = new DelegateKeyEvent(keyUp); break; case "keypress": keyhandel = new DelegateKeyEvent(keypress); break; default: throw new CommandParametersException("The command is not right"); } if (timer != null) { timer.Start(); } else { if (keyhandel != null) { keyhandel(vk); } } } catch { throw; } } }