Beispiel #1
0
 public void Processor_StopSendEvent(object sender, CommandsEventArgs e)
 {
     lock (_lockStop)
     {
         _stop = true;
     }
 }
Beispiel #2
0
        private void FtpMonitor_RemoveThreadEvent(object sender, CommandsEventArgs e)
        {
            _logger.Info($"Remove 1 thread from user {e.User}");
            string key = e.User.ToUpper();

            lock (_lockObj)
            {
                if (_threadsCount.ContainsKey(key))
                {
                    _threadsCount[key] += 1;
                }
            }
        }
        private void FtpMonitor_StartProcessEvent(object sender, CommandsEventArgs e)
        {
            _logger.Debug($"Start process event for user {e.User}");
            string key = e.User.ToUpper();

            lock (_lockObject)
            {
                if (_pausedUsers.Contains(key))
                {
                    _pausedUsers.Remove(key);
                }
            }
        }
        private void FileCommandsWatcher_Changed(object sender, FileSystemEventArgs e)
        {
            if (IsDuplicatedEvent())
            {
                return;
            }
            //_fileSystemWatcher.EnableRaisingEvents = false;
            //Commands newCommands = GetCommands();
            string command = GetCommnd();

            if (string.IsNullOrEmpty(command))
            {
                return;
            }

            string[] commandArray = command.Split(' ');

            if (commandArray.Length == 3)
            {
                string commandDate   = commandArray[0];
                string commandName   = commandArray[1];
                string commandParams = commandArray[2];

                switch (commandName.ToUpper())
                {
                case "STARTPROCESS":
                    var args = new CommandsEventArgs()
                    {
                        User = commandParams
                    };
                    OnStartProcess(args);
                    break;

                case "STOPPROCESS":
                    args = new CommandsEventArgs()
                    {
                        User = commandParams
                    };
                    OnStopProcess(args);
                    break;

                case "ADDTHREAD":
                    args = new CommandsEventArgs()
                    {
                        User = commandParams
                    };
                    OnAddThread(args);
                    break;

                case "REMOVETHREAD":
                    args = new CommandsEventArgs()
                    {
                        User = commandParams
                    };
                    OnRemoveThread(args);
                    break;

                case "CHANGECONFIGURATION":
                    OnChangeConfiguration();
                    break;

                case "STOPSEND":
                    args = new CommandsEventArgs()
                    {
                        User = commandParams
                    };
                    OnStopSend(args);
                    break;

                case "GENERATEREPORT":
                    args = new CommandsEventArgs()
                    {
                        User = commandParams
                    };
                    OnGenerateReport(args);
                    break;
                }
            }

            //_fileSystemWatcher.EnableRaisingEvents = true;
        }
 protected virtual void OnGenerateReport(CommandsEventArgs args)
 {
     GenerateReportEvent?.Invoke(this, args);
 }
 protected virtual void OnStopSend(CommandsEventArgs args)
 {
     StopSendEvent?.Invoke(this, args);
 }
 protected virtual void OnRemoveThread(CommandsEventArgs args)
 {
     RemoveThreadEvent?.Invoke(this, args);
 }
 protected virtual void OnAddThread(CommandsEventArgs args)
 {
     AddThreadEvent?.Invoke(this, args);
 }
 protected virtual void OnStopProcess(CommandsEventArgs args)
 {
     StopProcessEvent?.Invoke(this, args);
 }