public static User Select(IDbConnection dbConn, String login) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_LOGIN; DbUtil.AddParameter(command, "@login", login); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new User(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static AllowedQueue Select(IDbConnection dbConn, User user, Queue queue) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_USER_QUEUE_ID; DbUtil.AddParameter(command, "@queue_id", queue.Id); DbUtil.AddParameter(command, "@user_id", user.Id); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new AllowedQueue(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static IList <WorkItemData> SelectAll(IDbConnection dbConn, int workItemId) { IDataReader reader = null; var tmp = new List <WorkItemData>(); try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_WORK_ITEM_ID; DbUtil.AddParameter(command, "@item_id", workItemId); reader = command.ExecuteReader(); if (reader == null) { return(tmp); } while (reader.Read()) { tmp.Add(new WorkItemData(reader)); } return(tmp); } finally { DbUtil.ReallyClose(reader); } }
public static Queue Select(IDbConnection dbConn, int queueId) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_ID; DbUtil.AddParameter(command, "@queue_id", queueId); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new Queue(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static WorkItemAccess Select(IDbConnection dbConn, int workItemId, int userId) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_ITEM_USER_ID; DbUtil.AddParameter(command, "@item_id", workItemId); DbUtil.AddParameter(command, "@user_id", userId); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new WorkItemAccess(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static WorkItemData Select(IDbConnection dbConn, int dataId) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_DATA_ID; DbUtil.AddParameter(command, "@data_id", dataId); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new WorkItemData(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static Step Select(IDbConnection dbConn, String name, int mapId) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_NAME_MAP; DbUtil.AddParameter(command, "@name", name); DbUtil.AddParameter(command, "@map_id", mapId); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new Step(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static Step Select(IDbConnection dbConn, int stepId) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_ID; DbUtil.AddParameter(command, "@step_id", stepId); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new Step(reader)); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } finally { DbUtil.ReallyClose(reader); } }
public static Map Select(IDbConnection dbConn, String name) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_NAME; DbUtil.AddParameter(command, "@name", name); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new Map(reader)); // Note: this assumes that we only every want the one with the // max version. If that stops being true, we will need an // overload that specifies the version. } finally { DbUtil.ReallyClose(reader); } }
/// <summary> /// Find all the rules hanging of a specified step, in order /// </summary> /// <returns>The select.</returns> /// <param name="dbconn">connection to database</param> /// <param name="step">The step</param> public static IList <Rule> Select(IDbConnection dbConn, Step step) { var tmp = new List <Rule>(); IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_STEP_ID; DbUtil.AddParameter(command, "@step_id", step.Id); reader = command.ExecuteReader(); if (reader == null) { return(null); } while (reader.Read()) { tmp.Add(new Rule(reader)); } return(tmp); } finally { DbUtil.ReallyClose(reader); } }
// TODO: spec overloads this method with ranges. // which is a good idea as opposed to the quick- // and-dirty "slurp" method written below. public static IList <WorkItem> SelectByPriority(IDbConnection dbConn, Queue queue) { IDataReader reader = null; List <WorkItem> tmp = new List <WorkItem>(); try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_QUEUE_PRIORITY; DbUtil.AddParameter(command, "@queue_id", queue.Id); DbUtil.AddParameter(command, "@available", (int)WorkItemState.Available); reader = command.ExecuteReader(); if (reader == null) { return(null); } while (reader.Read()) { tmp.Add(new WorkItem(reader)); } return(tmp); } finally { DbUtil.ReallyClose(reader); } }
public static WorkItem Select(IDbConnection dbConn, String name) { IDataReader reader = null; try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_NAME; DbUtil.AddParameter(command, "@name", name); reader = command.ExecuteReader(); if (reader == null) { return(null); } if (!reader.Read()) { return(null); } return(new WorkItem(reader)); } finally { DbUtil.ReallyClose(reader); } }
public static IList <Session> SelectAll(IDbConnection dbConn , User user ) { IDataReader reader = null; IList <Session> tmp = new List <Session>(); try { IDbCommand command = dbConn.CreateCommand(); command.CommandText = SELECT_BY_USER_ID; DbUtil.AddParameter(command, "@user_id", user.Id); reader = command.ExecuteReader(); if (reader == null) { return(null); } while (reader.Read()) { tmp.Add(new Session(reader)); } } finally { DbUtil.ReallyClose(reader); } return(tmp); }