/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Diff of /trunk/xmltv_parser/main.cs

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

--- trunk/xmltv_parser/main.cs	2013/03/07 13:36:42	30
+++ trunk/xmltv_parser/main.cs	2013/03/07 13:46:39	31
@@ -9,6 +9,8 @@
 using libxmltv.Core;
 using Enterprise.Logging;
 using libxmltv.Interfaces;
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
 
 namespace xmltv_parser
 {
@@ -73,12 +75,41 @@
 
         private void mnuItemOpenSavedData_Click(object sender, EventArgs e)
         {
-
+            var result = xmltv_program_data_loader.ShowDialog();
+            if (result != DialogResult.OK) return;
+            try
+            {
+                using (Stream stream = File.Open(xmltv_program_data_loader.FileName, FileMode.Open))
+                {
+                    try
+                    {
+                        BinaryFormatter bin = new BinaryFormatter();
+                        Programs = (List<IXMLTVProgram>)bin.Deserialize(stream);
+                    }
+                    catch (Exception ex) { gLog.Log.Error.WriteLine(ex.ToString()); }
+                }
+            }
+            catch (Exception ex) { gLog.Log.Error.WriteLine(ex.ToString()); }
+            CreateControls();
         }
 
         private void mnuItemSaveData_Click(object sender, EventArgs e)
         {
-
+            var result = xmltv_program_data_saver.ShowDialog();
+            if (result != DialogResult.OK) return;
+            try
+            {
+                using (Stream stream = File.Open(xmltv_program_data_saver.FileName, FileMode.Create))
+                {
+                    try
+                    {
+                        BinaryFormatter bin = new BinaryFormatter();
+                        bin.Serialize(stream, Programs);
+                    }
+                    catch (Exception ex) { gLog.Log.Error.WriteLine(ex.ToString()); }
+                }
+            }
+            catch (Exception ex) { gLog.Log.Error.WriteLine(ex.ToString()); }
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22