/// <summary>
        /// method to be activated when command enters
        /// </summary>
        /// <param name="sender">the sender object</param>
        /// <param name="e"> args for the command</param>
        public void OnCommandRecieved(object sender, ClientCommandEventArgs e)
        {
            //check which command was given and execute in a new Task
            Task t = new Task(() =>
            {
                bool result;
                string output;
                try
                {
                    output = MyController.ExecuteCommand(e.Args.CommandID, e.Args.Args, out result);
                }
                catch
                {
                    output = "";
                }
                if (e.Args.CommandID == (int)CommandEnum.CloseCommand)
                {
                    if (e.Args.RequestDirPath == MyPath || String.Equals("*", e.Args.RequestDirPath))
                    {
                        //CommandDone?.Invoke(this, new CommandDoneEventArgs(e.Client, output));
                        // return;

                        for (int i = 0; i < MyDirectoryWWatcher.Length; i++)
                        {
                            MyDirectoryWWatcher[i].EnableRaisingEvents = false;
                            MyDirectoryWWatcher[i].Dispose();
                        }
                        UpdateLog("directory closed: " + MyPath, MessageTypeEnum.INFO);
                        MyLogging.Log("directory closed: " + MyPath, MessageTypeEnum.INFO);
                        DirectoryClosing?.Invoke(this, new DirectoryCloseEventArgs(null, null));
                        CommandDone?.Invoke(this, new CommandDoneEventArgs(e.Client, output));
                        return;
                    }
                }
                CommandDone?.Invoke(this, new CommandDoneEventArgs(e.Client, output));
            });

            t.Start();
        }
Example #2
0
 static void OnCommandDone(CommandDoneType type, string caption)
 {
     CommandDone?.Invoke(null, new CommandDoneEventArgs(type, caption));
 }
Example #3
0
 private void OnCommandDone()
 {
     CommandDone.Raise(this, EventArgs.Empty);
 }