Parent Directory
|
Revision Log
|
Patch
--- trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs 2013/03/14 19:36:01 157 +++ trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs 2013/03/14 20:26:05 159 @@ -12,6 +12,37 @@ internal class SQLLITE { #region DATABASE DEFINITIONS + + public interface ICHANNEL + { + Int64 oid { get; } + String name { get; } + String channelID { get; } + Int64 channel_number { get; } + String favourite_channel { get; } + String display_name { get; } + } + private class CHANNEL : ICHANNEL + { + public CHANNEL() + { + BaseDatabaseDefinition<CHANNEL>.CreateDefault(this); + } + //public RECORDING_SCHEDULE(SQLiteDataReader r, int index) { BaseDatabaseDefinition<RECORDING_SCHEDULE>.Create(this, r, index); } + + public static void Create(ref CHANNEL instance, SQLiteDataReader r, int index) + { + BaseDatabaseDefinition<CHANNEL>.Create(ref instance, r, index); + } + #region ICHANNEL members + public Int64 oid { get; set; } + public String name { get; set; } + public String channelID { get; set; } + public Int64 channel_number { get; set; } + public String favourite_channel { get; set; } + public String display_name { get; set; } + #endregion + } public interface IRECORDING_SCHEDULE { Int64 oid { get; } @@ -182,6 +213,7 @@ { public const string RECORDING_SCHEDULE = "RECORDING_SCHEDULE"; public const string PROGRAMME = "PROGRAMME"; + public const string CHANNEL = "CHANNEL"; } //public SQLLite() { } @@ -196,6 +228,7 @@ return; } ConnectionTest(); + ReadChannelData(); ReadRecodringScheduleData(); ReadProgrammeData(); OnCreatedInstance(this, new EventArgs()); @@ -214,6 +247,7 @@ private string Database; public List<IPROGRAMME> Programs { get; private set; } public List<IRECORDING_SCHEDULE> Recordings { get; private set; } + public List<ICHANNEL> Channels { get; private set; } #endregion @@ -233,7 +267,7 @@ using (SQLiteConnection con = CreateConnection()) { con.Open(); - string command_text = string.Format("select * from {0};", TABLES.PROGRAMME); + string command_text = string.Format("select * from {0};", TABLES.CHANNEL); gLog.Verbose.Debug.WriteLine("Executing Command: '{0}'", command_text); using (SQLiteCommand cmd = new SQLiteCommand(command_text, con)) { @@ -288,7 +322,47 @@ return false; } } - + private void ReadChannelData() + { + try + { + List<ICHANNEL> channels = new List<ICHANNEL>(); + using (SQLiteConnection con = CreateConnection()) + { + con.Open(); + string command_text = string.Format("select * from {0};", TABLES.CHANNEL); + gLog.Verbose.Debug.WriteLine("Executing Command: '{0}'", command_text); + using (SQLiteCommand cmd = new SQLiteCommand(command_text, con)) + { + using (SQLiteDataReader r = cmd.ExecuteReader()) + { + if (!r.HasRows) + { + gLog.Warn.WriteLine("Query: '{0}' returned no rows.", cmd.CommandText); + } + else + { + while (r.Read()) + { + CHANNEL channel = new CHANNEL(); + for (int i = 0; i < r.FieldCount; i++) + { + CHANNEL.Create(ref channel, r, i); + } + channels.Add(channel); + } + } + } + } + con.Clone(); + } + this.Channels = channels; + } + catch (Exception ex) + { + gLog.Error.WriteLine(ex.ToString()); + } + } private void ReadProgrammeData() { try @@ -357,7 +431,6 @@ { RECORDING_SCHEDULE.Create(ref recording, r, i); } - recordings.Add(recording); } } @@ -372,5 +445,6 @@ gLog.Error.WriteLine(ex.ToString()); } } + } }
ViewVC Help | |
Powered by ViewVC 1.1.22 |