Ejemplo n.º 1
0
        private void Form6_Load(object sender, EventArgs e)
        {
            string rekeningID = Home.rekeningID;

            ArduinoData ad           = new ArduinoData();
            HTTPget     httpget      = new HTTPget();
            int         balans       = httpget.getRekening(rekeningID).Balans;
            string      balansString = Convert.ToString(balans / 100);

            textBox1.Text = balansString + ".00 €";

            while (true)
            {
                String input = ad.getString();
                if (input.Contains("*KEY") || input.Contains("#KEY"))
                {
                    String caseString = ad.getString();         // CAN ONLY BE * or #

                    switch (caseString)
                    {
                    case "*KEY":
                        new Bedraginvoer().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;

                    case "#KEY":
                        new Stoppen().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void Form9_Load(object sender, EventArgs e)
        {
            ArduinoData ad = new ArduinoData();

            while (true)
            {
                String input = ad.getString();
                if (input.Contains("*KEY") || input.Contains("#KEY"))
                {
                    String caseString = ad.getString();
                    switch (caseString)
                    {
                    case "*KEY":
                        new DankU().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;

                    case "#KEY":
                        new Home().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string      requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            ArduinoData inputData   = JsonConvert.DeserializeObject <ArduinoData>(requestBody);

            DateTime      logDate        = DateTime.UtcNow;
            List <string> outputMessages = new List <string>();

            foreach (SensorData sensor in inputData.SensorData)
            {
                // Partion Key: LightSensor_1__Resolution_1__Date_2020-05-20__Hour_00
                string partitionKey = String.Format("{0}_{1}__{2}_{3}__{4}_{5}__{6}_{7}", sensor.Name.Replace(" ", ""), sensor.Id, "Resolution", 60, "Date", logDate.ToString("yyyy-MM-dd"), "Hour", logDate.Hour.ToString().PadLeft(2, '0'));

                // Row Key: Minute_00__Second_01
                string rowKey = String.Format("Minute_{0}__Second_{1}", logDate.Minute.ToString().PadLeft(2, '0'), logDate.Second.ToString().PadLeft(2, '0'));

                SensorReading newRecord = new SensorReading();
                newRecord.PartitionKey = partitionKey;
                newRecord.RowKey       = rowKey;
                newRecord.Units        = sensor.Units;
                newRecord.DataType     = sensor.DataType;
                newRecord.Value        = sensor.Value;


                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
                CloudTableClient    tableClient    = storageAccount.CreateCloudTableClient(new TableClientConfiguration());
                CloudTable          table          = tableClient.GetTableReference("SensorReading");

                TableOperation insertOrMergeOperation = TableOperation.InsertOrReplace(newRecord);
                TableResult    result = await table.ExecuteAsync(insertOrMergeOperation);

                SensorReading insertedSensorDetail = result.Result as SensorReading;
                string        responseMessage      = "Values inserted:" + JsonConvert.SerializeObject(insertedSensorDetail);
                outputMessages.Add(responseMessage);

                // Log the 5 minute entry separately
                if (logDate.Minute % 5 == 0)
                {
                    // Partion Key: LightSensor_1__Resolution_300__Date_2020-05-20__Hour_00
                    partitionKey = String.Format("{0}_{1}__{2}_{3}__{4}_{5}__{6}_{7}", sensor.Name.Replace(" ", ""), sensor.Id, "Resolution", 300, "Date", logDate.ToString("yyyy-MM-dd"), "Hour", logDate.Hour.ToString().PadLeft(2, '0'));

                    // Row Key: Minute_00
                    rowKey = String.Format("Minute_{0}", logDate.Minute.ToString().PadLeft(2, '0'));

                    newRecord.PartitionKey = partitionKey;
                    newRecord.RowKey       = rowKey;

                    result = await table.ExecuteAsync(insertOrMergeOperation);

                    insertedSensorDetail = result.Result as SensorReading;
                    responseMessage      = "Values inserted:" + JsonConvert.SerializeObject(insertedSensorDetail);
                    outputMessages.Add(responseMessage);
                }
            }


            return(new OkObjectResult(null));
        }
Ejemplo n.º 4
0
 public Executer(String r, String u, ArduinoData a, String p)
 {
     this.rekeningID = r;
     this.userName   = u;
     this.arduino    = a;
     this.pasID      = p;
     this.rekening   = downloadConnection.getRekening(rekeningID);
     this.saldo      = rekening.Balans;
 }
Ejemplo n.º 5
0
 public TransactionManager(String r, int u, ArduinoData a, String p, Stock s)
 {
     this.rekeningID = r;
     this.klantID    = u;
     this.userName   = downloadConnection.getKlant(klantID.ToString()).achternaam;
     this.arduino    = a;
     this.pasID      = p;
     this.rekening   = downloadConnection.getRekening(rekeningID);
     this.saldo      = rekening.balans;
     this.stock      = s;
 }
Ejemplo n.º 6
0
    void Start()
    {
        enemy      = FindObjectOfType <Enemy>();
        player     = FindObjectOfType <Player>();
        flashlight = FindObjectOfType <Flashlight>();
        save       = FindObjectOfType <GameResultSave>();
        aData      = FindObjectOfType <ArduinoData>();

        if (save != null)
        {
            save.gameWon = false;
        }
    }
Ejemplo n.º 7
0
        public async Task <IActionResult> SellRecipeDrug(string userId, int recipeDrugId)
        {
            var user = await _userManager.FindByIdAsync(userId);

            if (user == null)
            {
                return(BadRequest("No such user"));
            }
            var recipe = _uow.RecipeDrugRepository.Get(r => r.Id == recipeDrugId)
                         .FirstOrDefault();



            ArduinoData data = new ArduinoData
            {
                DoctorId = userId,
                DrugId   = recipe.DrugId
            };

            SaveData(data);
            return(Ok());
        }
Ejemplo n.º 8
0
        private void Bon_Load(object sender, EventArgs e)
        {
            ArduinoData ad    = new ArduinoData();
            Printer     print = new Printer(amount, klantid, rekeningID);

            while (true)
            {
                String input = ad.getString();
                if (input.Contains("*KEY") || input.Contains("#KEY") || input.Contains("0KEY"))
                {
                    String caseString = input;          // CAN ONLY BE * or #

                    switch (caseString)
                    {
                    case "*KEY":
                        print.printTicket();
                        new DankU().Show();
                        Thread.Sleep(1);
                        this.Hide();
                        break;

                    case "#KEY":
                        new DankU().Show();
                        Thread.Sleep(1);
                        this.Hide();
                        break;

                    case "0KEY":
                        Email email = new Email(amount, rekeningID, Convert.ToInt32(klantid));
                        email.sendEmail();
                        new DankU().Show();
                        Thread.Sleep(1);
                        this.Hide();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 9
0
 private void SaveData(ArduinoData data)
 {
     HttpContext.Session.SetJson("ArduinoData", data);
 }
Ejemplo n.º 10
0
 public void SetPin(string newPin)
 {
     pin = ArduinoData.Pin(newPin);
 }
Ejemplo n.º 11
0
        private void Beginscherm_Load(object sender, EventArgs e)
        {
            PinInvoer pinInvoer = new PinInvoer();
            Hoofdmenu hoofdmenu = new Hoofdmenu();
            ArduinoData arduino = new ArduinoData();
            Stock stock = new Stock(arduino);
            Hash security = new Hash();
            TransactionManager transactionManager;
            Boolean reset = false;
            Boolean pinCorrect;
            String[] pasInformation;
            bool EE = true;
            //User user;
            try
            {
            while (true) ///Infinite loop so that the program returns here after every cancelation.
            {
                while (true)
                {
                    pinCorrect = false;
                    pasInformation = new String[4];
                    reset = false;
                    transactionManager = null;
                    int KlantID;
                    String rekeningID;
                    String pasID;
                    HTTPget httpget = new HTTPget();
                    HTTPpost httppost = new HTTPpost();
                    while (true)
                    {
                        String s = arduino.getFirstString();
                        if (s.Contains(",NEWUID"))
                        {
                            pasInformation = s.Split('\n', '\n', '\n');
                            Int32.TryParse(pasInformation[2],out KlantID);
                            rekeningID = pasInformation[1];
                            pasID = pasInformation[0];
                            break;
                        }
                        else if (s.Contains("open"))
                        {
                            Cursor.Show();
                            stock.restock();
                        }
                    }
                    if (httpget.getActiefStand(pasID) == false)
                    {
                        BlockScreen tmp = new BlockScreen();
                        break;
                    }
                    pinInvoer.Show();
                    while (pinCorrect == false)
                    {
                        int insertedDigits = 0;
                        String pincode = "";
                        Boolean confirmed = false;
                        while (confirmed == false) ///Waits for user input until 4 digits have been submitted.
                        {
                            String input = arduino.getString();
                            if (checkInput(input) == true && insertedDigits < 4)
                            {
                                pinInvoer.printStar();
                                pinInvoer.falsepininfo.Visible = false;
                                insertedDigits++;
                                pincode += input.ElementAt(0);
                            }
                            else if (input.Contains("#KEY"))
                            {
                                reset = true;
                                break;
                            }
                            else if (input.Contains("CKEY"))
                            {
                                pinInvoer.clear();
                                insertedDigits = 0;
                                pincode = "";
                            }
                            if (insertedDigits == 4)
                            {
                                if (input.Contains("*")) { confirmed = true; }
                            }
                        }
                        pinInvoer.clear();
                        if (reset == true) { break; }
                        if (pincode == "1337" && EE) //Added easter egg
                        {
                            pinInvoer.pictureBox2.Visible = true;
                            pinInvoer.Refresh();
                            System.Threading.Thread.Sleep(8000);
                            reset = true;
                            pinInvoer.pictureBox2.Visible = false;
                            break;
                        }
                        if (security.checkHash(rekeningID, pincode) == false)
                        {
                            pinInvoer.falsepininfo.Visible = true;
                            HTTPpost tmp = new HTTPpost();
                            tmp.Incrementfalsepin(pasID);
                            HTTPget tmp2 = new HTTPget();
                            if(tmp2.getPinclass(pasID).poging >=2)
                            {
                                reset = true;
                            }

                        }
                        else
                        {
                            httppost.resetfalsepin(pasID);
                            pinCorrect = true;
                        }
                    }
                    pinInvoer.Hide();
                    if (reset == true)
                    {
                        break;
                    }
                    hoofdmenu.Show();
                    transactionManager = new TransactionManager(rekeningID, KlantID, arduino, pasID, stock);
                    while (true)
                    {
                        int choice = arduino.getChoice();
                        if (choice != 0)
                        {
                            transactionManager.executeChoice(choice);
                            if (transactionManager.getEndOfSession() == true)
                            {
                                hoofdmenu.Hide();
                                break;
                            }
                        }

                    }
                }
            }
            }

            catch (Exception) //Made the application safe, as soon as an exception is found, Close everything and show the out of order Form, main thread isnt even running anymore
            {
                ErrorScreen error = new ErrorScreen();
                List<Form> openForms = new List<Form>();
                foreach (Form f in Application.OpenForms)
                    openForms.Add(f);
                foreach (Form f in openForms)
                {
                    if (f.Name != "ErrorScreen")
                        f.Close();
                }
                while (true)
                { } //Loop forever :)
            }
        }
Ejemplo n.º 12
0
        private ArduinoData GetCart()
        {
            ArduinoData data = HttpContext.Session.GetJson <ArduinoData>("ArduinoData") ?? new ArduinoData();

            return(data);
        }
Ejemplo n.º 13
0
        private void Beginscherm_Load(object sender, EventArgs e)
        {
            //bool killscreen = true;
            PinInvoer   pinInvoer = new PinInvoer();
            Hoofdmenu   hoofdmenu = new Hoofdmenu();
            ArduinoData arduino   = new ArduinoData();
            Hash        security  = new Hash();
            Executer    executer;
            Boolean     reset = false;
            Boolean     pinCorrect;

            String[] pasInformation;
            bool     EE = true;

            //User user;

            //try
            //{
            while (true) ///Infinite loop so that the program returns here after every cancelation.
            {
                while (true)
                {
                    pinCorrect     = false;
                    pasInformation = new String[4];
                    reset          = false;
                    executer       = null;
                    String   KlantID;
                    String   rekeningID;
                    String   pasID;
                    HTTPget  httpget  = new HTTPget();
                    HTTPpost httppost = new HTTPpost();
                    while (true)
                    {
                        String s = arduino.getFirstString();
                        if (s.Contains(",NEWUID"))
                        {
                            pasInformation = s.Split('\n', '\n', '\n');
                            KlantID        = pasInformation[2];
                            rekeningID     = pasInformation[1];
                            pasID          = pasInformation[0];
                            break;
                        }
                    }
                    if (!httpget.getActiefStand(pasID))
                    {
                        BlockScreen tmp = new BlockScreen();
                        break;
                    }
                    pinInvoer.Show();
                    while (pinCorrect == false)
                    {
                        int     insertedDigits = 0;
                        String  pincode        = "";
                        Boolean confirmed      = false;
                        while (confirmed == false) ///Waits for user input until 4 digits have been submitted.
                        {
                            String input = arduino.getString();
                            if (checkInput(input) == true && insertedDigits < 4)
                            {
                                pinInvoer.printStar();
                                pinInvoer.falsepininfo.Visible = false;
                                insertedDigits++;
                                pincode += input.ElementAt(0);
                            }
                            else if (input.Contains("#KEY"))
                            {
                                reset = true;
                                break;
                            }
                            else if (input.Contains("CKEY"))
                            {
                                pinInvoer.clear();
                                insertedDigits = 0;
                                pincode        = "";
                            }
                            if (insertedDigits == 4)
                            {
                                if (input.Contains("*"))
                                {
                                    confirmed = true;
                                }
                            }
                        }
                        pinInvoer.clear();
                        if (reset == true)
                        {
                            break;
                        }
                        if (pincode == "1337" && EE) //Added easter egg
                        {
                            pinInvoer.pictureBox2.Visible = true;
                            pinInvoer.Refresh();
                            System.Threading.Thread.Sleep(8000);
                            reset = true;
                            pinInvoer.pictureBox2.Visible = false;
                            break;
                        }
                        if (security.checkHash(rekeningID, pincode) == false)
                        {
                            pinInvoer.falsepininfo.Visible = true;
                            HTTPpost tmp = new HTTPpost();
                            tmp.Incrementfalsepin(pasID);
                            if (!httpget.getActiefStand(pasID))
                            {
                                pinInvoer.Close();
                            }
                        }
                        else
                        {
                            httppost.resetfalsepin(pasID);
                            pinCorrect = true;
                        }
                    }
                    pinInvoer.Hide();
                    if (reset == true)
                    {
                        break;
                    }
                    hoofdmenu.Show();
                    executer = new Executer(rekeningID, KlantID, arduino, pasID);
                    while (true)
                    {
                        int choice = arduino.getChoice();
                        if (choice != 0)
                        {
                            executer.executeChoice(choice);
                            if (executer.getEndOfSession() == true)
                            {
                                hoofdmenu.Hide();
                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 14
0
        private void Extraladen()
        {
            ArduinoClass bootup = new ArduinoClass();

            if (!config)
            {
                bootup.makePort("COM6");
                config = true;
            }

            PinInvoer pinInvoer = new PinInvoer();

            Home        home     = new Home();
            ArduinoData arduino  = new ArduinoData();
            Hash        security = new Hash();
            Executer    executer;
            Boolean     reset = false;
            Boolean     pinCorrect;

            String[] pasInformation;
            bool     EE = true;

            try
            {
                while (true)
                {
                    pinCorrect     = false;
                    pasInformation = new String[4];
                    reset          = false;
                    executer       = null;
                    String   KlantID;
                    String   rekeningID;
                    String   pasID;
                    HTTPget  httpget  = new HTTPget();
                    HTTPpost httppost = new HTTPpost();

                    while (true)
                    {
                        //String emu = ("AAAAAA\n11248649\n1004\n,NEWUID");
                        String s = arduino.getFirstString();
                        if (s.Contains("NEWUID"))
                        {
                            pasInformation = s.Split('\n', '\n', '\n');
                            KlantID        = pasInformation[2];
                            rekeningID     = pasInformation[1];
                            pasID          = pasInformation[0];
                            //Error.show(rekeningID + "," + KlantID + "," + pasID);
                            //Error.show("PasID: " + pasID + "\nRekID: " + rekeningID + "\nKlantID: " + KlantID);
                            pinInvoer.giveInfo(pasInformation);
                            home.giveInfo(pasInformation);
                            //Error.show(KlantID);
                            //Error.show(rekeningID);
                            //Error.show(pasID);

                            executer = new Executer(rekeningID, KlantID, arduino, pasID);

                            break;
                        }
                    }
                    pinInvoer.Show();

                    Thread.Sleep(1);
                    this.Close();
                    break;
                }
            }
            catch (Exception)
            {
                OutOfOrder error = new OutOfOrder();
                error.Show();
                error.Refresh();
                List <Form> openForms = new List <Form>();
                foreach (Form f in Application.OpenForms)
                {
                    openForms.Add(f);
                }
                foreach (Form f in openForms)
                {
                    if (f.Name != "OutOfOrder")
                    {
                        f.Close();
                    }
                }
                while (true)
                {
                }   //Loop forever :)
            }
        }
Ejemplo n.º 15
0
        private void Beginscherm_Load(object sender, EventArgs e)
        {
            PinInvoer          pinInvoer = new PinInvoer();
            Hoofdmenu          hoofdmenu = new Hoofdmenu();
            ArduinoData        arduino   = new ArduinoData();
            Stock              stock     = new Stock(arduino);
            Hash               security  = new Hash();
            TransactionManager transactionManager;
            Boolean            reset = false;
            Boolean            pinCorrect;

            String[] pasInformation;
            bool     EE = true;

            //User user;
            try
            {
                while (true) ///Infinite loop so that the program returns here after every cancelation.
                {
                    while (true)
                    {
                        pinCorrect         = false;
                        pasInformation     = new String[4];
                        reset              = false;
                        transactionManager = null;
                        int      KlantID;
                        String   rekeningID;
                        String   pasID;
                        HTTPget  httpget  = new HTTPget();
                        HTTPpost httppost = new HTTPpost();
                        while (true)
                        {
                            String s = arduino.getFirstString();
                            if (s.Contains(",NEWUID"))
                            {
                                pasInformation = s.Split('\n', '\n', '\n');
                                Int32.TryParse(pasInformation[2], out KlantID);
                                rekeningID = pasInformation[1];
                                pasID      = pasInformation[0];
                                break;
                            }
                            else if (s.Contains("open"))
                            {
                                Cursor.Show();
                                stock.restock();
                            }
                        }
                        if (httpget.getActiefStand(pasID) == false)
                        {
                            BlockScreen tmp = new BlockScreen();
                            break;
                        }
                        pinInvoer.Show();
                        while (pinCorrect == false)
                        {
                            int     insertedDigits = 0;
                            String  pincode        = "";
                            Boolean confirmed      = false;
                            while (confirmed == false) ///Waits for user input until 4 digits have been submitted.
                            {
                                String input = arduino.getString();
                                if (checkInput(input) == true && insertedDigits < 4)
                                {
                                    pinInvoer.printStar();
                                    pinInvoer.falsepininfo.Visible = false;
                                    insertedDigits++;
                                    pincode += input.ElementAt(0);
                                }
                                else if (input.Contains("#KEY"))
                                {
                                    reset = true;
                                    break;
                                }
                                else if (input.Contains("CKEY"))
                                {
                                    pinInvoer.clear();
                                    insertedDigits = 0;
                                    pincode        = "";
                                }
                                if (insertedDigits == 4)
                                {
                                    if (input.Contains("*"))
                                    {
                                        confirmed = true;
                                    }
                                }
                            }
                            pinInvoer.clear();
                            if (reset == true)
                            {
                                break;
                            }
                            if (pincode == "1337" && EE) //Added easter egg
                            {
                                pinInvoer.pictureBox2.Visible = true;
                                pinInvoer.Refresh();
                                System.Threading.Thread.Sleep(8000);
                                reset = true;
                                pinInvoer.pictureBox2.Visible = false;
                                break;
                            }
                            if (security.checkHash(rekeningID, pincode) == false)
                            {
                                pinInvoer.falsepininfo.Visible = true;
                                HTTPpost tmp = new HTTPpost();
                                tmp.Incrementfalsepin(pasID);
                                HTTPget tmp2 = new HTTPget();
                                if (tmp2.getPinclass(pasID).poging >= 2)
                                {
                                    reset = true;
                                }
                            }
                            else
                            {
                                httppost.resetfalsepin(pasID);
                                pinCorrect = true;
                            }
                        }
                        pinInvoer.Hide();
                        if (reset == true)
                        {
                            break;
                        }
                        hoofdmenu.Show();
                        transactionManager = new TransactionManager(rekeningID, KlantID, arduino, pasID, stock);
                        while (true)
                        {
                            int choice = arduino.getChoice();
                            if (choice != 0)
                            {
                                transactionManager.executeChoice(choice);
                                if (transactionManager.getEndOfSession() == true)
                                {
                                    hoofdmenu.Hide();
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception) //Made the application safe, as soon as an exception is found, Close everything and show the out of order Form, main thread isnt even running anymore
            {
                ErrorScreen error     = new ErrorScreen();
                List <Form> openForms = new List <Form>();
                foreach (Form f in Application.OpenForms)
                {
                    openForms.Add(f);
                }
                foreach (Form f in openForms)
                {
                    if (f.Name != "ErrorScreen")
                    {
                        f.Close();
                    }
                }
                while (true)
                {
                }   //Loop forever :)
            }
        }
Ejemplo n.º 16
0
        private void Form2_Load(object sender, EventArgs e)
        {
            //Executer ex = new Executer();
            //Beginscherm bs = new Beginscherm();
            ArduinoData arduino    = new ArduinoData();
            HTTPget     httpget    = new HTTPget();
            Hash        security   = new Hash();
            Boolean     pinCorrect = false;
            int         attempt    = 0;

            //bool EE = true;

            this.Show();
            this.Refresh();
            String pincode = "";

            Label[] lblarr = new Label[4];
            fillarr(lblarr);
            while (pinCorrect == false) //while true
            {
                int     insertedDigits = 0;
                Boolean confirmed      = false;
                String  input          = "";

                while (confirmed == false)
                {
                    input = arduino.getString();
                    if (!input.Contains("NEWUID") && (input.Contains("1") || input.Contains("2") || input.Contains("3") || input.Contains("4KEY") || input.Contains("5KEY") || input.Contains("6KEY") || input.Contains("7KEY") || input.Contains("8KEY") || input.Contains("9KEY") || input.Contains("0KEY")))
                    {
                        if (checkInput(input) == true && insertedDigits < 4)
                        {
                            insertedDigits++;
                            switch (insertedDigits)
                            {
                            case 1:
                                label3.Text = "*";
                                break;

                            case 2:
                                label4.Text = "*";
                                break;

                            case 3:
                                label5.Text = "*";
                                break;

                            case 4:
                                label6.Text = "*";
                                break;
                            }
                            this.Refresh();
                            pincode += input.ElementAt(0);
                            //Error.show(pincode);
                        }

                        if (insertedDigits == 4)
                        {
                            if (input.Contains("*"))
                            {
                                confirmed = true;
                            }
                            //Error.show(pincode);
                            if (security.checkHash(rekeningID, pincode) == true)
                            {
                                new Home().Show();
                                Thread.Sleep(1);
                                this.Close();
                                break;
                            }
                        }
                        //int rek = Convert.ToInt32(rekeningID);
                        //int pin = Convert.ToInt32(pincode);
                    }
                    if (input.Contains("CKEY"))     //Clear all KEY WORKS
                    {
                        pincode = "";               // USED TO RESET PINCODE TO null WHEN CLEARED
                        clearall();
                        insertedDigits = 0;
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void Form4_Load(object sender, EventArgs e)
        {
            ArduinoData           ad       = new ArduinoData();
            HTTPget               httpget  = new HTTPget();
            HTTPpost              httppost = new HTTPpost();
            Executer              exec     = new Executer(Home.rekeningID, Home.klantID, ad, Home.pasID);
            ArduinoDispenserClass adc      = new ArduinoDispenserClass();
            Home home = new Home();


            aanwzChker();

            int amount;

            //int rekID = Convert.ToInt32(Home.rekeningID);
            pasID   = Home.pasID;
            klantID = Home.klantID;
            while (true)
            {
                String input = ad.getString();
                if (input.Contains("1KEY") || input.Contains("3KEY") || input.Contains("4KEY") || input.Contains("6KEY") || input.Contains("7KEY") || input.Contains("#KEY"))
                {
                    String caseString = input;
                    switch (caseString)
                    {
                    case "1KEY":     //10 euro
                        amount = 10;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "3KEY":     //20 euro
                        amount = 20;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "4KEY":     //50 euro
                        amount = 50;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "6KEY":     //70 euro
                        amount = 70;
                        if (home.berekener(amount) == true)
                        {
                            adc.makePort("COM5");
                            httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount * 100));
                            adc.dispense(amount);
                            new Bon(amount, klantID, Home.rekeningID).Show();
                            Thread.Sleep(1);
                            this.Close();
                        }
                        else
                        {
                            label2.Text = "Kan niet gedispensed worden.";
                            System.Threading.Thread.Sleep(500);
                            label2.Text = "";
                        }
                        break;

                    case "7KEY":     //bedrag invoer
                        new Bedraginvoer().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;

                    case "#KEY":     //afbreken
                        new Stoppen().Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }
                }
            }
        }
Ejemplo n.º 18
0
 public Stock(ArduinoData a)
 {
     this.arduino = a;
 }
Ejemplo n.º 19
0
        private void Form3_Load(object sender, EventArgs e)
        {
            label3.Hide();
            label4.Visible = false;
            string                pasID;
            string                klantID;
            ArduinoData           arduino   = new ArduinoData();
            PinInvoer             pinInvoer = new PinInvoer();
            HTTPget               httpget   = new HTTPget();
            HTTPpost              httppost  = new HTTPpost();
            Executer              exec      = new Executer(Home.rekeningID, Home.klantID, arduino, Home.pasID);
            ArduinoDispenserClass adc       = new ArduinoDispenserClass();
            //adc.makePort("COM5");
            //String caseString = arduino.getString();

            int amount;

            //int rekID = Convert.ToInt32(Home.rekeningID);
            pasID   = Home.pasID;
            klantID = Home.klantID;

            string ssaldo = Convert.ToString(exec.saldo);
            //Error.show(ssaldo);

            int    bedrag       = 0;
            String bedragString = "";
            String input;

            while (true)
            {
                input = arduino.getString();

                if (!input.Contains("NEWUID") && (input.Contains("1") || input.Contains("2") || input.Contains("3") || input.Contains("4KEY") || input.Contains("5KEY") || input.Contains("6KEY") || input.Contains("7KEY") || input.Contains("8KEY") || input.Contains("9KEY") || input.Contains("0KEY"))) //!input.Contains("*") || !input.Contains("$") || !input.Contains("A") || !input.Contains("B") || !input.Contains("C") || !input.Contains("#") ||
                {
                    this.Refresh();
                    bedragString += input.ElementAt(0);
                }

                Int32.TryParse(bedragString, out bedrag);
                setDisplay(bedragString);

                int checker = bedrag % 10;


                switch (input)
                {
                case "*KEY":
                    this.Refresh();
                    amount = bedrag * 100;
                    if (checker != 0)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else if (amount > exec.saldo)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else if (amount < 10)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else if (amount > 20000)
                    {
                        bedragString = "";
                        setDisplay(bedragString);
                        this.Refresh();
                        break;
                    }
                    else
                    {
                        adc.makePort("COM5");
                        this.Refresh();
                        httppost.UpdateBalans(Home.rekeningID, (exec.saldo - amount));
                        adc.dispense(amount / 100);
                        new Bon(amount, klantID, Home.rekeningID).Show();
                        Thread.Sleep(1);
                        this.Close();
                        break;
                    }

                case "CKEY":                                         //press 2x c for clear or c+*?? bug

                    bedragString = "";
                    setDisplay(bedragString);
                    this.Refresh();                                  // USED TO RESET BEDRAGSTRING TO null WHEN CLEARED
                    break;

                case "#KEY":     // stoppen
                    new Stoppen().Show();
                    Thread.Sleep(1);
                    this.Close();
                    break;
                }
            }
        }
Ejemplo n.º 20
0
 public TransactionManager(String r, int u, ArduinoData a, String p, Stock s)
 {
     this.rekeningID = r;
     this.klantID = u;
     this.userName = downloadConnection.getKlant(klantID.ToString()).achternaam;
     this.arduino = a;
     this.pasID = p;
     this.rekening = downloadConnection.getRekening(rekeningID);
     this.saldo = rekening.balans;
     this.stock = s;
 }
Ejemplo n.º 21
0
 public Stock(ArduinoData a)
 {
     this.arduino = a;
 }