/[xmltv_parser]/trunk/GBPVRProgramDatabaseFixer/Program.cs
ViewVC logotype

Diff of /trunk/GBPVRProgramDatabaseFixer/Program.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 162 by william, Thu Mar 14 21:40:19 2013 UTC revision 163 by william, Fri Mar 15 16:53:40 2013 UTC
# Line 14  namespace GBPVRProgramDatabaseFixer Line 14  namespace GBPVRProgramDatabaseFixer
14  {  {
15      class Program      class Program
16      {      {
17          static SQLLITE sqlite;          static ISQLLITE sqlite;
18          static string XMLTV_FILE = "";          static string XMLTV_FILE = "";
19          static string GBPVR_DATABASE = "";          static string GBPVR_DATABASE = "";
20    
# Line 88  namespace GBPVRProgramDatabaseFixer Line 88  namespace GBPVRProgramDatabaseFixer
88    
89              LoadXMLTVFile();              LoadXMLTVFile();
90              LoadGBPVRDatabase();              LoadGBPVRDatabase();
91              PerformDatabaseProcessing();                    PerformDatabaseProcessing();
92          }          }
93    
94          static void ConsoleOverwritePreviosLine(string format, params object[] args)          static void ConsoleOverwritePreviosLine(string format, params object[] args)
# Line 163  namespace GBPVRProgramDatabaseFixer Line 163  namespace GBPVRProgramDatabaseFixer
163                  LOADING_GBPVR_DATABASE = false;                  LOADING_GBPVR_DATABASE = false;
164                  return;                  return;
165              }              }
166                sqlite = SQLLITE.Create(fi_GBPVRDATABASE.FullName, new EventHandler<EventArgs>(SQLLITE_OnInstanceCreated));
             sqlite = new SQLLITE(fi_GBPVRDATABASE.FullName, new EventHandler<EventArgs>(SQLLITE_OnInstanceCreated));  
167              while (!SQLLIST_INSTANCE_CREATED) { Application.DoEvents(); }              while (!SQLLIST_INSTANCE_CREATED) { Application.DoEvents(); }
168              LOADING_GBPVR_DATABASE = false;              LOADING_GBPVR_DATABASE = false;
169          }          }
# Line 182  namespace GBPVRProgramDatabaseFixer Line 181  namespace GBPVRProgramDatabaseFixer
181              gbpvr_recordings = sqlite.Recordings;                          gbpvr_recordings = sqlite.Recordings;            
182              Type datatype;              Type datatype;
183              var xmlt_raw_program_data = (IProgramDefinitionList)XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out datatype);              var xmlt_raw_program_data = (IProgramDefinitionList)XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out datatype);
184              xmltv_programs = xmlt_raw_program_data.ToList().OrderBy(p => p.ChannelNumber).ThenBy(p => DateTime.Parse(p.Start)).ToList();              //xmltv_programs = xmlt_raw_program_data.ToList().OrderBy(p => p.ChannelNumber).ThenBy(p => DateTime.Parse(p.Start)).ToList();
185                //xmltv_programs = xmltv_programs.FindAll(p => p.Title == "Law & Order: Criminal Intent").ToList();
186                xmltv_programs = xmlt_raw_program_data.ToList().OrderBy(p => DateTime.Parse(p.Start)).ToList();
             xmltv_programs = xmltv_programs.FindAll(p => p.Title == "Law & Order: Criminal Intent").ToList();  
   
187    
188    
189              //var data = xmltv_programs[0];              var gbpvr_programs_startdate_range = sqlite.GetProgramsDateRange(gbpvr_programs);
190              //DateTime p = DateTime.Parse(data.Start);              var xmltv_programs_startdate_range = GetXMLTVProgramStartDateRange(xmltv_programs);
191              //string strP = p.ToString("yyyy/MM/dd HH:mm:ss.fffffff");              gbpvr_programs = sqlite.FilterProgramsByDateRange(gbpvr_programs, xmltv_programs_startdate_range);
192                            xmltv_programs = xmltv_programs.OrderBy(s => s.ChannelNumber).ThenBy(s => DateTime.Parse(s.Start)).ToList();
193              CheckScheduledRecordingsForDiscrepancies();              CheckScheduledRecordingsForDiscrepancies();
194              CheckProgramsForDiscrepancies();              CheckProgramsForDiscrepancies();
195          }          }
196    
197            static IDateTimeRange GetXMLTVProgramStartDateRange(List<libxmltv.Interfaces.IProgramDefinition> programs)
198            {
199                IDateTimeRange range = DateTimeRange.Create();
200                var list = new List<libxmltv.Interfaces.IProgramDefinition>(programs.ToArray());
201                DateTime first = new DateTime();
202                DateTime last = new DateTime();
203                first = DateTime.Parse(list.OrderBy(s => DateTime.Parse(s.Start)).ToList().First().Start);
204                last = DateTime.Parse(list.OrderBy(s => DateTime.Parse(s.Start)).ToList().Last().Start);
205                gLog.Info.WriteLine("\tFirst: {0} = ({1})", first.ToString("yyyy/MM/dd HH:mm:ss.fffffff"), first.ToDateTimeString());
206                gLog.Info.WriteLine("\tLast: {0} = ({1})", last.ToString("yyyy/MM/dd HH:mm:ss.fffffff"), last.ToDateTimeString());
207                range = DateTimeRange.Create(first, last);
208                return range;
209            }
210    
211          static void CheckScheduledRecordingsForDiscrepancies()          static void CheckScheduledRecordingsForDiscrepancies()
212          {          {
213              //gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");              //gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");

Legend:
Removed from v.162  
changed lines
  Added in v.163

  ViewVC Help
Powered by ViewVC 1.1.22