/[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 198 by william, Sat Mar 16 22:02:01 2013 UTC revision 199 by william, Sat Mar 16 22:25:44 2013 UTC
# Line 848  namespace GBPVRProgramDatabaseFixer Line 848  namespace GBPVRProgramDatabaseFixer
848          public void UpdateGBPVRPrograms(List<IPROGRAMME> programs)          public void UpdateGBPVRPrograms(List<IPROGRAMME> programs)
849          {          {
850              int ChunkSize = 500;              int ChunkSize = 500;
851              var ChunkList = programs.Chunk<IPROGRAMME>(ChunkSize).ToList();              var ChunkList = programs.Chunk<IPROGRAMME>(ChunkSize);
852    
853              int total = programs.Count;              double total = programs.Count;
854              int index = 0;              double index = 0;
855              double progress = 0;              double progress = 0;
856              Stopwatch st = new Stopwatch();              Stopwatch st1 = new Stopwatch();
857              st.Start();              st1.Start();
858              foreach (var p in ChunkList)              foreach (var p in ChunkList)
859              {              {
860                    Stopwatch st2 = new Stopwatch();
861                    st2.Start();
862                  progress = 100.0 * (index / total);                  progress = 100.0 * (index / total);
863                  //gLog.Info.WriteLine("Inserting {0} gbpvr programs.", p.Count);                    //gLog.Info.WriteLine("Inserting {0} gbpvr programs.", p.Count);  
864                  if (!InsertProgramEntryDatabase(p.ToList()))                  if (!InsertProgramEntryDatabase(p.ToList()))
865                  {                  {
866                      gLog.Error.WriteLine("Failed to insert one or more program(s)");                      gLog.Error.WriteLine("Failed to insert one or more program(s)");
867                  }                  }
868                    st2.Stop();
869                    gLog.Warn.WriteLine("    operation took: {0:0.00000} seconds", st2.Elapsed.TotalSeconds);
870                    gLog.Warn.WriteLine(System.Environment.NewLine);
871                  gLog.ReportProgress(this, new ReportProgressEventArgs((int)progress, string.Format("Inserting GBPVR Programs: {0:00}%", (int)progress)));                  gLog.ReportProgress(this, new ReportProgressEventArgs((int)progress, string.Format("Inserting GBPVR Programs: {0:00}%", (int)progress)));
872                  index += p.Count();                  index += (double)p.Count();
873                    
874              }              }
875              st.Stop();              st1.Stop();
876              gLog.Warn.WriteLine("    operation took: {0:0.00000} minutes", st.Elapsed.TotalMinutes);              gLog.Warn.WriteLine("    operation took: {0:0.00000} minutes overall", st1.Elapsed.TotalMinutes);
877          }          }
878    
879          private bool RemoveAllProgramDatabaseEntries()          private bool RemoveAllProgramDatabaseEntries()

Legend:
Removed from v.198  
changed lines
  Added in v.199

  ViewVC Help
Powered by ViewVC 1.1.22