In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

AdsConnect60 works, but now...

Xailer professional forum in English
Maarten Roos
Mensajes: 126
Registrado: Lun Mar 29, 2010 10:24 am

AdsConnect60 works, but now...

Mensaje por Maarten Roos »

I use TAdsDataSource for the remote Advantage server and TCdxDataSource for the standalone without ADS versions and now I want to setup the versions which connect through internet.
What is the quickest and best way for me to do?
I have now for example:

METHOD ConnectToEMS( oSender ) CLASS TFormMain
local hConnect, oError := Nil
::nServerType := asDEFAULT
/* get ServerType registry key */
WITH OBJECT tregistry():Create()
:Root := HKEY_CURRENT_USER
IF :OpenKey( "SoftwareECEMEMS" ) == 0
::nServerType := Val(:GetString( "ServerType" ))
:CloseKey()
ENDIF
:Destroy()
END WITH
::oStatusBar1:aItems[1]:ctext := Alltrim(::oStatusBar1:aItems[1]:ctext) +" - "+ GetServerType()
SWITCH ::nServerType
CASE asDEFAULT
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asLOCAL
ADSSetServerType(ADS_LOCAL_SERVER)
EXIT
CASE asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asAIS
ADSSetServerType(ADS_AIS_SERVER)
EXIT
CASE asREMOTE_AIS
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
CASE asANY
::nServerType := asREMOTE
ADSSetServerType(ADS_REMOTE_SERVER)
EXIT
END
if ::nServerType==asLOCAL
REQUEST DBFCDX
rddSetDefault( "DBFCDX" )
else
REQUEST ADS
RddRegister("ADS",1)
RddSetDefault("ADS")
AdsSetFileType(ADS_CDX)
REQUEST ADSKEYCOUNT, ADSKEYNO, ADSGETRELKEYPOS, ADSSETRELKEYPOS
endif
AdsRightsCheck(.F.)
AdsLocking(.F.)
/* check for connection */
if ::nServerType==asREMOTE
/* ADS */
IF AdsConnect("Emsads", ::nServerType)
WITH OBJECT ::oCdx
:cConnect := ::cDataPath
:nServerType := ::nServerType
END WITH
WITH OBJECT ::oCdxMain
:cConnect := ::cDataPath
:nServerType := ::nServerType
END WITH
ELSE
MsgStop("Cannot establish an ADS connection!")
QUIT
ENDIF
elseif ::nServerType==asAIS
/* AIS */
IF AdsConnect60( ::cDataPath+"EMSAIS.add",ADS_AIS_SERVER,"xxxx","xxxx")
WITH OBJECT ::oCdx
:cConnect := ::cDataPath+"EMSAIS.add"
:cUser := "xxxx"
:cPassword := "xxxx"
:lUseDictionary := .t.
:nServerType := ::nServerType
END WITH
WITH OBJECT ::oCdxMain
:cConnect := ::cDataPath+"EMSAIS.add"
:cUser := "xxxx"
:cPassword := "xxxx"
:lUseDictionary := .t.
:nServerType := ::nServerType
END WITH
ELSE
//MsgInfo(AdsGetLastError())
MsgStop("Cannot establish an AIS connection!")
QUIT
ENDIF
else
/* local without ADS */
endif
RETURN Nil


METHOD DBFCreate( oSender ) CLASS TLogIn
WITH OBJECT oSender
:oDataSource := GetCDXMainDataSource()
:lOpen := .t.
END WITH
RETURN Nil


FUNCTION GetCDXMainDataSource()
LOCAL oDataSource := Nil, nType := Application:oMainForm:nServerType
/*
oCdx ==> TAdsDataSource
oCdxMain ==> TAdsDataSource
oCdxLocal ==> TCdxDataSource
oCdxMainLocal ==> TCdxDataSource
*/
SWITCH nType
CASE asDEFAULT
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asLOCAL
oDataSource := Application:oMainForm:oCdxMainLocal
EXIT
CASE asREMOTE
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asAIS
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asREMOTE_AIS
oDataSource := Application:oMainForm:oCdxMain
EXIT
CASE asANY
oDataSource := Application:oMainForm:oCdxMain
EXIT
END
RETURN oDataSource

How do I simple make it work with AIS with above code? Or do I have to setup it completely different? I know I have to use the 'use'-command, but how do I pass the cVarName for alias()
Thx in advantage!
Maarten
Responder