//private TagMatrix tagMatrix = new TagMatrix(); //private string lastLoadedPath; //private List<FileElementActionSubscriber> selectionChangedListeners = // new List<FileElementActionSubscriber>(); public string GetFolderWithLeastNonZeroUntaggedCount(string folderPath, FilePathFilter fpf, bool fileInsteadOfDb) { //we are going to be going through multiple folders, //we don't want to load all of them to our main matrix TagMatrix temp = new TagMatrix(); temp.AddFolder(folderPath); if (fileInsteadOfDb) { temp.LoadFromXml(Configuration.GetTagFilePath(folderPath)); } else { temp.LoadFromDb(folderPath); } string leastPath = folderPath; int leastCount = temp.GetFilesForTag(TagMatrix.TAG_UNTAGGED, fpf).Count(); foreach (string path in Directory.GetDirectories(folderPath)) { temp.Clear(); temp.AddFolder(path); if (fileInsteadOfDb) { temp.LoadFromXml(Configuration.GetTagFilePath(path)); } else { temp.LoadFromDb(path); } int count = temp.GetFilesForTag(TagMatrix.TAG_UNTAGGED, fpf).Count(); if (count > 0) { if (leastCount < 1 || count < leastCount) { leastCount = count; leastPath = path; } } } return leastPath; }
public IEnumerable<string> GetFilesForTag(string tag, FilePathFilter fpf) { return fpf.Filter(GetFilesForTag(tag)); }