internal int ExecuteNonQuery() { SqlConnection.ExecutePermission.Demand(); long scopeID = SqlClientEventSource.Log.TryScopeEnterEvent("<sc.SqlCommandSet.ExecuteNonQuery|API> {0}", ObjectID); try { if (Connection.IsContextConnection) { throw SQL.BatchedUpdatesNotAvailableOnContextConnection(); } ValidateCommandBehavior(ADP.ExecuteNonQuery, CommandBehavior.Default); BatchCommand.BatchRPCMode = true; BatchCommand.ClearBatchCommand(); BatchCommand.Parameters.Clear(); for (int ii = 0; ii < _commandList.Count; ii++) { LocalCommand cmd = _commandList[ii]; BatchCommand.AddBatchCommand(cmd.CommandText, cmd.Parameters, cmd.CmdType, cmd.ColumnEncryptionSetting); } return(BatchCommand.ExecuteBatchRPCCommand()); } finally { SqlClientEventSource.Log.TryScopeLeaveEvent(scopeID); } }
internal int ExecuteNonQuery() { SqlConnection.ExecutePermission.Demand(); IntPtr hscp; Bid.ScopeEnter(out hscp, "<sc.SqlCommandSet.ExecuteNonQuery|API> %d#", ObjectID); try { if (Connection.IsContextConnection) { throw SQL.BatchedUpdatesNotAvailableOnContextConnection(); } ValidateCommandBehavior(ADP.ExecuteNonQuery, CommandBehavior.Default); BatchCommand.BatchRPCMode = true; BatchCommand.ClearBatchCommand(); BatchCommand.Parameters.Clear(); for (int ii = 0; ii < _commandList.Count; ii++) { LocalCommand cmd = _commandList[ii]; BatchCommand.AddBatchCommand(cmd.CommandText, cmd.Parameters, cmd.CmdType); } return(BatchCommand.ExecuteBatchRPCCommand()); } finally { Bid.ScopeLeave(ref hscp); } }
internal int ExecuteNonQuery() { int num2; IntPtr ptr; SqlConnection.ExecutePermission.Demand(); Bid.ScopeEnter(out ptr, "<sc.SqlCommandSet.ExecuteNonQuery|API> %d#", this.ObjectID); try { if (this.Connection.IsContextConnection) { throw SQL.BatchedUpdatesNotAvailableOnContextConnection(); } this.ValidateCommandBehavior("ExecuteNonQuery", CommandBehavior.Default); this.BatchCommand.BatchRPCMode = true; this.BatchCommand.ClearBatchCommand(); this.BatchCommand.Parameters.Clear(); for (int i = 0; i < this._commandList.Count; i++) { LocalCommand command = this._commandList[i]; this.BatchCommand.AddBatchCommand(command.CommandText, command.Parameters, command.CmdType); } num2 = this.BatchCommand.ExecuteBatchRPCCommand(); } finally { Bid.ScopeLeave(ref ptr); } return(num2); }
public async Task BasicTest() { var services = CreateServices(); var commander = services.Commander(); var count = 0; (await commander.Call(LocalCommand.New(() => ++ count))).Should().Be(1); count.Should().Be(1); (await commander.Call(LocalCommand.New(async _ => { await Task.Delay(10); return(++count); }))).Should().Be(2); count.Should().Be(2); await commander.Call(LocalCommand.New((Action)(() => ++ count))); count.Should().Be(3); await commander.Call(LocalCommand.New(_ => { ++count; return(Task.CompletedTask); })); count.Should().Be(4); }
private void stopJBossToolStripMenuItem_Click(object sender, EventArgs e) { if (JBossCommand != null) { JBossCommand.TerminateCommand(); JBossCommand = null; } }
private void SendCommandLocal() { var localCommand = new LocalCommand { CommandId = Guid.NewGuid(), }; this.Bus.SendLocal(localCommand); Console.WriteLine("Sent command with Id {0}.", localCommand.CommandId); Console.WriteLine("=========================================================================="); }
internal int ExecuteNonQuery() { int updateCount = 0; for (int i = 0; i < this.m_commandList.Count; i++) { LocalCommand command = m_commandList[i]; } return(updateCount); }
public void ExecuteLocalCommand() { ICommand command = new LocalCommand(new string[] { "foo" }); ValueEnvironment parent = new ValueEnvironment(); ValueEnvironment localenv = new ValueEnvironment(parent, ValueEnvironmentType.Local); ValueEnvironment childenv = new ValueEnvironment(localenv); command.Execute(null, childenv); Assert.IsFalse(childenv.ContainsValue("foo")); Assert.IsFalse(parent.ContainsValue("foo")); Assert.IsTrue(localenv.ContainsValue("foo")); }
public void Handle(MyRequest1 message) { Console.WriteLine("Message1"); using (var tx = new TransactionScope(TransactionScopeOption.RequiresNew)) { var localCommand = new LocalCommand { CommandId = Guid.NewGuid(), }; this.Bus.SendLocal(localCommand); tx.Complete(); } throw new Exception(); }
public void ParseLocalVariables() { Parser parser = new Parser("local foo, bar"); ICommand command = parser.ParseCommand(); Assert.IsNotNull(command); Assert.IsInstanceOfType(command, typeof(LocalCommand)); LocalCommand localcmd = (LocalCommand)command; Assert.AreEqual(2, localcmd.Names.Count); Assert.AreEqual("foo", localcmd.Names.First()); Assert.AreEqual("bar", localcmd.Names.Skip(1).First()); }
internal int ExecuteNonQuery() { ValidateCommandBehavior(nameof(ExecuteNonQuery), CommandBehavior.Default); BatchCommand.BatchRPCMode = true; BatchCommand.ClearBatchCommand(); BatchCommand.Parameters.Clear(); for (int ii = 0; ii < _commandList.Count; ii++) { LocalCommand cmd = _commandList[ii]; BatchCommand.AddBatchCommand(cmd.CommandText, cmd.Parameters, cmd.CmdType, cmd.ColumnEncryptionSetting); } return(BatchCommand.ExecuteBatchRPCCommand()); }
internal int ExecuteNonQuery() { ValidateCommandBehavior(nameof(ExecuteNonQuery), CommandBehavior.Default); using (TryEventScope.Create("SqlCommandSet.ExecuteNonQuery | API | Object Id {0}, Commands executed in Batch RPC mode", ObjectID)) { BatchCommand.BatchRPCMode = true; BatchCommand.ClearBatchCommand(); BatchCommand.Parameters.Clear(); for (int ii = 0; ii < _commandList.Count; ii++) { LocalCommand cmd = _commandList[ii]; BatchCommand.AddBatchCommand(cmd.CommandText, cmd.Parameters, cmd.CmdType, cmd.ColumnEncryptionSetting); } return(BatchCommand.ExecuteBatchRPCCommand()); } }
private void startJBossToolStripMenuItem_Click(object sender, EventArgs e) { if (JBossCommand != null) { MessageBox.Show("JBoss already running!"); return; } this.Cursor = Cursors.WaitCursor; JBossCommand = new LocalCommand(); this.SuspendLayout(); ConnectionTab tab = CreateTab("JBoss", JBossCommand); JBossCommand.ExecuteCommand(Settings.Default.JBossCommand, Settings.Default.JBossCommandArguments, Settings.Default.JBossTerminate, Settings.Default.JBossTerminateArguments); this.ResumeLayout(); this.Cursor = Cursors.Default; }
public static void Main(string[] args) { #if DEBUG if (args.Any(a => string.Equals(a, "--debug", StringComparison.Ordinal))) { args = args.Where(a => !string.Equals(a, "--debug", StringComparison.Ordinal)).ToArray(); Console.WriteLine($"Waiting for debugger. Process ID: {Process.GetCurrentProcess().Id}"); Console.WriteLine("Press ENTER to continue"); Console.ReadLine(); } #endif var app = new CommandLineApplication(); app.Description = "Crank's Revenge"; app.HelpOption("-h|--help"); LocalCommand.Register(app); AgentCommand.Register(app); WorkerCommand.Register(app); ServerCommand.Register(app); app.Command("help", cmd => { var commandArgument = cmd.Argument("<COMMAND>", "The command to get help for."); cmd.OnExecute(() => { app.ShowHelp(commandArgument.Value); return(0); }); }); app.OnExecute(() => { app.ShowHelp(); return(0); }); app.Execute(args); }
private void localTerminalToolStripMenuItem_Click(object sender, EventArgs e) { if (JBossCommand != null) { MessageBox.Show("local terminal already active!"); return; } this.Cursor = Cursors.WaitCursor; LocalTerminalCommand = new LocalCommand(); this.SuspendLayout(); ConnectionTab tab = CreateTab("Local Terminal", LocalTerminalCommand); LocalTerminalCommand.ExecuteCommand(Settings.Default.LocalTerminal); this.ResumeLayout(); this.Cursor = Cursors.Default; LocalTerminalCommand.SendCommand("ls"); }
public async Task ExceptionTest() { var services = CreateServices(); var commander = services.Commander(); var count = 0; count.Should().Be(0); var context = await commander.Run(LocalCommand.New(() => throw new NullReferenceException())); context.UntypedResult.Error !.GetBaseException().Should().BeOfType <NullReferenceException>(); context = await commander.Run(LocalCommand.New(async _ => { await Task.Delay(10); throw new NullReferenceException(); #pragma warning disable 162 return(1); #pragma warning restore 162 })); context.UntypedResult.Error !.GetBaseException().Should().BeOfType <NullReferenceException>(); }
internal int ExecuteNonQuery() { ValidateCommandBehavior(nameof(ExecuteNonQuery), CommandBehavior.Default); long scopeID = SqlClientEventSource.Log.TryScopeEnterEvent("SqlCommandSet.ExecuteNonQuery | API | Object Id {0}, Commands executed in Batch RPC mode", ObjectID); try { BatchCommand.BatchRPCMode = true; BatchCommand.ClearBatchCommand(); BatchCommand.Parameters.Clear(); for (int ii = 0; ii < _commandList.Count; ii++) { LocalCommand cmd = _commandList[ii]; BatchCommand.AddBatchCommand(cmd.CommandText, cmd.Parameters, cmd.CmdType, cmd.ColumnEncryptionSetting); } return(BatchCommand.ExecuteBatchRPCCommand()); } finally { SqlClientEventSource.Log.TryScopeLeaveEvent(scopeID); } }
internal void Append(SqlCommand command) { ADP.CheckArgumentNull(command, nameof(command)); string cmdText = command.CommandText; if (string.IsNullOrEmpty(cmdText)) { throw ADP.CommandTextRequired(nameof(Append)); } CommandType commandType = command.CommandType; switch (commandType) { case CommandType.Text: case CommandType.StoredProcedure: break; case CommandType.TableDirect: throw SQL.NotSupportedCommandType(commandType); default: throw ADP.InvalidCommandType(commandType); } SqlParameterCollection parameters = null; SqlParameterCollection collection = command.Parameters; if (0 < collection.Count) { parameters = new SqlParameterCollection(); // clone parameters so they aren't destroyed for (int i = 0; i < collection.Count; ++i) { SqlParameter p = new SqlParameter(); collection[i].CopyTo(p); parameters.Add(p); // SQL Injection awareness if (!s_sqlIdentifierParser.IsMatch(p.ParameterName)) { throw ADP.BadParameterName(p.ParameterName); } } foreach (SqlParameter p in parameters) { // deep clone the parameter value if byte[] or char[] object obj = p.Value; byte[] byteValues = (obj as byte[]); if (null != byteValues) { int offset = p.Offset; int size = p.Size; int countOfBytes = byteValues.Length - offset; if ((0 != size) && (size < countOfBytes)) { countOfBytes = size; } byte[] copy = new byte[Math.Max(countOfBytes, 0)]; Buffer.BlockCopy(byteValues, offset, copy, 0, copy.Length); p.Offset = 0; p.Value = copy; } else { char[] charValues = (obj as char[]); if (null != charValues) { int offset = p.Offset; int size = p.Size; int countOfChars = charValues.Length - offset; if ((0 != size) && (size < countOfChars)) { countOfChars = size; } char[] copy = new char[Math.Max(countOfChars, 0)]; Buffer.BlockCopy(charValues, offset, copy, 0, copy.Length * 2); p.Offset = 0; p.Value = copy; } else { ICloneable cloneable = (obj as ICloneable); if (null != cloneable) { p.Value = cloneable.Clone(); } } } } } int returnParameterIndex = -1; if (null != parameters) { for (int i = 0; i < parameters.Count; ++i) { if (ParameterDirection.ReturnValue == parameters[i].Direction) { returnParameterIndex = i; break; } } } LocalCommand cmd = new LocalCommand(cmdText, parameters, returnParameterIndex, command.CommandType, command.ColumnEncryptionSetting); CommandList.Add(cmd); }
internal void Append(SqlCommand command) { SqlParameterCollection parameters; int num7; ADP.CheckArgumentNull(command, "command"); Bid.Trace("<sc.SqlCommandSet.Append|API> %d#, command=%d, parameterCount=%d\n", this.ObjectID, command.ObjectID, command.Parameters.Count); string commandText = command.CommandText; if (ADP.IsEmpty(commandText)) { throw ADP.CommandTextRequired("Append"); } CommandType commandType = command.CommandType; switch (commandType) { case CommandType.Text: case CommandType.StoredProcedure: { parameters = null; SqlParameterCollection parameters2 = command.Parameters; if (0 < parameters2.Count) { parameters = new SqlParameterCollection(); for (int i = 0; i < parameters2.Count; i++) { SqlParameter destination = new SqlParameter(); parameters2[i].CopyTo(destination); parameters.Add(destination); if (!SqlIdentifierParser.IsMatch(destination.ParameterName)) { throw ADP.BadParameterName(destination.ParameterName); } } foreach (SqlParameter parameter in parameters) { object obj2 = parameter.Value; byte[] src = obj2 as byte[]; if (src != null) { int offset = parameter.Offset; int size = parameter.Size; int num5 = src.Length - offset; if ((size != 0) && (size < num5)) { num5 = size; } byte[] dst = new byte[Math.Max(num5, 0)]; Buffer.BlockCopy(src, offset, dst, 0, dst.Length); parameter.Offset = 0; parameter.Value = dst; } else { char[] chArray2 = obj2 as char[]; if (chArray2 != null) { int srcOffset = parameter.Offset; int num4 = parameter.Size; int num3 = chArray2.Length - srcOffset; if ((num4 != 0) && (num4 < num3)) { num3 = num4; } char[] chArray = new char[Math.Max(num3, 0)]; Buffer.BlockCopy(chArray2, srcOffset, chArray, 0, chArray.Length * 2); parameter.Offset = 0; parameter.Value = chArray; } else { ICloneable cloneable = obj2 as ICloneable; if (cloneable != null) { parameter.Value = cloneable.Clone(); } } } } } num7 = -1; if (parameters != null) { for (int j = 0; j < parameters.Count; j++) { if (ParameterDirection.ReturnValue == parameters[j].Direction) { num7 = j; break; } } } break; } case CommandType.TableDirect: throw SQL.NotSupportedCommandType(commandType); default: throw ADP.InvalidCommandType(commandType); } LocalCommand item = new LocalCommand(commandText, parameters, num7, command.CommandType); this.CommandList.Add(item); }
internal void Append(SqlCommand command) { ADP.CheckArgumentNull(command, "command"); Bid.Trace("<sc.SqlCommandSet.Append|API> %d#, command=%d, parameterCount=%d\n", ObjectID, command.ObjectID, command.Parameters.Count); string cmdText = command.CommandText; if (ADP.IsEmpty(cmdText)) { throw ADP.CommandTextRequired(ADP.Append); } CommandType commandType = command.CommandType; switch(commandType) { case CommandType.Text: case CommandType.StoredProcedure: break; case CommandType.TableDirect: Debug.Assert(false, "command.CommandType"); throw System.Data.SqlClient.SQL.NotSupportedCommandType(commandType); default: Debug.Assert(false, "command.CommandType"); throw ADP.InvalidCommandType(commandType); } SqlParameterCollection parameters = null; SqlParameterCollection collection = command.Parameters; if (0 < collection.Count) { parameters = new SqlParameterCollection(); // clone parameters so they aren't destroyed for(int i = 0; i < collection.Count; ++i) { SqlParameter p = new SqlParameter(); collection[i].CopyTo(p); parameters.Add(p); // SQL Injection awarene if (!SqlIdentifierParser.IsMatch(p.ParameterName)) { throw ADP.BadParameterName(p.ParameterName); } } foreach(SqlParameter p in parameters) { // deep clone the parameter value if byte[] or char[] object obj = p.Value; byte[] byteValues = (obj as byte[]); if (null != byteValues) { int offset = p.Offset; int size = p.Size; int countOfBytes = byteValues.Length - offset; if ((0 != size) && (size < countOfBytes)) { countOfBytes = size; } byte[] copy = new byte[Math.Max(countOfBytes, 0)]; Buffer.BlockCopy(byteValues, offset, copy, 0, copy.Length); p.Offset = 0; p.Value = copy; } else { char[] charValues = (obj as char[]); if (null != charValues) { int offset = p.Offset; int size = p.Size; int countOfChars = charValues.Length - offset; if ((0 != size) && (size < countOfChars)) { countOfChars = size; } char[] copy = new char[Math.Max(countOfChars, 0)]; Buffer.BlockCopy(charValues, offset, copy, 0, copy.Length*2); p.Offset = 0; p.Value = copy; } else { ICloneable cloneable = (obj as ICloneable); if (null != cloneable) { p.Value = cloneable.Clone(); } } } } } int returnParameterIndex = -1; if (null != parameters) { for(int i = 0; i < parameters.Count; ++i) { if (ParameterDirection.ReturnValue == parameters[i].Direction) { returnParameterIndex = i; break; } } } LocalCommand cmd = new LocalCommand(cmdText, parameters, returnParameterIndex, command.CommandType); CommandList.Add(cmd); }
/// <summary> /// LUA结构支持 /// </summary> /// <returns></returns> public override void GetLuaStruct(StringBuilder code) { base.GetLuaStruct(code); int idx; if (!string.IsNullOrWhiteSpace(Friend)) { code.AppendLine($@"['Friend'] = '{Friend.ToLuaString()}',"); } else { code.AppendLine($@"['Friend'] = nil,"); } code.AppendLine($@"['FriendKey'] ='{FriendKey}',"); code.AppendLine($@"['LocalCommand'] ={(LocalCommand.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(CommandId)) { code.AppendLine($@"['CommandId'] = '{CommandId.ToLuaString()}',"); } else { code.AppendLine($@"['CommandId'] = nil,"); } if (!string.IsNullOrWhiteSpace(NotifyEntity)) { code.AppendLine($@"['NotifyEntity'] = '{NotifyEntity.ToLuaString()}',"); } else { code.AppendLine($@"['NotifyEntity'] = nil,"); } if (!string.IsNullOrWhiteSpace(ClientEntity)) { code.AppendLine($@"['ClientEntity'] = '{ClientEntity.ToLuaString()}',"); } else { code.AppendLine($@"['ClientEntity'] = nil,"); } code.AppendLine($@"['IsCommandResult'] ={(IsCommandResult.ToString().ToLower())},"); code.AppendLine($@"['IsMulit'] ={(IsMulit.ToString().ToLower())},"); if (!string.IsNullOrWhiteSpace(Org)) { code.AppendLine($@"['Org'] = '{Org.ToLuaString()}',"); } else { code.AppendLine($@"['Org'] = nil,"); } if (EsEntity != null) { code.AppendLine($@"['EsEntity'] = {EsEntity.GetLuaStruct()},"); } if (LocalEntity != null) { code.AppendLine($@"['LocalEntity'] = {LocalEntity.GetLuaStruct()},"); } }
public void Append(OracleCommand command) { System.Data.Common.ADP.CheckArgumentNull(command, "command"); if (System.Data.Common.ADP.IsEmpty(command.CommandText)) { throw System.Data.Common.ADP.CommandTextRequired("Append"); } ICollection parameters = command.Parameters; OracleParameter[] array = new OracleParameter[parameters.Count]; parameters.CopyTo(array, 0); string[] parameterNames = new string[array.Length]; if (0 < array.Length) { for (int i = 0; i < array.Length; i++) { parameterNames[i] = array[i].ParameterName; OracleParameter destination = command.CreateParameter(); array[i].CopyTo(destination); object obj2 = destination.Value; if (obj2 is byte[]) { byte[] src = (byte[])obj2; int offset = destination.Offset; int size = destination.Size; int num4 = src.Length - offset; if ((size != 0) && (size < num4)) { num4 = size; } byte[] dst = new byte[Math.Max(num4, 0)]; Buffer.BlockCopy(src, offset, dst, 0, dst.Length); destination.Offset = 0; destination.Value = dst; } else if (obj2 is char[]) { char[] chArray2 = (char[])obj2; int srcOffset = destination.Offset; int num3 = destination.Size; int num2 = chArray2.Length - srcOffset; if ((num3 != 0) && (num3 < num2)) { num2 = num3; } char[] chArray = new char[Math.Max(num2, 0)]; Buffer.BlockCopy(chArray2, srcOffset, chArray, 0, chArray.Length * 2); destination.Offset = 0; destination.Value = chArray; } else if (obj2 is ICloneable) { destination.Value = ((ICloneable)obj2).Clone(); } array[i] = destination; } } string statementText = command.StatementText; bool isQuery = false; LocalParameter[] parameterInsertionPoints = this.ParseText(command, statementText, out isQuery); LocalCommand command2 = new LocalCommand(statementText, isQuery, array, parameterNames, parameterInsertionPoints); this._dirty = true; this.CommandList.Add(command2); }
internal void Append(HsqlCommand command) { HsqlParameterCollection parameters; if (command == null) { throw new ArgumentNullException( "command"); } string commandText = command.CommandText; if (string.IsNullOrEmpty(commandText)) { throw new ArgumentException("Command Text Required", "command.CommandText"); } CommandType commandType = command.CommandType; switch (commandType) { case CommandType.Text: case CommandType.StoredProcedure: { parameters = null; HsqlParameterCollection commandParameters = command.Parameters; int parameterCount = commandParameters.Count; if (parameterCount > 0) { parameters = new HsqlParameterCollection(); for (int i = 0; i < parameterCount; i++) { HsqlParameter destination = commandParameters[i].Clone(); parameters.Add(destination); if (!IdentifierParser.IsMatch(destination .ParameterName)) { throw new HsqlDataSourceException( "Bad Parameter Name", org.hsqldb.Trace.GENERAL_ERROR, "S1000"); } } } break; } case CommandType.TableDirect: { throw new ArgumentOutOfRangeException( "command.CommandType", commandType, "Enumeration Value Not Supported."); } default: { throw new ArgumentOutOfRangeException( "command.CommandType", commandType, "Invalid Enumeration Value"); } } int returnParameterIndex = -1; for (int j = 0; j < parameters.Count; j++) { if (ParameterDirection.ReturnValue == parameters[j].Direction) { returnParameterIndex = j; break; } } LocalCommand item = new LocalCommand( commandText, parameters, returnParameterIndex, commandType); m_commandList.Add(item); }
private void UpdateParameter(ParameterNameChange pnc) { foreach (OctopusLib.Action action in ActionCollection) { foreach (Command command in action.ActionCommands) { switch (command.CommandType) { case RunCommandType.Local: LocalCommand lc = command as LocalCommand; MatchCollection lccmdVars = Regex.Matches(lc.CommandText, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (lccmdVars.Count > 0) { foreach (Match var in lccmdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { lc.CommandText = Regex.Replace(lc.CommandText, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } break; case RunCommandType.Remote: RemoteCommand rc = command as RemoteCommand; MatchCollection rccmdVars = Regex.Matches(rc.CommandText, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (rccmdVars.Count > 0) { foreach (Match var in rccmdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { rc.CommandText = Regex.Replace(rc.CommandText, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } if (!string.IsNullOrEmpty(rc.RemoteRunAsUsername)) { MatchCollection rcrunasusernameVars = Regex.Matches(rc.RemoteRunAsUsername, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (rcrunasusernameVars.Count > 0) { foreach (Match var in rcrunasusernameVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { rc.RemoteRunAsUsername = Regex.Replace(rc.RemoteRunAsUsername, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } } if (!string.IsNullOrEmpty(rc.RemoteRunAsPassword)) { MatchCollection rcrunaspwdVars = Regex.Matches(rc.RemoteRunAsPassword, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (rcrunaspwdVars.Count > 0) { foreach (Match var in rcrunaspwdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { rc.RemoteRunAsPassword = Regex.Replace(rc.RemoteRunAsPassword, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } } if (!string.IsNullOrEmpty(rc.WorkingDirectory)) { MatchCollection rcwdVars = Regex.Matches(rc.WorkingDirectory, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (rcwdVars.Count > 0) { foreach (Match var in rcwdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { rc.WorkingDirectory = Regex.Replace(rc.WorkingDirectory, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } } break; case RunCommandType.LinuxSSH: LinuxSSHCommand lsshc = command as LinuxSSHCommand; MatchCollection lsshccmdVars = Regex.Matches(lsshc.CommandText, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (lsshccmdVars.Count > 0) { foreach (Match var in lsshccmdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { lsshc.CommandText = Regex.Replace(lsshc.CommandText, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } break; case RunCommandType.Copy: CopyCommand cc = command as CopyCommand; if (!string.IsNullOrEmpty(cc.CopySourceDir)) { MatchCollection ccsdVars = Regex.Matches(cc.CopySourceDir, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (ccsdVars.Count > 0) { foreach (Match var in ccsdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { cc.CopySourceDir = Regex.Replace(cc.CopySourceDir, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } } if (!string.IsNullOrEmpty(cc.CopySourceFiles)) { MatchCollection ccsfVars = Regex.Matches(cc.CopySourceFiles, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (ccsfVars.Count > 0) { foreach (Match var in ccsfVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { cc.CopySourceFiles = Regex.Replace(cc.CopySourceFiles, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } } if (!string.IsNullOrEmpty(cc.CopyTargetDir)) { MatchCollection cctdVars = Regex.Matches(cc.CopyTargetDir, @"{%(.+?)%}", RegexOptions.IgnoreCase); if (cctdVars.Count > 0) { foreach (Match var in cctdVars) { string varName = var.Groups[1].Value; if (varName.Equals(pnc.OldValue)) { cc.CopyTargetDir = Regex.Replace(cc.CopyTargetDir, string.Format(@"{{%{0}%}}", pnc.OldValue), string.Format(@"{{%{0}%}}", pnc.NewValue)); } } } } break; } } } }
public void Append(OracleCommand command) { System.Data.Common.ADP.CheckArgumentNull(command, "command"); if (System.Data.Common.ADP.IsEmpty(command.CommandText)) { throw System.Data.Common.ADP.CommandTextRequired("Append"); } ICollection parameters = command.Parameters; OracleParameter[] array = new OracleParameter[parameters.Count]; parameters.CopyTo(array, 0); string[] parameterNames = new string[array.Length]; if (0 < array.Length) { for (int i = 0; i < array.Length; i++) { parameterNames[i] = array[i].ParameterName; OracleParameter destination = command.CreateParameter(); array[i].CopyTo(destination); object obj2 = destination.Value; if (obj2 is byte[]) { byte[] src = (byte[]) obj2; int offset = destination.Offset; int size = destination.Size; int num4 = src.Length - offset; if ((size != 0) && (size < num4)) { num4 = size; } byte[] dst = new byte[Math.Max(num4, 0)]; Buffer.BlockCopy(src, offset, dst, 0, dst.Length); destination.Offset = 0; destination.Value = dst; } else if (obj2 is char[]) { char[] chArray2 = (char[]) obj2; int srcOffset = destination.Offset; int num3 = destination.Size; int num2 = chArray2.Length - srcOffset; if ((num3 != 0) && (num3 < num2)) { num2 = num3; } char[] chArray = new char[Math.Max(num2, 0)]; Buffer.BlockCopy(chArray2, srcOffset, chArray, 0, chArray.Length * 2); destination.Offset = 0; destination.Value = chArray; } else if (obj2 is ICloneable) { destination.Value = ((ICloneable) obj2).Clone(); } array[i] = destination; } } string statementText = command.StatementText; bool isQuery = false; LocalParameter[] parameterInsertionPoints = this.ParseText(command, statementText, out isQuery); LocalCommand command2 = new LocalCommand(statementText, isQuery, array, parameterNames, parameterInsertionPoints); this._dirty = true; this.CommandList.Add(command2); }
internal void Append(HsqlCommand command) { HsqlParameterCollection parameters; if (command == null) { throw new ArgumentNullException( "command"); } string commandText = command.CommandText; if (string.IsNullOrEmpty(commandText)) { throw new ArgumentException("Command Text Required", "command.CommandText"); } CommandType commandType = command.CommandType; switch (commandType) { case CommandType.Text: case CommandType.StoredProcedure: { parameters = null; HsqlParameterCollection commandParameters = command.Parameters; int parameterCount = commandParameters.Count; if (parameterCount > 0) { parameters = new HsqlParameterCollection(); for (int i = 0; i < parameterCount; i++) { HsqlParameter destination = commandParameters[i].Clone(); parameters.Add(destination); if (!IdentifierParser.IsMatch(destination .ParameterName)) { throw new HsqlDataSourceException( "Bad Parameter Name", org.hsqldb.Trace.GENERAL_ERROR,"S1000"); } } } break; } case CommandType.TableDirect: { throw new ArgumentOutOfRangeException( "command.CommandType", commandType, "Enumeration Value Not Supported."); } default: { throw new ArgumentOutOfRangeException( "command.CommandType", commandType, "Invalid Enumeration Value"); } } int returnParameterIndex = -1; for (int j = 0; j < parameters.Count; j++) { if (ParameterDirection.ReturnValue == parameters[j].Direction) { returnParameterIndex = j; break; } } LocalCommand item = new LocalCommand( commandText, parameters, returnParameterIndex, commandType); m_commandList.Add(item); }