Accents characters in script


(Roberto) #1

Hello.

I have two problems using RelativityServer.

1 - In this script, I’m using accents in messages but in client (Delphi) accents
are not shown.

 function beforeProcessDeltaChange(delta, change, wasRefreshed, canRemove)
 {
 	if (change.isDelete) {
 	    service = "SERVICO= " + change.oldValues['id_servico'] + "-"+change.oldValues['servico'];
 	    if (change.oldValues['id_servico'] == 1)
 	     {
 	        service = "SERVICO=" + change.oldValues['servico'];	
 	        msg = "Violação de regras no servidor: #SERVICO: Não pode ser excluido!"
 	        .replace("#SERVICO", service);
 	 	    fail(msg);}
 	}
 }

image

2 - How do I handle server errors? I would like to show
messages to the user according to the error.


(EvgenyK) #2

1 - In this script, I’m using accents in messages but in client (Delphi) accents are not shown.

Relativity writes messages in delta changes as AnsiString.
Logged as 79944.
as a temporary workaround - you can write meg in server events in UTF8 format.

2 - How do I handle server errors? I would like to show messages to the user according to the error.

Are you using TDAVCLReconcileProvider/TDAFMXReconcileProvider on client side?


(Roberto) #3

Example ??

TDAVCLReconcileProvider


(EvgenyK) #4

try to specify this error like

Violação de regras no servidor: #SERVICO: Não pode ser excluido!

try to set RemoteDataAdapter.FailureBehavior to fbShowReconcile . in this case, error message won’t be shown


(Roberto) #5

Could you send me an example of how can I set up a “Form Reconcile” according to
with my needs, I looked in the examples folder of DA and I did not find anything on the subject.

I Need:
Translate from English to Portuguese,
in some cases I will not show anything, just configure
what to do according to error.

In short, I need to make my own reconcile form.


(EvgenyK) #6

create own descendant of TDABaseReconcileProvider, where implement Show method

  TMyReconcileProvider = class(TDABaseReconcileProvider)
  public
    procedure Show(RemoteDataAdapter: TDABaseDataAdapter; var AFailedDeltaList: TDADeltaChangeList; aTableList: TDADataTableList); override;
  end;

you can use uDAReconcileDialog.pas and uDAReconcileDialogDetails.pas as examples of it.

by other hand, you can show error w/o ReconcileProvider.
RDA has some events where you can change default behavior of it.


(Roberto) #7

This is what I need, showing the error to
custom mode user …

Send me an example of how I catch the server error and
I do the customization.


(EvgenyK) #8

you can use OnBeforeProcessFailures event.

just grab Message field from aFailedDeltas[x] in loop

procedure TForm83.DARemoteDataAdapter1BeforeProcessFailures(Sender: TObject;
  TDADataTableList; aFailedDeltas: TDADeltaChangeList;
  var aFailureBehavior: TDAFailureBehavior);
begin
  raise MyException.Create('');
end;

see more details how things work at TDABaseDataAdapter.ThrowFailures


(Roberto) #9

I looked in the documentation I did not see anything about it …
have you ot demos ? or can you send me an example of how
to handle this event?


(EvgenyK) #10

try to use

procedure TForm83.DARemoteDataAdapter1BeforeProcessFailures(Sender: TObject;
  TDADataTableList; aFailedDeltas: TDADeltaChangeList;
  var aFailureBehavior: TDAFailureBehavior);
var
  mes: String;
  i:integer;
begin
  mes := '';
  for i := 0 to aFailedDeltas.Count-1 do
    mes := mes+ aFailedDeltas[i].Message+sLineBreak;
  raise Exception.Create('Failures:'+sLineBreak+mes);
end;

(Roberto) #11

Thanks for the help … waiting for the correction of the relativity server (UTF8)

I have another question, but I’ll create another topic.