示例#1
0
        private PassKadeDeparture SendDataToServer(string base64WebcamImage, string base64IpCameraImage, string paymentMethod, string bankCode = "")
        {
            int    vehicleFare = TKHelper.IDRToNominal(txtPassKadeFare.Text.ToString());
            string uid         = ticket.Text.ToString();
            string uidType     = TKHelper.GetUidType(uid);
            string vehicleType = tipe_kendaraan.Text.ToString();
            string departure   = TKHelper.ConvertDatetimeToDefaultFormat(departureDatetime.Text.ToString());
            string username    = Properties.Settings.Default.Username;
            string plateNumber = nomor_plat.Text.ToString();
            string IpAddress   = TKHelper.GetLocalIPAddress();
            string cargoType   = TKHelper.DictionaryGetValueByKey(outloadTypeDict, tarifMuatan.Text.ToString());
            PassKadeDepartureRequest passKadeDepartureRequest = new PassKadeDepartureRequest(uidType, uid, vehicleType, departure, username, plateNumber, vehicleFare, CargoFare, cargoType, IpAddress, paymentMethod, bankCode, base64WebcamImage, base64IpCameraImage);
            var sentParam = JsonConvert.SerializeObject(passKadeDepartureRequest);

            string             passKadeDepartureRequestApiUrl = Properties.Resources.SaveDataPassKadeDepartureApiUrl;
            DataResponseObject response = (DataResponseObject)restApi.post(IpAddressServer, passKadeDepartureRequestApiUrl, true, sentParam);

            if (response != null)
            {
                if (response.Status == 206)
                {
                    return(JsonConvert.DeserializeObject <PassKadeDeparture>(response.Data.ToString()));
                }
                else
                {
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", response.Message, ToolTipIcon.Warning);
                    return(null);
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", Constant.ERROR_MESSAGE_INVALID_RESPONSE_FROM_SERVER, ToolTipIcon.Error);
                return(null);
            }
        }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string feedback = this.ValidateFields();

            if (feedback == Constant.MESSAGE_OK)
            {
                // check the payment method whether it's cash or non-cash
                int    totalFare     = TKHelper.IDRToNominal(txtGrandTotal.Text.ToString());
                string paymentMethod = nonCash.Checked ? "NCSH" : "CASH";

                if (paymentMethod == "NCSH")
                {
                    string bankCode      = "BNI";
                    string ipv4          = TKHelper.GetLocalIPAddress();
                    string TIDSettlement = Properties.Settings.Default.TID;
                    string operator_name = Properties.Settings.Default.Username;

                    // need to disconnect SCard from WinsCard.dll beforehand in order to execute further actions to avoid 'Outstanding Connection' Exception.
                    mifareCard.disconnect();

                    DataDeduct responseDeduct = bni.DeductBalance(bankCode, ipv4, TIDSettlement, operator_name);
                    if (!responseDeduct.IsError)
                    {
                        string base64WebcamImage        = CameraHelper.CaptureWebcamImage(camera, webcamImage);
                        string base64LiveCameraSnapshot = CameraHelper.SnapshotLiveCamera();
                        if (!string.IsNullOrEmpty(base64LiveCameraSnapshot))
                        {
                            PassKadeDeparture passKadeDeparture = SendDataToServer(base64WebcamImage, base64LiveCameraSnapshot, paymentMethod, bankCode);
                            StoreDataToDatabase(responseDeduct, passKadeDeparture);
                            notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Success", Constant.TRANSACTION_SUCCESS, ToolTipIcon.Info);
                            Clear();
                        }
                    }
                    else
                    {
                        notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", responseDeduct.Message, ToolTipIcon.Error);
                    }
                }
                else
                {
                    string base64WebcamImage       = CameraHelper.CaptureWebcamImage(camera, webcamImage);
                    string base4LiveCameraSnapshot = CameraHelper.SnapshotLiveCamera();
                    if (!string.IsNullOrEmpty(base4LiveCameraSnapshot))
                    {
                        PassKadeDeparture passKadeDeparture = SendDataToServer(base64WebcamImage, base4LiveCameraSnapshot, paymentMethod);
                        if (passKadeDeparture != null)
                        {
                            notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Success", Constant.TRANSACTION_SUCCESS, ToolTipIcon.Info);
                            Clear();
                        }
                    }
                }
            }
            else
            {
                notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", feedback, ToolTipIcon.Warning);
            }
        }
示例#3
0
        private void SaveDataLostTicket()
        {
            int    totalFare     = TKHelper.IDRToNominal(txtGrandTotal.Text.ToString());
            string paymentMethod = cash.Checked ? "CASH" : "NCSH";

            if (paymentMethod == "NCSH")
            {
                string bankCode      = "BNI";
                string ipv4          = TKHelper.GetLocalIPAddress();
                string TIDSettlement = Properties.Settings.Default.TID;
                string operator_name = Properties.Settings.Default.Username;

                DataDeduct responseDeduct = bni.DeductBalance(bankCode, ipv4, TIDSettlement, operator_name);
                if (!responseDeduct.IsError)
                {
                    string base64WebcamImage             = CameraHelper.CaptureWebcamImage(camera, webcamImage);
                    string base64LiveCameraSnapshotImage = CameraHelper.SnapshotLiveCamera();
                    if (!string.IsNullOrEmpty(base64LiveCameraSnapshotImage))
                    {
                        ParkingOut parkingOut = SendDataToServer(base64WebcamImage, base64LiveCameraSnapshotImage, paymentMethod, totalFare);
                        StoreDataToDatabase(responseDeduct, parkingOut);
                        notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Success", Constant.TRANSACTION_SUCCESS, ToolTipIcon.Info);
                        Clear();
                    }
                }
                else
                {
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Error", responseDeduct.Message, ToolTipIcon.Error);
                }
            }
            else
            {
                string base64WebcamImage             = CameraHelper.CaptureWebcamImage(camera, webcamImage);
                string base64LiveCameraSnapshotImage = CameraHelper.SnapshotLiveCamera();
                if (!string.IsNullOrEmpty(base64LiveCameraSnapshotImage))
                {
                    SendDataToServer(base64WebcamImage, base64LiveCameraSnapshotImage, paymentMethod, totalFare);
                    notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Success", Constant.TRANSACTION_SUCCESS, ToolTipIcon.Info);
                    Clear();
                }
            }
        }