Exemplo n.º 1
0
        private static void StartService(string[] args)
        {
            ComponentRegister.Register(ComponentType.Server);

            _logger = IoCContainer.Instance.Resolve <ILogger>();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var logFileConfig = GetLogConfiguration();

            _logger.AddLogDestination(new FileLogDestination(logFileConfig));

            _logger.Log(string.Format("Server starting up local time - {0}", DateTime.UtcNow.ToLocalTime()));

            if (Environment.UserInteractive)
            {
                _logger.AddLogDestination(new ConsoleLogDestination());

                _logger.Log("Detected User Interactive session.");

                Console.CancelKeyPress += Console_CancelKeyPress;

                _logger.Log("Press Ctrl+C to shut down server.");
            }

            _logger.Start();

            _logger.Log("Starting up HostService");

            _hostService = new HostService();

            _logger.Log("HostService running.");

            _stopService.WaitOne();

            _logger.Log("Server shutting down...");

            _hostService.Stop();

            _logger.Log("Server shut down.");

            //last thing to do is shut down logging system
            _logger.Stop();

            //last thing that happens ever
            _serviceStopped.Set();
        }
Exemplo n.º 2
0
        private Tuple <ILogger, TestLogDestination> CreateLogger()
        {
            ILogger            logger = Logger.CreateInstance();
            TestLogDestination dest   = new TestLogDestination();

            logger.AddLogDestination(dest);

            logger.Start();

            logger.Flush();

            Thread.Sleep(1000);

            dest.Messages.Clear();

            return(new Tuple <ILogger, TestLogDestination>(logger, dest));
        }
Exemplo n.º 3
0
        public static int Main(string[] args)
        {
            Environment.ExitCode = 0;

            _logger = Logger.CreateInstance();
            _logger.AddLogDestination(new ConsoleLogDestination());
            _logger.Start();

            try
            {
                _settings = new Settings(_logger);
                _settings.SourceFolder = Path.GetFullPath(_settings.SourceFolder);

                string[] files = Directory.GetFiles(_settings.SourceFolder, _searchPath, SearchOption.AllDirectories);
                _logger.Log("Found " + files.Length + " projects.");

                foreach (var projectFile in files)
                {
                    if (!string.IsNullOrEmpty(projectFile))
                    {
                        if (File.Exists(projectFile))
                        {
                            var project = new Project(projectFile);

                            GlobalAssemblyUpdater(project);

                            OutFolderUpdater(project);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex.ToString(), LogMessageSeverity.Critical);
                Environment.ExitCode--;
            }

            _logger.Log("Done, returning " + Environment.ExitCode + ", bye!");
            _logger.Stop();
            return(Environment.ExitCode);
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            _logger = Logger.CreateInstance();

            _logger.AddLogDestination(new ConsoleLogDestination());

            _logger.Start();

            Console.CancelKeyPress += Console_CancelKeyPress;

            ComponentServiceAbuser abuser = new ComponentServiceAbuser(_logger);

            abuser.Start();

            _stop.WaitOne();

            abuser.Stop();

            _logger.Stop();

            _exit.Set();
        }
Exemplo n.º 5
0
        public static int Main(string[] args)
        {
            Environment.ExitCode = 0;

            ILogger logger = Logger.CreateInstance();

            logger.AddLogDestination(new ConsoleLogDestination());

            logger.Start();

            _settings = new Settings(logger);

            if (File.Exists(_settings.AssemblyInfoFile))
            {
                var lines = File.ReadAllLines(_settings.AssemblyInfoFile);

                string oldVersion   = string.Empty;
                string finalVersion = string.Empty;

                for (int i = 0; i < lines.Count(); i++)
                {
                    var line = lines[i];

                    if (line.StartsWith("[assembly:"))
                    {
                        if (line.Contains("Version"))
                        {
                            if (string.IsNullOrEmpty(oldVersion))
                            {
                                var reg = new Regex(@"\d+(?:\.\d+)+");
                                var mc  = reg.Match(line);

                                if (mc.Success)
                                {
                                    oldVersion = mc.Value;

                                    int indexOfLastDot = oldVersion.LastIndexOf('.');

                                    if (indexOfLastDot > 0)
                                    {
                                        string realVersion = oldVersion.Substring(0, indexOfLastDot);

                                        logger.Log(string.Format("##teamcity[setParameter name='{0}' value='{1}']", _settings.TeamCityParameterName, realVersion));

                                        finalVersion = string.Format("{0}.{1}", realVersion, _settings.BuildNumber);

                                        logger.Log(string.Format("##teamcity[buildNumber '{0}']", finalVersion));

                                        logger.Log(string.Format("Setting version to \"{0}\".", finalVersion));

                                        lines[i] = line.Replace(oldVersion, finalVersion);
                                    }
                                    else
                                    {
                                        logger.Log(string.Format("Cannot find version number in file \"{0}\".", _settings.AssemblyInfoFile), LogMessageSeverity.Error);
                                        Environment.ExitCode--;
                                    }
                                }
                            }
                            else
                            {
                                if (!string.IsNullOrEmpty(finalVersion))
                                {
                                    lines[i] = line.Replace(oldVersion, finalVersion);
                                }
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(finalVersion))
                {
                    logger.Log(string.Format("Saving to file \"{0}\".", _settings.AssemblyInfoFile));
                    File.WriteAllLines(_settings.AssemblyInfoFile, lines);
                }
            }
            else
            {
                logger.Log(string.Format("Cannot find file \"{0}\".", _settings.AssemblyInfoFile), LogMessageSeverity.Error);
                Environment.ExitCode--;
            }

            logger.Stop();

            return(Environment.ExitCode);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            _logger = Logger.CreateInstance();

            _logger.AddLogDestination(new ConsoleLogDestination());

            var config = new FileLogDestinationConfig();

            config.LogDirectory        = ".\\logs";
            config.LogFileExtension    = "csv";
            config.LogFilePrefix       = "TestLog";
            config.LogMessageFormatter = new CSVLogMessageFormatter();
            config.MaxLogFileCount     = 10;
            config.MaxLogFileSize      = 10;

            _logger.AddLogDestination(new FileLogDestination(config));


            TCPLogDestinationConfig tcp_config = new TCPLogDestinationConfig();

            tcp_config.LogMessageFormatter = new CSVLogMessageFormatter();
            tcp_config.HostName            = "testboxen";
            tcp_config.Port = 40514;

            //_logger.AddLogDestination(new TCPLogDestination(tcp_config));

            Core.Logging.Log4Net.LogDestinationConfigs.XMLDestinationConfig xml_config = new Core.Logging.Log4Net.LogDestinationConfigs.XMLDestinationConfig();
            xml_config.LogDirectory  = ".\\xml_logs";
            xml_config.LogFilePrefix = "XmlTestLog";

            _logger.AddLogDestination(new Core.Logging.Log4Net.XMLDestination(xml_config));

            RemoteLogDestination remote = new RemoteLogDestination();

            _logger.AddLogDestination(remote);


            EventViewerDestinationConfig event_viewer_config = new EventViewerDestinationConfig();

            event_viewer_config.Source  = "HostService";
            event_viewer_config.LogName = "Host Service Log";

            _logger.AddLogDestination(new EventViewerDestination(event_viewer_config));

            _logger.Start();

            Console.CancelKeyPress += Console_CancelKeyPress;

            _abuser = new LogAbuser(_logger);

            _abuser.SleepTimeInMilliseconds = 5000;

            foreach (string s in args)
            {
                if (s == "very")
                {
                    _abuser.VeryAbusive = true;
                }

                if (s == "super")
                {
                    _abuser.SuperAbusive = true;
                }

                if (s == "ultra")
                {
                    _abuser.UltraAbusive = true;
                }
            }

            _abuser.Start();

            while (!_stop.WaitOne(50))
            {
                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(true).Key;

                    switch (key)
                    {
                    case ConsoleKey.UpArrow:
                        _abuser.SleepTimeInMilliseconds = _abuser.SleepTimeInMilliseconds + 500;
                        break;

                    case ConsoleKey.DownArrow:
                        _abuser.SleepTimeInMilliseconds = _abuser.SleepTimeInMilliseconds - 500;

                        if (_abuser.SleepTimeInMilliseconds < 0)
                        {
                            _abuser.SleepTimeInMilliseconds = 1;
                        }

                        break;
                    }
                }
            }

            _abuser.Stop();

            _logger.Stop();

            _stopped.Set();
        }