Olá amigos, estou desenvolvendo um módulo de matrículas OnLine no intraweb,
depois de tudo feito, funcionando certinho, passei para os testes finais e
verifiquei que o arquivo pdf gerado no rave (Ficha de Matrícula, Boleto, etc
...) saem com os dados de uma outra pessoa quando este processo de inscrição
é feito simultaneamente, alguém teria uma dica para que isto não
acontece-se? A classe TIWUserSessionBase é única para cada usuário não é?
Veja um exemplo:
//Função que rega o arquivo pdf e retorna o link do mesmo
function TUserSession.ImprimeFichaMatricula(Matricula, Curso, Ano: Integer):
string;
  var Arquivo : string;
      vcdsIMat: TClientDataSet;
      rvProject: TRvProject;
      rvPDF: TRvRenderPDF;
      rvSystem: TRvSystem;
begin
  rvProject := TRvProject.Create(Self);
  rvProject.Name := 'rvFichaMatricula';
  rvPDF := TRvRenderPDF.Create(Self);
  rvSystem := TRvSystem.Create(Self);
  try
    rvProject.Engine := rvSystem;

    rvProject.Close;
    cdsFichaMatricula.Close;
    cdsFichaMatricula.Params[0].Value := Matricula;
    cdsFichaMatricula.Open;

    if cdsFichaMatricula.RecordCount = 1 then
    begin
      Arquivo := 'FichaMatricula' + WebApplication.AppID + '.pdf';

      rvProject.ProjectFile := gsAppPath + 'Files\FichaMatricula.rav';
      rvProject.Open;

      vcdsIMat := TClientDataSet.Create(Self);
      vcdsIMat.Name := 'vcdsIMat';
      try

        vcdsIMat.Data := Consulta('SELECT C.CSI_NOMCUR, P.CSI_DATA,
P.CSI_INSCRICAO '+
                                  'FROM TSI_PREMATRICULA P '+
                                  'INNER JOIN TSI_CADCUR C ON (C.CSI_CODCUR
= P.CSI_CODCUR) '+
                                  'WHERE P.CSI_CODESC = '+vgCodEscola+
                                  'AND P.CSI_ANOLET = '+IntToStr(Ano)+
                                  'AND P.CSI_MATALU = '+IntToStr(Matricula)+
                                  'AND P.CSI_CODCUR = '+IntToStr(Curso));

        with rvProject do
        begin
          SetParam('Curso',vcdsIMat.Fields[0].AsString);
          SetParam('Inscricao',vcdsIMat.Fields[2].AsString);
          SetParam('DataMat',vcdsIMat.Fields[1].AsString);
        end;

        with rvSystem do
        begin
          SystemSetups := [];
          DefaultDest := rdFile;
          DoNativeOutput:= False;
          RenderObject:= rvPDF;
          OutputFileName:= gsAppPath + 'Files\'+ Arquivo;
        end;

        rvProject.Execute;

      finally
        rvProject.Close;
        vcdsIMat.Free;
      end;

      Result :=
'window.open("'+WebApplication.Request.URL+'/files/'+Arquivo+'", "","");';
    end
    else
    begin
      Result := 'window.open("Files/FichaNaoEncontrada.html", "","");';
    end;
  finally
    rvProject.Free;
    rvPDF.Free;
    rvSystem.Free;
  end;
end;


//Procedimento que mostra a ficha
procedure TF0InfPreMatricula.iwlnkFichaMatriculaClick(Sender: TObject);
  var Matricula, Curso: Integer;
begin
  with UserSession do
  begin
    Matricula := StrToInt(Parametros[0]);
    Curso := StrToInt(Parametros[2]);
    AddToInitProc(ImprimeFichaMatricula(Matricula,Curso,vgAnoLetivo));
  end;
end;

Aparentemente, pelos testes que fiz, parece que as informações ficam
armazenadas no servidor, quando outro usuário chama o mesmo procedimento ele
apenas cria outro arquivo com as mesmas informações obtidas antes, estranho
é que eu crio e destruo os componentes em tempo de execução e mesmo assim o
problema persiste.

Qualquer ajuda é bem vinda! Desde já agradeço.

Fábio Thomaz.


[As partes desta mensagem que não continham texto foram removidas]

Responder a