private void ReadFile(string pnFilePaths, int gbNumber) { this.projectNumbers.Clear(); if (!string.IsNullOrWhiteSpace(pnFilePaths)) { foreach (var pnFileUnpatched in pnFilePaths.Split(';')) { var pnFile = Utils.PatchFilePath(pnFileUnpatched); if (!string.IsNullOrWhiteSpace(pnFile) && File.Exists(pnFile)) { var allPnLines = File.ReadAllLines(pnFile, Encoding.Default); foreach (var line in allPnLines.Skip(1)) { var pn = new ProjectNumber(); if (pn.TryParse(line)) { this.projectNumbers.Add(pn); } else { logger.Warn($"Could not parse project numbers line: {line}"); } } // break after first file worked break; } } } this.FilterByGBNumber(gbNumber); this.pnHash = this.projectNumbers.ToDictionary(pnum => pnum.Number, pnum => pnum.Description); }
private void ReadPNFile(string pnFilePaths, int gbNumber) { if (!string.IsNullOrWhiteSpace(pnFilePaths)) { foreach (var pnFileUnpatched in pnFilePaths.Split(';')) { var pnFile = Utils.PatchFilePath(pnFileUnpatched); if (!string.IsNullOrWhiteSpace(pnFile) && File.Exists(pnFile)) { var allPnLines = File.ReadAllLines(pnFile, Encoding.Default); foreach (string line in allPnLines.Skip(1)) { var pn = new ProjectNumber(line); this.projectNumbers.Add(pn); } // break after first file worked break; } } } this.FilterByGBNumber(gbNumber); try { this.pnHash = this.projectNumbers.ToDictionary(pnum => pnum.Number, pnum => pnum.Description); } catch (Exception e) { logger.Warn(e, "Exception while converting project numbers to dictionary"); } }
private void ReadPNFile(string pnFilePaths, int gbNumber) { if (!string.IsNullOrWhiteSpace(pnFilePaths)) { foreach (var pnFileUnpatched in pnFilePaths.Split(';')) { var pnFile = Utils.PatchFilePath(pnFileUnpatched); if (!string.IsNullOrWhiteSpace(pnFile) && File.Exists(pnFile)) { var allPnLines = File.ReadAllLines(pnFile, Encoding.Default); foreach (string line in allPnLines.Skip(1)) { var pn = new ProjectNumber(); pn.GB = Convert.ToInt32(line.Substring(0, 1)); pn.Number = line.Substring(0, 5); pn.Description = line.Substring(14); this.ProjectNumbers.Add(pn); } // break after first file worked break; } } } this.SetGBNumber(gbNumber); this.pnHash = this.ProjectNumbers.ToDictionary(pnum => pnum.Number, pnum => pnum.Description); }