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

Diff of /trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs

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

revision 165 by william, Fri Mar 15 17:33:15 2013 UTC revision 166 by william, Sat Mar 16 13:16:42 2013 UTC
# Line 17  namespace GBPVRProgramDatabaseFixer Line 17  namespace GBPVRProgramDatabaseFixer
17          List<SQLLITE.IRECORDING_SCHEDULE> Recordings { get; }          List<SQLLITE.IRECORDING_SCHEDULE> Recordings { get; }
18          List<SQLLITE.ICHANNEL> Channels { get; }          List<SQLLITE.ICHANNEL> Channels { get; }
19          IDateTimeRange GetProgramsDateRange(List<SQLLITE.IPROGRAMME> programs);          IDateTimeRange GetProgramsDateRange(List<SQLLITE.IPROGRAMME> programs);
20          List<SQLLITE.IPROGRAMME> FilterProgramsByDateRange(List<SQLLITE.IPROGRAMME> programs, IDateTimeRange range, out List<SQLLITE.IPROGRAMME> removed_programs);          List<SQLLITE.IPROGRAMME> GetValidPrograms(List<SQLLITE.IPROGRAMME> gbpvr_programs, List<libxmltv.Interfaces.IProgramDefinition> xmltv_programs, out List<SQLLITE.IPROGRAMME> removed_programs);
21    
22      }      }
23      public class SQLLITE : ISQLLITE      public class SQLLITE : ISQLLITE
# Line 293  namespace GBPVRProgramDatabaseFixer Line 293  namespace GBPVRProgramDatabaseFixer
293              return range;              return range;
294          }          }
295    
296          public List<SQLLITE.IPROGRAMME> FilterProgramsByDateRange(List<SQLLITE.IPROGRAMME> programs, IDateTimeRange range, out List<SQLLITE.IPROGRAMME> removed_programs)          public List<SQLLITE.IPROGRAMME> GetValidPrograms(List<SQLLITE.IPROGRAMME> gbpvr_programs, List<libxmltv.Interfaces.IProgramDefinition> xmltv_programs, out List<SQLLITE.IPROGRAMME> source_invalid)
297          {          {
298              removed_programs = new List<IPROGRAMME>();              source_invalid = new List<IPROGRAMME>();
299              List<SQLLITE.IPROGRAMME> list = new List<IPROGRAMME>(programs.ToArray());              List<SQLLITE.IPROGRAMME> source = new List<IPROGRAMME>(gbpvr_programs.ToArray());
300              list = list.OrderBy(s => s.start_time).ToList();              source = source.OrderBy(s => s.start_time).ToList();
301              List<SQLLITE.IPROGRAMME> list2 = new List<IPROGRAMME>();              List<SQLLITE.IPROGRAMME> source_valid = new List<IPROGRAMME>();
302              if (range == null)              //if (range == null)
303              {              //{
304                  gLog.Warn.WriteLine("The DateTimeRange passed in is null...returning the original program list");              //    gLog.Warn.WriteLine("The DateTimeRange passed in is null...returning the original program list");
305                  return list;              //    return list;
306              }              //}
307              //gLog.Warn.WriteLine("FilterProgramsByDateRange has not been implemented");              //gLog.Warn.WriteLine("FilterProgramsByDateRange has not been implemented");
308              
309              foreach (var program in list)              double total = source.Count;
310              {              double index = 0;
311                  if (program.start_time >= range.Start &&              double progress = 0;
312                      program.start_time <= range.End)              foreach (var program in source)
313                {
314                    //if (program.start_time >= range.Start &&
315                    //    program.start_time <= range.End)
316                    //{
317                    //    list2.Add(program);
318                    //}
319                    //else
320                    //{
321                    //    removed_programs.Add(program);
322                    //}  
323                    progress = 100.0 * (index / total);
324                    gLog.ReportProgress(this, new ReportProgressEventArgs((int)progress, string.Format("SQLLITE: Filtering GBPVR Programs: {1:00}%", progress)));
325                    var xmltv_entry = program.AsXMLTVProgramDefinition(this);
326                    if (xmltv_programs.Contains(xmltv_entry))
327                  {                  {
328                      list2.Add(program);                      source_valid.Add(program);
329                  }                  }
330                  else                  else
331                  {                  {
332                      removed_programs.Add(program);                      source_invalid.Add(program);
333                  }                  }
334                    index++;
335              }              }
336              list2 = list2.OrderBy(s => s.channel_oid).ThenBy(s => s.start_time).ToList();  
337              removed_programs = removed_programs.OrderBy(s => s.channel_oid).ThenBy(s => s.start_time).ToList();              //for (int i = 0; i < programs.Count(); i++)
338              return list2;              //{
339                //    var gbpvr_entry = gbpvr[i];
340                //    var xmltv_entry = gbpvr_entry.AsXMLTVProgramDefinition(sqlite);
341                //    if (!xmltv[i].Equals(xmltv_entry))
342                //    {
343                //        gLog.Warn.WriteLine("Warning GBPVR Program oid: {0} might be invalid", gbpvr_entry.oid);
344                //    }
345                //}
346    
347                source_valid = source_valid.OrderBy(s => s.channel_oid).ThenBy(s => s.start_time).ToList();
348                source_invalid = source_invalid.OrderBy(s => s.channel_oid).ThenBy(s => s.start_time).ToList();
349                return source_valid;
350          }          }
351          #endregion          #endregion
352    

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

  ViewVC Help
Powered by ViewVC 1.1.22