Ejemplo n.º 1
0
        //Altemating
        private ScannedStudent AddStudentAltemating(DataSeed ds, Dismissal dismissal, ScannedStudent scannedStudent)
        {
            isMoveRemoveCard = false;
            var laneId         = Lanes.ElementAt(currentLaneNumber).Id;
            var lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);

            lane2FlightObj = CheckIsLane(ds, dismissal.UserId, laneId, lane2FlightObj);

            if (!ds.IsCarExistInPrevLane(lane2FlightObj.Flight2LaneId, scannedStudent.ParentLicense))
            {
                currentLaneNumber = currentLaneNumber >= (Lanes.Count() - 1) ? 0 : (currentLaneNumber + 1);
                laneId            = Lanes.ElementAt(currentLaneNumber).Id;
                lane2FlightObj    = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
            }
            else
            {
                lane2FlightObj.CountCarsInLane -= 1;
            }

            lane2FlightObj = CheckIsLane(ds, dismissal.UserId, laneId, lane2FlightObj);

            //check isLanefull
            if (CountCarInLane(ds, dismissal.UserId, lane2FlightObj, scannedStudent.ParentLicense))
            {
                lane2FlightObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
            }

            dismissal.FlightLaneId          = lane2FlightObj.Flight2LaneId;
            lane2FlightObj.CountCarsInLane += 1;
            dismissal.CarNumber             = lane2FlightObj.CountCarsInLane;
            scannedStudent.CardId           = ds.AddStudentToDismissal(dismissal);
            scannedStudent.FlightNumber     = lane2FlightObj.FlightNumber;
            scannedStudent.FligthId         = lane2FlightObj.FlightId;
            if (scannedStudent.CardId == 0)
            {
                lane2FlightObj.CountCarsInLane -= 1;
                Status = "Barcode did not save. Please, try to scanne again!";
                return(null);
            }
            scannedStudent.Lane = Lanes.Where(p => p.Id == lane2FlightObj.LaneId).FirstOrDefault();

            return(scannedStudent);
        }
Ejemplo n.º 2
0
        public string ChangeLane(List <int> cardId, int laneId, int userId)
        {
            string parentName = null;
            int    prevl2fId;

            using (var ds = new DataSeed()) {
                var l2fObj = ScannerFlights.FirstOrDefault(p => p.LaneId == laneId);
                l2fObj = CheckIsLane(ds, userId, laneId, l2fObj);
                if (CountCarInLane(ds, userId, l2fObj, ""))
                {
                    l2fObj = ScannerFlights.FirstOrDefault(sf => sf.LaneId == laneId);
                }
                if (LaneLogistic == ScannerType.SingleScanner && curentLaneId == 0)
                {
                    if (!isMoveRemoveCard)
                    {
                        currentLaneNumber = currentLaneNumber <= 0 ? (Lanes.Count() - 1) : (currentLaneNumber - 1);
                        isMoveRemoveCard  = true;
                    }
                    else if (isMoveRemoveCard && Lanes.ElementAt(currentLaneNumber >= (Lanes.Count() - 1) ? 0 : (currentLaneNumber + 1)).Id == laneId)
                    {
                        isMoveRemoveCard  = false;
                        currentLaneNumber = currentLaneNumber >= (Lanes.Count() - 1) ? 0 : (currentLaneNumber + 1);
                    }
                }

                l2fObj.CountCarsInLane += 1;
                parentName              = ds.ChangeLane(cardId, l2fObj.Flight2LaneId, l2fObj.CountCarsInLane, out prevl2fId);
            };

            if (prevl2fId != 0)
            {
                var prevObjL2F = ScannerFlights.FirstOrDefault(p => p.Flight2LaneId == prevl2fId);
                if (prevObjL2F != null)
                {
                    prevObjL2F.CountCarsInLane -= 1;
                }
            }
            return(parentName);
        }