/* LoadInfo Server - DMS - march 99 - by Sebastien DENEUX */ typeof db = SqlDB;; typeof open=I;; typeof dbname=S;; typeof dblogin=S;; typeof dbpassw=S;; typeof dbsql=S;; fun myDMSgetLogin (cli) = let _DMSgetLogin cli -> loginName in let strfind "@" loginName 0 -> pos in if pos == nil then loginName else substr loginName 0 pos ;; /*-----------*/ fun cliDestroyed(cli)= _DMSevent this cli "destroyed" nil nil;; /*-----------*/ /*add items [S r1] [S r1] values fieldName*/ fun ajouterItems(RESULT,nomsChampsItems,cli)= if (RESULT!=nil)&&(nomsChampsItems!=nil) then let RESULT -> [res1 suite1] in let nomsChampsItems -> [champs1 suite2] in ( /*_fooS strcat "LOADINFO : champsItem=" champs1; _fooS strcat "LOADINFO : resultat=" res1;*/ let mkItem [champs1 res1 0 nil] -> monItem in _DMSaddItem cli monItem; ajouterItems suite1 suite2 cli; 0 ) else 0;; /*-----------*/ /*transform [S r1] in S with spaces*/ fun buildSTR(t)= if t==nil then nil else let t -> [mot1 suite] in strcat strcat mot1 " " (buildSTR suite);; /*-----------*/ /*slq request processing (different lines)*/ fun traiterRequetesSqlAjoutItem(r,cli)= /*r=[[S r1] r1]*/ if r!=nil then let r -> [ligneNomsChampsItems[ligneRequete fin]] in let buildSTR ligneRequete -> requete in ( /*_fooS strcat "LOADINFO : requete=" requete;*/ let hd SqlRequest db requete (SQL_CHAR myDMSgetLogin cli)::nil -> RESULT in if (SqlCod db)==SQL_SUCCESS then ajouterItems RESULT ligneNomsChampsItems cli else if (SqlCod db)==SQL_NO_DATA then ( _fooS strcatn "###LOADINFO SQL NO_DATA requete = ("::requete::")"::nil; 0 ) else ( _fooS strcatn "###LOADINFO SQL ERROR requete = ("::requete::") -> delClient"::nil; _DLGMessageBox _channel nil strcat "LOADINFO : " (_loc this "ERROR_TITLE" nil) (_loc this "ACCESS_ERROR" nil) 0; _DMSdelClient cli ); traiterRequetesSqlAjoutItem fin cli ) else 0;; /*-----------*/ fun activate(from,cli,action,param,rep)= if !strcmp action "destroy" then ( _DMSdelClientDMI this cli; cliDestroyed cli ) else if !strcmp action "start" then /*add elements in SLQ fields of the editor in client inventory*/ ( _DMSclearItem cli; let strextr dbsql -> requetesSql in traiterRequetesSqlAjoutItem requetesSql cli; _DMSevent this cli "in" nil nil; 0; ) else nil;; /*-----------*/ fun IniDMI(file)= _DMSregisterDMI this @activate @cliDestroyed nil nil; let strextr _getpack _checkpack file -> l in (set open=atoi getInfo l "open"; set dbname=getInfo l "dbname"; set dblogin=getInfo l "dblogin"; set dbpassw=getInfo l "dbpassw"; set dbsql=getInfo l "dbsql"); set db=SqlCreate _channel dbname dblogin if dbpassw==nil then "" else dbpassw; if db==nil then let strcat _DMSgetName this " : unable to access to dataBase" -> errorMsg in (_fooS strcat "### " errorMsg;_DLGMessageBox _channel nil "Error" errorMsg 0;0) else nil;;