Ejemplo n.º 1
0
        public bool Send(string command)
        {
            if (Status != CommandProcessorStatus.Ready)
            {
                throw new InvalidOperationException(string.Format("Cannot process a command processor that is currently in the '{0}' state.", Status));
            }
            if (string.IsNullOrWhiteSpace(command))
            {
                throw new ArgumentException("Processing command cannot be null or empty.", "command");
            }

            try
            {
                Status = CommandProcessorStatus.Processing;

                ProcessIt(command);

                Status = CommandProcessorStatus.Ready;
            }
            catch (Exception err)
            {
                Error  = err;
                Status = CommandProcessorStatus.Faulted;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        public bool Open()
        {
            if (Status != CommandProcessorStatus.Closed)
            {
                throw new InvalidOperationException(string.Format("Cannot open a command processor that is currently in the '{0}' state.", Status));
            }

            try
            {
                Log.SetAttributes(ResourceManagement.CommandConfiguration.LoggingAttributes);

                Log.DebugFormat("Opening command processor.");

                Create();

                Status = CommandProcessorStatus.Ready;
            }
            catch (Exception err)
            {
                Error  = err;
                Status = CommandProcessorStatus.Faulted;
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public bool Send(string command, int?timeoutMilliseconds)
        {
            if (Status != CommandProcessorStatus.Ready)
            {
                throw new InvalidOperationException(string.Format("Cannot process a command processor that is currently in the '{0}' state.", Status));
            }
            if (string.IsNullOrWhiteSpace(command))
            {
                throw new ArgumentException("Processing command cannot be null or empty.", "command");
            }

            Command = command;

            var retryCount   = 0;
            var isSuccessful = false;

            do
            {
                try
                {
                    Status = CommandProcessorStatus.Processing;

                    ProcessIt(command, timeoutMilliseconds);

                    Status = CommandProcessorStatus.Ready;

                    isSuccessful = true;
                }
                catch (Exception err)
                {
                    if (!CheckForKnownExceptions(err))
                    {
                        Error  = err;
                        Status = CommandProcessorStatus.Faulted;
                        return(false);
                    }

                    retryCount++;
                }
            } while (!isSuccessful && retryCount <= MaximumRetryFailures);

            return(true);
        }
Ejemplo n.º 4
0
        public bool Close()
        {
            if (Status != CommandProcessorStatus.Ready)
            {
                throw new InvalidOperationException(string.Format("Cannot close a command processor that is currently in the '{0}' state.", Status));
            }

            try
            {
                Log.DebugFormat("Closing command processor.");

                Delete();

                Status = CommandProcessorStatus.Closed;
            }
            catch (Exception err)
            {
                Error  = err;
                Status = CommandProcessorStatus.Faulted;
                return(false);
            }
            return(true);
        }