Exemplo n.º 1
0
        public void CarInGate(Gate gate)
        {
            if (!gate.DriveIn)
            {
                CarOutGate(gate);
                return;
            }
            bool residentVehicle = false;

            foreach (var resident in ResidentsList)
            {
                if (resident.LicensePlate == gate.OpenGatesFor)
                {
                    residentVehicle = true;
                }
            }
            Vehicle vehicle = new Vehicle(gate.OpenGatesFor, residentVehicle);

            Task.Factory.StartNew(() =>
            {
                System.Threading.Thread.Sleep(20000);
                if (CheckIfNotParked(vehicle))
                {
                    Form.Invoke((MethodInvoker) delegate { ConsoleLog.Add("Automobilis nepastatytas " + vehicle); });
                }
            });
            MockedVehiclesInOut.Add(vehicle);
            NotParkedVehicles.Add(vehicle);
        }
Exemplo n.º 2
0
        public void CarOut(string licensePlate, int camId)
        {
            Gate gate = Gates.FirstOrDefault(gt => gt.Id == camId);

            if (gate == null)
            {
                Form.Invoke((MethodInvoker) delegate { ConsoleLog.Add("Kameros klaida"); });
                return;
            }

            Vehicle vehicle = NotParkedVehicles.FirstOrDefault(veh => veh.LicensePlate == licensePlate);

            if (vehicle == null)
            {
                Form.Invoke((MethodInvoker) delegate { ConsoleLog.Add("Mašina sistemoje nerasta!!! " + licensePlate); });
                gate.OpenVehicle(licensePlate, false);
                return;
            }

            if (!vehicle.Paid)
            {
                if (ResidentsList.FirstOrDefault(s => s.LicensePlate == vehicle.LicensePlate) == null)
                {
                    Form.Invoke((MethodInvoker) delegate { ConsoleLog.Add("Važiuoja nesusimokėjus " + vehicle); });
                    return;
                }

                vehicle.Resident = true;
                vehicle.Paid     = true;
            }

            gate.OpenVehicle(licensePlate, false);
        }
Exemplo n.º 3
0
        public void CarOutGate(Gate gate)
        {
            var vehicle = NotParkedVehicles.FirstOrDefault(v => v.LicensePlate == gate.OpenGatesFor);

            if (vehicle == null)
            {
                return;
            }
            NotParkedVehicles.Remove(vehicle);
            MockedVehiclesInOut.First(veh => veh == vehicle && veh.InParkingLot).OnExit();
        }
Exemplo n.º 4
0
        public Vehicle Parked(string license)
        {
            Vehicle vehicle;

            lock (NotParkedVehicles)
            {
                vehicle = NotParkedVehicles.FirstOrDefault(v => v.LicensePlate == license);
                if (vehicle != null)
                {
                    NotParkedVehicles.Remove(vehicle);
                }
            }
            return(vehicle);
        }
Exemplo n.º 5
0
 public void ArchiveCar(Vehicle vehicle)
 {
     if (!NotParkedVehicles.Remove(vehicle))
     {
         foreach (var parkingLotParkingSpace in ParkingLot.ParkingSpaces)
         {
             if (parkingLotParkingSpace.Vehicle == null)
             {
                 continue;
             }
             if (!parkingLotParkingSpace.Vehicle.Equals(vehicle))
             {
                 continue;
             }
             parkingLotParkingSpace.Vehicle = null;
         }
     }
 }
Exemplo n.º 6
0
        public void Pay(string licensePlat)
        {
            Vehicle vehicle = NotParkedVehicles.FirstOrDefault(v => v.LicensePlate == licensePlat);

            if (vehicle != null)
            {
                vehicle.OnPay();
            }
            else
            {
                foreach (var parkingLotParkingSpace in ParkingLot.ParkingSpaces)
                {
                    if (parkingLotParkingSpace.Vehicle != null && parkingLotParkingSpace.Vehicle.LicensePlate == licensePlat)
                    {
                        parkingLotParkingSpace.Vehicle.OnPay();
                        return;
                    }
                }
            }
        }
Exemplo n.º 7
0
 public void UnParked(Vehicle vehicle)
 {
     NotParkedVehicles.Add(vehicle);
 }
Exemplo n.º 8
0
 public bool CheckIfNotParked(Vehicle vehicle)
 {
     return(NotParkedVehicles.Contains(vehicle));
 }