private void AnalyseDirectory( string[] directories, ILocationManager locationManager, IClsNmbManager clsNmbManager, IFaultManager faultManager) { for (int index = 0; index < directories.Length; ++index) { string[] subDirectories = System.IO.Directory.GetDirectories(directories[index]); string[] files = System.IO.Directory.GetFiles(directories[index], "*.jpg"); if (files != null && files.Length > 0) { this.AnalyseFiles( files, locationManager, clsNmbManager, faultManager); } if (subDirectories != null && subDirectories.Length > 0) { this.AnalyseDirectory( subDirectories, locationManager, clsNmbManager, faultManager); } } }
/// <summary> /// Get all the images in the base path. /// </summary> /// <returns></returns> public List <IImageDetails> ReadImages( ILocationManager locationManager, IClsNmbManager clsNmbManager, IFaultManager faultManager) { this.Initialise(); string[] directories = System.IO.Directory.GetDirectories(basePath); string[] files = System.IO.Directory.GetFiles(basePath, "*.jpg"); if (files != null && files.Length > 0) { this.AnalyseFiles( files, locationManager, clsNmbManager, faultManager); } if (directories != null && directories.Length > 0) { this.AnalyseDirectory( directories, locationManager, clsNmbManager, faultManager); } return(this.images); }
public static IImageDetails AnalyseImageDetails( string path, ILocationManager locationManager, IClsNmbManager clsNmbManager, IFaultManager faultManager) { IImageDetails image; string imageName = System.IO.Path.GetFileName(path); string[] filenameArray = imageName.Split(extensionSeparator); string[] inputArray = filenameArray[0].Split(majorTick); if (inputArray.Length < 2 || inputArray.Length > 4) { faultManager.AddFault( "Can't split into nmb and stn", imageName); } string[] nmbsArray = inputArray[0].Split(minorTick); ILocation stn = locationManager.GetStn( inputArray[1]); string year = inputArray.Length > 2 ? inputArray[2] : string.Empty; string multipleNote = inputArray.Length > 3 ? inputArray[3] : string.Empty; image = new ImageDetails( path, year, stn, multipleNote); ClsClass clss = ImageDetailFactory.GetCls( nmbsArray.ToList(), path, faultManager, clsNmbManager); image.SetClss( clss.Clss, clss.PresentNmbs); return(image); }
public List <IClsDetails> ReadClsDetails( IFaultManager faultManager) { List <IClsDetails> clsCollection = new List <IClsDetails>(); string path = this.basePath + Path.DirectorySeparatorChar + "ClsNmb"; string[] files = Directory.GetFiles( path, "*.txt"); for (int filesIndex = 0; filesIndex < files.Length; ++filesIndex) { IClsDetails cls = this.AnalyseFile(files[filesIndex]); clsCollection.Add(cls); } return(clsCollection); }
private void AnalyseFiles( string[] files, ILocationManager locationManager, IClsNmbManager clsNmbManager, IFaultManager faultManager) { //List<IImageDetails> images = new List<IImageDetails>(); for (int index = 0; index < files.Length; ++index) { IImageDetails image = ImageDetailFactory.AnalyseImageDetails( files[index], locationManager, clsNmbManager, faultManager); this.images.Add(image); } //return this.images; }
private static ClsClass GetCls( List <string> nmbs, string imageName, IFaultManager faultManager, IClsNmbManager clsNmbManager) { List <ICls> clss = new List <ICls>(); List <string> present = new List <string>(); foreach (string nmb in nmbs) { string[] individualNmbArray = nmb.Split(clsTick); if (individualNmbArray.Length != 2) { faultManager.AddFault( "Numbers Incorrect", imageName); continue; } present.Add(individualNmbArray[1]); // Go to nmb manager and get all associated nmbs //List<string> foundNmbs = new List<string>() { individualNmbArray[1] }; List <string> foundNmbs = clsNmbManager.FindAllNmbs( individualNmbArray[0], individualNmbArray[1]); bool foundCls = false; foreach (ICls cls in clss) { if (cls.Name == individualNmbArray[0]) { foreach (string foundNmb in foundNmbs) { cls.AddNmb(foundNmb); } foundCls = true; break; } } if (!foundCls) { ICls newCls = new Cls( individualNmbArray[0]); foreach (string foundNmb in foundNmbs) { newCls.AddNmb(foundNmb); } clss.Add(newCls); } } return (new ClsClass( clss, present)); }
public List <ILocation> ReadLocations( string fileName, IFaultManager faultManager, List <string> lines, List <string> counties, List <string> regions, List <string> big4regions) { List <ILocation> locations = new List <ILocation>(); if (!File.Exists(fileName)) { return(locations); } using (StreamReader reader = new StreamReader(fileName)) { string currentLine = string.Empty; currentLine = reader.ReadLine(); while (currentLine != null) { string[] currentLineArray = currentLine.Split(Separator); if (currentLineArray.Length != 5) { faultManager.AddFault( "Invalid line in locations file", fileName); continue; } int?line = this.GetIndex( lines, currentLineArray[LineIndex]); int?county = this.GetIndex( counties, currentLineArray[CountyIndex]); int?region = this.GetIndex( regions, currentLineArray[RegionIndex]); int?big4 = this.GetIndex( big4regions, currentLineArray[Big4Index]); locations.Add( new Location( currentLineArray[NameIndex], line, county, region, big4)); currentLine = reader.ReadLine(); } } return(locations); }