Esempio n. 1
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            IEnumerable <QueueDescriptor> queueDescriptors;

            if (_options.Public)
            {
                queueDescriptors = tools.GetPublicQueuesByMachine(_options.Machine, TransactionFromFlags(_options.Transactional, _options.NonTransactional));
            }
            else
            {
                queueDescriptors = tools.GetPrivateQueues(_options.Machine, TransactionFromFlags(_options.Transactional, _options.NonTransactional));
            }

            if (!string.IsNullOrEmpty(_options.Filter))
            {
                queueDescriptors = Filter(_options.Filter, queueDescriptors);
            }

            IReporter r;

            if (!string.IsNullOrEmpty(_options.DumpFile))
            {
                r = new JsonFileReporter(queueDescriptors, _options.DumpFile);
            }
            else
            {
                r = new LineReporter(queueDescriptors);
            }

            r.Report(log);
            return(true);
        }
Esempio n. 2
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            IEnumerable<QueueDescriptor> queueDescriptors;
            if(_options.Public)
            {
                queueDescriptors = tools.GetPublicQueuesByMachine(_options.Machine, TransactionFromFlags(_options.Transactional, _options.NonTransactional));
            }
            else
            {
                queueDescriptors = tools.GetPrivateQueues(_options.Machine, TransactionFromFlags(_options.Transactional, _options.NonTransactional));
            }

            if(!string.IsNullOrEmpty(_options.Filter))
            {
                queueDescriptors = Filter(_options.Filter, queueDescriptors);
            }

            IReporter r;

            if(!string.IsNullOrEmpty(_options.DumpFile))
            {
                r = new JsonFileReporter(queueDescriptors, _options.DumpFile);
            }
            else
            {
                r = new LineReporter(queueDescriptors);
            }

            r.Report(log);
            return true;
        }
Esempio n. 3
0
 public bool Execute(string subject, IQueueTools tools, IOutput log)
 {
     foreach(var m in tools.Tail(subject))
     {
         log.Out(m.ToString());
     }
     return true;
 }
Esempio n. 4
0
 public bool Execute(string subject, IQueueTools tools, IOutput log)
 {
     foreach (var m in tools.Tail(subject))
     {
         log.Out(m.ToString());
     }
     return(true);
 }
Esempio n. 5
0
        protected static bool Invoke(string initialSubject, ICommand q, IQueueTools tools, IOutput output, IInput input)
        {
            if (string.IsNullOrEmpty(initialSubject))
            {
                return ExecuteSafelyForEachInput(input, tools, output, q.Execute);
            }

            return ExecuteSafely(initialSubject, tools, output, (Func<string, IQueueTools, IOutput, bool>)q.Execute);
        }
Esempio n. 6
0
        protected static bool Invoke(string initialSubject, ICommand q, IQueueTools tools, IOutput output, IInput input)
        {
            if (string.IsNullOrEmpty(initialSubject))
            {
                return(ExecuteSafelyForEachInput(input, tools, output, q.Execute));
            }

            return(ExecuteSafely(initialSubject, tools, output, (Func <string, IQueueTools, IOutput, bool>)q.Execute));
        }
Esempio n. 7
0
 // in case action takes a subject (queue)
 protected static bool ExecuteSafely(string subject, IQueueTools tools, IOutput output, Func<string, IQueueTools, IOutput, bool> action)
 {
     try
     {
         return action.Invoke(subject, tools, output);
     }
     catch (Exception e)
     {
         output.Error(subject, e.Message);
         return false;
     }
 }
Esempio n. 8
0
 // in case action takes a subject (queue)
 protected static bool ExecuteSafely(string subject, IQueueTools tools, IOutput output, Func <string, IQueueTools, IOutput, bool> action)
 {
     try
     {
         return(action.Invoke(subject, tools, output));
     }
     catch (Exception e)
     {
         output.Error(subject, e.Message);
         return(false);
     }
 }
Esempio n. 9
0
        protected static bool ExecuteSafelyForEachInput(IInput input, IQueueTools tools, IOutput output, Func<string, IQueueTools, IOutput, bool> f)
        {
            string line = string.Empty;
            bool res = false;

            while(!string.IsNullOrEmpty(line = input.ReadLine()))
            {
                var exres = ExecuteSafely(line, tools, output, f);
                res = res || exres;
            }

            return res ;
        }
Esempio n. 10
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Error(subject, "Doesn't exist.");
                return false;
            }

            log.OK(subject, string.Format("{0} message(s).", tools.Count(subject)));
            return true;
        }
Esempio n. 11
0
        protected static bool ExecuteSafelyForEachInput(IInput input, IQueueTools tools, IOutput output, Func <string, IQueueTools, IOutput, bool> f)
        {
            string line = string.Empty;
            bool   res  = false;

            while (!string.IsNullOrEmpty(line = input.ReadLine()))
            {
                var exres = ExecuteSafely(line, tools, output, f);
                res = res || exres;
            }

            return(res);
        }
Esempio n. 12
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Error(subject, "Doesn't exist.");
                return(false);
            }

            log.OK(subject, string.Format("{0} message(s).", tools.Count(subject)));
            return(true);
        }
Esempio n. 13
0
 public bool Execute(string subject, IQueueTools tools, IOutput log)
 {
     try
     {
         int copied = tools.Transfer(subject, _opts.Destination, null, false, false);
         log.Out(subject + " copied to " + _opts.Destination + " (" + copied + " messages)");
         return(true);
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
         return(false);
     }
 }
Esempio n. 14
0
File: QCp.cs Progetto: jondot/qtools
 public bool Execute(string subject, IQueueTools tools, IOutput log)
 {
     try
     {
         int copied = tools.Transfer(subject, _opts.Destination, null, false, false);
         log.Out(subject + " copied to " + _opts.Destination + " ("+ copied +" messages)");
         return true;
     }
     catch (Exception ex)
     {
         log.Error(ex.Message);
         return false;
     }
 }
Esempio n. 15
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Warn(subject, "Doesn't exist, nothing to truncate.");
                return(false);
            }

            tools.DeleteAllMessages(subject);
            log.OK(subject, "Truncated.");

            return(true);
        }
Esempio n. 16
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Warn(subject, "Doesn't exist, nothing to truncate.");
                return false;
            }

            tools.DeleteAllMessages(subject);
            log.OK(subject, "Truncated.");

            return true;
        }
Esempio n. 17
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Warn(subject, "Does not exist.");
                return(true);
            }

            tools.Delete(subject);
            log.OK(subject, "Deleted.");

            return(true);
        }
Esempio n. 18
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Warn(subject, "Does not exist.");
                return true;
            }

            tools.Delete(subject);
            log.OK(subject, "Deleted.");

            return true;
        }
Esempio n. 19
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Warn(subject, "Doesn't exist. Skipping.");
                return(false);
            }

            log.Info(subject, "Listing results.");
            foreach (var res in tools.Cat(subject, _opts.WithExtension))
            {
                log.Out(res.ToString());
            }

            return(true);
        }
Esempio n. 20
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (!alreadyExists)
            {
                log.Warn(subject, "Doesn't exist. Skipping.");
                return false;
            }

            log.Info(subject, "Listing results.");
            foreach(var res in tools.Grep(subject, _opts.Expression, _opts.CaseInsensitive))
            {
                log.Out(res.ToString());
            }

            return true;
        }
Esempio n. 21
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (alreadyExists && !_opts.Force)
            {
                log.Error(subject, "Already exists. Issue -f to force creation.");
                return(false);
            }

            if (alreadyExists && _opts.Force)
            {
                tools.Delete(subject);
                log.Warn(subject, "Deleted (force).");
            }

            tools.Create(subject, _opts.User, _opts.Permissions, _opts.Transactional,
                         _opts.Limit);

            log.OK(subject, "Created.");
            return(true);
        }
Esempio n. 22
0
        public bool Execute(string subject, IQueueTools tools, IOutput log)
        {
            bool alreadyExists = tools.Exists(subject);

            if (alreadyExists && !_opts.Force)
            {
                log.Error(subject, "Already exists. Issue -f to force creation.");
                return false;
            }

            if (alreadyExists && _opts.Force)
            {
                tools.Delete(subject);
                log.Warn(subject, "Deleted (force).");
            }

            tools.Create(subject, _opts.User, _opts.Permissions, _opts.Transactional,
                        _opts.Limit);

            log.OK(subject, "Created.");
            return true;
        }