public Task <DataTable> GetData( CodeTorch.Core.DataConnection connection, CodeTorch.Core.DataCommand dataCommand, List <CodeTorch.Core.ScreenDataCommandParameter> parameters, string commandText, Action <DataTable> successAction, Action <Exception> errorAction ) { return(GetDataTable(connection, dataCommand, parameters, commandText, successAction, errorAction)); }
public Task <object> ExecuteCommand( CodeTorch.Core.DataConnection connection, CodeTorch.Core.DataCommand dataCommand, List <CodeTorch.Core.ScreenDataCommandParameter> parameters, string commandText, Action <DataTable> successAction, Action <Exception> errorAction ) { return(Exec(connection, dataCommand, parameters, commandText)); }
public Task <XDocument> GetXmlData( CodeTorch.Core.DataConnection connection, CodeTorch.Core.DataCommand dataCommand, List <CodeTorch.Core.ScreenDataCommandParameter> parameters, string commandText, Action <DataTable> successAction, Action <Exception> errorAction ) { // TODO: Implement this method throw new NotImplementedException(); }
public void RefreshSchema(CodeTorch.Core.DataConnection connection, CodeTorch.Core.DataCommand dataCommand) { // TODO: Implement this method // throw new NotImplementedException(); }
public DataColumnCollection InferDataCommandResultsetColumns(DataConnection connection, CodeTorch.Core.DataCommand cmd) { var emptyDT = new DataTable(); /* DataTable data; * Database db = CreateDatabase(connection); * StringBuilder SQL = new StringBuilder(); * * SQL.AppendLine("SET FMTONLY ON "); * string sep = ""; * * if (cmd.Type.ToString().ToLower() == "storedprocedure") * { * SQL.Append("EXEC "); * } * SQL.Append(cmd.Text); * SQL.Append(" "); * * if (cmd.Type.ToString().ToLower() == "storedprocedure") * { * foreach (CodeTorch.Core.DataCommandParameter p in cmd.Parameters) * { * if (!p.IsUserDefinedType) * { * SQL.AppendFormat("{0} {1}=null", sep, p.Name); * sep = ","; * } * } * } * SQL.AppendLine(); * SQL.AppendLine("SET FMTONLY OFF "); * * //create command and specify stored procedure name * DbCommand command = db.GetSqlStringCommand(SQL.ToString()); * * // specify stored procedure parameters * if (cmd.Type.ToString().ToLower() == "text") * { * foreach (CodeTorch.Core.DataCommandParameter p in cmd.Parameters) * { * db.AddInParameter(command, p.Name, DbType.String, DBNull.Value); * } * } * * * //execute command * data = ExecuteDataTable(db, null, command); * * return data.Columns;*/ return(emptyDT.Columns); }
public void RefreshSchema(DataConnection connection, CodeTorch.Core.DataCommand command) { RefreshSchemaDetails(connection, command); }
private void RefreshSchemaDetails(DataConnection connection, CodeTorch.Core.DataCommand command) { switch (command.Type.ToString().ToLower()) { case "storedprocedure": //get parameters DataTable paramDT = GetStoredProcedureParameters(connection, null, command.Text); command.Parameters.Clear(); foreach (DataRow p in paramDT.Rows) { CodeTorch.Core.DataCommandParameter param = new CodeTorch.Core.DataCommandParameter(); param.Name = p["ParameterName"].ToString(); param.Size = Convert.ToInt32(p["length"]); param.Type = GetParameterTypeFromDBType(p["ParameterDBType"].ToString(), Convert.ToBoolean(p["is_user_defined"]), Convert.ToBoolean(p["is_table_type"])); param.Direction = GetParameterDirectionFromDB(Convert.ToBoolean(p["IsOutParam"])); param.TypeName = p["ParameterDBType"].ToString(); param.IsUserDefinedType = Convert.ToBoolean(p["is_user_defined"]); param.IsTableType = Convert.ToBoolean(p["is_table_type"]); command.Parameters.Add(param); } break; case "text": string[] paramTokens = command.Text.Split('@'); if (paramTokens.Length > 0) { List <string> paramlist = new List <string>(); for (int paramIndex = 1; paramIndex < paramTokens.Length; paramIndex++) { string temp = paramTokens[paramIndex]; int paramEndIndex = temp.Length - 1; for (int i = 0; i < temp.Length; i++) { bool IsValidChar = false; //if character is letter or digit if (Char.IsLetterOrDigit(temp[i])) { IsValidChar = true; } //if character is @ if (temp[i] == '@') { IsValidChar = true; } if (temp[i] == '$') { IsValidChar = true; } if (temp[i] == '#') { IsValidChar = true; } if (temp[i] == '_') { IsValidChar = true; } if (!IsValidChar) { paramEndIndex = (i - 1); break; } } string paramitem = string.Empty; //int paramEndIndex = paramTokens[paramIndex].IndexOf(' '); //if (paramEndIndex > 0) //{ // paramitem = paramTokens[paramIndex].Substring(0, paramEndIndex); //} //else //{ // paramitem = paramTokens[paramIndex]; //} paramitem = paramTokens[paramIndex].Substring(0, paramEndIndex + 1); if (!paramlist.Contains("@" + paramitem)) { paramlist.Add("@" + paramitem); } } command.Parameters.Clear(); foreach (string paramItem in paramlist) { CodeTorch.Core.DataCommandParameter param = new CodeTorch.Core.DataCommandParameter(); param.Name = paramItem; param.Size = 200; param.Type = DataCommandParameterType.String; param.Direction = DataCommandParameterDirection.In; //param - reset dirty flag command.Parameters.Add(param); } } break; } if (command.ReturnType.ToString().ToLower() == "datatable") { DataColumnCollection columns = this.InferDataCommandResultsetColumns(connection, command); command.Columns.Clear(); foreach (DataColumn col in columns) { CodeTorch.Core.DataCommandColumn column = new CodeTorch.Core.DataCommandColumn(); column.Name = col.ColumnName; column.Type = col.DataType.Name; command.Columns.Add(column); } } }
public DataColumnCollection InferDataCommandResultsetColumns(DataConnection connection, CodeTorch.Core.DataCommand cmd) { DataTable data; Database db = CreateDatabase(connection); StringBuilder SQL = new StringBuilder(); SQL.AppendLine("SET FMTONLY ON "); string sep = ""; if (cmd.Type.ToString().ToLower() == "storedprocedure") { SQL.Append("EXEC "); } SQL.Append(cmd.Text); SQL.Append(" "); if (cmd.Type.ToString().ToLower() == "storedprocedure") { foreach (CodeTorch.Core.DataCommandParameter p in cmd.Parameters) { if (!p.IsUserDefinedType) { SQL.AppendFormat("{0} {1}=null", sep, p.Name); sep = ","; } } } SQL.AppendLine(); SQL.AppendLine("SET FMTONLY OFF "); //create command and specify stored procedure name DbCommand command = db.GetSqlStringCommand(SQL.ToString()); // specify stored procedure parameters if (cmd.Type.ToString().ToLower() == "text") { foreach (CodeTorch.Core.DataCommandParameter p in cmd.Parameters) { db.AddInParameter(command, p.Name, DbType.String, DBNull.Value); } } //execute command data = ExecuteDataTable(db, null, command); return(data.Columns); }
private DataTable GetData(System.Data.Common.DbTransaction tran, string CommandName, string WorkflowCode, string FromWorkflowStepCode, string ToWorkflowStepCode, string EntityID, string Comment, string UserName, string WorkflowCodeParameter, string FromWorkflowStepCodeParameter, string ToWorkflowStepCodeParameter, string EntityIDParameter, string CommentParameter, string UsernameParameter ) { DataCommandService dataCommandDB = DataCommandService.GetInstance(); List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter parameter = null; DataCommand command = DataCommand.GetDataCommand(CommandName); if (command == null) { throw new ApplicationException(String.Format("DataCommand {0} could not be found in configuration", CommandName)); } if (!String.IsNullOrEmpty(WorkflowCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = WorkflowCodeParameter; parameter.Value = WorkflowCode; parameters.Add(parameter); } if (!String.IsNullOrEmpty(FromWorkflowStepCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = FromWorkflowStepCodeParameter; parameter.Value = FromWorkflowStepCode; parameters.Add(parameter); } if (!String.IsNullOrEmpty(ToWorkflowStepCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = ToWorkflowStepCodeParameter; parameter.Value = ToWorkflowStepCode; parameters.Add(parameter); } if (!String.IsNullOrEmpty(EntityIDParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = EntityIDParameter; parameter.Value = EntityID; parameters.Add(parameter); } if (!String.IsNullOrEmpty(CommentParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = CommentParameter; parameter.Value = Comment; parameters.Add(parameter); } if (!String.IsNullOrEmpty(UsernameParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = UsernameParameter; parameter.Value = UserName; parameters.Add(parameter); } //execute command with transaction // CommandType type = (command.Type == DataCommandCommandType.StoredProcedure) ? CommandType.StoredProcedure : CommandType.Text; DataTable data = dataCommandDB.GetData(tran, command, parameters, command.Text); return(data); }
public override void Execute(System.Data.Common.DbTransaction tran, string WorkflowCode, string FromWorkflowStepCode, string ToWorkflowStepCode, string EntityID, string Comment, string UserName) { //base.Execute(tran); DataCommandService dataCommandDB = DataCommandService.GetInstance(); DataCommand command = DataCommand.GetDataCommand(this.ExecuteCommand); if (command == null) { throw new ApplicationException(String.Format("DataCommand {0} could not be found in configuration", this.ExecuteCommand)); } List <ScreenDataCommandParameter> parameters = new List <ScreenDataCommandParameter>(); ScreenDataCommandParameter parameter = null; if (!String.IsNullOrEmpty(this.WorkflowCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = this.WorkflowCodeParameter; parameter.Value = WorkflowCode; parameters.Add(parameter); } if (!String.IsNullOrEmpty(this.FromWorkflowStepCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = this.FromWorkflowStepCodeParameter; parameter.Value = FromWorkflowStepCode; parameters.Add(parameter); } if (!String.IsNullOrEmpty(this.ToWorkflowStepCodeParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = this.ToWorkflowStepCodeParameter; parameter.Value = ToWorkflowStepCode; parameters.Add(parameter); } if (!String.IsNullOrEmpty(this.EntityIDParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = this.EntityIDParameter; parameter.Value = EntityID; parameters.Add(parameter); } if (!String.IsNullOrEmpty(this.CommentParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = this.CommentParameter; parameter.Value = Comment; parameters.Add(parameter); } if (!String.IsNullOrEmpty(this.UsernameParameter)) { parameter = new ScreenDataCommandParameter(); parameter.Name = this.UsernameParameter; parameter.Value = UserName; parameters.Add(parameter); } //execute command with transaction //CommandType type = (command.Type == DataCommandCommandType.StoredProcedure) ? CommandType.StoredProcedure : CommandType.Text; object retVal = dataCommandDB.ExecuteCommand(tran, command, parameters, command.Text); }