private void timerStatus_Tick(object sender, EventArgs e) { var logPath = Environment.ExpandEnvironmentVariables(@"%APPDATA%\hydra\cache\Log.txt"); var registrySettings = new RegistrySettings(); var doEvents = false; string logDirectoryPath; if (paused) { return; } registrySettings.Initialize(); this.CurrentWorkingDirectory = registrySettings.CurrentWorkingDirectory; this.PackageCachePath = registrySettings.PackagePathCache; if (!this.PackageCachePath.IsNullOrEmpty()) { logPath = Path.Combine(this.PackageCachePath, "Log.txt"); } logDirectoryPath = Path.GetDirectoryName(logPath); if (Directory.Exists(logDirectoryPath)) { this.PackageCachePath = logDirectoryPath; toolsFolder = Path.Combine(this.PackageCachePath, "tools"); reportsFolder = Path.Combine(this.PackageCachePath, "reports"); sweepsFolder = Path.Combine(this.PackageCachePath, "sweeps"); if (!watchingCache) { folderViewService = new FolderViewService(listViewFolders, logDirectoryPath); folderViewService.Start(); watchingCache = true; } if (Directory.Exists(sweepsFolder)) { var directorySweeps = new DirectoryInfo(sweepsFolder); var sweepLogFiles = directorySweeps.GetFiles(); var names = new List <string>(); if (sweepLogFiles.Length > 0) { if (!panelSweeps.Visible) { panelSweeps.Visible = true; sweepsToolStripMenuItem.Checked = panelSweeps.Visible; } foreach (var sweepLogFile in sweepLogFiles.OrderBy(f => f.Name)) { var regex = new Regex(@"(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})_(?<hour>\d{2})(?<minute>\d{2})(?<second>\d{2})_"); regex.Match(sweepLogFile.Name, (match) => { var year = int.Parse(match.GetGroupValue("year")); var month = int.Parse(match.GetGroupValue("month")); var day = int.Parse(match.GetGroupValue("day")); var hour = int.Parse(match.GetGroupValue("hour")); var minute = int.Parse(match.GetGroupValue("minute")); var second = int.Parse(match.GetGroupValue("second")); var dateTime = new DateTime(year, month, day, hour, minute, second); var name = dateTime.ToDateTimeText(); names.Add(name); if (!listBoxSweeps.Items.Cast <SweepLogItem>().Any(i => i.Name == name)) { var logItem = new SweepLogItem(name, dateTime, sweepLogFile); listBoxSweeps.Items.Add(logItem); listBoxSweeps.ScrollToLast(); } }); } } foreach (var logItemDelete in listBoxSweeps.Items.Cast <SweepLogItem>().ToList().Where(i => !names.Any(n => n == i.Name))) { listBoxSweeps.Items.Remove(logItemDelete); } } else { listBoxSweeps.Items.Clear(); } } if (File.Exists(logPath)) { IEnumerable <string> logLines = null; try { using (var reader = new StreamReader(File.Open(logPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))) { var linesLength = richTextBoxStatus.Lines.Length; if (linesLength > 0) { logLines = reader.ReadToEnd().GetLines().Skip(richTextBoxStatus.Lines.Length); if (linesLength > lastLinesLength) { } lastLinesLength = linesLength; } else { logLines = reader.ReadToEnd().GetLines(); } } if (logLines.Count() > 0) { richTextBoxStatus.AppendText(logLines.ToMultiLineList() + "\r\n"); richTextBoxStatus.ScrollToEnd(); } } catch (Exception ex) { SetTempStatus($"Error with log file: { ex.Message }"); } } if (!this.CurrentWorkingDirectory.IsNullOrEmpty()) { if (timerCounter == 0) { var directory = new DirectoryInfo(Path.Combine(this.CurrentWorkingDirectory, "src")); var processes = Process.GetProcessesByName("node"); int count; if (processes.Length > 0) { count = processes.Length; killNodeToolStripMenuItem.Text = $"{ killNodeOriginalMenuText } ({ count })"; } else { killNodeToolStripMenuItem.Text = killNodeOriginalMenuText; } if (directory.Exists) { try { count = directory.GetFileSystemInfos().Length; directory = new DirectoryInfo(Path.Combine(this.CurrentWorkingDirectory, "node_modules")); count += directory.GetFileSystemInfos().Length; deleteSrcAndNodeModulesToolStripMenuItem.Text = $"{ deleteSrcAndNodeModulesOriginalMenuText } ({ count })"; } catch { } } else { deleteSrcAndNodeModulesToolStripMenuItem.Text = deleteSrcAndNodeModulesOriginalMenuText; } directory = new DirectoryInfo(this.CurrentWorkingDirectory); if (directory.Exists) { try { count = directory.GetFileSystemInfos().Length; deleteWorkingFolderToolStripMenuItem.Text = $"{ deleteWorkingFolderOriginalMenuText } ({ count })"; clearConfigPackagesToolStripMenuItem.Enabled = true; } catch { } } else { deleteWorkingFolderToolStripMenuItem.Text = deleteWorkingFolderOriginalMenuText; } directory = new DirectoryInfo(this.PackageCachePath); if (directory.Exists) { try { count = directory.GetFileSystemInfos().Length; clearCacheToolStripMenuItem.Enabled = true; clearCacheToolStripMenuItem.Text = $"{ clearCacheOriginalMenuText } ({ count })"; } catch { } } else { clearCacheToolStripMenuItem.Text = clearCacheOriginalMenuText; } } if (!deleteSrcAndNodeModulesToolStripMenuItem.Enabled) { deleteSrcAndNodeModulesToolStripMenuItem.Enabled = true; doEvents = true; } if (!deleteWorkingFolderToolStripMenuItem.Enabled) { deleteWorkingFolderToolStripMenuItem.Enabled = true; doEvents = true; } if (!clearWorkingFolderToolStripMenuItem.Enabled) { clearWorkingFolderToolStripMenuItem.Enabled = true; doEvents = true; } } if (!clearCacheToolStripMenuItem.Enabled && !this.PackageCachePath.IsNullOrEmpty()) { doEvents = true; } cacheStatusProperties.LastAttemptedUpdate = cacheStatusAgent.LastAttemptedUpdate == DateTime.MinValue ? string.Empty : cacheStatusAgent.LastAttemptedUpdate.ToDateTimeText(); if (cacheStatusAgent.LastAttemptedUpdate != DateTime.MinValue) { } cacheStatusProperties.LastAttemptedError = cacheStatusAgent.LastAttemptedError; if (doEvents) { this.DelayInvoke(1, () => { this.DoEvents(); }); } timerCounter = ++timerCounter % 10; }