private ParkingOut SendDataToServer(string webcamCapturedImage, string liveCameraSnapshotImage, string paymentMethod, int totalFare) { string vehicle = tipe_kendaraan.SelectedItem.ToString(); string username = Properties.Settings.Default.Username; string datetimeOut = TKHelper.ConvertDatetimeToDefaultFormat(waktu_keluar.Text.ToString()); string plateNumber = nomor_plat.Text.ToString(); string ipAddress = TKHelper.GetLocalIPAddress(); LostTicketRequest lostTicketRequest = new LostTicketRequest(vehicle, username, datetimeOut, totalFare, plateNumber, ipAddress, paymentMethod, webcamCapturedImage, liveCameraSnapshotImage); var payload = JsonConvert.SerializeObject(lostTicketRequest); string lostTicketApiUrl = Properties.Resources.LostTicketAPIURL; DataResponseObject response = (DataResponseObject)restApi.post(ipAddressServer, lostTicketApiUrl, true, payload); if (response != null) { if (response.Status == 206) { return(JsonConvert.DeserializeObject <ParkingOut>(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); } }
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); } }
private ParkingOut SendDataToServer(string base64Image, string base64LiveCameraSnapshotImage) { string dataBarcode = barcode.Text.ToString(); string uid = supervisorCard.Text.ToString(); string uidType = TKHelper.GetUidType(dataBarcode); string vehicle = vehicleType.Text.ToString(); string datetimeOut = TKHelper.ConvertDatetimeToDefaultFormat(timeOut.Text.ToString()); string username = Properties.Settings.Default.Username; string dataPlateNumber = plateNumber.Text.ToString(); string ipAddressLocal = TKHelper.GetLocalIPAddress(); ParkingOutFreePassRequest freePassRequest = new ParkingOutFreePassRequest(vehicle, uidType, dataBarcode, username, datetimeOut, dataPlateNumber, ipAddressLocal, uid, base64Image, base64LiveCameraSnapshotImage); var sent_param = JsonConvert.SerializeObject(freePassRequest); DataResponseObject response = (DataResponseObject)restApi.post(ip_address_server, Properties.Resources.SaveDataFreePassAPIURL, true, sent_param); if (response != null) { switch (response.Status) { case 206: return(JsonConvert.DeserializeObject <ParkingOut>(response.Data.ToString())); default: 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); } }
private DataPedestrianCargoResponse SendDataToServer(string paymentMethod, string bankCode = "") { List <DataPedestrianTypeQuantity> dataPedestrianTypeQuantities = GetDataPedestrianTypeQuantities(); string IpAddress = TKHelper.GetLocalIPAddress(); string DatetimeIn = TKHelper.ConvertDatetimeToDefaultFormat(datetimeIn.Text.ToString()); string Username = Properties.Settings.Default.Username; string CargoType = TKHelper.DictionaryGetValueByKey(CargoTypes, tarifMuatan.Text.ToString()); PedestrianRequest pedestrianRequest = new PedestrianRequest(dataPedestrianTypeQuantities, IpAddress, DatetimeIn, Username, CargoFare, CargoType, paymentMethod, bankCode); var sentParam = JsonConvert.SerializeObject(pedestrianRequest); DataResponseObject response = (DataResponseObject)restApi.post(Properties.Settings.Default.IPAddressServer, Properties.Resources.SaveDataPedestrianApiUrl, true, sentParam); if (response != null) { switch (response.Status) { case 206: return(JsonConvert.DeserializeObject <DataPedestrianCargoResponse>(response.Data.ToString())); default: 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); } }
private ParkingOut SendDataToServer(int totalFare, string base64Image, string base64LiveCameraImage, string paymentMethod, string bankCode = "") { string uid = textBox1.Text.ToString(); string uidType = TKHelper.GetUidType(uid); string vehicle = comboBox1.Text.ToString(); string datetimeOut = TKHelper.ConvertDatetimeToDefaultFormat(textBox4.Text.ToString()); string username = Properties.Settings.Default.Username; string plateNumber = textBox2.Text.ToString(); string ipAddressLocal = TKHelper.GetLocalIPAddress(); ParkingOutRequest parkingOutRequest = new ParkingOutRequest(uidType, uid, vehicle, datetimeOut, username, plateNumber, totalFare, ipAddressLocal, paymentMethod, bankCode, base64Image, base64LiveCameraImage); var sent_param = JsonConvert.SerializeObject(parkingOutRequest); DataResponseObject response = (DataResponseObject)restApi.post(ip_address_server, Properties.Resources.SaveDataParkingAPIURL, true, sent_param); if (response != null) { switch (response.Status) { case 206: return(JsonConvert.DeserializeObject <ParkingOut>(response.Data.ToString())); default: notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", response.Message, ToolTipIcon.Warning); return(null); } } else { notifyIcon.ShowBalloonTip(Constant.NOTIFICATION_TRAY_TIMEOUT, "Warning", Constant.ERROR_MESSAGE_INVALID_RESPONSE_FROM_SERVER, ToolTipIcon.Warning); return(null); } }
public string DeductBalance(string bank, string ipv4, string TIDSettlement, string operator_name, int amount = 1) { try { // check if deducted amount is sufficient within balance range and the balance must be greater than 0 int cardBalance = Int32.Parse(this.GetCardBalance()); if (cardBalance > 0 && (cardBalance - amount) > 0) { string result = bni.debitProcess(this.readerList[2].ToString(), this.selectedReader.ToString(), amount, Properties.Settings.Default.TID); // store deduct result card to server string created = tk.ConvertDatetimeToDefaultFormat(tk.GetCurrentDatetime()); string query = "INSERT INTO deduct_card_results (result, amount, transaction_dt, bank, ipv4, operator, ID_reader, created) VALUES('" + result + "', '" + amount + "', '" + created + "', '" + bank + "', '" + ipv4 + "', '" + operator_name + "', '" + TIDSettlement + "', '" + created + "')"; try { database.Insert(query); Console.WriteLine("Successfully Deducted for Rp. " + amount + ",-."); Console.WriteLine("Current Balance : " + String.Format("{0:n}", Int32.Parse(this.GetCardBalance()))); //this.CreateSettlement(result); acr123u.connectDirect(); int repeat = 3; int onDuration = 5; int OffDuration = 10; acr123u.setBuzzerControl((byte)repeat, (byte)onDuration, (byte)OffDuration); this.LEDStatus = LEDGreen; this.LEDStatus |= LEDAntGreen; acr123u.LCDBacklightControl(0xFF); this.acr123u.setLEDControl(this.LEDStatus); this.SetLCDDisplayText("Success ..."); acr123u.disconnect(); return("OK"); } catch (Exception ex) { Console.WriteLine(ex.Message); return(ex.Message); } } else { acr123u.connectDirect(); this.SetLCDDisplayText("Insufficient Bal"); Console.WriteLine("Can't Deduct : Insufficient Balance."); int repeat = 2; int onDuration = 5; int OffDuration = 10; acr123u.setBuzzerControl((byte)repeat, (byte)onDuration, (byte)OffDuration); this.LEDStatus = LEDRed; this.LEDStatus |= LEDAntRed; acr123u.LCDBacklightControl(0xFF); this.acr123u.setLEDControl(this.LEDStatus); acr123u.disconnect(); return("Can't Deduct : Insufficient Balance."); } } catch (Exception ex) { acr123u.connectDirect(); this.SetLCDDisplayText("Fail to Process."); Console.WriteLine(ex.Message); int repeat = 2; int onDuration = 5; int OffDuration = 10; acr123u.setBuzzerControl((byte)repeat, (byte)onDuration, (byte)OffDuration); this.LEDStatus = LEDRed; this.LEDStatus |= LEDAntRed; acr123u.LCDBacklightControl(0xFF); this.acr123u.setLEDControl(this.LEDStatus); acr123u.disconnect(); return(ex.Message); } }