Normal
OK. I know now what it doesn't work:[code] private TVDatabase() { } /// <summary> /// static constructor. Opens or creates the tv database from database\TVDatabaseV6.db /// </summary> static TVDatabase() { lock (typeof(TVDatabase)) { try { // Open database Log.Write("opening tvdatabase"); System.IO.Directory.CreateDirectory("database"); //Upgrade(); m_db = new SQLiteClient(@"database\TVDatabaseV9.db"); CreateTables(); if (m_db!=null) { m_db.Execute("PRAGMA cache_size=8192\n"); m_db.Execute("PRAGMA synchronous='OFF'\n"); m_db.Execute("PRAGMA count_changes='OFF'\n"); } } catch (Exception ex) { Log.Write("TVDatabase exception err:{0} stack:{1}", ex.Message,ex.StackTrace); } Log.Write("tvdatabase opened"); } }[/code][code]static public bool GetRecordings(ref ArrayList recordings) { lock (typeof(TVDatabase)) { recordings.Clear(); try { if (null==m_db) return false; string strSQL; strSQL=String.Format("select * from channel,recording where recording.idChannel=channel.idChannel order by iStartTime"); SQLiteResultSet results; results=m_db.Execute(strSQL); if (results.Rows.Count== 0) return false; for (int i=0; i < results.Rows.Count;++i) { long iStart=Int64.Parse(Get(results,i,"recording.iStartTime")); long iEnd=Int64.Parse(Get(results,i,"recording.iEndTime")); TVRecording rec=new TVRecording (); rec.Channel=Get(results,i,"channel.strChannel"); rec.Start=iStart; rec.End=iEnd; rec.Canceled = Int64.Parse(Get(results,i,"recording.iCancelTime")); rec.ID=Int32.Parse(Get(results,i,"recording.idRecording")); rec.Title=Get(results,i,"recording.strProgram"); rec.RecType=(TVRecording.RecordingType)Int32.Parse(Get(results,i,"recording.iRecordingType")); int iContectRec=Int32.Parse(Get(results,i,"recording.bContentRecording")); if (iContectRec==1) rec.IsContentRecording=true; else rec.IsContentRecording=false; recordings.Add(rec); } return true; } catch(SQLiteException ex) { Log.Write("TVDatabase exception err:{0} stack:{1}", ex.Message,ex.StackTrace); } return false; } }[/code]The reasen is that I can't initiate a new TVDatabase, which opens the database:Should be like:Dim tvb As New MediaPortal.TV.Database.TVDatabaseTVDatabase is private!!But I have to insanciate m_db, in order to get it work.Either [USER=10277]frodo[/USER] can change this or I have to program my own SQLite subroutines, but then I don't know if MP supports multi user access.[USER=10277]frodo[/USER] Can you please give me a hint!Thanks!!
OK. I know now what it doesn't work:
[code] private TVDatabase()
{
}
/// <summary>
/// static constructor. Opens or creates the tv database from database\TVDatabaseV6.db
/// </summary>
static TVDatabase()
lock (typeof(TVDatabase))
try
// Open database
Log.Write("opening tvdatabase");
System.IO.Directory.CreateDirectory("database");
//Upgrade();
m_db = new SQLiteClient(@"database\TVDatabaseV9.db");
CreateTables();
if (m_db!=null)
m_db.Execute("PRAGMA cache_size=8192\n");
m_db.Execute("PRAGMA synchronous='OFF'\n");
m_db.Execute("PRAGMA count_changes='OFF'\n");
catch (Exception ex)
Log.Write("TVDatabase exception err:{0} stack:{1}", ex.Message,ex.StackTrace);
Log.Write("tvdatabase opened");
}[/code]
[code]static public bool GetRecordings(ref ArrayList recordings)
recordings.Clear();
if (null==m_db) return false;
string strSQL;
strSQL=String.Format("select * from channel,recording where recording.idChannel=channel.idChannel order by iStartTime");
SQLiteResultSet results;
results=m_db.Execute(strSQL);
if (results.Rows.Count== 0) return false;
for (int i=0; i < results.Rows.Count;++i)
long iStart=Int64.Parse(Get(results,i,"recording.iStartTime"));
long iEnd=Int64.Parse(Get(results,i,"recording.iEndTime"));
TVRecording rec=new TVRecording ();
rec.Channel=Get(results,i,"channel.strChannel");
rec.Start=iStart;
rec.End=iEnd;
rec.Canceled = Int64.Parse(Get(results,i,"recording.iCancelTime"));
rec.ID=Int32.Parse(Get(results,i,"recording.idRecording"));
rec.Title=Get(results,i,"recording.strProgram");
rec.RecType=(TVRecording.RecordingType)Int32.Parse(Get(results,i,"recording.iRecordingType"));
int iContectRec=Int32.Parse(Get(results,i,"recording.bContentRecording"));
if (iContectRec==1) rec.IsContentRecording=true;
else rec.IsContentRecording=false;
recordings.Add(rec);
return true;
catch(SQLiteException ex)
return false;
The reasen is that I can't initiate a new TVDatabase, which opens the database:
Should be like:
Dim tvb As New MediaPortal.TV.Database.TVDatabase
TVDatabase is private!!
But I have to insanciate m_db, in order to get it work.
Either [USER=10277]frodo[/USER] can change this or I have to program my own SQLite subroutines, but then I don't know if MP supports multi user access.
[USER=10277]frodo[/USER] Can you please give me a hint!
Thanks!!