Beispiel #1
0
 /// <summary>
 /// When a command is being received, this function execute it via the IController, and
 /// then informs the ILogging.
 /// </summary>
 /// <param name="sender"> the object that sent the command </param>
 /// <param name="e"> the command's arguments </param>
 void IHandler.OnCommandReceived(object sender, CommandReceivedEventArgs e)
 {
     if (e.CommandID == CommandEnum.CloseCommand)
     {
         DirectoryCloseEventArgs args = new DirectoryCloseEventArgs(e.RequestDirPath, "Closing Handler: " + path);
         OnClose(args);
     }
     else if (e.CommandID == CommandEnum.CloseServerCommand)
     {
         DirectoryCloseEventArgs args = new DirectoryCloseEventArgs(path, "Server Closure " + path + " closed");
         stopWatching(args);
     }
     else
     {
         // The Event that will be activated upon new Command
         string logMsg = controller.ExecuteCommand(e.CommandID, e.Args, out bool result);
         if (result)
         {
             logger.Log(logMsg, MessageTypeEnum.INFO);
         }
         else
         {
             logger.Log(logMsg, MessageTypeEnum.FAIL);
         }
     }
 }
        /// <summary>
        /// Invokes the CommandReceived event and passes the appropriate args to the subscribed Objects.
        /// </summary>
        /// <param name="id">CommandEnum the code for the specific command</param>
        /// <param name="args">List<String> the args used by the Command</param>
        /// <param name="path">String, the target directory/file path</param>
        public void SendCommand(CommandEnum id, List <String> args, string path)
        {
            CommandReceivedEventArgs cArgs = new CommandReceivedEventArgs(id, args, path);

            CommandReceived?.Invoke(this, cArgs);
            if (id == CommandEnum.CloseServerCommand)
            {
                OnCloseServer();
            }
        }