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); }
/// <summary> /// Initialises a new instance of the <see cref="BLManager"/> class. /// </summary> public BLManager() { //basePath = "C:\\_myDocs\\bert\\03_projects\\my_programing\\cSharpWPF\\tPix\\tPix\\bin\\Debug//testDb"; basePath = "C:\\_myDocs\\bert\\01_common_stuff\\ba_0811\\pics"; randomGenerator = new Random(); Factories.ClsNmbFactory clsNmbReader = new BL.Factories.ClsNmbFactory(basePath); Factories.ImageReader reader = new BL.Factories.ImageReader(basePath); this.faultManager = new BL.Model.FaultManager(); this.locationManager = new BL.Model.LocationManager( basePath, faultManager); this.clsNmbManager = new ClsNmbManager( clsNmbReader.ReadClsDetails( faultManager)); this.allImages = reader.ReadImages( locationManager, clsNmbManager, faultManager); locationManager.Save(); }
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); }
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)); }