public Case(string caseNumber, string caseName, string path, CaseDirectory caseDirectory) { this.CaseNumber = caseNumber; this.CaseName = caseName; this.RootPath = path; //this.CaseNotes = caseNotes; this.RootCaseDirectory = caseDirectory; }
private static CaseDirectory GetDirectories(string path) { CaseDirectory item = new CaseDirectory(); item.RootPath = path; item.DirectoryName = new DirectoryInfo(path).Name; foreach (string dir in Directory.GetDirectories(path)) { item.CaseDirectories.Add(GetDirectories(dir)); } List <BitmapImage> images = new List <BitmapImage>(); foreach (string file in Directory.GetFiles(path)) { CaseFile caseFile = new CaseFile(); string ext = Path.GetExtension(file); if (ext.ToLower() == ".jpg" || ext.ToLower() == ".png") { BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(file); bitmap.EndInit(); images.Add(bitmap); } if (ext == ".docx") { Regex rgx = new Regex(@"\w{2}\d{8}"); if (rgx.IsMatch(Path.GetFileName(file))) { caseFile.CaseNotes = ConvertDocxToCaseNotes(file); } } caseFile.RootPath = file; caseFile.FileName = Path.GetFileNameWithoutExtension(file); caseFile.Extension = ext; item.Images = images; item.CaseFiles.Add(caseFile); } return(item); }
private static List <CaseNotes> GetCaseNotes(CaseDirectory caseDir, Regex rgx, List <CaseNotes> caseNotes) { foreach (CaseFile file in caseDir.CaseFiles) { if (file.Extension != ".docx") { continue; } if (!rgx.IsMatch(file.FileName)) { continue; } CaseNotes notes = ConvertDocxToCaseNotes(file.RootPath); caseNotes.Add(notes); } foreach (CaseDirectory dir in caseDir.CaseDirectories) { GetCaseNotes(dir, rgx, caseNotes); } return(caseNotes); }