/// <summary> /// Initializes a new instance of the 'CommandKeyEventArgs' class. /// </summary> public ExecuteCommandEventArgs(ExecuteCommandType executeCommandType) { ExecuteCommandType = executeCommandType; }
/// <summary> /// Initializes a new instance of the 'ExecuteCommandBaseEventArgs' class. /// </summary> public ExecuteCommandBaseEventArgs() { mExecuteCommandType = ExecuteCommandType.None; }
/// <summary> /// Exectue the Command Type. /// </summary> /// <param name="executeCommandType">Command Type.</param> /// <param name="args">Command Arguments</param> public virtual void ExecuteCommand(ExecuteCommandType executeCommandType, params object[] args) { ProcessExecuteCommand(this,new ExecuteCommandEventArgs(executeCommandType)); //HandleScenarioExecuteCommand(null, new ExecuteCommandEventArgs(executeCommandType)); }
/// <summary> /// Initializes a new instance of the 'ExecuteCommandBaseEventArgs' class. /// </summary> public ExecuteCommandBaseEventArgs() { mExecuteCommandType= ExecuteCommandType.None; }
/// <summary> /// This method executes stored procedures. /// </summary> /// <param name="procName">Procedure name</param> /// <param name="paramValues">Multi-dimensional array that describes the input parameters. /// Each parameter must have at least a parameter name (String) and a value (Object) in its second dimension. /// You can also specify "true" for an output parameter but this is not required for input parameters</param> /// <param name="outputParameters">This multi-dimensional array will contain the output parameters, in the format /// { "@Name" (String), value (Object) }. This array will also contain a return value if present, with the "@@Return" name</param> /// <returns>Returns any resulting rows as an array of DynamicEntity objects</returns> public DynamicEntity[] Execute(String procName, ExecuteCommandType commandType, Object[,] paramValues, ref Object[,] outputParameters) { List <DynamicEntity> results = new List <DynamicEntity>(); using (SqlCommand cmd = new SqlCommand(procName, m_Connection)) { cmd.CommandType = (System.Data.CommandType)Enum.Parse(typeof(System.Data.CommandType), Enum.GetName(typeof(ExecuteCommandType), commandType)); if (m_Connection.State == ConnectionState.Closed) { m_Connection.Open(); } List <SqlParameter> output = new List <SqlParameter>(); if (null != paramValues) { for (int i = 0; i < paramValues.GetLength(0); ++i) { if (null != paramValues[i, 0]) { String name = paramValues[i, 0].ToString(); SqlParameter param = new SqlParameter( name.StartsWith("@") ? name : "@" + name, paramValues[i, 1] ); param.Direction = ParameterDirection.Input; for (int j = 2; j < paramValues.GetLength(1); ++j) { if ((paramValues[i, j] as Boolean?) != null) { param.Direction = (bool)paramValues[i, j] ? ParameterDirection.Output : ParameterDirection.Input; } else if ((paramValues[i, j] as Int32?) != null) { param.Size = (int)paramValues[i, j]; } } if (param.Direction == ParameterDirection.Output) { output.Add(param); } cmd.Parameters.Add(param); } } } using (SqlDataReader reader = cmd.ExecuteReader(m_OwnsConnection ? CommandBehavior.CloseConnection : CommandBehavior.Default)) { EntityDbField[] fields = new EntityDbField[reader.FieldCount]; for (int i = 0; i < reader.FieldCount; ++i) { fields[i] = new EntityDbField( reader.GetName(i), SqlDbType.Variant, null); } while (reader.Read()) { DynamicEntity entity = new DynamicEntity(fields); for (int i = 0; i < reader.FieldCount; ++i) { entity.SetValueForDbField(fields[i], reader.GetValue(i)); } results.Add(entity); } reader.Close(); } outputParameters = new Object[output.Count, 2]; for (int j = 0; j < output.Count; ++j) { outputParameters[j, 0] = output[j].ParameterName.Replace("@", ""); outputParameters[j, 1] = output[j].Value; } } return(results.ToArray()); }
public DynamicEntity[] Execute(String procName, ExecuteCommandType commandType, Object[,] paramValues) { Object[,] output = null; return(Execute(procName, commandType, paramValues, ref output)); }