Jump to content

Ranja AZ

Members
  • Content Count

    26
  • Joined

  • Last visited

  • Days Won

    1

Ranja AZ last won the day on August 27 2023

Ranja AZ had the most liked content!

Community Reputation

2 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Ranja AZ

    Open HFSQL WINDEV Table error

    My objective is to access the tables of a database named GMAO of a WINDEV HFSQL (Hyperfile SQL) server. I try to use ODBC. Here is my source: procedure TForm1.Button1Click(Sender: TObject); var FDConnectionODBCHFSQL: TFDConnection; TableODBC:TFDTable; begin TableODBC := TFDTable.Create(nil); FDConnectionODBCHFSQL := TFDConnection.Create(nil); try FDConnectionODBCHFSQL.Params.Clear; FDConnectionODBCHFSQL.DriverName := 'ODBC'; FDConnectionODBCHFSQL.Params.Add('ODBCDriver=HFSQL'); FDConnectionODBCHFSQL.Params.Add('Database=GMAO'); FDConnectionODBCHFSQL.Params.Add('User_Name=admin'); FDConnectionODBCHFSQL.Params.Add('ExtendedMetadata=True'); FDConnectionODBCHFSQL.Params.Add('ODBCAdvanced=Server Name=DESKHOLY-PC;Server Port=4900;IntegrityCheck=1'); FDConnectionODBCHFSQL.Open; TableODBC.Connection := FDConnectionODBCHFSQL; TableODBC.TableName := 'appartenance'; try TableODBC.Open; ShowMessage('Table is open!'); except on E: Exception do begin ShowMessage('Open Table error : ' + E.Message); exit; end; end; except on E: Exception do begin ShowMessage('Connection Error: ' + E.Message); exit; end; end; end; The connection goes through, but when I try to open a table there is always an error: Error opening Table: [FireDAC][Phys][ODBC][Microsoft][ODBC Driver Manager] The driver does not support this function. Please, can anyone help me to resolve this issue? Regards!
  2. Ranja AZ

    Please need help for some java lines program to Delphi

    Thank you! The issue is resolved now. following code: procedure TForm2.Button2Click(Sender: TObject); var OpenResult : JMxResult; begin OpenResult := TJMxResult.Create; OpenResult := mSM62K2DriverApi.open(StringToJString('/dev/ttyS0'),115200); Memo1.Lines.Add(JStringToString(OpenResult.getMsg)); end; procedure TForm2.Button3Click(Sender: TObject); var OpenResult : JMxResult; begin OpenResult := TJMxResult.Create; OpenResult := mSM62K2DriverApi.close; Memo1.Lines.Add(JStringToString(OpenResult.getMsg)); end; procedure TForm2.FormCreate(Sender: TObject); begin CanPrint := True; DeviceEnginex := deviceEngine; Printerx := deviceEngine.getPrinter(); DeviceInfo := deviceEngine.getDeviceInfo(); POSModel := JStringToString(DeviceInfo.GetModel()); TJGeneralDdi.JavaClass.ddi_device_poweron; sleep(1000); mSM62K2DriverApi := TJSM62K2DriverApi.JavaClass.init; end; Regards.
  3. Ranja AZ

    Please need help for some java lines program to Delphi

    Here is what I tried: unit UBio306; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.StdCtrls, FMX.Controls.Presentation, classes,decoder, JustouchApi, MxAlgShankshake, SM62K2UARTAPI, nexgoSystemService_sdk_71, Androidapi.JNI.Media, FMX.Helpers.Android, Androidapi.JNI.JavaTypes, Androidapi.JNIBridge, Androidapi.Helpers, Androidapi.JNI.GraphicsContentViewText, FMX.Memo.Types, FMX.ScrollBox, FMX.Memo; Type TForm2 = class(TForm) ImageControl1: TImageControl; Button1: TButton; Button2: TButton; Memo1: TMemo; Button3: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); private { Déclarations privées } DeviceEnginex : JDeviceEngine; FOnPrintListner : JOnPrintListener; public { Déclarations publiques } DeviceInfo : JDeviceInfo; POSModel : String; CanPrint : Boolean; Printerx : JPrinter1; mSM62K2DriverApi : JSM62K2DriverApi; end; TOnPrintListener=class(TJavaLocal, JOnPrintListener) public procedure onPrintResult(param0: Integer); cdecl; end; var Form2: TForm2; deviceEngine : JDeviceEngine; implementation {$R *.fmx} procedure TOnPrintListener.onPrintResult(param0: Integer); begin // end; procedure TForm2.Button1Click(Sender: TObject); begin if FOnPrintListner=Nil then FOnPrintListner := TOnPrintListener.Create; Printerx.initPrinter; Printerx.setTypeface(TJTypeface.JavaClass.DEFAULT); Printerx.appendPrnStr(StringToJString('Test this ' + FormatDateTime('dd/mm/yy-hh:nn:ss',now) + #13#10 + #13#10#13#10#13#10#13#10#13#10#13#10),18,TJAlignEnum.JavaClass.LEFT,true); Printerx.startPrint(false,FOnPrintListner); end; procedure TForm2.Button2Click(Sender: TObject); var OpenResult : JMxResult; begin OpenResult := TJMxResult.Create; OpenResult := mSM62K2DriverApi.open(StringToJString('/dev/ttyS0'),115200); Memo1.Lines.Add(JStringToString(OpenResult.getMsg)); end; procedure TForm2.Button3Click(Sender: TObject); var OpenResult : JMxResult; begin OpenResult := TJMxResult.Create; OpenResult := mSM62K2DriverApi.close; Memo1.Lines.Add(JStringToString(OpenResult.getMsg)); end; procedure TForm2.FormCreate(Sender: TObject); begin CanPrint := True; DeviceEnginex := deviceEngine; Printerx := deviceEngine.getPrinter(); DeviceInfo := deviceEngine.getDeviceInfo(); POSModel := JStringToString(DeviceInfo.GetModel()); TJGeneralDdi.JavaClass.ddi_device_poweron; sleep(1000); end; end. When I click on Button2 I get the access violation error.
  4. Ranja AZ

    Please need help for some java lines program to Delphi

    What I don't understand is the creation of the App class (public class App extends Application) for opening the serial port with the instructions below: MxResult<?> open = App.getInstance().getSM62K2DriverApi().open(com, baudRate); showLog(open.getMsg(), true); MxResult<?> init = App.getInstance().getSM62K2DriverApi().AlgHandshakeInit(); Is it not possible to directly create an mSM62K2DriverApi object? Regards.
  5. Ranja AZ

    Please need help for some java lines program to Delphi

    The code is in Java. I don't know the Java language. So I want to do it in Delphi. Thanks!
  6. Hello everybody! I have a NEXGO android POS with an integrated biometric reader. I have already converted the SDKs to delphi for the biometrics reader. I also have a sample application but it's in Java (see attached). Can someone help me translate the following program lines? SM62K2UARTAPI.pas file is SDK library. app.java: package com.miaxis; import android.app.Application; import com.miaxis.alg.MxFingerAlgAPI; import com.miaxis.data.AppDataBase; import com.miaxis.finger.api.SM62K2DriverApi; import com.miaxis.utils.FileUtils; import java.io.File; import java.util.concurrent.Executor; import java.util.concurrent.Executors; /** * @author Tank * @date 2021/12/11 5:40 下午 * @des * @updateAuthor * @updateDes */ public class App extends Application { private final Executor executor = Executors.newSingleThreadExecutor(); private final SM62K2DriverApi mSM62K2DriverApi = new SM62K2DriverApi(); private final MxFingerAlgAPI mMxFingerAlgAPI = new MxFingerAlgAPI(); private static final String LicenseName = "license.txt"; public static final int RequestCode = 1001; private static App context; @Override public void onCreate() { super.onCreate(); context = this; AppDataBase.getInstance().init(this); } public String getLicenseFilePath(){ return new File(FileUtils.getPrivateDirectory(this), App.LicenseName).getAbsolutePath(); } public static App getInstance() { return context; } public SM62K2DriverApi getSM62K2DriverApi() { return this.mSM62K2DriverApi; } public MxFingerAlgAPI getMxFingerAlg() { return this.mMxFingerAlgAPI; } public Executor getExecutor() { return executor; } } in MainActivity.java: (What I want to convert in Delphi) private void open() { showLog(getString(R.string.text_open)); mMainViewModel.busy.postValue(true); mMainViewModel.opened.postValue(true); GeneralDdi.ddi_device_poweron(); SystemClock.sleep(500); try { String com = binding.etCom.getText().toString(); int baudRate = Integer.parseInt(binding.etBaudRate.getText().toString()); MxResult<?> open = App.getInstance().getSM62K2DriverApi().open(com, baudRate); showLog(open.getMsg(), true); MxResult<?> init = App.getInstance().getSM62K2DriverApi().AlgHandshakeInit(); showLog(getString(R.string.text_Alg_Handshake_Init) + "\n" + init.getMsg(), true); mMainViewModel.opened.postValue(open.isSuccess()); } catch (Exception e) { e.printStackTrace(); showLog(getString(R.string.button_open) + "\n" + e); mMainViewModel.opened.postValue(false); } mMainViewModel.busy.postValue(false); } Thank you! App.java MainActivity.java SM62K2UARTAPI.pas
  7. Hello everyone! Following all your instructions, everything is OK now. Many thanks to all of you!
  8. I Try to test it with REST Debugger: same result.
  9. I show you what I do in Postman. May be help.
  10. You are right about Authorization!
  11. Before calling "payments" API, I called another API using the same token access: token work fine!
  12. by adding the following lines request.Params.AddItem; request.Params[3].Name := 'Content-Type'; request.Params[3].Value := 'application/json'; request.Params[3].Kind := pkHTTPHEADER; result is the same: status 401
  13. Uwe Raabe, Thank you so much! It's work! After Authorization, I have to execute payment with the following cURL: curl --location --request POST 'https://<API server host>/merchant/v1/payments/' --header 'Content-Type: application/json' --header 'Authorization: bearer koeQidreesddfzsbxOXKjccccccc' \ --header 'X-Country: MG' --header 'X-Currency: MGA' --data-raw '{ "reference": "Testing API", "subscriber": { "country": "MG", "currency": "MGA", "msisdn": 331170348 }, "transaction": { "amount": 1000, "country":"MG", "currency": "MGA", "id": "242EB08E-0ACD-445C-8FF7-320FFD85B4A4" } }' With Postman it's work with status 200. But with following code status is always 401 var client := TRESTClient.Create('https://<API server host>/merchant/v1/payments/'); try var request := TRESTRequest.Create(nil); try request.Client := client; request.Method := TRESTRequestMethod.rmPOST; request.Accept := '*/*'; request.Params.AddItem; request.Params[0].Name := 'Autorization'; request.Params[0].Value := 'bearer koeQidreesddfzsbxOXKjccccccc'; request.Params[0].Kind := pkHTTPHEADER; request.Params.AddItem; request.Params[1].Name := 'X-Country'; request.Params[1].Value := 'MG'; request.Params[1].Kind := pkHTTPHEADER; request.Params.AddItem; request.Params[2].Name := 'X-Currency'; request.Params[2].Value := 'MGA'; request.Params[2].Kind := pkHTTPHEADER; request.AddBody('{"reference": "Testing API","subscriber": {"country": "MG", "currency": "MGA", "msisdn": 331170348}, "transaction": {"amount": 1000, "country":"MG", "currency": "MGA", "id": "FE9833FE-D5A3-4450-9786-90735F75EBFB"}}', TRESTContentType.ctAPPLICATION_JSON); request.Execute; var response := request.Response; Is there error in my code? Regard!
  14. Hello Uwe Raabe, Thanks for your response! I try it! Regards
  15. Hello everyone, Can someone help me to transform the following cURL request with use of TRESTClient and TRESTRequest: curl --location --request POST 'https://<API server host>/auth/oauth2/token' -H 'Content-Type: application/json' -H 'Accepte: */*' --data-raw '{ "client_id": "013C1A93-3D33-4986-8A7C-773D02C26214", "client_secret": "FE8FBA46-6ABF-4DF1-8D5E-31345DAAD194", "grant_type": "client_credentials" }' Regards.
×