예제 #1
0
        private bool IsFlightEmpty(int flightId)
        {
            var lanes = ScannerFlights.Where(f => f.FlightId == flightId && f.CountCarsInLane == 0).Select(f => f.LaneId).ToList();

            if (lanes != null && lanes.Count() == Lanes.Count())
            {
                return(true);
            }
            return(false);
        }
예제 #2
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);
        }
예제 #3
0
파일: Pool.cs 프로젝트: joaeschu/3-
        public int getFreeLanes(DateTime diaConHora)
        {
            int cont = Lanes.Count();

            if (!tabla.ContainsKey(diaConHora))
            {
                return(Lanes.Count());
            }
            else
            {
                Dictionary <Lane, int> d = tabla[diaConHora];
                foreach (Lane l in d.Keys.ToArray())
                {
                    if (d[l] > 0)
                    {
                        cont--;
                    }
                }
                return(cont);
            }
        }
예제 #4
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);
        }
예제 #5
0
        public string RemoveCard(List <int> cardId, out int flightId)
        {
            string message = null;

            flightId = 0;
            int  l2fId;
            bool isHasParentOtherStudent;

            using (var ds = new DataSeed()) {
                if (LaneLogistic == ScannerType.SingleScanner && curentLaneId == 0)
                {
                    if (!isMoveRemoveCard)
                    {
                        currentLaneNumber = currentLaneNumber <= 0 ? (Lanes.Count() - 1) : (currentLaneNumber - 1);
                    }
                    else
                    {
                        isMoveRemoveCard = false;
                    }
                }
                message = ds.RemoveDissmisalCard(cardId, out l2fId, out isHasParentOtherStudent);
            };

            if (l2fId != 0)
            {
                var objL2F = ScannerFlights.FirstOrDefault(p => p.Flight2LaneId == l2fId);
                if (objL2F != null)
                {
                    if (!isHasParentOtherStudent)
                    {
                        objL2F.CountCarsInLane -= 1;
                    }
                }

                if (IsFlightEmpty(objL2F.FlightId))
                {
                    int  flId     = objL2F.FlightId;
                    bool isDelete = false;
                    using (var ds = new DataSeed())
                    {
                        isDelete = ds.DeleteFlightById(flId);
                    }
                    if (isDelete)
                    {
                        FlightNumber--;
                        for (int i = 0; i < ScannerFlights.Count(); i++)
                        {
                            if (ScannerFlights[i].FlightId == flId)
                            {
                                ScannerFlights.RemoveAt(i);
                                i--;
                            }
                        }
                        Flight flight = Flights.FirstOrDefault(f => f.Id == flId);
                        Flights.Remove(flight);
                        flightId = flId;
                    }
                }
            }
            return(message);
        }