private string GenerateUpdateFileName(string path, string name) { var now = DateTime.Now.ToString("yyyy_MM_dd"); var todayUpdates = sourceProvider .GetFilesInDirectory(path, "sql") .Select(p => Path.GetFileNameWithoutExtension(p)) .Where(p => p.StartsWith(now)) .ToList(); int id = 0; while (todayUpdates.Any(p => p.StartsWith(now + "_" + id.ToString().PadLeft(2, '0')))) id++; return Path.Join(path, $"{now}_{id:00}_{name}.sql"); }
public IEnumerable <CoreCommand> GetAllCommands() { List <CoreCommand> result = new(); Dictionary <string, List <(string command, string?rbac, string?reference)> > commands = new(); foreach (var cppFilePath in coreSourceProvider.GetFilesInDirectory(commandsPath, "cpp")) { var cppFile = coreSourceProvider.ReadLines(cppFilePath) .Select(line => line.Trim()) .Between(t => t.StartsWith("/*"), t => t.EndsWith("*/"), true) .Where(line => !line.StartsWith("//")) .Between(line => line.Contains("GetCommands() const override"), line => line.StartsWith("return")); string currentGroupName = ""; commands.Clear(); foreach (var line in cppFile) { Match m = ReNewGroup.Match(line); if (m.Success) { currentGroupName = m.Groups[1].Value; commands[currentGroupName] = new(); continue; } m = ReLineNewStyleReference.Match(line); if (m.Success) { var commandPart = m.Groups[1].Value; var childrenList = m.Groups[2].Value; commands[currentGroupName].Add((commandPart, null, childrenList)); continue; } m = ReLineNewStyleCommand.Match(line); if (m.Success) { var commandPart = m.Groups[1].Value; var rbac = m.Groups[3].Value; commands[currentGroupName].Add((commandPart, rbac, null)); continue; } m = ReLineOldStyle.Match(line); if (m.Success) { var commandPart = m.Groups[1].Value; if (m.Groups[5].Length > 0) { var children = m.Groups[5].Value; commands[currentGroupName].Add((commandPart, null, children)); } else { var rbac = m.Groups[2].Value; commands[currentGroupName].Add((commandPart, rbac, null)); } } } if (commands.Count > 0 && !string.IsNullOrEmpty(currentGroupName)) { DenormalizeCommands(commands, "", currentGroupName, result); } } return(result); }