/// <summary> /// Updates an existing entry record /// </summary> /// <param name="entry"> /// The entry to update /// </param> /// <returns> /// The updated entry record /// </returns> public Entry UpdateEntry(Entry entry) { Execute( "UPDATE Entry SET " + "BackupEntryID = @p1, " + "SessionID = @p2, " + "RetrievalID = @p3, " + "State = @p4, " + "Offset = @p5, " + "Length = @p6 " + "WHERE ID = @p0;", entry.ID, entry.BackupEntryID, entry.Session.ID, (entry.Retrieval != null) ? entry.Retrieval.ID : (Object)null, Convert.ToInt32(entry.State), entry.Offset, entry.Length ); return entry; }
/// <summary> /// Inserts a new entry record /// </summary> /// <param name="entry"> /// The entry to insert /// </param> /// <returns> /// The inserted entry, including the generated primary key /// </returns> public Entry InsertEntry(Entry entry) { Execute( "INSERT INTO Entry (" + "BackupEntryID, " + "SessionID, " + "RetrievalID, " + "State, " + "Offset, " + "Length) " + "VALUES (@p0, @p1, @p2, @p3, @p4, @p5);", entry.BackupEntryID, entry.Session.ID, (entry.Retrieval != null) ? entry.Retrieval.ID : (Object)null, Convert.ToInt32(entry.State), entry.Offset, entry.Length ); return entry; }
/// <summary> /// Searches for the next pending entry record /// </summary> /// <param name="session"> /// The session to query /// </param> /// <returns> /// The next entry record with a status of pending, if any /// Null otherwise /// </returns> public Entry LookupNextEntry(Session session) { return Fetch( "SELECT " + "ID, " + "BackupEntryID, " + "RetrievalID, " + "State, " + "Offset, " + "Length " + "FROM Entry " + "WHERE SessionID = @p0 " + "AND State = @p1 " + "ORDER BY RetrievalID, Offset " + "LIMIT 1;", new Object[] { session.ID, EntryState.Pending }, reader => { var entry = new Entry() { ID = Convert.ToInt32(reader[0]), BackupEntryID = Convert.ToInt32(reader[1]), Session = session, Retrieval = (!reader.IsDBNull(2)) ? FetchRetrieval(Convert.ToInt32(reader[2])) : null, State = (EntryState)Convert.ToInt32(reader[3]), Offset = Convert.ToInt64(reader[4]), Length = Convert.ToInt64(reader[5]) }; if (entry.Retrieval != null) entry.Retrieval.Session = session; return entry; } ); }
/// <summary> /// Deletes an existing entry /// </summary> /// <param name="entry"> /// The entry to delete /// </param> public void DeleteEntry(Entry entry) { Execute( "DELETE FROM Entry WHERE ID = @p0;", entry.ID ); }