Parent Directory
|
Revision Log
|
Patch
--- trunk/GBPVRProgramDatabaseFixer/Program.cs 2013/03/14 16:56:05 154 +++ trunk/GBPVRProgramDatabaseFixer/Program.cs 2013/03/14 17:10:09 155 @@ -14,12 +14,18 @@ { static string XMLTV_FILE = ""; static string GBPVR_DATABASE = ""; + + static bool LOADING_XMLTV_FILE = false; static bool XMLTV_INSTANCE_CREATED = false; + static int LAST_REPORTED_XMLTV_PROGRESS = 0; - static int LAST_REPORTED_XMLTV_PROGRESS =0; - static FileInfo fi_XMLTVFILE; + static bool LOADING_GBPVR_DATABASE = false; + static bool SQLLIST_INSTANCE_CREATED = false; + static int LAST_REPORTED_SQLLITE_PROGRESS = 0; + static FileInfo fi_XMLTVFILE; + static FileInfo fi_GBPVRDATABASE; static void CreateLog() { string log_path = Application.StartupPath; @@ -78,34 +84,84 @@ } LoadXMLTVFile(); + LoadGBPVRDatabase(); + } + + static void ConsoleOverwritePreviosLine(string format, params object[] args) + { + Console.WriteLine(format,args); + Console.SetCursorPosition(0, Console.CursorTop - 1); } static void gLog_ReportProgress(object sender, ReportProgressEventArgs e) { - if (LAST_REPORTED_XMLTV_PROGRESS != e.Progress) + if (!XMLTV_INSTANCE_CREATED && LOADING_XMLTV_FILE) { - Console.WriteLine("XMLTV: {0} Loading: {1:00}%", fi_XMLTVFILE.Name, e.Progress); - LAST_REPORTED_XMLTV_PROGRESS = e.Progress; + if (LAST_REPORTED_XMLTV_PROGRESS != e.Progress) + { + ConsoleOverwritePreviosLine("XMLTV: {0} Loading: {1:00}%", fi_XMLTVFILE.Name, e.Progress); + LAST_REPORTED_XMLTV_PROGRESS = e.Progress; + if (e.Progress == 100) + { + Console.WriteLine("XMLTV: {0} Loading: {1:00}%", fi_XMLTVFILE.Name, e.Progress); + } + } + } + if (!SQLLIST_INSTANCE_CREATED && LOADING_GBPVR_DATABASE) + { + if (LAST_REPORTED_SQLLITE_PROGRESS != e.Progress) + { + ConsoleOverwritePreviosLine("SQLLITE: {0} Loading: {1:00}%", fi_XMLTVFILE.Name, e.Progress); + LAST_REPORTED_SQLLITE_PROGRESS = e.Progress; + if (e.Progress == 100) + { + Console.WriteLine("SQLLITE: {0} Loading: {1:00}%", fi_XMLTVFILE.Name, e.Progress); + } + } } } static void LoadXMLTVFile() { + LOADING_XMLTV_FILE = true; if (string.IsNullOrEmpty(XMLTV_FILE)) { gLog.Error.WriteLine("XMLTV File is either a null or empty string."); + LOADING_XMLTV_FILE = false; return; } fi_XMLTVFILE = new FileInfo(XMLTV_FILE); if (!fi_XMLTVFILE.Exists) { gLog.Error.WriteLine("Could not find XMLTV File: {0}", fi_XMLTVFILE.FullName); + LOADING_XMLTV_FILE = false; return; } XMLTV.Create(fi_XMLTVFILE.FullName, new EventHandler<EventArgs>(XMLTV_OnInstanceCreated)); while (!XMLTV_INSTANCE_CREATED) { Application.DoEvents(); } + LOADING_XMLTV_FILE = false; } - static void XMLTV_OnInstanceCreated(object sender, EventArgs e) { XMLTV_INSTANCE_CREATED = true; } + + static void LoadGBPVRDatabase() + { + LOADING_GBPVR_DATABASE = true; + if (string.IsNullOrEmpty(GBPVR_DATABASE)) + { + gLog.Error.WriteLine("GBPVR Datbase is either a null or empty string."); + LOADING_GBPVR_DATABASE = false; + return; + } + fi_GBPVRDATABASE = new FileInfo(GBPVR_DATABASE); + if (!fi_GBPVRDATABASE.Exists) + { + gLog.Error.WriteLine("Could not find GBPVR Database: {0}", fi_GBPVRDATABASE.FullName); + LOADING_GBPVR_DATABASE = false; + return; + } + + + LOADING_GBPVR_DATABASE = false; + } } }
ViewVC Help | |
Powered by ViewVC 1.1.22 |