public object Execute(string procedureName, string parameters) { OperationHandler.OnOperating(new OperationArgs(CurrentUser.Id, TableOperation.Execute, ObjectType.StoreProcedure, procedureName, parameters)); if (string.IsNullOrEmpty(procedureName)) { throw new ArgumentNullException("procedureName"); } using (var cnn = connectionManager.WriteConnection) { object param = null; if (!string.IsNullOrEmpty(parameters)) { var obj = JsonConvert.DeserializeObject(parameters) as JObject; param = DynamicParametersBuilder.Build(obj); } var result = SqlMapper.Query(cnn, procedureName, param, null, false, null, System.Data.CommandType.StoredProcedure); OperationHandler.OnOperated(new OperationArgs(CurrentUser.Id, TableOperation.Execute, ObjectType.StoreProcedure, procedureName, parameters, result)); return(result); } }
public object Query(string tableName, string parameters) { OperationHandler.OnOperating(new OperationArgs(CurrentUser.Id, TableOperation.Select, ObjectType.TableOrView, tableName, parameters)); using (var cnn = connectionManager.ReadConnection) { var countSqlSB = new StringBuilder(); var pagination = new Pagination(); var sql = builder.BuildSelectSQL(tableName, parameters, countSqlSB, pagination); var data = SqlMapper.Query(cnn, sql); object result = null; if (countSqlSB.Length > 0) { var count = SqlMapper.Query <int>(cnn, countSqlSB.ToString()).FirstOrDefault(); pagination.count = count; result = new PaginationListViewModel <object>() { items = data, pagination = pagination }; } else { result = data; } OperationHandler.OnOperated(new OperationArgs(CurrentUser.Id, TableOperation.Select, ObjectType.TableOrView, tableName, parameters, result, true)); return(data); } }
public int Delete(string tableName, string parameters) { OperationHandler.OnOperating(new OperationArgs(CurrentUser.Id, TableOperation.Delete, ObjectType.TableOrView, tableName, parameters)); using (var cnn = connectionManager.WriteConnection) { var sql = builder.BuildDeleteSQL(tableName, parameters); var result = SqlMapper.Execute(cnn, sql); OperationHandler.OnOperated(new OperationArgs(CurrentUser.Id, TableOperation.Delete, ObjectType.TableOrView, tableName, parameters, result)); return(result); } }