Beispiel #1
0
        public void FindMatch(string folder, string pattern)
        {
            var selectedDirectory = Path.Combine(LogsParserConstants.DefaultLogsFolder, folder);

            var files = cacheService.Get(
                selectedDirectory,
                () => directoryService.GetLogFilesPerDirectory(selectedDirectory),
                60);

            foreach (var file in files)
            {
                var allFileLines = File.ReadAllLines(file);

                for (int i = 0; i < allFileLines.Length; i++)
                {
                    var row = allFileLines[i].IndexOf(pattern, StringComparison.CurrentCultureIgnoreCase);
                    if (row >= 0)
                    {
                        var model = new MatchModelHub()
                        {
                            Path     = $"{folder}/{Path.GetFileName(file)}",
                            Filename = Path.GetFileNameWithoutExtension(file),
                            Col      = i,
                            Row      = row
                        };
                        Clients.All.addLinkForMatch(model);
                    }
                }
            }
        }
Beispiel #2
0
        public ActionResult Index()
        {
            var directories = cacheService.Get(
                LogsParserConstants.DirectoriesCacheKey,
                () => directoryService.GetLogDirectories(), 60);

            var formViewModel = new SearchFormModel()
            {
                Directories = directories
            };

            return(View(formViewModel));
        }