Exemplo n.º 1
0
    public void resetfalsepin(String PasID)
    {
        HTTPget tmp       = new HTTPget();
        Pas     resetdata = tmp.getPinclass(PasID);

        incrementFalsePin(PasID, resetdata, 0).Wait();
    }
Exemplo n.º 2
0
    private async Task BlockPin(string loc)
    {
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
        using (var client = new HttpClient(new HttpClientHandler {
            UseProxy = false, ClientCertificateOptions = ClientCertificateOption.Automatic
        }))
        {
            client.BaseAddress = new Uri("https://hrsqlapp.tk");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            HTTPget tmp          = new HTTPget();
            Pas     uploadobject = tmp.getPinclass(loc);
            uploadobject.actief = 0;
            HttpResponseMessage response = await client.PutAsJsonAsync(String.Concat("/api/pass/", loc), uploadobject).ConfigureAwait(false);

            if (response.IsSuccessStatusCode)
            {
                //Error.show("SUCCES");
            }
            else
            {
                //Error.show("FAIL");
            }
        }
    }
Exemplo n.º 3
0
    public void Incrementfalsepin(String PasID)
    {
        HTTPget tmp        = new HTTPget();
        int     nrfalsepin = tmp.getFalsePinnr(PasID);
        Pas     uploaddata = tmp.getPinclass(PasID);

        nrfalsepin++;
        if (nrfalsepin >= 3)
        {
            BlockScreen a = new BlockScreen();
            BlockCard(PasID, uploaddata).Wait();
        }
        if (nrfalsepin < 3)
        {
            incrementFalsePin(PasID, uploaddata, nrfalsepin).Wait();
        }
    }
Exemplo n.º 4
0
 private async Task BlockPin(string loc)
 {
     System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
     using (var client = new HttpClient(new HttpClientHandler { UseProxy = false, ClientCertificateOptions = ClientCertificateOption.Automatic }))
     {
         client.BaseAddress = new Uri("https://hrsqlapp.tk");
         client.DefaultRequestHeaders.Accept.Clear();
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         HTTPget tmp = new HTTPget();
         Pas uploadobject = tmp.getPinclass(loc);
         uploadobject.actief = 0;
         HttpResponseMessage response = await client.PutAsJsonAsync(String.Concat("/api/pass/", loc), uploadobject).ConfigureAwait(false);
         if (response.IsSuccessStatusCode)
         {
             //Error.show("SUCCES");
         }
         else
         {
             //Error.show("FAIL");
         }
     }
 }
Exemplo n.º 5
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 :)
            }
        }
Exemplo n.º 6
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 :)
            }
        }