예제 #1
0
        public ActionResult Search(string applicationName, string q)
        {
            Environment currentEnvironment = GetSelectedEnvironment();

            ViewBag.EnvironmentName = currentEnvironment.Name;
            ViewBag.ApplicationName = applicationName;
            ViewBag.SearchQuery = q;

            IEnumerable<LogEntry> results = new LogEntry[0];

            if (_configuration.IsLuceneEnabled)
            {
                var searchRepository = new SearchRepository(_configuration);
                string query = searchRepository.CreateLuceneSearchSyntax(applicationName, currentEnvironment.Name, q);
                results = searchRepository.Search(query);
            }
            else
            {
                // Use MongoDB's slower search.
                results = _repository.Search(currentEnvironment.Name, applicationName, q);
            }

            return View(results);
        }
예제 #2
0
파일: Runner.cs 프로젝트: floradu88/kelpie
        public void Run(string[] args)
        {
            var options = new Options();
            bool success = CommandLine.Parser.Default.ParseArguments(args, options);

            if (success)
            {
                // Nothing to do
                if (!options.Import && !options.CopyFiles && !options.WipeData && !options.Index)
                {
                    System.Console.WriteLine(options.GetUsage());
                    return;
                }

                if (options.WipeData)
                {
                    System.Console.WriteLine("Wiping the database.");
                    _repository.DeleteAll();
                }

                var logReader = new FileSystemLogReader(_configuration);
                var containerList = new List<ServerLogFileContainer>();

                // Populate the list of files to copy/import first.
                if (options.CopyFiles || options.Import)
                {
                    if (!string.IsNullOrEmpty(options.Environment))
                    {
                        System.Console.WriteLine("- Restricting import to {0} environment only", options.Environment);
                        containerList = logReader.ScanSingleEnvironment(options.Environment).ToList();
                    }
                    else if (!string.IsNullOrEmpty(options.Server))
                    {
                        System.Console.WriteLine("- Restricting import to {0} server only", options.Server);
                        containerList.Add(logReader.ScanSingleServer(options.Server));
                    }
                    else
                    {
                        System.Console.WriteLine("- Importing from all environments and servers");
                        containerList = logReader.ScanAllEnvironments().ToList();
                    }
                }

                if (options.CopyFiles)
                {
                    foreach (ServerLogFileContainer container in containerList)
                    {
                        logReader.CopyToLocalDisk(container);
                    }
                }

                if (options.Import)
                {
                    var parser = new DefaultNLogFormatParser(_repository, options.SmartUpdate);

                    if (_configuration.ImportBufferSize > 0)
                        parser.MaxEntriesBeforeSave = _configuration.ImportBufferSize;

                    foreach (ServerLogFileContainer container in containerList)
                    {
                        parser.ParseAndSave(container);
                    }
                }

                if (options.Index)
                {
                    var searchRepository = new SearchRepository(_configuration);
                    searchRepository.CreateIndex(_repository);
                }

                System.Console.WriteLine("Finished.");
            }
        }