bebeantics
|
|
« on: May 08, 2020, 11:46:07 AM » |
|
Hello
A have a client/server application. Server runing as Windows Service, the client is an Android App.
On Server side i have a function, getAmef with this code: procedure Tdmactivserver.getAmefExecute(Sender: TRtcConnection; Param: TRtcFunctionInfo; Result: TRtcValue); var tip:integer; qr:tfdquery; rtcDS: TRtcDataSet; begin logfile('Citire casefiscale', '!', '!'); if Param.isNull['tip'] then raise Exception.Create('Parametru TIP lipseste!') else tip:=param.asInteger['tip'];
case tip of 1: logfile('Tip case: AMEF FISCALIZATE' , '!', '!'); 2: logfile('Tip case: AMEF NE-FISCALIZATE', '!', '!'); else begin logfile('Tip case: '+tip.ToString, '!', '!'); raise Exception.Create('Parametru TIP cu erroare!'); end; end;
try qr:=tfdquery.Create(self); qr.Connection:=db; try case tip of 1: begin qr.SQL.Add('SELECT c.seria, cast(c.aviz as char(10)) aviz, c.dataachizitie, c.configuratia, c.fiscalizata, c.idclient, c.idpctl, c.NUI, c.datavanzare, c.achizitieproprieclient, cl.denumire utilizator, pl.adresa'); qr.SQL.Add(', pl.localitatea, pl.judet, cl.tel1, cl.sms FROM casefiscale c'); qr.SQL.Add('left join clienti cl on cl.id=c.idclient'); qr.SQL.Add('left join punctedelucru pl on pl.id=c.idpctl'); qr.SQL.Add('where c.fiscalizata=1 order by cl.denumire'); end; 2: begin qr.SQL.Add('SELECT c.seria, cast(c.aviz as char(10)) aviz, c.dataachizitie, c.configuratia, c.fiscalizata, c.idclient, c.idpctl, c.NUI, c.datavanzare, c.achizitieproprieclient, cl.denumire utilizator, pl.adresa'); qr.SQL.Add(', pl.localitatea, pl.judet, cl.tel1, cl.sms FROM casefiscale c'); qr.SQL.Add('left join clienti cl on cl.id=c.idclient'); qr.SQL.Add('left join punctedelucru pl on pl.id=c.idpctl'); qr.SQL.Add('where c.fiscalizata=1 order by cl.denumire'); end; end; qr.Open(); logfile('Inregistrari='+qr.RecordCount.ToString, '!', '!'); rtcDS := TRtcDataSet.Create; try DelphiDataSetToRtc(qr, rtcDS); Result.asObject := rtcDS; except on E:EDatabaseError do begin logfile(e.Message, 'Exception', 'getAMEF.rtcDs'); rtcDS.Free; end; end; except on E:EDatabaseError do begin logfile(e.Message, 'Exception', 'getAMEF.qr'); end; end; finally qr.Close; qr.Free; end;
end;
On the client side, function request is: procedure TfrmAmef.Button4Click(Sender: TObject); var tip:integer; begin if sw1.IsChecked then tip:=2 else tip:=1;
// amef log.d('Request Amef'); log.d('Tip='+tip.ToString);
//dm.RtcClientModule.CancelRequests; with dm.RtcClientModule do begin data.Clear;
with data.NewFunction('getAmef') do begin param.asInteger['tip']:=tip; end;
try call(dm.rtcResult1); except on e:exception do begin log.d(e.message); end; end; end;
end;
The result side is: else if (Data.isType=rtc_Function) and (Data.asFunction.FunctionName='getAmef') then begin log.d('Rezultat la '+Data.asFunction.FunctionName); if Result.isType = rtc_Dataset then begin log.d('+'); rtcMamef.Close; try rtcMamef.asDataSet := Result.asDataSet; Result.Extract; rtcMamef.Open; log.d('Recno='+rtcMamef.RecordCount.ToString); except on e:exception do log.D(e.Message); end; end else end
First problem is this, and i can't figure out how to solve it: rtcMangDs is an rtcclientdatasource.
If I try to manage the fields (with the field manager), log.d displays the error message Field value required. If I do not add any field in the field manager, I receive the correct answer and and everything works.
The second problem, o functions on server side, if one field is index key, unique, unsigned, I have to do CAST on it to be able to work with that field in field manager.
How can I handle these problems, especially since the former holds me in down. With thanks
Field value required.
|