Example #1
0
        /// <summary>
        /// When implemented in a derived class, <see cref="M:System.ServiceProcess.ServiceBase.OnCustomCommand(System.Int32)"></see> executes when the Service Control Manager (SCM) passes a custom command to the service. Specifies actions to take when a command with the specified parameter value occurs.
        /// </summary>
        /// <param name="command">
        ///     The command message sent to the service :
        ///         1) Rehash des préférences et redémarrage de la surveillance.
        ///         2) Réinitialisation de la connexion databaseUpdate
        ///         3) 1 + 2
        /// </param>
        protected override void OnCustomCommand (int command) {
            switch (command) {
                case 3:
                    //1 + 2
                    options = MainOptions.Load();
                    goto case 2;
                    //Tiens, ça faisait bien une bonne dizaine
                    //d'années que je n'avais plus goto :p ^^

                case 2:
                    //Réinitialisation de la connexion databaseUpdate
                    databaseUpdate.Dispose();
                    databaseUpdate = new DatabaseUpdate(options.ConnectionString);
                    StopSurveillance();
                    StartSurveillance();
                    break;

                case 1:
                    //Rehash des préférences et redémarrage de la surveillance.
                    options = MainOptions.Load();
                    StopSurveillance();
                    StartSurveillance();
                    break;

                default:
                    throw new ArgumentException("Commande inconnue : " + command.ToString());
            }
        }
Example #2
0
 /// <summary>
 /// Start this service.
 /// </summary>
 protected override void OnStart (string[] args) {           
     //Lecture des préférences
     options = MainOptions.Load();
     //Initialisation de la base de données et de sa classe de mise à jour
     databaseUpdate = new DatabaseUpdate(options.ConnectionString);
     //Lancement de la surveillance des dossiers
     StartSurveillance();
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SurveillanceDossiers"/> class.
 /// </summary>
 /// <param name="path">The path to the folder to watch.</param>
 /// <param name="databaseUpdate">The database update component.</param>
 /// <param name="deleteTuneIfOrphan">if set to <c>true</c>, deletes tune if it's orphan.</param>
 /// <param name="indexSubdirectories">if set to <c>true</c> indexes also subdirectories</param>
 public SurveillanceDossiers (string path, DatabaseUpdate databaseUpdate, bool deleteTuneIfOrphan, bool indexSubdirectories) {
     watcher = new FileSystemWatcher(path);
     watcher.EnableRaisingEvents = true;
     watcher.IncludeSubdirectories = indexSubdirectories;
     //watcher.Filter
     watcher.Changed += delegate(object sender, FileSystemEventArgs e) { databaseUpdate.RecheckProperties(e.FullPath); };
     watcher.Created += delegate(object sender, FileSystemEventArgs e) { databaseUpdate.AddFile(e.FullPath); };
     watcher.Deleted += delegate(object sender, FileSystemEventArgs e) { databaseUpdate.DelFile(e.FullPath, deleteTuneIfOrphan); };
     watcher.Error += delegate(object sender, ErrorEventArgs e) {
         if (Error != null) Error(this, new ExceptionEventArgs(e.GetException()));
     };
     watcher.Renamed += delegate(object sender, RenamedEventArgs e) { databaseUpdate.MoveFile(e.OldFullPath, e.FullPath); };
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SurveillanceDossiers"/> class.
        /// </summary>
        /// <param name="path">The path to the folder to watch.</param>
        /// <param name="databaseUpdate">The database update component.</param>
        /// <param name="deleteTuneIfOrphan">if set to <c>true</c>, deletes tune if it's orphan.</param>
        public SurveillanceDossiers (string path, DatabaseUpdate databaseUpdate, bool deleteTuneIfOrphan)
            : this(path, databaseUpdate, deleteTuneIfOrphan, true) {

        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SurveillanceDossiers"/> class.
        /// </summary>
        /// <param name="path">The path to the folder to watch.</param>
        /// <param name="databaseUpdate">The database update component.</param>
        public SurveillanceDossiers (string path, DatabaseUpdate databaseUpdate)
            : this(path, databaseUpdate, false) {

        }