cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Error when executing MegaTransaction.Dispatch ("") from a Delphi (Win32) console program

chiareem
Member

Hello,

 

I built a tool to import/export Mega objects (person and actors).

It worked well with Mega 2005 but causes errors with Mega 2009.

 

The errors occur when Mega functions display à graphical UI

For example MegaTransation.Dispatch("") or when connecing to an environment with a bad password.

 

The equivalents functions in VBScript works fine.

 

My question: It is possible to avoid the display of graphical Windows when calling MEGA API ?

 

Thanks for your Help

 

Emmanuel Chiarello

Services Industriels de Genève

 

VBScript Test function:

  sEnvPath = WScript.Arguments.Item(0)

  sBase = WScript.Arguments.Item(1)

  sUser = WScript.Arguments.Item(2)

  sPassword = WScript.Arguments.Item(3)

  Set oSite = CreateObject("Mega.Application")

  WScript.Echo "Mega object created"

  Set oEnv = oSite.Environments.Item(sEnvPath)

  WScript.Echo "Mega Mega Site connected"

  set oUser = oEnv.Users.Item(sUser)

  WScript.Echo "Mega User retrieved"

  oEnv.CurrentAdministrator = sUser

  oEnv.CurrentPassword = sPassword

  set oTransaction = oEnv.Transactions.Create(sBase, oUser)

  WScript.Echo "Mega Transaction Created"

  oRoot = oTransaction.Database.Open

  WScript.Echo "Mega Database opened"

  oRoot.MegaCommit

  WScript.Echo "Mega Changes commited"

  oRoot.BaseClose

  WScript.Echo "Mega Database closed"

  oTransaction.Dispatch("")

  WScript.Echo "Mega Transaction Dispatched"

 

Delphi Test function:

procedure TForm1.MegaTest(sEnvPath, sBase,  sUser, sPassword: String);

var  

  oSite: OleVariant;

  oEnv: OleVariant;

  oUser: OleVariant;

  oTransaction: OleVariant;

  oRoot: OleVariant;

  iTrans: OleVariant;

begin

  oSite:= CreateOLEObject('Mega.Application');

  oEnv:= oSite.Environments.Item[sEnvPath];

  oUser:= oEnv.Users.Item[sUser];

  oEnv.CurrentAdministrator:= sUser;

  oEnv.CurrentPassword:= sPassword;

  oTransaction:= oEnv.Transactions.Create(sBase, oUser);  //failed if bad password

  oRoot:= oTransaction.Database.Open;

  oRoot.MegaCommit;

  oRoot.BaseClose;

  oTransaction.Dispatch('');  // Allways failed wiht "The server generated an exception"

end;

 

0 Replies