Exemplo n.º 1
0
 /// <summary>
 /// Switch for:
 /// Pumps Gas from a selected Zapfsäule. If the Zapfsaeule is already Tanking the Process is stopped
 /// If The Zapfsaeule isnt tanking yet the Zapfsaeule is locked and the Tanking process is started
 /// </summary>
 /// <param name="zapfsaeule">the selected zapfsaeule to tank from</param>
 /// <param name="fuelType">the selected fueltype to take from the zapfsaeule</param>
 public void PumpGasFromZapfsauele(Zapfsaeule zapfsaeule, IFuelType fuelType)
 {
     if (zapfsaeule.isTanking())
     {
         this.tankstellenkasse.AddTransaction(zapfsaeule.StopTankingTimer());
     }
     else
     {
         FuelTank currentFuelTank = this.availableFuelTanks.Find(x => x.GetFuelType() == fuelType);
         zapfsaeule.StartTankingTimer(currentFuelTank, this.SaveFuelTanks);
         zapfsaeule.Lock();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Standard constructor called when the programm is initialized / started. called when there is no instance when the singleton.current() function is called
        /// </summary>
        private Tankstelle()
        {
            this.availableFuelTanks = LoadPreviousFuelTanks(this.dataRepository);
            if (this.availableFuelTanks.Any() == false)
            {
                this.availableFuelTypes = new List <FuelType>
                {
                    new FuelType("Benzin", 120),
                    new FuelType("Diesel", 130),
                    new FuelType("Biodiesel", 100),
                };
                foreach (FuelType ft in this.availableFuelTypes)
                {
                    this.availableFuelTanks.Add(new FuelTank(ft, 1000));
                }
            }
            else
            {
                this.availableFuelTypes = this.availableFuelTanks.Select(x => x.GetFuelType()).Distinct().ToList();
            }

            // Erstellen einer Tankstellenkasse
            List <Container> containers = LoadPreviousContainers(this.dataRepository);

            if (!containers.Any())
            {
                this.cointype.Add(new Container(10, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(20, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(50, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(100, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(200, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(500, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(1000, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(2000, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(5000, 0, 1000, 100, 900, 100));
                this.cointype.Add(new Container(10000, 0, 1000, 100, 900, 100));

                SaveContainers();
            }
            else
            {
                this.cointype = containers;
            }

            this.tankstellenkasse = new Tankstellenkasse(this.dataRepository, this.cointype, 10000);

            IEnumerable <Zapfsaeule> zapfsauelen =
                Enumerable
                .Range(1, 5)
                .Select(zapfsaeulenNummer =>
            {
                IEnumerable <Zapfhahn> zapfhaehneFuerSaeule = this.availableFuelTypes.Select(fuelType => new Zapfhahn(fuelType));
                Zapfsaeule zapfsaeule = new Zapfsaeule(zapfsaeulenNummer.ToString(), zapfhaehneFuerSaeule.ToList());
                foreach (Transaction unpaidTransaction in this.tankstellenkasse.GetUnpaidTransactions())
                {
                    if (unpaidTransaction.GetZapfsauleName() == zapfsaeulenNummer.ToString())
                    {
                        zapfsaeule.Lock();
                        zapfsaeule.Selectzapfhahn(zapfsaeule.GetZapfhaene().Find(x => x.GetFuelType().GetFuelTypeName() == unpaidTransaction.GetFuelTypeName()));
                    }
                }
                return(zapfsaeule);
            });

            availableZapfsaeulen.AddRange(zapfsauelen);
        }