Пример #1
0
 public TeamCityNUnitLogger(string args, TextWriter output, ICommandLog log)
 {
     Output = output;
     Log    = log;
     CommandArgumentsForLogging = args;
     TeamCityFormatter          = new TeamCityFormatter();
 }
Пример #2
0
        public ProcessOutput Execute(string commandName, string commandArgs)
        {
            ICommandLog commandLog = Log.BeginExecutingCommand(commandName, commandArgs);

            string commandArgumentsForLogging = commandLog.CommandArgumentsForLogging;
            var    output = new CommandOutputReceiver(commandLog);

            Process p = CreateProcess(commandName, commandArgumentsForLogging, output);

            try
            {
                RunProcess(p);
            }
            catch (Win32Exception win32Ex)
            {
                if (win32Ex.NativeErrorCode == 2)
                { // executable file not found
                    throw new ShellExecutableNotFoundException(commandName);
                }
                throw;
            }

            commandLog.CommandComplete(p.ExitCode);

            return(new ProcessOutput
            {
                ExitCode = p.ExitCode,
                Output = output.Output,
                Error = output.Error,
                ErrorAndOutput = output.ErrorAndOutput
            });
        }
Пример #3
0
 public InMemEventStore(IServiceProvider serviceProvider)
 {
     _aggregateRepository  = new AggregateRepository(this);
     _projectionRepository = new ProjectionRepository(serviceProvider);
     _commandLog           = new InMemCommandLog();
     _sequences            = new InMemSequenceStore();
 }
Пример #4
0
        public PostgresEventStore(IServiceProvider serviceProvider, string connectionString, string databaseSchemaName, bool cleanAll = false)
        {
            _aggregateRepository  = new AggregateRepository(this);
            _projectionRepository = new ProjectionRepository(serviceProvider);

            var options = new StoreOptions();

            options.Connection(connectionString);
            options.Projections.Add(new Projection(_projectionRepository));

            // Serialize enums as strings
            var serializer = new Marten.Services.JsonNetSerializer();

            serializer.EnumStorage = Weasel.Core.EnumStorage.AsString;
            options.Serializer(serializer);

            // Can be overridden
            options.AutoCreateSchemaObjects = Weasel.Postgresql.AutoCreate.All;
            options.DatabaseSchemaName      = databaseSchemaName;

            _store = new DocumentStore(options);

            if (cleanAll)
            {
                _store.Advanced.Clean.CompletelyRemoveAll();
            }

            _commandLog = new PostgresCommandLog(_store);

            _sequences = new PostgresSequenceStore(connectionString, databaseSchemaName);
        }
Пример #5
0
 public TeamCityNUnitLogger(string args, TextWriter output, ICommandLog log)
 {
     Output = output;
     Log = log;
     CommandArgumentsForLogging = args;
     TeamCityFormatter = new TeamCityFormatter();
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RetroactiveCommandHandler{TCommand}"/> class.
 /// </summary>
 /// <param name="retroactive">Retroactive functional</param>
 /// <param name="commandLog">Command log</param>
 /// <param name="log">Application log</param>
 /// <param name="messageQueue">Message queue</param>
 /// <param name="handler">Underlying command handler</param>
 public RetroactiveCommandHandler(IRetroactive retroactive, ICommandLog commandLog, ILog log, IMessageQueue messageQueue, ICommandHandler <TCommand> handler)
 {
     _retroactive  = retroactive;
     _commandLog   = commandLog;
     _log          = log;
     _messageQueue = messageQueue;
     _handler      = handler;
 }
Пример #7
0
        public TeamCity5NUnitLogger(string args, TextWriter output, ICommandLog log)
            : base(args, output, log)
        {
            Output            = output;
            TeamCityFormatter = new TeamCityFormatter();

            SummaryRegex = new Regex(@"Tests run: (\d.*), Errors: (\d.*), Failures: (\d.*), Inconclusive: (\d.*), Time: (\d.*) seconds");
        }
Пример #8
0
        public TeamCity5NUnitLogger(string args, TextWriter output, ICommandLog log)
            : base(args, output, log)
        {
            Output = output;
            TeamCityFormatter = new TeamCityFormatter();

            SummaryRegex = new Regex(@"Tests run: (\d.*), Errors: (\d.*), Failures: (\d.*), Inconclusive: (\d.*), Time: (\d.*) seconds");
        }
Пример #9
0
        public override ICommandLog BeginExecutingCommand(string command, string args)
        {
            var commandName = Path.GetFileName(command);

            ICommandLog log = base.BeginExecutingCommand(command, args);

            return(GetLoggerForExecutable(args, log, commandName));
        }
Пример #10
0
 public CommandOutputReceiver(ICommandLog commandLog) {
     CommandLog = commandLog;
     OutputWriter = new StringWriter();
     SynchronizedOutputWriter = TextWriter.Synchronized(OutputWriter);
     ErrorWriter = new StringWriter();
     SynchronizedErrorWriter = TextWriter.Synchronized(ErrorWriter);
     CombinedWriter = new StringWriter();
     SynchronizedCombinedWriter = TextWriter.Synchronized(CombinedWriter);
 }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandHandler{T}"/> class.
 /// </summary>
 /// <param name="handler">Underlying handler to decorate</param>
 /// <param name="log">Application logger</param>
 /// <param name="timeline">Active timeline</param>
 /// <param name="commandLog">Command log</param>
 /// <param name="errorLog">Error log</param>
 /// <param name="branchManager">Branch manager</param>
 public CommandHandler(ICommandHandler <T> handler, ILog log, ITimeline timeline, ICommandLog commandLog, IErrorLog errorLog, IBranchManager branchManager)
 {
     _handler       = handler;
     _log           = log;
     _timeline      = timeline;
     _commandLog    = commandLog;
     _errorLog      = errorLog;
     _branchManager = branchManager;
 }
Пример #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NoTrackingBus"/> class.
        /// </summary>
        /// <param name="container"><see cref="SimpleInjector"/> container</param>
        /// <param name="log">Application log</param>
        /// <param name="timeline">Timeline</param>
        /// <param name="messageQueue">Message queue</param>
        /// <param name="commandLog">Command log</param>
        public NoTrackingBus(Container container, ILog log, ITimeline timeline, IMessageQueue messageQueue, ICommandLog commandLog)
        {
            _container    = container;
            _log          = log;
            _timeline     = timeline;
            _messageQueue = messageQueue;
            _commandLog   = commandLog;

            messageQueue.Alerts.OfType <BranchDeleted>().Subscribe(e => DeleteDispatcher(e.BranchId));
        }
Пример #13
0
 public CommandOutputReceiver(ICommandLog commandLog)
 {
     CommandLog                 = commandLog;
     OutputWriter               = new StringWriter();
     SynchronizedOutputWriter   = TextWriter.Synchronized(OutputWriter);
     ErrorWriter                = new StringWriter();
     SynchronizedErrorWriter    = TextWriter.Synchronized(ErrorWriter);
     CombinedWriter             = new StringWriter();
     SynchronizedCombinedWriter = TextWriter.Synchronized(CombinedWriter);
 }
Пример #14
0
        public TeamCityMsBuildLogger(string args, TextWriter stdout, ICommandLog log)
        {
            this.stdout = stdout;
            Log         = log;

            Type msBuildLoggerType = typeof(MSBuildLogger);

            string loggerType = String.Format(@"""/l:{0},{1}""", msBuildLoggerType.FullName, msBuildLoggerType.Assembly.Location);

            CommandArgumentsForLogging = args + " " + loggerType + " /nologo /noconsolelogger";
            warningRegex = CreateRegexFor("warning");
            errorRegex   = CreateRegexFor("error");

            TeamCityFormatter = new TeamCityFormatter();
        }
Пример #15
0
        public TeamCityMsBuildLogger(string args, TextWriter stdout, ICommandLog log)
        {
            this.stdout = stdout;
            Log = log;

            Type msBuildLoggerType = typeof(MSBuildLogger);

            string loggerType = String.Format(@"""/l:{0},{1}""", msBuildLoggerType.FullName, msBuildLoggerType.Assembly.Location);

            CommandArgumentsForLogging = args + " " + loggerType + " /nologo /noconsolelogger";
            warningRegex = CreateRegexFor("warning");
            errorRegex = CreateRegexFor("error");

            TeamCityFormatter = new TeamCityFormatter();
        }
Пример #16
0
        public void Execute(string arguments, ICommandLog log)
        {
            string[] parts = arguments.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length < 2)
            {
                log.WriteLine("Invalid number of arguments. The divide command requires at least two values.");
                return;
            }

            bool   isFirstValue = true;
            double quotient     = 0;

            StringBuilder result = new StringBuilder();

            foreach (var textValue in parts)
            {
                double numberValue;
                if (!double.TryParse(textValue, out numberValue))
                {
                    log.WriteLine(string.Format("'{0}' is not a number.", textValue));
                    return;
                }

                if (isFirstValue)
                {
                    quotient     = numberValue;
                    isFirstValue = false;
                }
                else
                {
                    quotient /= numberValue;
                }

                if (result.Length != 0)
                {
                    result.Append(" / ");
                }

                result.Append(textValue);
            }

            result.Append(" = ");
            result.Append(quotient);


            log.WriteLine(result.ToString());
        }
Пример #17
0
        private ICommandLog GetLoggerForExecutable(string args, ICommandLog log, string commandName)
        {
            switch (commandName.ToLower())
            {
            case "msbuild.exe":
                return(new TeamCityMsBuildLogger(args, Output, log));

            case "nunit-console.exe":
            case "nunit-console-x86.exe":
                return(NUnitLogger(args, Output, log));

            case "partcover.exe":
                return(GetLoggerForExecutable(args, log, GetPartCoverTarget(args)));

            default:
                return(log);
            }
        }
Пример #18
0
        public void Execute(string arguments, ICommandLog log)
        {
            string[] parts = arguments.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            if (parts.Length < 2)
            {
                log.WriteLine("Invalid number of arguments. The multiply command requires at least two values.");
                return;
            }

            double product = 1;

            StringBuilder result = new StringBuilder();

            foreach (var textValue in parts)
            {
                double numberValue;
                if (!double.TryParse(textValue, out numberValue))
                {
                    log.WriteLine(string.Format("'{0}' is not a number.", textValue));
                    return;
                }

                product *= numberValue;

                if (result.Length != 0)
                {
                    result.Append(" x ");
                }

                result.Append(textValue);
            }

            result.Append(" = ");
            result.Append(product);


            log.WriteLine(result.ToString());
        }
Пример #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BranchManager"/> class.
        /// </summary>
        /// <param name="log">Application logger</param>
        /// <param name="activeTimeline">Root timeline</param>
        /// <param name="messageQueue">Message queue</param>
        /// <param name="eventStore">Event store</param>
        /// <param name="sagaStore">Saga store</param>
        /// <param name="streamLocator">Stream locator</param>
        /// <param name="graph">Graph</param>
        /// <param name="commandLog">Command log</param>
        /// <param name="clock">Logical clock</param>
        public BranchManager(
            ILog log,
            ITimeline activeTimeline,
            IMessageQueue messageQueue,
            IEventStore <IAggregate> eventStore,
            IEventStore <ISaga> sagaStore,
            IStreamLocator streamLocator,
            IGraph graph,
            ICommandLog commandLog,
            IClock clock)
        {
            _log            = log;
            _activeTimeline = activeTimeline as Timeline;
            _messageQueue   = messageQueue;
            _eventStore     = eventStore;
            _streamLocator  = streamLocator;
            _graph          = graph;
            _commandLog     = commandLog;
            _clock          = clock;
            _sagaStore      = sagaStore;

            _branches.TryAdd(Master, activeTimeline.New(Master));
        }
Пример #20
0
 private ICommandLog GetLoggerForExecutable(string args, ICommandLog log, string commandName)
 {
     switch (commandName.ToLower())
     {
         case "msbuild.exe":
             return new TeamCityMsBuildLogger(args, Output, log);
         case "nunit-console.exe":
         case "nunit-console-x86.exe":
             return NUnitLogger(args, Output, log);
         case "partcover.exe":
             return GetLoggerForExecutable(args, log, GetPartCoverTarget(args));
         default:
             return log;
     }
 }
Пример #21
0
 public virtual ICommandLog NUnitLogger(string args, TextWriter output, ICommandLog log)
 {
     return new TeamCityNUnitLogger(args, output, log);
 }
Пример #22
0
 public virtual ICommandLog NUnitLogger(string args, TextWriter output, ICommandLog log)
 {
     return(new TeamCityNUnitLogger(args, output, log));
 }
Пример #23
0
 public override ICommandLog NUnitLogger(string args, TextWriter output, ICommandLog log)
 {
     return new TeamCity5NUnitLogger(args, output, log);
 }
Пример #24
0
 public override ICommandLog NUnitLogger(string args, TextWriter output, ICommandLog log)
 {
     return(new TeamCity5NUnitLogger(args, output, log));
 }