/// <summary> /// Selects the archive source online to list. /// </summary> /// <returns>The archive source online to list.</returns> public IList<ArchiveSource> SelectArchiveSourceOnlineToList() { string query = "SELECT * FROM archivesource WHERE SourceIsOnline = '1'"; var sourceList = new List<ArchiveSource>(); if (this.Connection.State != ConnectionState.Open) { this.OpenConnection(); } MySqlCommand cmd = new MySqlCommand(query, this.Connection); MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { var source = new ArchiveSource(); source.GetArchiveSource(dataReader); sourceList.Add(source); } } dataReader.Close(); this.CloseConnection(); return sourceList; }
/// <summary> /// Selects the archive source by identifier. /// </summary> /// <returns>The archive source by identifier.</returns> /// <param name="sourceId">Source identifier.</param> public ArchiveSource SelectArchiveSourceById(long sourceId) { string query = "SELECT * FROM archivesource WHERE Id = @SourceId"; var source = new ArchiveSource(); if (this.Connection.State != ConnectionState.Open) { this.OpenConnection(); } MySqlCommand cmd = new MySqlCommand(query, this.Connection); cmd.Parameters.AddWithValue("@SourceId", sourceId); MySqlDataReader dataReader = cmd.ExecuteReader(); if (dataReader.HasRows) { while (dataReader.Read()) { source = source.GetArchiveSource(dataReader); } } dataReader.Close(); this.CloseConnection(); return source; }