public Dictionary<string, List<string>> GetImages() { var rollPaths = new RollPaths(this.Roll); string qALog = rollPaths.GetImgProcessPath() + @"\ImageQA.log"; if (File.Exists(qALog)) { string text = File.ReadAllText(qALog); // 42091_327600-00019.j2k=Other // 42092_2421406263_1204-00021-L00010.j2k=Deskew // -?\w+? var matches = Regex.Matches(text, @"(_|-)(\d{5})(-[LR]\d{5})?\..*=(\w+)") .Cast<Match>(); foreach (var match in matches) { var key = match.Groups[4].Value; var number = int.Parse(match.Groups[2].Value); if (Images.ContainsKey(key)) Images[key].Add(number.ToString()); else Images.Add(key, new List<string> { number.ToString() }); } return Images; } else return null; }
public void Initialize(string fileName) { FileName = fileName; MyRollPaths = new RollPaths(); JobSpecPath = fileName; if (File.Exists(JobSpecPath)) RootElement = XElement.Load(JobSpecPath); AutoCropElement = RootElement.Element("ProcessingSteps").Element("ImageProcessing").Element("ProcessSequence").Element("AutoCrop"); DeskewElement = RootElement.Element("ProcessingSteps").Element("ImageProcessing").Element("ProcessSequence").Element("Deskew"); if (AutoCropElement != null) { if (AutoCropElement.Attribute("xDirection").Value == "true" && AutoCropElement.Attribute("yDirection").Value == "true") AutoCrop = true; else AutoCrop = false; if (AutoCropElement.Attribute("AggressiveFactor").Value == "true") AggressiveFactor = true; else AggressiveFactor = false; CropPadding = Convert.ToInt32(AutoCropElement.Attribute("CropPadding").Value); } if (DeskewElement != null) DeskewMaxAngle = Convert.ToInt32(DeskewElement.Attribute("MaxAngle").Value); }
public JobSpecUpdates(Roll myRoll, RollPaths myRollPaths) { MyRoll = myRoll; MyRollPaths = myRollPaths; JobSpecDataReturn = MyRollPaths.GetJobSpec(); if (File.Exists(JobSpecDataReturn + @"\" + MyRoll.ProjectId + @"\" + MyRoll.RollName + ".xml")) JobSpecPath = JobSpecDataReturn + @"\" + MyRoll.ProjectId + @"\" + MyRoll.RollName + ".xml"; else if (File.Exists(JobSpecDataReturn + @"\" + MyRoll.RollName.Substring(0, 5) + @"\" + MyRoll.RollName + ".xml")) JobSpecPath = JobSpecDataReturn + @"\" + MyRoll.RollName.Substring(0, 5) + @"\" + MyRoll.RollName + ".xml"; RefreshRootElement(); if (RootElement != null) { if (RootElement.Descendants("Roll") .Where(roll => roll.Elements("ImageProcessing").Any()).Any()) { if (RootElement.Element("Roll").Descendants("ImageProcessing") .Where(roll => roll.Elements("ProcessSequence").Any()).Any()) { if (RootElement.Element("Roll").Element("ImageProcessing").Descendants("ProcessSequence") .Where(roll => roll.Elements("AutoCrop").Any()).Any()) { AutoCropElement = RootElement.Element("Roll").Element("ImageProcessing").Element("ProcessSequence").Element("AutoCrop"); AutoCropExists = true; } else AutoCropExists = false; DeskewElement = RootElement.Element("Roll").Element("ImageProcessing").Element("ProcessSequence").Element("Deskew"); } } if (AutoCropElement != null) { if (AutoCropElement.Attribute("xDirection").Value == "true" && AutoCropElement.Attribute("yDirection").Value == "true") AutoCrop = true; else AutoCrop = false; if (AutoCropElement.Attribute("AggressiveFactor").Value == "true") AggressiveFactor = true; else AggressiveFactor = false; CropPadding = Convert.ToInt32(AutoCropElement.Attribute("CropPadding").Value); } if (DeskewElement != null) DeskewMaxAngle = Convert.ToInt32(DeskewElement.Attribute("MaxAngle").Value); } }