/* DESCRIPTION : * PARAMETERS : * ALTERS : * RETURNS : */ private bool simulateWorkOnDb() { // Get a hold of the current test tray we are working on TestTray tt = kdb.TestTrays.Find(this.currentTestTrayId); if (tt.IsCompleted) { // Tray is complete and we are still waiting on runner; return return(false); } int nextFogLampId = tt.FogLamps.Count + 1; while ((nextFogLampId <= 60) && (this.fogLampsMade > 0)) { FogLamp fl = new FogLamp(); fl.FogLampId = nextFogLampId; fl.ExperienceLevelOfAssembler = (int)this.experienceLevel; fl.TestTrayId = this.currentTestTrayId; kdb.FogLamps.Add(fl); nextFogLampId++; if (nextFogLampId == 61) { // Mark tray as complete tt.IsCompleted = true; } } this.kdb.Workstations.Find(this.wstation.WorkstationId).BezelAmount = this.bezelBin; this.kdb.Workstations.Find(this.wstation.WorkstationId).BulbAmount = this.bulbBin; this.kdb.Workstations.Find(this.wstation.WorkstationId).HarnessAmount = this.harnessBin; this.kdb.Workstations.Find(this.wstation.WorkstationId).HousingAmount = this.housingBin; this.kdb.Workstations.Find(this.wstation.WorkstationId).LensAmount = this.lensBin; this.kdb.Workstations.Find(this.wstation.WorkstationId).ReflectorAmount = this.reflectorBin; kdb.SaveChanges(); return(true); }
/* DESCRIPTION : * PARAMETERS : * ALTERS : * RETURNS : */ private bool simulateWorkOnDb() { // Get a hold of the current test tray we are working on TestTray tt = kdb.TestTrays.Find(this.currentTestTrayId); if (tt.IsCompleted) { // Tray is complete and we are still waiting on runner; return return(false); } int nextFogLampId = tt.FogLamps.Count + 1; while ((nextFogLampId <= 60) && (this.fogLampsMade > 0)) { FogLamp fl = new FogLamp(); fl.FogLampId = nextFogLampId; fl.ExperienceLevelOfAssembler = (int)this.experienceLevel; fl.TestTrayId = this.currentTestTrayId; kdb.FogLamps.Add(fl); nextFogLampId++; if (nextFogLampId == 61) { // Mark tray as complete tt.IsCompleted = true; } } kdb.SaveChanges(); return(true); }
/* DESCRIPTION : Tests numToTest number of fog lamps. If they are effective, * add foglamp to the order (through a connecting OrderLine) and to the * internal passedTesting list. If defective, simply add to failedTesting * list. * PARAMETERS : * int numToTest : number of foglamps to test. * ALTERS : * Adds OrderLine to db for every effective foglamp. * Changes FogLamp's IsEffective field. * Adds to either passedTesting or failedTesting. * RETURNS : void */ public void Test(int numToTest) { IQueryable <FogLamp> queryAssembled = from lamp in this.kdb.FogLamps join tray in this.kdb.TestTrays on lamp.TestTrayId equals tray.TestTrayId where lamp.IsEffective == null where tray.IsCompleted == true where tray.IsCurrentlyInUse == false select lamp; for (int lamp_i = 0; lamp_i < numToTest; ++lamp_i) { if (lamp_i >= queryAssembled.Count()) { // Break if there's no more lamps to test break; } FogLamp fl = queryAssembled.First(); switch (fl.ExperienceLevelOfAssembler) { case 1: if (this.random.NextDouble() > this.rookieDefectRate) { fl.IsEffective = true; this.passedTesting.Add(fl); OrderLine ol = new OrderLine(); ol.OrderId = this.currOrder.OrderId; ol.TestTrayId = fl.TestTrayId; ol.FogLampId = fl.FogLampId; this.kdb.OrderLines.Add(ol); } else { fl.IsEffective = false; this.failedTesting.Add(fl); } break; case 2: if (this.random.NextDouble() > this.experiencedDefectRate) { fl.IsEffective = true; this.passedTesting.Add(fl); OrderLine ol = new OrderLine(); ol.OrderId = this.currOrder.OrderId; ol.TestTrayId = fl.TestTrayId; ol.FogLampId = fl.FogLampId; this.kdb.OrderLines.Add(ol); } else { fl.IsEffective = false; this.failedTesting.Add(fl); } break; case 3: if (this.random.NextDouble() > this.seniorDefectRate) { fl.IsEffective = true; this.passedTesting.Add(fl); OrderLine ol = new OrderLine(); ol.OrderId = this.currOrder.OrderId; ol.TestTrayId = fl.TestTrayId; ol.FogLampId = fl.FogLampId; this.kdb.OrderLines.Add(ol); } else { fl.IsEffective = false; this.failedTesting.Add(fl); } break; } // Save changes, so that next time we get the query, // .First() will be different this.kdb.SaveChanges(); // TODO: Check if order has been fulfilled this.checkOrderStatus(); } }