public static void Main(string[] args) { DynamicStartingConfig config = new DynamicStartingConfig(); RVS1 = new Warehouse(config.FCName, config.BrandInUse, config.FirstIsle, config.LastIsle, config.OddIsles, config.EvenIsles ); AssignmentLogic LogicEngine = new AssignmentLogic(); LogicEngine.GetSkus(); LogicEngine.AssignIsles(RVS1); LogicEngine.WriteSkus(RVS1); int maxIsle = RVS1.Isles.Max(i => i.IsleID); int maxBayInMaxIsle = RVS1.Isles.FirstOrDefault(i => i.IsleID == maxIsle).Bays.Max(b => b.BayID); int maxShelf = 5; int maxPosition = 8; Console.WriteLine("The last shelf position is: " + RVS1.Isles.FirstOrDefault(i => i.IsleID == maxIsle) .Bays.FirstOrDefault(b => b.BayID == maxBayInMaxIsle) .Shelves.FirstOrDefault(s => s.ShelfID == maxShelf) .Positions.FirstOrDefault(p => p.PositionID == maxPosition).Location()); Console.WriteLine(Directory.GetCurrentDirectory()); }
public void WriteSkus(iWarehouse FC) { string outputDirectory = ConfigurationManager.AppSettings["OutputFolderPath"].ToString(); if (!Directory.Exists(outputDirectory)) { throw new ConfigurationErrorsException("Bad output directory: " + outputDirectory); } string outputFile = Path.Combine(outputDirectory, "skuPlacement.csv"); using (FileStream fs = new FileStream(outputFile, FileMode.OpenOrCreate)) using (StreamWriter sw = new StreamWriter(fs)) { foreach (iIsle isle in FC.Isles.OrderBy(i => i.IsleID)) { foreach (iBay bay in isle.Bays.OrderBy(b => b.BayID)) { foreach (iShelf shelf in bay.Shelves.OrderBy(s => s.ShelfID)) { foreach (iPosition position in shelf.Positions.OrderBy(p => p.PositionID)) { string positionInformation = position.Location() + ","; string entry = ""; foreach (string skuName in position.AssignedSkus) { entry = positionInformation + skuName; sw.WriteLine(entry); } } } } } } }
public Isle(iWarehouse inwarehouse, int isleid, isleBayConfiguration islebayconfig) { inWarehouse = inwarehouse; isleID = isleid; config = islebayconfig; switch (config) { case isleBayConfiguration.Even: for (int i = 2; i <= 24; i += 2) { bays.Add(new Bay(this, i)); } break; case isleBayConfiguration.Odd: for (int i = 1; i <= 24; i += 2) { bays.Add(new Bay(this, i)); } break; case isleBayConfiguration.All: default: for (int i = 1; i <= 24; i++) { bays.Add(new Bay(this, i)); } break; } }
/// <summary> /// Determine which range of Isle to be on, the rotation of the isles, and what the current shelf is, and which bay (front or back) to work from. /// </summary> /// <param name="FC">Fc.</param> public void AssignIsles(iWarehouse FC) { //Creates the ranges of isles SKU are prioritized into List <Tuple <int, int> > Ranges = new List <Tuple <int, int> >() { new Tuple <int, int>(FC.Isles.Min(f => f.IsleID), 10), new Tuple <int, int>(11, 15), new Tuple <int, int>(16, 20), new Tuple <int, int>(21, 25), new Tuple <int, int>(26, 30), new Tuple <int, int>(31, FC.Isles.Max(f => f.IsleID)) }; if (!int.TryParse(ConfigurationManager.AppSettings["InputFilePath"].ToString(), out int shelfCount)) { throw new ConfigurationErrorsException("Failed to parse shelf count in app config."); } //Loopes through each range of isles foreach (Tuple <int, int> range in Ranges) { //Goes shelf by shelf across each range. for (int s = 1; s <= shelfCount; s++) { restartRangeAt = 0; currentIsle = range.Item1; if (FC.Isles.Min(v => v.IsleID) <= range.Item2 && FC.Isles.Min(v => v.IsleID) > range.Item1) { currentIsle = FC.Isles.Min(v => v.IsleID); } frontBay = true; //checks that shelf in that range has space while (FC.HasOpenSpace(s, range)) { if (FC.Isles.Select(e => e.IsleID).ToList().Contains(currentIsle)) { if (FC.Isles.FirstOrDefault(l => l.IsleID == currentIsle).HasOpenSpace(s)) { assignPositionResults result = AssignBays(FC.Isles.FirstOrDefault(l => l.IsleID == currentIsle), s); if (result == assignPositionResults.outOfSkusToAssign) { return; } } } //cleanup at end of assignment each time currentIsle += 3; if (frontBay) { frontBay = false; } else { frontBay = true; } //Cleanup at end of looop through range if (currentIsle > range.Item2) { restartRangeAt += 1; if (restartRangeAt == 3) { restartRangeAt = 0; } currentIsle = range.Item1 + restartRangeAt; if (frontBay) { frontBay = false; } else { frontBay = true; } } } } } }