/[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 164 by william, Fri Mar 15 16:57:50 2013 UTC revision 165 by william, Fri Mar 15 17:33:15 2013 UTC
# Line 170  namespace GBPVRProgramDatabaseFixer Line 170  namespace GBPVRProgramDatabaseFixer
170          static void SQLLITE_OnInstanceCreated(object sender, EventArgs e) { SQLLIST_INSTANCE_CREATED = true; }          static void SQLLITE_OnInstanceCreated(object sender, EventArgs e) { SQLLIST_INSTANCE_CREATED = true; }
171    
172    
173          static List<SQLLITE.IPROGRAMME> gbpvr_programs;          static List<SQLLITE.IPROGRAMME> gbpvr_invalid_programs;
174            static List<SQLLITE.IPROGRAMME> gbpvr_valid_programs;
175          static List<SQLLITE.ICHANNEL> gbpvr_channels;          static List<SQLLITE.ICHANNEL> gbpvr_channels;
176          static List<SQLLITE.IRECORDING_SCHEDULE> gbpvr_recordings;          static List<SQLLITE.IRECORDING_SCHEDULE> gbpvr_recordings;
177          static List<libxmltv.Interfaces.IProgramDefinition> xmltv_programs;          static List<libxmltv.Interfaces.IProgramDefinition> xmltv_programs;
178          static void PerformDatabaseProcessing()          static void PerformDatabaseProcessing()
179          {          {
180              gbpvr_channels = sqlite.Channels;             gbpvr_channels = sqlite.Channels;
181              gbpvr_programs = sqlite.Programs;              //gbpvr_programs = sqlite.Programs;
182                gbpvr_invalid_programs = new List<SQLLITE.IPROGRAMME>();
183                gbpvr_valid_programs = new List<SQLLITE.IPROGRAMME>();
184              gbpvr_recordings = sqlite.Recordings;                          gbpvr_recordings = sqlite.Recordings;            
185              Type datatype;              Type datatype;
186              var xmlt_raw_program_data = (IProgramDefinitionList)XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out datatype);              var xmlt_raw_program_data = (IProgramDefinitionList)XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out datatype);
187              //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();
188              //xmltv_programs = xmltv_programs.FindAll(p => p.Title == "Law & Order: Criminal Intent").ToList();              //xmltv_programs = xmltv_programs.FindAll(p => p.Title == "Law & Order: Criminal Intent").ToList();
189              xmltv_programs = xmlt_raw_program_data.ToList().OrderBy(p => DateTime.Parse(p.Start)).ToList();              xmltv_programs = xmlt_raw_program_data.ToList().OrderBy(p => DateTime.Parse(p.Start)).ToList();
190                var gbpvr_programs_startdate_range = sqlite.GetProgramsDateRange(sqlite.Programs);
   
             var gbpvr_programs_startdate_range = sqlite.GetProgramsDateRange(gbpvr_programs);  
191              var xmltv_programs_startdate_range = GetXMLTVProgramStartDateRange(xmltv_programs);              var xmltv_programs_startdate_range = GetXMLTVProgramStartDateRange(xmltv_programs);
192              List<SQLLITE.IPROGRAMME> gbpvr_removed_programs = new List<SQLLITE.IPROGRAMME>();  
193              gbpvr_programs = sqlite.FilterProgramsByDateRange(gbpvr_programs, xmltv_programs_startdate_range, out gbpvr_removed_programs);              gbpvr_valid_programs = sqlite.FilterProgramsByDateRange(sqlite.Programs, xmltv_programs_startdate_range, out gbpvr_invalid_programs);
194              xmltv_programs = xmltv_programs.OrderBy(s => s.ChannelNumber).ThenBy(s => DateTime.Parse(s.Start)).ToList();              xmltv_programs = xmltv_programs.OrderBy(s => s.ChannelNumber).ThenBy(s => DateTime.Parse(s.Start)).ToList();
195              CheckScheduledRecordingsForDiscrepancies();  
196              CheckProgramsForDiscrepancies();              gbpvr_channels.TrimExcess();
197                gbpvr_invalid_programs.TrimExcess();
198                gbpvr_valid_programs.TrimExcess();
199                gbpvr_recordings.TrimExcess();
200                xmltv_programs.TrimExcess();
201    
202                
203                
204    
205    
206                CheckScheduledRecordingsForDiscrepancies(gbpvr_recordings);
207                
208                CheckProgramsForDiscrepancies(gbpvr_valid_programs.ToArray(), xmltv_programs.ToArray());
209          }          }
210    
211          static IDateTimeRange GetXMLTVProgramStartDateRange(List<libxmltv.Interfaces.IProgramDefinition> programs)          static IDateTimeRange GetXMLTVProgramStartDateRange(List<libxmltv.Interfaces.IProgramDefinition> programs)
# Line 209  namespace GBPVRProgramDatabaseFixer Line 222  namespace GBPVRProgramDatabaseFixer
222              return range;              return range;
223          }          }
224    
225          static void CheckScheduledRecordingsForDiscrepancies()          static void CheckScheduledRecordingsForDiscrepancies(List<SQLLITE.IRECORDING_SCHEDULE> gbpvr)
226          {          {
227              //gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");              //gLog.Warn.WriteLine("CheckScheduledRecordingsForDiscrepancies() has not been implemented");
228              var manual_gbpvr_recordings = gbpvr_recordings.FindAll(p => p.recording_type == 0).ToList();              var manual_gbpvr_recordings = gbpvr.FindAll(p => p.recording_type == 0).ToList();
229    
230              foreach (var manual_recording in manual_gbpvr_recordings)              foreach (var manual_recording in manual_gbpvr_recordings)
231              {              {
# Line 253  namespace GBPVRProgramDatabaseFixer Line 266  namespace GBPVRProgramDatabaseFixer
266              }              }
267          }          }
268    
269          static void CheckProgramsForDiscrepancies()          static void CheckProgramsForDiscrepancies(SQLLITE.IPROGRAMME[] gbpvr, libxmltv.Interfaces.IProgramDefinition[] xmltv)
270          {          {
271              gLog.Warn.WriteLine("CheckProgramsForDiscrepancies() has not been implemented");              //gLog.Warn.WriteLine("CheckProgramsForDiscrepancies() has not been implemented");
272                if (gbpvr.Count() != xmltv.Count())
273                {
274                    throw new ArgumentOutOfRangeException("gbpvr.Count/xmltv.Count", string.Format("gbpvr.Count: '0x{0:x8}' != xmltv.Count: '0x{1:x8}'", gbpvr.Count(),xmltv.Count()));
275                }
276                for (int i = 0; i < gbpvr.Count(); i++)
277                {
278                    var gbpvr_entry = gbpvr[i];
279                    var xmltv_entry = gbpvr_entry.AsXMLTVProgramDefinition(sqlite);
280                    if (!xmltv[i].Equals(xmltv_entry))
281                    {
282                        gLog.Warn.WriteLine("Warning GBPVR Program oid: {0} might be invalid", gbpvr_entry.oid);
283                    }
284                }
285          }          }
286      }      }
287  }  }

Legend:
Removed from v.164  
changed lines
  Added in v.165

  ViewVC Help
Powered by ViewVC 1.1.22