示例#1
0
        private bool PullDataParkingOut()
        {
            string            APIPullData  = Properties.Resources.RequestVehicleTypeAPIURL;
            DataResponseArray receivedData = (DataResponseArray)restApi.get(this.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));

                    if (TKHelper.WriteDataIntoJSONFile(vehicleTypes, Constant.DIR_PATH_SOURCE, Constant.PATH_FILE_MASTER_DATA_PARKING_OUT))
                    {
                        return(true);
                    }
                    else
                    {
                        notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_WRITE_MASTER_DATA_FILE, ToolTipIcon.Error);
                        return(false);
                    }

                default:
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", receivedData.Message, ToolTipIcon.Error);
                    return(false);
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error);
                return(false);
            }
        }
示例#2
0
        private void ApiSignIn(string username, string password)
        {
            var           APIUrl        = Properties.Resources.LoginAPIURL;
            SignInRequest signInRequest = new SignInRequest(username, password);
            string        sent_param    = JsonConvert.SerializeObject(signInRequest);

            DataResponseArray response = (DataResponseArray)restApi.post(this.ip_address_server, APIUrl, false, sent_param);

            if (response != null)
            {
                switch (response.Status)
                {
                case 201:
                    try
                    {
                        switch (Properties.Settings.Default.GateType.ToLower())
                        {
                        case "in":
                            this.passKadeIn = new PassKadeIn(this);
                            this.passKadeIn.Show();
                            break;

                        case "out":
                            this.cashier = new Cashier(this);
                            this.cashier.Show();
                            break;

                        default:
                            this.pedestrian = new Pedestrian(this);
                            this.pedestrian.Show();
                            break;
                        }
                        Hide();
                    }
                    catch (Exception)
                    {
                        notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_WEBCAM, ToolTipIcon.Error);
                        return;
                    }
                    break;

                default:
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", response.Message, ToolTipIcon.Error);
                    break;
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_FAIL_TO_CONNECT_SERVER, ToolTipIcon.Error);
            }
        }
示例#3
0
        private AutoCompleteStringCollection SearchBarcode(string keyword)
        {
            var queryParam             = "?barcode=" + keyword;
            var ApiURL                 = Properties.Resources.SearchBarcodeAPIURL + queryParam;
            DataResponseArray response = (DataResponseArray)restApi.get(IpAddressServer, ApiURL, false);

            if (response != null)
            {
                if (response.Status == 206)
                {
                    string         data     = response.Data.ToString();
                    List <Barcode> barcodes = JsonConvert.DeserializeObject <List <Barcode> >(data);
                    if (barcodes.Count > 0)
                    {
                        foreach (Barcode barcode in barcodes)
                        {
                            listBarcodeSuggestion.Items.Add(barcode.barcode);
                        }
                    }
                }
            }
            return(autoComplete);
        }