/[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/14 19:25:17	156
+++ trunk/GBPVRProgramDatabaseFixer/SQLLITE.cs	2013/03/14 19:36:01	157
@@ -190,6 +190,11 @@
             this.OnInstanceCreated = OnInstanceCreated;
             //CreateConnection(database);
             this.Database = database;
+            if (!CreateDatabaseBackup())
+            {
+                gLog.Error.WriteLine("Failed to backup database.");
+                return;
+            }
             ConnectionTest();
             ReadRecodringScheduleData();
             ReadProgrammeData();
@@ -254,7 +259,7 @@
                             }
                         }
                     }
-                    con.Clone();                    
+                    con.Clone();
                 }
                 OnCreatedInstance(this, new EventArgs());
             }
@@ -264,6 +269,26 @@
             }
         }
 
+
+        private bool CreateDatabaseBackup()
+        {
+            try
+            {
+                string backup_file = string.Format("{0}.{1}", this.Database, DateTime.Now.ToString("yyyyMMddHHmmss"));
+                gLog.Info.WriteLine("Creating Database backup...");
+                gLog.Info.WriteLine("\tSource: {0}", this.Database);
+                gLog.Info.WriteLine("\tDestination: {0}", backup_file);
+
+                System.IO.File.Copy(this.Database, backup_file);
+                return true;
+            }
+            catch (Exception ex)
+            {
+                gLog.Error.WriteLine(ex.ToString());
+                return false;
+            }
+        }
+
         private void ReadProgrammeData()
         {
             try

 

  ViewVC Help
Powered by ViewVC 1.1.22