예제 #1
0
        private void updatePrice()
        {
            // Update parking price for car number
            string    req     = "select c.*, DATEDIFF(minute, c.enter_dt, '" + getBaseDateTimeNow() + "') as diff from cars c where c.id = '" + id + "' and c.enter = '1' and c.paid != '1' order by c.id desc";
            ArrayList results = config.Select(req);
            string    topay   = "";

            for (int i = 0; i < results.Count; i++)
            {
                NameValueCollection row = (NameValueCollection)results[i];

                // Update the previous entry
                price p = new price(config.db, row["number"], row["diff"]);
                req = "update cars set payment_dt='" + getBaseDateTimeNow() + "', payment_mns='" + row["diff"] + "', payment_dhm='" + p.dayshoursmns + "', amount='" + p.amount + "' where id = '" + id + "'";
                config.noSelect(req);
                topay = p.amount.ToString();
            }
            if (results.Count == 0 || topay == "")
            {
                labelPaymentGrid.Text = "Error Invalid Reference";
                butPay.Visible        = false;
            }
            else
            {
                labelPaymentGrid.Text = "TOTAL to PAY : " + topay + " sh";
            }
        }
예제 #2
0
        private void updatePrice()
        {
            // Update parking price for car number
            string    req     = "select c.*, DATEDIFF(minute, c.enter_dt, '" + getBaseDateTimeNow() + "') as diff from cars c where c.number = '" + dbCarsFilter.Text + "' and c.enter = '1'  and c.paid != '1' order by c.id desc";
            ArrayList results = config.Select(req);

            for (int i = 0; i < results.Count; i++)
            {
                NameValueCollection row = (NameValueCollection)results[i];
                string id = row["id"];
                // Update the previous entry
                price p = new price(config.db, row["number"], row["diff"]);
                req = "update cars set payment_dt='" + getBaseDateTimeNow() + "', payment_mns='" + row["diff"] + "', payment_dhm='" + p.dayshoursmns + "', amount='" + p.amount + "' where id = '" + id + "'";
                config.noSelect(req);
            }
        }
예제 #3
0
        public void insertCameraData(DBConnect db, byte[] data, string hardOcrResult, string cleanOcrResult)
        {
            int    maxsecdonothing = 20;
            string id_gate         = "0";
            // Following the camera, we know if enter = 0 or 1
            string    req     = "select enter from cameras where ident='" + ident + "'";
            ArrayList results = db.Select(req);

            for (int l = 0; l < 1; l++)
            {
                NameValueCollection row = (NameValueCollection)results[l];
                this.enter = row["enter"];
            }
            if (hardOcrResult != "")
            {
                req = "insert into camera_pictures (hardOcr,cleanOcr,ident,enter,photoname, dt) OUTPUT INSERTED.id VALUES ('" + hardOcrResult + "','" + cleanOcrResult + "','" + ident + "','" + enter + "','', '" + getBaseDateTimeNow() + "');";
                int newid = db.noSelect(req, "@cdata", data);
                req = "update camera_pictures set photoname='camerapicture-" + newid + ".jpg' where id=" + newid;
                db.noSelect(req);

                ImageProcessing image = new ImageProcessing();
                string          path  = HttpContext.Current.Server.MapPath("~");
                image.saveToFile(data, path, @"images\camerapicture-" + newid + ".jpg");

                // Get the gate (id_parking) of the camera
                req     = "select id_parking from cameras where ident = '" + ident + "'";
                results = db.Select(req);
                if (results.Count != 0)
                {
                    NameValueCollection row = (NameValueCollection)results[0];
                    id_gate = row["id_parking"];
                }
                // we check if the car is enter with out exit, so consider it's exit (for test 1 camera)
                if (enter == "1") // the car is entering in the parking
                {
                    // to prevent multiple update, we check date time
                    req     = "select c.*, DATEDIFF(second, c.enter_dt, '" + getBaseDateTimeNow() + "') as diff from cars c where c.enter = '1' and c.number = '" + cleanOcrResult + "' order by c.id desc";
                    results = db.Select(req);
                    string previd = "0";
                    if (results.Count != 0)
                    {
                        NameValueCollection row = (NameValueCollection)results[0];
                        // if < 20s we do nothing
                        if (Int32.Parse(row["diff"]) < maxsecdonothing)
                        {
                            return;
                        }
                        previd = row["id"];
                        enter  = "0";
                    }
                }

                if (enter == "1") // the car is entering in the parking
                {
                    // Create an entry in the cars table
                    req   = "insert into cars (number, enter, enter_dt, id_enter_gate, id_enter_picture, dt, paid) OUTPUT INSERTED.id VALUES ('" + cleanOcrResult + "','" + enter + "','" + getBaseDateTimeNow() + "','" + id_gate + "','" + newid.ToString() + "','" + getBaseDateTimeNow() + "', '0');";
                    newid = db.noSelect(req);
                }
                else // The car is exiting the parking
                {
                    req     = "select c.*, DATEDIFF(minute, c.enter_dt, '" + getBaseDateTimeNow() + "') as diff from cars c where c.number = '" + cleanOcrResult + "' order by c.id desc";
                    results = db.Select(req);
                    if (results.Count != 0)
                    {
                        NameValueCollection row = (NameValueCollection)results[0];
                        string id = row["id"];
                        // Update the previous entry
                        price p = new price(db, ident, row["diff"]);
                        req   = "update cars set enter='" + enter + "', exit_dt='" + getBaseDateTimeNow() + "', id_exit_gate='" + id_gate + "', id_exit_picture='" + newid.ToString() + "', dt='" + getBaseDateTimeNow() + "', total_mns='" + row["diff"] + "', total_dhm='" + p.dayshoursmns + "' where id = '" + id + "'";
                        newid = db.noSelect(req);
                    }
                }
            }
        }
예제 #4
0
        public void requestAndLoadConfig()
        {
            // Request parameters devices to get messages from storage if route used in azure
            // Sensors
            string    req     = "select * from azure where type = 'STORAGE' and ident = 'SENSOR'";
            ArrayList results = db.Select(req);

            storageSensorDevice = new SensorDevice[results.Count];
            for (int l = 0; l < results.Count; l++)
            {
                System.Collections.Specialized.NameValueCollection row = (NameValueCollection)results[l];
                // To Get Message from Storage container (for Sensors)
                storageSensorDevice[l] = new SensorDevice("", "");
                // Readed messages sent using OnNetClientReceived to form
                storageSensorDevice[l].OnNetClientReceived += new SensorDevice.NetClientReceived(netClient_DataReceived);
                // Read message from Storage Account, buth the specific Blob container : TFMinis devicetfminicontainer
                storageSensorDevice[l].readMessagesFromBlob(row["ConnectionString"], row["EventsEndpoint"]);
                if (l == 0)
                {
                    SensorDeviceClient = new AzureDeviceClient(row["ConnectionString"], row["EventsEndpoint"], OcrKey);
                }
            }

            // OCR Computer Vision Key
            req     = "select * from azure where type = 'VISION' and ident = 'OCR'";
            results = db.Select(req);
            for (int l = 0; l < 1; l++)
            {
                NameValueCollection row = (NameValueCollection)results[l];
                OcrKey = row["PrimaryKey"];
            }

            // Cameras
            req                 = "select * from azure where type = 'STORAGE' and ident = 'CAMERA'";
            results             = db.Select(req);
            storageCameraDevice = new CameraDevice[results.Count];
            for (int l = 0; l < results.Count; l++)
            {
                NameValueCollection row = (NameValueCollection)results[l];
                // To Get Message from Storage container (for Sensors)
                storageCameraDevice[l] = new CameraDevice("", "");
                // Readed messages sent using OnNetClientReceived to form
                storageCameraDevice[l].OnNetClientReceived += new CameraDevice.NetClientReceived(netClient_DataReceived);
                // Read message from Storage Account, buth the specific Blob container : TFMinis devicecameracontainer
                storageCameraDevice[l].readMessagesFromBlob(row["ConnectionString"], row["EventsEndpoint"], OcrKey);
                // Create a Test camera device for c# program
                if (l == 0)
                {
                    CameraDeviceClient = new AzureDeviceClient(row["ConnectionString"], row["EventsEndpoint"], OcrKey);
                }
            }

            // Update parking price for all cars inside
            req     = "select c.*, DATEDIFF(minute, c.enter_dt, '" + getBaseDateTimeNow() + "') as diff from cars c where c.enter = '1' and c.paid != '1' order by c.id desc";
            results = db.Select(req);
            for (int i = 0; i < results.Count; i++)
            {
                NameValueCollection row = (NameValueCollection)results[i];
                string id = row["id"];
                // Update the previous entry
                price p = new price(db, row["number"], row["diff"]);
                req = "update cars set payment_dt='" + getBaseDateTimeNow() + "', payment_mns='" + row["diff"] + "', payment_dhm='" + p.dayshoursmns + "', amount='" + p.amount + "' where id = '" + id + "'";
                db.noSelect(req);
            }
        }