/[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

--- trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/16 20:14:46	192
+++ trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/16 21:04:37	193
@@ -845,26 +845,38 @@
         }
         public void UpdateGBPVRPrograms(List<IOldNewProgram> programs)
         {
-            
-            //double total = programs.Count;
-            //double index = 0;
-            //double progress = 0;
-            List<IPROGRAMME> new_program_list = new List<IPROGRAMME>();
-            foreach (var program in programs)
+            int STEP = 100;
+            List<List<IPROGRAMME>> array_list = new List<List<IPROGRAMME>>(); // holds a list of ~STEP programs per index
+            for (int i = 0; i < programs.Count;)
             {
-                new_program_list.Add(program.NewProgram);
+                List<IPROGRAMME> tmp = new List<IPROGRAMME>(STEP);
+                for (int j = 0; j < STEP; j++)
+                {
+                    try
+                    {
+                        tmp.Add(programs[i + j].NewProgram);
+                    }
+                    catch { }
+                }
+                tmp.TrimExcess();
+                array_list.Add(tmp);
+                i += STEP;
             }
-            //new_program_list.TrimExcess();
-            gLog.Info.WriteLine("Inserting {0} gbpvr programs.", new_program_list.Count);
-            Stopwatch st = new Stopwatch();
-            st.Start();
-            if (!InsertProgramEntryDatabase(new_program_list))
+            array_list.TrimExcess();
+
+            foreach (var p in array_list)
             {
-                gLog.Error.WriteLine("Failed to insert one or more program(s)");
-            }
-            //string command = BuildGBPVRMultiInsertCommand(new_program_list);
-            st.Stop();
-            gLog.Warn.WriteLine("    operation took: {0:0.00000} minutes", st.Elapsed.TotalMinutes);
+                gLog.Info.WriteLine("Inserting {0} gbpvr programs.", p.Count);
+                Stopwatch st = new Stopwatch();
+                st.Start();
+                if (!InsertProgramEntryDatabase(p))
+                {
+                    gLog.Error.WriteLine("Failed to insert one or more program(s)");
+                }
+                st.Stop();
+                gLog.Warn.WriteLine("    operation took: {0:0.00000} minutes", st.Elapsed.TotalMinutes);
+            }          
+
         }
 
         private bool RemoveAllProgramDatabaseEntries()

 

  ViewVC Help
Powered by ViewVC 1.1.22