Пример #1
0
        public string CloseHandler(DirectoryHandlerClosedEventArgs args, out EventLogEntryType result)
        {
            DirectoryHandlerClosed?.Invoke(this, args);
            result = EventLogEntryType.Information;

            return(args.DirectoryPath);
        }
        public string Execute(string[] args, out EventLogEntryType result)
        {
            DirectoryHandlerClosedEventArgs directoryHandlerClosedEventArgs =
                new DirectoryHandlerClosedEventArgs(args[0], "Close");

            string s = _imageServer.CloseHandler(directoryHandlerClosedEventArgs, out result);

            return(directoryHandlerClosedEventArgs.Closed ? s : null);
        }
Пример #3
0
        /// <summary>
        ///     Called when a directory handler is closed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DirectoryHandlerClosedEventArgs" /> instance containing the event data.</param>
        private void OnDirectoryHandlerClosed(object sender, DirectoryHandlerClosedEventArgs e)
        {
            eventLog.WriteEntry("In OnDirectoryHandlerClosed", EventLogEntryType.Information);

            // 'e' being 'null' means to remove all handlers.
            if (e == null)
            {
                _settingsInfo.HandledDirectories.Clear();
            }
            else
            {
                _settingsInfo.HandledDirectories.Remove(e.DirectoryPath);
                _tcpServer.RemoveDirHandlerFromAllGuis(e.DirectoryPath);
            }
        }
        /// <summary>
        ///     Parse the msg recieved from the server.
        /// </summary>
        /// <param name="msg">The message to parse.</param>
        public void ParseMessage(string msg)
        {
            string[]    parameters = msg.Split('|');
            CommandEnum command    = (CommandEnum)Enum.Parse(typeof(CommandEnum), parameters[0]);

            switch (command)
            {
            case CommandEnum.NewLogCommand:
                Log(parameters[1], (EventLogEntryType)Enum.Parse(typeof(EventLogEntryType), parameters[2]));
                break;

            case CommandEnum.CloseDirectoryHandlerCommand:
                DirectoryHandlerClosedEventArgs
                    dhceArgs = new DirectoryHandlerClosedEventArgs(parameters[1], "hmm");

                DirectoryHandlerRemoved?.Invoke(this, dhceArgs);
                break;

            case CommandEnum.NewFileCommand:
                break;

            case CommandEnum.ConfigCommand:
                ConfigurationReceivedEventArgs creArgs = new ConfigurationReceivedEventArgs(parameters[1]);
                ConfigurationReceived?.Invoke(this, creArgs);
                break;

            case CommandEnum.LogHistoryCommand:
                string  jsonMsg        = msg.Replace(CommandEnum.LogHistoryCommand + "|", "");
                JObject logHistoryJson = JObject.Parse(jsonMsg);
                List <Tuple <string, EventLogEntryType> > entries =
                    logHistoryJson["LOGS"].ToObject <List <Tuple <string, EventLogEntryType> > >();

                foreach (Tuple <string, EventLogEntryType> logEntry in entries)
                {
                    Log(logEntry.Item1, logEntry.Item2);
                }
                LogHistoryMessageRecieved?.Invoke(this, null);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #5
0
        /// <summary>
        ///     Called when a directory handler is closed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="DirectoryHandlerClosedEventArgs" /> instance containing the event data.</param>
        public void OnDirectoryHandlerClosed(object sender, DirectoryHandlerClosedEventArgs args)
        {
            if (args != null && !args.DirectoryPath.Equals(_path))
            {
                return;
            }

            _dirWatcher.Created -= OnNewFileCreated;

            DirectoryHandlerClosed?.Invoke(this,
                                           new DirectoryHandlerClosedEventArgs(_path, "in OnDirectoryHandlerClosed"));

            _loggingService.Log("Stopped handling directory " + _path, EventLogEntryType.Information);
            if (args != null)
            {
                args.Closed = true;
            }

            ImageServer imageServer = (ImageServer)sender;

            imageServer.DirectoryHandlerClosed -= OnDirectoryHandlerClosed;
            imageServer.CommandRecieved        -= OnCommandRecieved;
        }