- Sinae
- Nombre de messages : 3
Date d'inscription : 03/06/2008
Acomba sdk and c#
Sam 14 Juin 2008 - 21:39
Hi i'm using the acomba sdk in delphi 7 and in c# and the same code that is working in delphi isnt in c#.
The problem seem when i need to pass a UserKey that the com function acomba.FindKey(userIndex, 1) is suppose to update the userIndex cardpos.
When i call this function from delphi i have no problem and the userIndex.cardPos give me the good value but in c# i get a wrong one like if the userIndex.
here the c# code
here the delphi code
The problem seem when i need to pass a UserKey that the com function acomba.FindKey(userIndex, 1) is suppose to update the userIndex cardpos.
When i call this function from delphi i have no problem and the userIndex.cardPos give me the good value but in c# i get a wrong one like if the userIndex.
here the c# code
- Code:
namespace AcombaView
{
public partial class MainForm : Form
{
// private AcombaWrapper acombaGateway = new AcombaWrapper();
private AcombaX acomba = new AcombaXClass(); //this is with interop dll but when using new AcombaX directly from the registrated com class i have the same error described bellow
private UserKey *userIndex = new UserKeyClass();
private long exist;
private int error;
private string companyPath;
private string acombaPath;
private string password;
public MainForm()
{
InitializeComponent();
companyPath = @"c:\F1000.dta\company";
acombaPath = @"c:\Acomba";
password = "";
exist = acomba.CompanyExists(companyPath);
if (exist != 0)
{
error = acomba.OpenCompany(acombaPath, companyPath);
if (error == 0)
{
userIndex.UsNumber = "SUPERVISOR";
try
{
//here is the bug i have (findkey will not return an error code but the userIndex.CardPos is not updated with the good value
error = acomba.FindKey(userIndex, 1);
}
catch (Exception ex) {}
if (error == 0)
{
error = acomba.LogCurrentUser(userIndex.UsCardPos, password);
if (error == 0)
MessageBox.Show("User connection successfully completed","good", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
else
//here is the error msg i receive because the LogCurrentUser is failing due to cardpos being wrongly assigned in the FindKey method call
MessageBox.Show("Error: " + acomba.GetErrorMessage(error),"err", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Error: " + acomba.GetErrorMessage(error), "err", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Error: " + acomba.GetErrorMessage(error), "err", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MessageBox.Show("Invalid company access path","humm", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
here the delphi code
- Code:
var
Acomba: AcombaX;
AcombaPath: string;
CompanyPath: string;
Error: Longint;
Exist: Longint;
Password: string;
UserIndex: UserKey;
procedure OpenCo;
begin
//Interfaces Initialization
Acomba := CoAcombaX.Create;
UserIndex := CoUserKey.Create;
//Access path to the company's files to open
CompanyPath := 'C:\F1000.dta\Company';
//Access path to Acomba registration cards
AcombaPath := 'C:\Acomba';
//User's password
Password := '';
//Checks whether or not the company to open exists
Exist := Acomba.CompanyExists(CompanyPath);
if Exist <> 0 then
begin
//Opens the Demo company
Error := Acomba.OpenCompany(AcombaPath, CompanyPath);
if Error = 0 then
begin
//Finds the user "SuperVisor" in order to obtain her CardPos
UserIndex.UsNumber := 'SUPERVISOR';
Error := Acomba.FindKey(UserIndex, 1); //this is working in delphi without problem
if Error = 0 then
begin
//Connects the "SuperVisor" user using her password
Error := Acomba.LogCurrentUser(UserIndex.UsCardPos, Password);
if Error = 0 then
ShowMessage('User connection successfully completed.') // i get this message because cardpos is rightfully assigned in delphi
else
ShowMessage('Error: ' + Acomba.GetErrorMessage(Error));
end
else
ShowMessage('Error: ' + Acomba.GetErrorMessage(Error));
end
else
ShowMessage('Error: ' + Acomba.GetErrorMessage(Error));
end
else
ShowMessage('Invalid company access path.');
end;
- adidas
- Nombre de messages : 37
Age : 51
Ville : L'Épiphanie
Date d'inscription : 14/07/2007
Error with FindKey
Ven 8 Jan 2010 - 12:01
I know i'm a little late, but here is the answer:
When you're searching using findkey, only the fields inthe selected index are updated, and the fields name start by key_xxx, until you said true to retieve the selected card. ( .findkey(1,true) ).
In the case expressed here, you are not allowed to retrieve the card, because you're still not logged in. But you have right to browse users index. The cardpos will be updated in the field named key_UsCardPos, and not Cardpos.
I hope it helped.
When you're searching using findkey, only the fields inthe selected index are updated, and the fields name start by key_xxx, until you said true to retieve the selected card. ( .findkey(1,true) ).
In the case expressed here, you are not allowed to retrieve the card, because you're still not logged in. But you have right to browse users index. The cardpos will be updated in the field named key_UsCardPos, and not Cardpos.
I hope it helped.
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum