/[EmuXPortal]/trunk/EmuXPortal/Api/RomFavorite.cs
ViewVC logotype

Diff of /trunk/EmuXPortal/Api/RomFavorite.cs

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

--- trunk/EmuXPortal/Api/RomFavorite.cs	2014/08/05 04:13:36	237
+++ trunk/EmuXPortal/Api/RomFavorite.cs	2014/08/05 04:50:39	238
@@ -1,4 +1,4 @@
-´╗┐using EmuXPortal.Logging;
+´╗┐using Enterprise.Logging;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -70,7 +70,7 @@
         }
         #region static members
 
-        internal static List<IRomConfig> GetRoms(logger log)
+        internal static List<IRomConfig> GetRoms()
         {
             List<IRomConfig> roms = new List<IRomConfig>();
             //lst_favorites.ForEach(s => roms.Add(s.RomConfig));
@@ -87,8 +87,8 @@
                 }
                 catch (ArgumentException)
                 {
-                    var emu_config = EmuConfigLoader.Load(log, rom.RomConfig.Config.ConfigPath, rom.RomConfig.Config.EmuRomPath);
-                    rom_config = RomLoader.Load(log, rom.RomConfig.RomFile, emu_config);
+                    var emu_config = EmuConfigLoader.Load(rom.RomConfig.Config.ConfigPath, rom.RomConfig.Config.EmuRomPath);
+                    rom_config = RomLoader.Load(rom.RomConfig.RomFile, emu_config);
                 }                                            
                 roms.Add(rom_config);
             }
@@ -122,7 +122,7 @@
             return favorites;
         }
 
-        public static bool IsFavorite(logger log,IRomConfig rom)
+        public static bool IsFavorite(IRomConfig rom)
         {
             foreach (var c_rom in lst_favorites)
             {
@@ -133,22 +133,22 @@
             }
             return false;
         }
-        public static bool AddFavorite(logger log, IRomConfig rom)
+        public static bool AddFavorite(IRomConfig rom)
         {
-            if (IsFavorite(log,rom))
+            if (IsFavorite(rom))
             {
-                log.WriteLine("Rom is already favorited: [{0}]",rom.RomTitle);
+                gLog.Debug.WriteLine("Rom is already favorited: [{0}]", rom.RomTitle);
                 return false;
             }
             lst_favorites.Add(new RomFavorite(rom));
-            log.WriteLine("Added rom to favorites: [{0}]", rom.RomTitle);
+            gLog.Debug.WriteLine("Added rom to favorites: [{0}]", rom.RomTitle);
             return true;
         }
-        public static bool RemoveFavorite(logger log, IRomConfig rom)
+        public static bool RemoveFavorite(IRomConfig rom)
         {
-            if (!IsFavorite(log, rom))
+            if (!IsFavorite(rom))
             {
-                log.WriteLine("Rom is not favorited: [{0}]", rom.RomTitle);
+                gLog.Debug.WriteLine("Rom is not favorited: [{0}]", rom.RomTitle);
                 return false;
             }
             //lst_favorites.Remove(new RomFavorite(rom));
@@ -168,41 +168,41 @@
                 lst_favorites.RemoveAt(index);
             }
 
-            log.WriteLine("Removed rom from favorites: [{0}]", rom.RomTitle);
+            gLog.Debug.WriteLine("Removed rom from favorites: [{0}]", rom.RomTitle);
             return true;
         }
-        public static bool UpdateFavorites(logger log)
+        public static bool UpdateFavorites()
         {            
-            bool ret = SaveFavorites(log);
+            bool ret = SaveFavorites();
             if (!ret)
             {
-                log.WriteLine("Failed to update favorites (failed to save)");
+                gLog.Debug.WriteLine("Failed to update favorites (failed to save)");
             }
             else
             {
-                ret = Config.ConfigLoader.LoadFavorites(log);
+                ret = Config.ConfigLoader.LoadFavorites();
                 if (!ret)
                 {
-                    log.WriteLine("Failed to update favorites (failed to load)");
+                    gLog.Debug.WriteLine("Failed to update favorites (failed to load)");
                 }
                 else
                 {
-                    log.WriteLine("Updated favorites");
+                    gLog.Debug.WriteLine("Updated favorites");
                 }
             }
             return ret;
         }
 
-        internal static bool LoadFavorites(logger log, string ini)
+        internal static bool LoadFavorites(string ini)
         {
             try
             {
                 lst_favorites.Clear();
-                log.WriteLine("Loading Favorites: {0}", ini);
+                gLog.Debug.WriteLine("Loading Favorites: {0}", ini);
                 FileInfo fi = new FileInfo(ini);
                 if (!fi.Exists)
                 {
-                    log.WriteLine("\tFailed to Load Favorites (file not found): {0}", ini);
+                    gLog.Debug.WriteLine("\tFailed to Load Favorites (file not found): {0}", ini);
                     return false;
                 }
                 using (FileStream fs = new FileStream(ini, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
@@ -219,27 +219,27 @@
                                 string rom = reader.GetAttribute(ROM_FILE);                                
                                 string added = reader.GetAttribute(DATE_ADDED);
                                 if (added == null) { added = DateTime.Now.ToString(); }
-                                IEmuConfig emu_config = EmuConfigLoader.Load(log, config, "");
-                                var emu_rom = RomLoader.Load(log, rom, emu_config);
+                                IEmuConfig emu_config = EmuConfigLoader.Load(config, "");
+                                var emu_rom = RomLoader.Load(rom, emu_config);
                                 lst_favorites.Add(new RomFavorite(emu_rom, DateTime.Parse(added)));
                             }                            
                         }
                     }
-                }                
-                log.WriteLine("Loaded Favorites: {0}", ini);
-                SaveFavorites(log);
+                }
+                gLog.Debug.WriteLine("Loaded Favorites: {0}", ini);
+                SaveFavorites();
                 return true;
 
             }
             catch (Exception ex)
             {
-                log.WriteLine("\tFailed to Load Favorites: {0}", ini);
-                Console.WriteLine(ex.ToString());
-                log.WriteLine("Error: {0}", ex.ToString());
+                gLog.Error.WriteLine("\tFailed to Load Favorites: {0}", ini);
+                //Console.WriteLine(ex.ToString());
+                gLog.Verbose.Error.WriteLine("Error: {0}", ex.ToString());
                 return false;
             }
         }
-        internal static bool SaveFavorites(logger log)
+        internal static bool SaveFavorites()
         {
             // clean-up any duplicates
             lst_favorites = lst_favorites.Distinct(new FavoriesComparor()).ToList();
@@ -247,16 +247,16 @@
             string ini = Config.ConfigLoader.FAVORITES_FILE_INI;
             try
             {
-                log.WriteLine("Saving Favorites: {0}", ini);
+                gLog.Debug.WriteLine("Saving Favorites: {0}", ini);
                 FileInfo fi = new FileInfo(ini);
                 if (fi.Exists)
                 {
-                    log.WriteLine("Favorites file already exists - overwriting: {0}", ini);
+                    gLog.Debug.WriteLine("Favorites file already exists - overwriting: {0}", ini);
                     fi.Delete();
                 }
                 else
                 {
-                    log.WriteLine("Favorites file does not exist - creating: {0}", ini);
+                    gLog.Debug.WriteLine("Favorites file does not exist - creating: {0}", ini);
                 }
                 using (FileStream fs = new FileStream(ini, FileMode.CreateNew, FileAccess.Write, FileShare.Read))
                 {
@@ -297,16 +297,16 @@
                         writer.WriteFullEndElement();
                     }
                 }
-                
-                log.WriteLine("Saved Favorites: {0}", ini);
+
+                gLog.Debug.WriteLine("Saved Favorites: {0}", ini);
                 return true;
 
             }
             catch (Exception ex)
             {
-                log.WriteLine("\tFailed to Save Favorites: {0}", ini);
+                gLog.Error.WriteLine("\tFailed to Save Favorites: {0}", ini);
                 Console.WriteLine(ex.ToString());
-                log.WriteLine("Error: {0}", ex.ToString());
+                gLog.Verbose.Error.WriteLine("Error: {0}", ex.ToString());
                 return false;
             }
         }

 

  ViewVC Help
Powered by ViewVC 1.1.22