public LibraryWatcherService()
 {
     InitializeComponent();
     if (!Config.isValidSettingValue("LIBRARY_NAME")) {
         string message = "The library name is not set in the configuration file";
         eventLog.WriteEntry(message, EventLogEntryType.Error);
         throw new Exception(message);
     }
     if (!Config.isValidSettingValue("DEST_FILE")) {
         string message = "The destination file is not set in the configuration file";
         eventLog.WriteEntry(message, EventLogEntryType.Error);
         throw new Exception(message);
     }
     string name = Properties.Settings.Default.LIBRARY_NAME;
     string destinationFile = Properties.Settings.Default.DEST_FILE;
     Library library = new Library(name, LibraryManager.getLibraryFolders(name));
     if (!library.isValid()) {
         string message = "Could not load the library: " + library.Name;
         eventLog.WriteEntry(message, EventLogEntryType.Error);
         throw new Exception(message);
     }
     LibraryFile db = new LibraryFile(library, destinationFile);
     db.init();
     watcher = new LibraryWatcher(library, db);
 }
Beispiel #2
0
 /// <summary>
 /// The entry point for the CLI application
 /// </summary>
 /// <param name="args"></param>
 static void CLI(string[] args)
 {
     Args arguments = Args.parse(args);
     if (arguments == null) {
         Console.WriteLine(Args.getHelpMessage());
         Environment.Exit(0);
     }
     try {
         Args.validate(arguments);
     } catch (Exception e) {
         Console.WriteLine(e.Message);
         Environment.Exit(1);
     }
     LibraryFile db = new LibraryFile(arguments.Library, arguments.Destination);
     db.init();
     LibraryWatcher watcher = new LibraryWatcher(arguments.Library, db);
     watcher.watch();
     Console.WriteLine("Written " + arguments.Library.Name + " library contents to " + arguments.Destination);
     watcher.close();
     Environment.Exit(0);
 }
 public LibraryWatcher(Library library, LibraryFile file)
 {
     this.library = library;
     libraryFile = file;
     watchers = new List<FileSystemWatcher>();
 }