/* Items2 Server - DMS - march 99 - by Sebastien DENEUX */ typeof myDB = SqlDB;; typeof open=I;; typeof dbname=S;; typeof dblogin=S;; typeof dbpassw=S;; typeof dbsql=S;; /*-------------------------------------*/ /*evenement destruction module client envoyé au client*/ fun cliDestroyed(cli)= { _DMSevent this cli "destroyed" nil nil };; /*-------------------------------------*/ /*traitement des requetes SQL (differentes lignes)*/ fun traiterRequetesSqlAjoutItem(r,cli)= if r!=nil then let r -> [nomChampsItem[requete fin]] in { /* _fooS strcat "Reference Item : " nomChampsItem;*/ let hd hd SqlRequest myDB requete (SQL_CHAR _DMSgetLogin cli)::nil -> RESULT in let mkItem [nomChampsItem RESULT 0 nil] -> monItem in /* {*/ _DMSaddItem cli monItem; /* _fooS strcat"Nom Item trouve : " RESULT; }; */ traiterRequetesSqlAjoutItem fin cli; } else 0;; /*-------------------------------------*/ fun activate(from,cli,action,param,rep)= /* _showconsole;*/ if !strcmp action "destroy" then /*destruction client*/ { _DMSdelClientDMI this cli; cliDestroyed cli } else if !strcmp action "start" then /*ajout des elements dans champs SQL de l'editeur dans l'inventaire du client*/ { let _DMSgetLogin cli -> NomLoginClient in { _DMSclearItem cli; let lineextr dbsql -> requetesSql in traiterRequetesSqlAjoutItem requetesSql cli; }; _DMSevent this cli "started" 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 myDB=SqlCreate _channel dbname dblogin if dbpassw==nil then "" else dbpassw; if myDB == nil then (_showconsole; _fooS "Unable to access database\n") else _fooS "Database opened successfully\n";;