#1 Re: mORMot 1 » rtti dynarray debug and release mode » 2019-01-09 07:38:30

hi ab,
enabling debug information on release mode i can step by step into the line of code that cause the access violation

in SynCommons.pas

procedure CopyArray(dest, source, typeInfo: Pointer; cnt: PtrUInt);
asm
{$ifdef CPU64}
        .NOFRAME
        jmp     System.@CopyArray
{$else} push    dword ptr[EBP + 8]
        call    System.@CopyArray // RTL is fast enough for this           <------ACCESS VIOLATION
{$endif}
end;

the same operation in debug mode work well. yikes
i create a new option (call production) copy from Release and disable optimization flag and ALL WORK FINE.
this can help?
Thanks

#2 Re: mORMot 1 » rtti dynarray debug and release mode » 2019-01-07 17:14:26

hi ab,
the problem in the problem is often that in debug mode all work like a charm! so i cant debug!

#3 Re: mORMot 1 » rtti dynarray debug and release mode » 2019-01-07 11:22:01

you're right mvp

i work on delphi 10.1 berlin 32bit

array declaration

TRigaDocumento = record
   IDArticolo: TID;
   Tipo: TTipoRigaDocumento;
   Codice: RawUTF8;
   Descrizione: RawUTF8;
   Quantita: Double;
   UnitaMisura: RawUTF8;
   PrezzoUnitario: Double;
   TipoPrezzo: TTipoPrezzo;
   Aliquota: Double;
   PercentualeScontoMaggiorazione1: Double;
   PercentualeScontoMaggiorazione2: Double;
   PercentualeScontoMaggiorazione3: Double;
   Lotto: RawUTF8;
   Reparto: RawUTF8;
   function getPrezzoNetto: Double;
   function getPrezzoLordo: Double;
   function getImponibile: Double;
   function getImposta: Double;
   function getTotale: Double;
   function getPercentualeScontoMaggiorazioneTotale: Double;
   function getImportoScontoMaggiorazioneTotale: Double;
   property PrezzoNetto: Double read getPrezzoNetto;
   property PrezzoLordo: Double read getPrezzoLordo;
   property Imponibile: Double read getImponibile;
   property Imposta: Double read getImposta;
   property Totale: Double read getTotale;
   property PercentualeScontoMaggiorazioneTotale: Double read getPercentualeScontoMaggiorazioneTotale;
   property ImportoScontoMaggiorazioneTotale: Double read getImportoScontoMaggiorazioneTotale;
end;
TRigheDocumento = array of TRigaDocumento;

DynArray init (where self.DARigheDocumento is TDynArray variable and aRigheDocumento is TRigheDocumento variable)

self.DARigheDocumento.Init(System.Typeinfo(TRigheDocumento), aRigheDocumento);

example operation with AV

self.DARigheDocumento.ElemCopyAt(aIndex, aRigaDocumento);

There is problem after the update of mORMot framework version '1.18.3372' to version '1.18.4932'
the Access Violation there is only in Release mode. In Debug mode all work fine.

if you need other information ask me obviously.
thanks a lot

#5 mORMot 1 » rtti dynarray debug and release mode » 2019-01-02 15:25:06

lele9
Replies: 7

Hi,
first of all happy new year smile
i have update mormot framework from 01/2017 to last nightly build and i have a problem with RTTI in a unit where i use TDynArray.
The problem (Access Violation) appear only in Release mode, not in Debug mode.

i think is something about this in mormot.pas

{.$define USETYPEINFO} // define for debugg, not on production

but i don't understand why and how resolve.

anyone can help me?
thanks
Emanuele.

#6 Re: mORMot 1 » How to use Multi table transaction » 2017-01-22 08:12:03

Hi,
Why don t use array of record (detail) as tsqlmasterrecord s property?

#7 Re: mORMot 1 » A mORMot Wordpress REST API (and WooCommerce API) consumer » 2017-01-03 05:46:15

Hi,
I download mormorò nigth build and your fresh code from guthub bit now i have anche access violation when i try to get user or customer.
Thanks

#9 Re: mORMot 1 » A mORMot Wordpress REST API (and WooCommerce API) consumer » 2016-12-22 10:26:01

Hi EvaF,
i'm testing your mormot-WP-REST-API.
I try to follow your instruction on readme, installed the plugin (but some version of plugin is updated), generate the key, edit json configuration file.
I have no response when i try to "get WP users".
I get error 404: rest_no_route if i try to create new user.
I read well woocommerce customers with "get Woo Customers".
I get error 404: woocommerce_api_no_route if i try to create new customer.
I think that i mistake something in the configuration file or in wordpress configuration.
Can you help me to understand?
thanks

#10 Re: mORMot 1 » modify record structure on database in production » 2016-08-11 06:48:33

thanks for the reply edwinsn!
for future implementation it might be best to avoid array of record to avoid such situations?in favor of?
thanks a lot!
Emanuele

#11 mORMot 1 » modify record structure on database in production » 2016-08-10 08:44:00

lele9
Replies: 2

hi,
i need to add a new field to a record that is declared in a TSQLRecord as array of record and stored as BLOB.

TImmobile = record
   Descrizione: RawUTF8;
   DatiCatastali: TIDDynArray;
   Percorrenza: Integer;
   Varia: Integer;                                <------------------------ NEW FIELD
end;
TImmobili = array of TImmobile;

TSQLConsorzio = class (TSQLRecord)
...
   property Immobili: TImmobili read FImmobili write FImmobili;
...
end;

If i insert new TSQLConsorzio it'all ok but when i try to retrieve an "old" TSQLConsorzio i have AV on retrieve.
The database is in production.
How can modify the structure and update the old blob field?
Thanks

#12 Re: mORMot 1 » OnUpdateEvent as trigger » 2016-03-22 07:35:12

i can define a method based services instead to declare an ancestor class?it works?
i would a service that passing a generic TSQLRecord can store it to the server in atomic operation with business logic if exists.

#13 Re: mORMot 1 » OnUpdateEvent as trigger » 2016-03-21 16:58:48

thinking about your suggest i write an interface-based-service to save and delete my TSQLRecord class.
something like this

IServiceCRUD = interface(IInvokable)['{FDD9121B-77A4-4C20-A283-42A80D54D42F}']
   function Delete(aRecord: TSQLRecord; var IDs: TIDDynArray): Integer;
   function Save(aRecord: TSQLRecord): Integer;
end;

and in implementation class (server-side) i write my business logic.
but i see that TSQLRecord is a bad parameter.
How can i do?
thanks for the patience

#14 Re: mORMot 1 » OnUpdateEvent as trigger » 2016-03-21 09:49:47

Excuse me ab but i think i must put this at server-side level. I can't expect that all client appplication know business logic.
I think OnUpdateEvent should be perfect if i can do atomic operation like in a transaction.
Have you different idea about this?what do you suggest?

#15 mORMot 1 » OnUpdateEvent as trigger » 2016-03-21 08:19:29

lele9
Replies: 7

Hi ab,
what is the best way to use trigger in mORMot?
i need to update other TSQLRecord on insert/update/delete...
I see OnUpdateEvent, but how can be sure that all trigger operations are atomic with the insert/update/delete that raise?
thanks

#16 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2016-03-18 09:53:11

hi ab,
i'm testing this code

procedure TSQLDocumento.ComputeFieldsBeforeWrite(aRest: TSQLRest;
  aOccasion: TSQLEvent);
var I: IServiceDocumento;
begin
   inherited;
   if aRest.Services['ServiceDocumento'].Get(I) then
   begin
      case aOccasion of
         seAdd: I.EmettiDocumento(self);
         seUpdate: I.ModificaDocumento(self);
         seDelete: I.AnnullaDocumento(self);
      end;
   end;
end;

and i see that seDelete Occasion never happen!
when i delete a record seem do not enter in ComputeFieldsBeforeWrite.
how can manage this case?
thanks

#17 mORMot 1 » RawUTF8DynArrayContains » 2015-10-20 10:05:36

lele9
Replies: 1

Hi,
i have a TMySQLRecord class with a property like this:

 property Proprietari: TProprietari read FProprietari write FProprietari; 

where TProprietari is

TProprietario = record
   RagioneSociale: RawUTF8;
   CodiceFiscale: RawUTF8;
   Indirizzo: RawUTF8;
   Comune: RawUTF8;
   Cap: RawUTF8;
   Telefono: RawUTF8;
end;
TProprietari = array of TProprietario;

i need to get all TSQLRecord IDs where TProprietario.CodiceFiscale is equal to aCodiceFiscale parameter.
i see RawUTF8DynArrayContainsNoCase function and i write this code but doesn't work. Maybe work only on TRawUTF8DynArray?

 aClient.OneFieldValues(TMySQLRecord , 'ID', FormatUTF8('RawUTF8DynArrayContainsNoCase(Proprietari, ?)', [], [aCodiceFiscale]), IDs);

any other idea?

thanks

#18 Re: mORMot 1 » dynamic array and javascript (ajax) client » 2015-08-18 10:59:14

but setting the ByPassAuthentication property to true anyone can call the service, instead i would that just logged in user (with just read permission) can do.
it's possible?

#19 Re: mORMot 1 » dynamic array and javascript (ajax) client » 2015-08-18 09:23:34

ok, i had write an interface-based service and all work fine.

just another question:
my ajax client need just to read, but if i use a "Guest" user i get forbidden when call the service. It's possible to have just read permission and able to call interface-based service?

#20 Re: mORMot 1 » dynamic array and javascript (ajax) client » 2015-08-18 07:06:48

thanks ab,
i will use TDocVariant in next time, but now i'm writing an ajax client for an application that is in production, so change the model is too difficult.
there are solution to pass a dynamic array as json to an ajax client or to read a dynamic array from the client?
thanks a lot.

#21 mORMot 1 » dynamic array and javascript (ajax) client » 2015-08-17 14:38:38

lele9
Replies: 7

hi ab,
i have a dynamic array property in a TSQLRecord definition and i would read (just read!) it from a javascript (ajax) client.
now i get a base64 encoded string that its hard to read (there are a good way to do?!).
i read from documentation that i can save a dynamic array as Json instead BLOB, but i don't understand what is the correct and fast way to do.
can you help me to undestand?
thanks,
Emanuele

#22 Re: mORMot 1 » TTimeLog and Javascript client » 2015-08-13 08:20:25

for other user, i hope can help.
excuse my poor javascript.

function TimeLogFromDateTime(dataText) {
                var giorno = new Date(dataText).getDate();
                var mese = new Date(dataText).getMonth();
                mese++;
                var anno = new Date(dataText).getFullYear();
                var temp = 0 + (giorno * Math.pow(2,5)) + (mese * Math.pow(2,10)) + (anno * Math.pow(2,14)) - ((1 * Math.pow(2,5)) + (1 * Math.pow(2,10)));
                var result = temp * Math.pow(2,12);
                return result;
            }

            function TimeLogToDateTime(Value) {
                var result = new Date();
                //window.alert(Value);
                var Y = Math.round(Value / Math.pow(2,(6+6+5+5+4)) & 4095);
                var M = 1+((Value) / Math.pow(2,(6+6+5+5))) & 15;
                var D = 1+((Value) / Math.pow(2,(6+6+5))) & 31;
                result.setFullYear(Y);
                result.setMonth(M-1);
                result.setDate(D);
                result.setHours(0);
                result.setMinutes(0);
                result.setSeconds(0);
                result.setMilliseconds(0);
                if (Value & (1 * Math.pow(2,(6+6+5))-1) != 0) {
                    var HH = ((Value) / Math.pow(2,(6+6))) & 31;
                    var MM = ((Value) / Math.pow(2,6)) & 63;
                    var SS = (Value) & 63;
                    result.setHours(HH);
                    result.setMinutes(MM);
                    result.setSeconds(SS);
                    result.setMilliseconds(0);
                }
                return result;
            }

#23 Re: mORMot 1 » TTimeLog and Javascript client » 2015-08-12 15:09:06

any idea to write a javascript TimeLogToDateTime function?

#24 Re: mORMot 1 » TTimeLog and Javascript client » 2015-08-12 06:32:36

ooops sorry, now i understand!

var temp = 0 + (day * Math.pow(2,5)) + (month * Math.pow(2,10)) + (year * Math.pow(2,14)) - ((1 * Math.pow(2,5)) + (1 * Math.pow(2,10)));
var timeLog = temp * Math.pow(2,12);

this javascript code seems to work!

#25 Re: mORMot 1 » TTimeLog and Javascript client » 2015-08-12 06:12:19

var timeLog = 0 + (day * 5) + (month * 10) + (year * 14) - ((1 * 5) + (1 * 10));
timeLog = (timeLog * 12);

like this?

#26 Re: mORMot 1 » TTimeLog and Javascript client » 2015-08-11 15:05:23

i looked and i write this javascript code but the number dont seems a ttimelog...

var timeLog = 0 + (day << 5) + (month << 10) + (year << 14) - ((1 << 5) + (1 << 10));
timeLog = (timeLog << 12);

NB i need date only
where i mistake?

#27 Re: mORMot 1 » TTimeLog and Javascript client » 2015-08-11 13:59:39

hi ab,
excuse me but maybe i explained wrong or i don't understand what do you mean.
i retrieve data from a javascript client page (that use the mormotClient.js written from Esmond, thanks!).
I need to query on TTimeLog field and so, i think, i need to encode a DateTime javascript variable to TTimeLog.
how to do?
thanks

#28 mORMot 1 » TTimeLog and Javascript client » 2015-08-11 09:56:17

lele9
Replies: 12

Hi,
i'm writing a javascript client that get data with a query.
now i should write a condition on a TTimeLog field but i don't know how to convert a Date to TTimeLog in javascript.
Any idea?
thanks,
Emanuele.

#29 Re: mORMot 1 » validate multi fields unique » 2015-07-21 10:36:43

thanks,
i write this code, maybe can help other users, quickly tested, but please check its ok.

TSynValidateUniqueFields = class(TSynValidateRest)
  private
    faFieldsNames: TRawUTF8DynArray;
  protected
    procedure SetParameters(Value: RawUTF8); override;
  public
    function Process(aFieldIndex: integer; const Value: RawUTF8; var ErrorMsg: string): boolean; override;
    property aFieldsNames: TRawUTF8DynArray read faFieldsNames write faFieldsNames;
  end;

function TSynValidateUniqueFields.Process(aFieldIndex: integer;
  const Value: RawUTF8; var ErrorMsg: string): boolean;
var aID: TID;
    aWhere: RawUTF8;
  I: Integer;
begin
   result := false;
   if (fProcessRest=nil) or (fProcessRec=nil) then
    result := true else
   begin
      aWhere := '(';
      aWhere := aWhere + '(1=1)';
      for I := 0 to Length(self.faFieldsNames)-1 do
         aWhere := aWhere + ' AND (' + self.faFieldsNames[i] + '=:('+
                   QuotedStr(fProcessRec.GetFieldValue(self.faFieldsNames[i]),'''')+'):)';
      aWhere := aWhere + ')';
      with fProcessRec.RecordProps do
         SetID(pointer(fProcessRest.OneFieldValue(Table, 'ID', aWhere)), aID);
      if (aID>0) and (aID<>fProcessRec.GetID) then
        ErrorMsg := sValidationFieldDuplicate
      else
        result := true;
   end;

end;

procedure TSynValidateUniqueFields.SetParameters(Value: RawUTF8);
var V: TPUtf8CharDynArray;
  I: Integer;
begin
  JSONDecode(Value, ['FieldNames'], V, True);
  SetLength(self.faFieldsNames, 0);
  I := 0;
  while (V[0]<>nil) do
  begin
     SetLength(self.faFieldsNames, Length(self.faFieldsNames)+1);
     self.faFieldsNames[i] := GetNextItem(V[0]);
     inc(I);
  end;
end;

that can be used as this

TSQLSampleRecord.AddFilterOrValidate('propA', TSynValidateUniqueFields.Create('{"FieldNames":"propA,propB"}'));

thanks,
Emanuele

#30 mORMot 1 » validate multi fields unique » 2015-07-20 15:22:18

lele9
Replies: 3

hi,
how validate a TSQLRecord on multi fields unique values?
an example to explain:

TSQLSampleRecord = class (TSQLRecord)
property propA: RawUTF8;
property propB: RawUTF8;
property propC: RawUTF8;
end;

i would execute a validate to deny an insert of two TSQLSampleRecord with same PropA AND PropB.

maybe TSynValidateRest can help me?how?

thanks

#32 mORMot 1 » mormot login from php web page » 2015-06-25 14:19:27

lele9
Replies: 1

hi,
i'm writing a php page to get some TSQLRecord data from a mormot http server.
i have no problem with authentication disabled but how can i login from php page if authentication is enabled?
thanks,
Emanuele.

#33 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-20 06:38:29

it works!!!
thanks ab for the step by step help smile
another question, you ask me for the sicSingle/sicShared interface service.
In this case i use the service to update other table/tsqlRecord when add/update/delete a TSQLDocumento so i use sicSingle.
What do you think is the best instance implementation for this case?

#34 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-19 17:52:28

step by step parsing properties i found that the error is in RiepilogoIVA property.

this is the Json value

'{"ID":0,"CodiceDocumento":"","TipoDocumento":"","Numero":"","Data":135243497472,"CedentePrestatore":{"RagioneSociale":"","CodiceFiscale":"","PartitaIva":"","RegimeFiscale":"","Indirizzo":"","NumeroCivico":"","CAP":"","Comune":"","Provincia":"","Nazione":"","UfficioREA":"","NumeroREA":"","CapitaleSociale":0,"SocioUnitco":"","StatoLiquidazione":"","Telefono":"","Fax":"","eMail":""},"CessionarioCommittente":{"RagioneSociale":"","CodiceFiscale":"","PartitaIva":"","Indirizzo":"","NumeroCivico":"","CAP":"","Comune":"","Provincia":"","Nazione":""},"RagioneSociale":"","CodiceFiscale":"","PartitaIva":"","Indirizzo":"","NumeroCivico":"","CAP":"","Comune":"","Provincia":"","Nazione":"","TipoRitenuta":"","ImportoRitenuta":0,"AliquotaRitenuta":0,"CausalePagamento":"","BolloVirtuale":"","ImportoBollo":0,"PercentualeScontoMaggiorazione":0,"ImportoScontoMaggiorazione":0,"Arrotondamento":0,"CausaleDocumento":"","Art73":false,"Vettore":{"RagioneSociale":"","CodiceFiscale":"","PartitaIva":"","Indirizzo":"","NumeroCivico":"","CAP":"","Comune":"","Provincia":"","Nazione":"","NumeroLicenzaGuida":""},"MezzoTrasporto":"","CausaleTrasporto":"","NumeroColli":0,"AspettoColli":"","UnitaMisuraPesoColli":"","PesoColli":0,"DataOraRitiro":127489671168,"DataInizioTrasporto":127489671168,"IndirizzoConsegna":"","NumeroCivicoConsegna":"","CAPConsegna":"","ComuneConsegna":"","ProvinciaConsegna":"","NazioneConsegna":"","DataOraConsegna":127489671168,"CondizioniPagamento":"","DettagliPagamento":[],"RigheDocumento":[],"RiepilogoIVA":[],"Imponibile":0,"Imposta":0,"Totale":0,"DataCreazione":135243570155,"CreatoDa":"Admin","UltimaModifica":135243570155,"ModificatoDa":""}]'

and this is the TSQLRecord Definition

TSQLDocumento = class (TSQLBase)
  private
    FTipoDocumento: RawUTF8;
    FCedentePrestatore: TAnagraficaCedentePrestatore;
    FCessionarioCommittente: TAnagraficaCessionarioCommittente;
    FNumero: RawUTF8;
    FData: TTimeLog;
    FCodiceDocumento: RawUTF8;
    FTipoRitenuta: RawUTF8;
    FAliquotaRitenuta: Double;
    FImportoRitenuta: Double;
    FCausalePagamento: RawUTF8;
    FBolloVirtuale: RawUTF8;
    FImportoBollo: Double;
    FPercentualeScontoMaggiorazione: Double;
    FImportoScontoMaggiorazione: Double;
    FArrotondamento: Double;
    FCausaleDocumento: RawUTF8;
    FArt73: Boolean;
    FVettore: TAnagraficaVettore;
    FMezzoTrasporto: RawUTF8;
    FCausaleTrasporto: RawUTF8;
    FNumeroColli: Integer;
    FAspettoColli: RawUTF8;
    FUnitaMisuraPesoColli: RawUTF8;
    FPesoColli: Double;
    FNazioneConsegna: RawUTF8;
    FComuneConsegna: RawUTF8;
    FNumeroCivicoConsegna: RawUTF8;
    FProvinciaConsegna: RawUTF8;
    FDataOraRitiro: TTimeLog;
    FCAPConsegna: RawUTF8;
    FIndirizzoConsegna: RawUTF8;
    FDataOraConsegna: TTimeLog;
    FCondizioniPagamento: RawUTF8;
    FDettagliPagamento: TDettagliPagamento;
    FRigheDocumento: TRigheDocumento;
    FDataInizioTrasporto: TTimeLog;
    function getRiepilogoIVA: TRiepilogoIVA;
    function getImponibile: Double;
    function getImposta: Double;
    function getTotale: Double;
    //function getRagioneSociale: RawUTF8;
  public
     procedure ComputeFieldsBeforeWrite(aRest: TSQLRest; aOccasion: TSQLEvent); override;
  published
     property CodiceDocumento: RawUTF8 index 4 read FCodiceDocumento write FCodiceDocumento;
     property TipoDocumento: RawUTF8 index 40 read FTipoDocumento write FTipoDocumento;
     property Numero: RawUTF8 index 30 read FNumero write FNumero;
     property Data: TTimeLog read FData write FData;
     property CedentePrestatore: TAnagraficaCedentePrestatore read FCedentePrestatore write FCedentePrestatore;
     property CessionarioCommittente: TAnagraficaCessionarioCommittente read FCessionarioCommittente write FCessionarioCommittente;
     property RagioneSociale: RawUTF8 read FCessionarioCommittente.RagioneSociale write FCessionarioCommittente.RagioneSociale;
     property CodiceFiscale: RawUTF8 read FCessionarioCommittente.CodiceFiscale write FCessionarioCommittente.CodiceFiscale;
     property PartitaIva: RawUTF8 read FCessionarioCommittente.PartitaIva write FCessionarioCommittente.PartitaIva;
     property Indirizzo: RawUTF8 read FCessionarioCommittente.Indirizzo write FCessionarioCommittente.Indirizzo;
     property NumeroCivico: RawUTF8 read FCessionarioCommittente.NumeroCivico write FCessionarioCommittente.NumeroCivico;
     property CAP: RawUTF8 read FCessionarioCommittente.CAP write FCessionarioCommittente.CAP;
     property Comune: RawUTF8 read FCessionarioCommittente.Comune write FCessionarioCommittente.Comune;
     property Provincia: RawUTF8 read FCessionarioCommittente.Provincia write FCessionarioCommittente.Provincia;
     property Nazione: RawUTF8 read FCessionarioCommittente.Nazione write FCessionarioCommittente.Nazione;
     property TipoRitenuta: RawUTF8 index 4 read FTipoRitenuta write FTipoRitenuta;
     property ImportoRitenuta: Double read FImportoRitenuta write FImportoRitenuta;
     property AliquotaRitenuta: Double read FAliquotaRitenuta write FAliquotaRitenuta;
     property CausalePagamento: RawUTF8 index 2 read FCausalePagamento write FCausalePagamento;
     property BolloVirtuale: RawUTF8 index 2 read FBolloVirtuale write FBolloVirtuale;
     property ImportoBollo: Double read FImportoBollo write FImportoBollo;
     property PercentualeScontoMaggiorazione: Double read FPercentualeScontoMaggiorazione write FPercentualeScontoMaggiorazione;
     property ImportoScontoMaggiorazione: Double read FImportoScontoMaggiorazione write FImportoScontoMaggiorazione;
     property Arrotondamento: Double read FArrotondamento write FArrotondamento;
     property CausaleDocumento: RawUTF8 read FCausaleDocumento write FCausaleDocumento;
     property Art73: Boolean read FArt73 write FArt73;
     property Vettore: TAnagraficaVettore read FVettore write FVettore;
     property MezzoTrasporto: RawUTF8 index 80 read FMezzoTrasporto write FMezzoTrasporto;
     property CausaleTrasporto: RawUTF8 index 100 read FCausaleTrasporto write FCausaleTrasporto;
     property NumeroColli: Integer read FNumeroColli write FNumeroColli;
     property AspettoColli: RawUTF8 index 100 read FAspettoColli write FAspettoColli;
     property UnitaMisuraPesoColli: RawUTF8 index 10 read FUnitaMisuraPesoColli write FUnitaMisuraPesoColli;
     property PesoColli: Double read FPesoColli write FPesoColli;
     property DataOraRitiro: TTimeLog read FDataOraRitiro write FDataOraRitiro;
     property DataInizioTrasporto: TTimeLog read FDataInizioTrasporto write FDataInizioTrasporto;
     property IndirizzoConsegna: RawUTF8 read FIndirizzoConsegna write FIndirizzoConsegna;
     property NumeroCivicoConsegna: RawUTF8 read FNumeroCivicoConsegna write FNumeroCivicoConsegna;
     property CAPConsegna: RawUTF8 read FCAPConsegna write FCAPConsegna;
     property ComuneConsegna: RawUTF8 read FComuneConsegna write FComuneConsegna;
     property ProvinciaConsegna: RawUTF8 read FProvinciaConsegna write FProvinciaConsegna;
     property NazioneConsegna: RawUTF8 read FNazioneConsegna write FNazioneConsegna;
     property DataOraConsegna: TTimeLog read FDataOraConsegna write FDataOraConsegna;
     property CondizioniPagamento: RawUTF8 index 4 read FCondizioniPagamento write FCondizioniPagamento;
     property DettagliPagamento: TDettagliPagamento read FDettagliPagamento write FDettagliPagamento;
     property RigheDocumento: TRigheDocumento read FRigheDocumento write FRigheDocumento;
     property RiepilogoIVA: TRiepilogoIVA read getRiepilogoIVA;
     property Imponibile: Double read getImponibile;
     property Imposta: Double read getImposta;
     property Totale: Double read getTotale;
end;

and the RiepilogoIVA definition

TDettaglioIVA = record
   Aliquota: Double;
   Imponibile: Double;
   Imposta: Double;
   Totale: Double;
end;
TRiepilogoIVA = array of TDettaglioIVA;

and the getRiepilogoIVA implementation detail

function TSQLDocumento.getRiepilogoIVA: TRiepilogoIVA;
var
  I, J: Integer;
  rIVA: TDynArray;
  dIVA: TDettaglioIVA;
begin
   setLength(result, 0);
   rIVA.Init(TypeInfo(TRiepilogoIVA), result);
   //ciclo tutte le righe del documento
   for I := 0 to High(self.FRigheDocumento) do
   begin
      dIVA.Aliquota := self.FRigheDocumento[i].Aliquota;
      dIVA.Imponibile := self.FRigheDocumento[i].getImponibile;
      dIVA.Imposta := self.FRigheDocumento[i].getImposta;
      dIVA.Totale := self.FRigheDocumento[i].getTotale;
      //verifico aliquota iva
      //se nuova inserisco riga
      J := rIVA.FindAndAddIfNotExisting(dIVA, nil, SortDynArrayDouble);
      //altrimenti la sommo a quella presente
      if (J > -1) then
      begin
         TDettaglioIVA(rIVA.ElemPtr(J)^).Imponibile := TDettaglioIVA(rIVA.ElemPtr(J)^).Imponibile + self.FRigheDocumento[i].getImponibile;
         TDettaglioIVA(rIVA.ElemPtr(J)^).Imposta := TDettaglioIVA(rIVA.ElemPtr(J)^).Imposta + self.FRigheDocumento[i].getImposta;
         TDettaglioIVA(rIVA.ElemPtr(J)^).Totale := TDettaglioIVA(rIVA.ElemPtr(J)^).Totale + self.FRigheDocumento[i].getTotale;
      end;
   end;
end;

#35 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-19 17:00:57

i think the problem is here...
in the function TServiceMethod.InternalExecute

case ValueType of
        smvObject: begin
          Par := JSONToObject(Objects[IndexVar],Par,valid);    <---- is not valid!! why?!
          if not valid then
            exit;
          IgnoreComma(Par);
        end;

any idea?

#36 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-19 15:14:47

Ctxt.ServiceParameters contains the TSQLRecord as Json, i think its correct.

#37 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-19 13:02:18

how can enabled map debugging information?

the step by step reach TSQLRestServerURIContext.InternalExecuteSOAByInterface
ServiceMethodIndex is 0
the debugger reach TServiceFactoryServer.ExecuteMethod until

if not fInterface.fMethods[Ctxt.ServiceMethodIndex].InternalExecute(
            [PAnsiChar(Inst.Instance)+entry^.IOffset],Ctxt.ServiceParameters,
             WR,Ctxt.Call.OutHead,Ctxt.Call.OutStatus,
             fExecution[Ctxt.ServiceMethodIndex].Options,
             Ctxt.ForceServiceResultAsJSONObject,
             {$ifdef LVCL}nil{$else}fBackgroundThread{$endif},
             Ctxt.ExecuteCallback) then begin
          Error('execution failed (probably due to bad input parameters)');
          exit; // wrong request
        end;

i try with sicShared with the same result.

#38 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-19 12:28:29

i try to find in TSQLRestRoutingREST.ExecuteSOAByInterface but i don't know what to search...

this is the log

TSynLog 1.18.1341 FTS3 2015-05-19T14:22:41

20150519 14224114 EXC   EInterfaceFactoryException ("TInterfacedObjectFakeClient.FakeCall(IServiceDocumento.ModificaDocumento) failed: '{\r\n\"errorCode\":400,\r\n\"errorText\":\"Single execution failed (probably due to bad input parameters) for IServiceDocumento.ModificaDocumento\"\r\n}'") at 007D229F  stack trace API 006BB508 006BB530 0040AB04 76FF0083 76FF07FF 007D229F 007D2563 007D303E

can help you to help me?

#39 Re: mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-19 11:49:12

hi ab,
no, the debugger don't reach  TServiceDocumento.EmettiDocumento() implementation methods.
authentication is enabled, i use setUser on client side.

#41 mORMot 1 » EInterfaceFactoryException when call interface service proc on client » 2015-05-13 09:39:55

lele9
Replies: 18

Hi,
i write my first interface service method.

define the interface

IServiceDocumento = interface(IInvokable)['{6B7E89EC-34B0-43A6-9C81-86A324FC1DF9}']
   function EmettiDocumento(aDocumento: TSQLDocumento): Integer;
   function AnnullaDocumento(aDocumento: TSQLDocumento): Integer;
   function ModificaDocumento(aDocumento: TSQLDocumento): Integer;
end;

implement the service in the server

TServiceDocumento = class(TInterfacedObject, IServiceDocumento)
public
   function EmettiDocumento(aDocumento: TSQLDocumento): Integer;
   function AnnullaDocumento(aDocumento: TSQLDocumento): Integer;
   function ModificaDocumento(aDocumento: TSQLDocumento): Integer;
end;

register services on server and on client

self.Server.ServiceRegister(TServiceDocumento, [TypeInfo(IServiceDocumento)], sicSingle);
self.Client.ServiceRegister([TypeInfo(IServiceDocumento)], sicSingle);

use the service on client side

procedure TSQLDocumento.ComputeFieldsBeforeWrite(aRest: TSQLRest;
  aOccasion: TSQLEvent);
var I: IServiceDocumento;
begin
   inherited;
   if aRest.Services['ServiceDocumento'].Get(I) then
   begin
      case aOccasion of
         seAdd: I.EmettiDocumento(self);
         seUpdate: I.ModificaDocumento(self);
         seDelete: I.AnnullaDocumento(self);
      end;
   end;
end;

error:
TInterfacedObjectFakeClient.FakeCall(IServiceDocumento.EmettiDocumento) failed
errorCode: 400
errorText: SingleExecution Failed (probably due to bad input parameters) for IServiceDocumento.EmettiDocumento

where i mistake?
thanks,
Emanuele

#42 Re: mORMot 1 » mormotUIEdit and tRawUTF8List » 2015-03-31 09:46:08

i would like to assign the checklistbox.items to a TRawUTF8List record property and viceversa implementing this part of MormotUIEdit

aValue := P.GetValue(aRecord,false);
aFieldType := Fields.List[i].SQLFieldType;
case aFieldType of
stfObject: 
   //in case of TRawUTF8List i would retrieve TStrings from aValue and put in TListBox.Items

any suggestion?

#43 Re: mORMot 1 » How to create new entity with linked entity? » 2015-03-30 11:01:28

Hi,
the ORM save the TSQLRecord's ID in database and not the Entity.
it's clear in Documentation.
So you must write
vSession.SystemUser := vUser.ID;

hope it's useful...

#44 Re: mORMot 1 » mormotUIEdit and tRawUTF8List » 2015-01-29 15:15:27

i mean that i would implement the section in the mormotUIEdit (procedure setRecord)

aValue := P.GetValue(aRecord,false);
aFieldType := Fields.List[i].SQLFieldType;
case aFieldType of
stfObject: 
   //in case of TRawUTF8List i would retrieve TStrings from aValue and put in TListBox.Items

can you help me?

#45 mORMot 1 » mormotUIEdit and tRawUTF8List » 2015-01-29 11:37:57

lele9
Replies: 3

hi ab,
i see the TRawUTF8List and i would like to load into TListBox.Items property in a setRecord of mormotUIEdit and viceversa in the save of mormotUIEdit.
how can i do?
thanks

#46 Re: mORMot 1 » Limit the number of client » 2015-01-26 10:19:42

in documentation you can search "14.1. Publishing a service on the server" that explain all.
you can see an example in MainDemo (see AuditTrail logging).

#47 Re: mORMot 1 » Limit the number of client » 2015-01-23 15:30:19

just an idea..
maybe you can check number of active session in a callback procedure?

#48 Re: mORMot 1 » OFF-TOPIC: Merry christmas... » 2014-12-24 08:06:54

Buon Natale e felice anno nuovo a tutti!!!

#49 Re: mORMot 1 » tsqlTable and Dataset » 2014-12-23 07:53:20

hi,
procedures IDArrayFromBits and IDArrayToBits of TSQLTable class can be used to marked/unmarked records?

#50 Re: mORMot 1 » tsqlTable and Dataset » 2014-12-22 07:04:40

ehm, yes, sorry, i mean, from tsqltable or tdataset point of view there are something to mark/unmark records?
i think that tsqltabletogrid bind visually a tsqltable to tdrawgrid, so marking a row in the grid do a mark in the record of tsqltable, is right?how?
thanks.

Board footer

Powered by FluxBB