示例#1
0
 public LostTicket(Login home)
 {
     InitializeComponent();
     this.home        = home;
     this.webcamImage = webcam;
     this.camera      = new Webcam(this);
     this.bni         = new BNI();
     this.database    = new DBConnect();
     restApi          = new RESTAPI();
     ipAddressServer  = Properties.Settings.Default.IPAddressServer;
     InitData();
 }
示例#2
0
        public Pedestrian(Login home)
        {
            InitializeComponent();

            this.home       = home;
            this.restApi    = new RESTAPI();
            this.database   = new DBConnect();
            this.bni        = new BNI();
            this.mifareCard = new MifareCard(this);
            this.mifareCard.RunMain();

            InitData();
            InitializePedestrianType();
        }
示例#3
0
 public void Initialize()
 {
     InitializeVehicleType();
     CameraHelper.StartIpCamera(liveCamera);
     this.webcamImage = webcam;
     if (Properties.Settings.Default.WebcamEnabled)
     {
         this.camera = new Webcam(this);
     }
     nonCash.Checked = true;
     this.restApi    = new RESTAPI();
     this.database   = new DBConnect();
     this.bni        = new BNI();
     this.mifareCard = new MifareCard(this);
     this.mifareCard.RunMain();
 }
示例#4
0
        private void Initialize()
        {
            InitializeVehicleType();
            InitializeOutload();
            CameraHelper.StartIpCamera(liveCamera);
            nonCash.Checked = true;

            this.bni         = new BNI();
            this.webcamImage = webcam;
            if (Properties.Settings.Default.WebcamEnabled)
            {
                this.camera = new Webcam(this);
            }

            this.mifareCard = new MifareCard(this);
            this.mifareCard.RunMain();
        }
示例#5
0
        private void Initialize()
        {
            nonCash.Checked = true;
            this.helper     = new TKHelper();
            //textBox4.Text = this.helper.GetCurrentDatetime();
            try
            {
                stream           = new JPEGStream(liveCameraURL);
                stream.NewFrame += stream_NewFrame;
                stream.Start();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Error : Cannot Connect to Live Camera. " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                LiveCamera.Image = Properties.Resources.no_image;
            }
            this.bni = new BNI(this);
            this.bni.RunMain();
            //this.StartTimer();

            // initialize vehicle type options
            try
            {
                comboBox1.Items.Add("- Pilih Tipe Kendaraan -");
                string masterDataFile = this.helper.GetApplicationExecutableDirectoryName() + "\\src\\master-data.json";
                using (StreamReader reader = new StreamReader(masterDataFile))
                {
                    string  json         = reader.ReadToEnd();
                    dynamic vehicleTypes = JsonConvert.DeserializeObject(json);
                    foreach (var types in vehicleTypes["VehicleTypes"])
                    {
                        comboBox1.Items.Add(types);
                    }
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                MessageBox.Show("Error : failed to fetch vehicle type data.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#6
0
        private void Initialize()
        {
            this.webcamImage = webcam;
            if (Properties.Settings.Default.WebcamEnabled)
            {
                this.camera = new Webcam(this);
            }
            this.restApi      = new RESTAPI();
            this.database     = new DBConnect();
            this.parkingIn    = new ParkingIn();
            autoComplete      = new AutoCompleteStringCollection();
            nonCash.Checked   = true;
            ip_address_server = Properties.Settings.Default.IPAddressServer;

            StartLiveCamera();

            this.bni = new BNI();

            this.mifareCard = new MifareCard(this);
            this.mifareCard.RunMain();

            // initialize vehicle type options
            try
            {
                comboBox1.Items.Add("- Pilih Tipe Kendaraan -");
                string masterDataFile = TKHelper.GetApplicationExecutableDirectoryName() + Constant.PATH_FILE_MASTER_DATA_PARKING_OUT;
                using (StreamReader reader = new StreamReader(masterDataFile))
                {
                    string  json         = reader.ReadToEnd();
                    dynamic vehicleTypes = JsonConvert.DeserializeObject(json);
                    foreach (var types in vehicleTypes["VehicleTypes"])
                    {
                        comboBox1.Items.Add(types);
                    }
                    comboBox1.SelectedIndex = 0;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_FETCH_VEHICLE_TYPE_DATA, ToolTipIcon.Error);
            }
        }
示例#7
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text.ToString();
            string password = textBox2.Text.ToString();

            if (username == "" || username == "Username")
            {
                MessageBox.Show("Username Harus Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (password == "" || password == "Password")
            {
                MessageBox.Show("Password Harus Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(this.setting.IPAddressServer))
            {
                MessageBox.Show("Invalid IP Address Server.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(this.setting.IPAddressLiveCamera))
            {
                MessageBox.Show("Invalid IP Address Live Camera.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // validate TID & Settlement MID for further transaction
            if (string.IsNullOrEmpty(this.tmid.TID))
            {
                MessageBox.Show("Invalid 'TID' value.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(this.tmid.MID))
            {
                MessageBox.Show("Invalid 'Settlement MID' value.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (Loading loading = new Loading(SignIn))
            {
                loading.ShowDialog(this);

                // check local database connection
                DBConnect database = new DBConnect();
                if (!database.CheckMySQLConnection())
                {
                    MessageBox.Show("Error : Can't Establish Connection to Local Database.\nPlease setup properly.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // check reader connection
                BNI bni = new BNI();
                if (!bni.CheckReaderConn())
                {
                    MessageBox.Show("Error : Contactless Reader not available.\nPlease plug it and then try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // remember me feature
                if (checkBox1.Checked)
                {
                    Properties.Settings.Default.Username   = username;
                    Properties.Settings.Default.Password   = password;
                    Properties.Settings.Default.RememberMe = "yes";
                }
                else
                {
                    Properties.Settings.Default.Username   = username;
                    Properties.Settings.Default.Password   = "";
                    Properties.Settings.Default.RememberMe = "no";
                }
                Properties.Settings.Default.Save();

                string ip_address_server = "http://" + this.setting.IPAddressServer;

                // pull some data from server e.g. Vehicle Types
                string       APIPullData  = Properties.Resources.RequestVehicleTypeAPIURL;
                RESTAPI      pull         = new RESTAPI();
                DataResponse receivedData = pull.API_Get(ip_address_server, APIPullData);
                if (receivedData != null)
                {
                    switch (receivedData.Status)
                    {
                    case 206:
                        JArray  receivedVehicleTypes = receivedData.Data;
                        JObject vehicleTypes         = new JObject();
                        vehicleTypes.Add(new JProperty("VehicleTypes", receivedVehicleTypes));

                        // write into a file called 'master-data.json'
                        try
                        {
                            string savedDir = tk.GetApplicationExecutableDirectoryName() + "\\src\\master-data.json";
                            string json     = JsonConvert.SerializeObject(vehicleTypes);
                            System.IO.File.WriteAllText(@savedDir, json);
                            //MessageBox.Show("Pull Master Data is Success.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    default:
                        MessageBox.Show(receivedData.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Error : Can't establish connection to server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                // send data API
                var     APIUrl = Properties.Resources.LoginAPIURL;
                JObject param  = new JObject();
                param["username"] = username;
                param["password"] = password;
                var sent_param = JsonConvert.SerializeObject(param);

                RESTAPI      api      = new RESTAPI();
                DataResponse response = api.API_Post(ip_address_server, APIUrl, sent_param);
                if (response != null)
                {
                    switch (response.Status)
                    {
                    case 201:
                        //MessageBox.Show(response.Message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        try
                        {
                            this.cashier = new Cashier(this);
                            this.cashier.Show();
                            Hide();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error : Can't Connect to Webcam.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        break;

                    default:
                        MessageBox.Show(response.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Error : Can't establish connection to server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }