private void SearchForNewLogFiles() { List <string> directoriesToDrop = new(); foreach (var directory in Settings.LogDirectories) { if (Directory.Exists(directory)) { // when a logfolder gets deleted that was added to Settings Chia Plot Status failed to start foreach (var filePath in Directory.GetFiles(directory)) { if (!PlotLogFiles.ContainsKey(filePath) && LooksLikeAPlotLog(filePath)) { PlotLogFiles[filePath] = new PlotLogFileParser(filePath); } } } else { directoriesToDrop.Add(directory); } } foreach (var directory in directoriesToDrop) { Settings.LogDirectories.Remove(directory); } }
public void RemoveLogFolder(string path) { Settings.LogDirectories.Remove(path); // drop plotlogs from that folder foreach (var plotLogFile in PlotLogFiles.Values) { var folder = plotLogFile.LogFolder; if (string.Equals(folder, path)) { PlotLogFiles.Remove(plotLogFile.LogFile); } folder = folder + "\\"; if (string.Equals(folder, path)) { PlotLogFiles.Remove(plotLogFile.LogFile); } } }
public List <(PlotLog, PlotLogReadable)> PollPlotLogs(string sortPropertyName, bool sortAsc, string?searchString, Filter filter) { SearchForNewLogFiles(); ConcurrentBag <PlotLog> plotLogs = ParseTheLogs(); if (Settings.AlwaysDoFullRead == true) // nullable, so == true { PlotLogFiles.Clear(); } HandleStatistics(plotLogs.ToList()); List <(PlotLog, PlotLogReadable)> plusReadable = new(); foreach (var plotLog in plotLogs) { foreach (var markOfDeath in Settings.MarksOfDeath) { if (markOfDeath.IsMatch(plotLog)) { plotLog.Health = new ConfirmedDead(true); } } if (!plotLog.IsRunning()) { plotLog.RunTimeSeconds = 0; } else if (plotLog.StartDate != null) { plotLog.RunTimeSeconds = (int)((TimeSpan)(DateTime.Now - plotLog.StartDate)).TotalSeconds; } plusReadable.Add((plotLog, new PlotLogReadable(plotLog))); } List <(PlotLog, PlotLogReadable)> result = Filter(searchString, filter, plusReadable); SortPlotLogs(sortPropertyName, sortAsc, result); return(result); }