Beispiel #1
0
 /// <summary>
 /// Updates an existing session record
 /// </summary>
 /// <param name="session">
 /// The session to update
 /// </param>
 /// <returns>
 /// The updated session record
 /// </returns>
 public Session UpdateSession(Session session)
 {
     Execute(
     "UPDATE Session SET " +
        "TotalLength = @p1, " +
        "RestoreLength = @p2, " +
        "State = @p3, " +
        "Flags = @p4, " +
        "RateLimit = @p5 " +
     "WHERE ID = @p0;",
     session.ID,
     session.TotalLength,
     session.RestoreLength,
     session.State,
     session.Flags,
     session.RateLimit
      );
      return session;
 }
Beispiel #2
0
 /// <summary>
 /// Searches for a path map record for a source node
 /// </summary>
 /// <param name="session">
 /// The restore session containing the path map
 /// </param>
 /// <param name="nodeID">
 /// The source backup node to map
 /// </param>
 /// <returns>
 /// The requested path map if found
 /// Null otherwise
 /// </returns>
 public PathMap LookupPathMap(Session session, Int32 nodeID)
 {
     return Fetch(
     "SELECT " +
        "ID, " +
        "Path " +
     "FROM PathMap " +
     "WHERE SessionID = @p0 " +
           "AND NodeID = @p1;",
     new Object[] { session.ID, nodeID },
     reader => new PathMap()
     {
        ID = Convert.ToInt32(reader[0]),
        Session = session,
        NodeID = nodeID,
        Path = Convert.ToString(reader[1])
     }
      );
 }
Beispiel #3
0
 /// <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;
     }
      );
 }
Beispiel #4
0
 /// <summary>
 /// Retrieves all retrieval records associated with a restore session
 /// </summary>
 /// <param name="session">
 /// The restore session to query
 /// </param>
 /// <returns>
 /// The enumeration of retrievals
 /// </returns>
 public IEnumerable<Retrieval> ListRetrievals(Session session)
 {
     return Enumerate(
     "SELECT " +
        "ID, " +
        "Blob, " +
        "Name, " +
        "Offset, " +
        "Length " +
     "FROM Retrieval " +
     "WHERE SessionID = @p0 " +
     "ORDER BY ID;",
     new Object[] { session.ID },
     reader => new Retrieval()
     {
        ID = Convert.ToInt32(reader[0]),
        Session = session,
        Blob = Convert.ToString(reader[1]),
        Name = (!reader.IsDBNull(2)) ? Convert.ToString(reader[2]) : null,
        Offset = Convert.ToInt64(reader[3]),
        Length = Convert.ToInt64(reader[4])
     }
      );
 }
Beispiel #5
0
 /// <summary>
 /// Inserts a new session record
 /// </summary>
 /// <param name="session">
 /// The session to insert
 /// </param>
 /// <returns>
 /// The inserted session, including the generated primary key
 /// </returns>
 public Session InsertSession(Session session)
 {
     Execute(
     "INSERT INTO Session (" +
        "TotalLength, " +
        "RestoreLength, " +
        "State, " +
        "Flags, " +
        "RateLimit, " +
        "Created) " +
     "VALUES (@p0, @p1, @p2, @p3, @p4, @p5);",
     session.TotalLength,
     session.RestoreLength,
     session.State,
     session.Flags,
     session.RateLimit,
     session.Created = DateTime.UtcNow
      );
      session.ID = GetLastRowID();
      return session;
 }
Beispiel #6
0
 /// <summary>
 /// Deletes an existing session
 /// </summary>
 /// <param name="session">
 /// The session to delete
 /// </param>
 public void DeleteSession(Session session)
 {
     Execute(
     "DELETE FROM Session WHERE ID = @p0;",
     session.ID
      );
 }