Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #11  
Antiguo 24-04-2023
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.757
Poder: 21
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Yo creo el fichero ToSign.xml, que es la factura a firmar.
Luego creo el bat como te muestro en el mensaje anterior con todo rellenado.
Este bat ejecuta AutorimaCommandLine.exe redirigido a un fichero llamado sign_result.txt.
Código:
"C:\...\AutoFirma\AutoFirmaCommandLine.exe" -i "C:\...\ToSign.xml" -o "C:\...\ToSign.xsig" -store windows -filter "subject.contains: EMPRESA SL" -format facturae > "C:\...\sign_result.txt"
Ejecuto el bat con un procedimiento que espera a que termine para evitar leer antes de tiempo:
Código Delphi [-]
function RunAndWait(Handle: THandle; Ejecutable, Argumentos: string; const RunDirectory: PChar = nil; const Visibilidad: integer = SW_SHOWNORMAL; MensajeSiCorrecto: boolean = True): DWORD;
var
  Info : TShellExecuteInfo;
  pInfo : PShellExecuteInfo;
  ExitCode : word;
  P : PChar;
begin
  { Puntero a Info }
  { Pointer to Info }
  pInfo := @Info;
  { Rellenamos Info }
  { Fill info }
  with Info do
  begin
     cbSize := SizeOf(Info);
     fMask := SEE_MASK_NOCLOSEPROCESS;
     wnd := Handle;
     lpVerb := nil;
     lpFile := PChar(Ejecutable);
     { Parametros al ejecutable }
     { Executable parameters }
     lpParameters := PChar(Argumentos + #0);
     if RunDirectory = '' then
        lpDirectory := nil
     else
        lpDirectory := PChar(RunDirectory + #0);
     nShow := Visibilidad;
     hInstApp := 0;
  end;
  { Ejecutamos }
  { Execute }
  if not ShellExecuteEx(pInfo) then
  begin
     Result := GetLastError;
     if FormatMessage(Format_Message_Allocate_Buffer + Format_Message_From_System,
        nil,
        Result,
        0, @P,
        0,
        nil) <> 0 then
     begin
        // Display the string.
        ShowMessage(P);
        // Free the buffer.
        LocalFree(integer(P));
     end;
  end
  else
     Result := 0; // Info.hInstApp;

  { Esperamos que termine }
  { Wait to finish }
  repeat
     ExitCode := WaitForSingleObject(Info.hProcess, 500);
     Application.ProcessMessages;
  until (ExitCode <> WAIT_TIMEOUT);
  ExitCode := GetLastError;

  GetExitCodeProcess(Info.hProcess, Result);
  if ((Result < 32) and (ExitCode = 0)) then
  begin
     ExitCode := GetLastError;
     if FormatMessage(Format_Message_Allocate_Buffer + Format_Message_From_System,
        nil,
        ExitCode,
        0, @P,
        0,
        nil) <> 0 then
     begin
        // Display the string.
        if MensajeSiCorrecto or (ExitCode <> 0) then
           ShowMessage(P);
        // Free the buffer.
        LocalFree(integer(P));
     end;
  end
  else
     Result := 0; // Info.hInstApp;
end;

Finalmente miro si el fichero sign_result.txt tiene el texto "La operacion ha terminado corectamente"
Código Delphi [-]
if ((SysUtils.FileExists(DameTempPath + 'sign_result.txt')) and (Pos('ha terminado correctamente', MemoRead(DameTempPath + 'sign_result.txt')) > 0)) then

Si es así guardo el fichero ToSign.xsig con un nombre acorde (Pro ejemplo: Factura_A-123.xsig) en la carpera de ficheros firmados para seguir con el resto de procesos.
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Facturas Electronicas Argentina Chaja Varios 3 10-07-2015 19:15:05
Agregar Adendas a Facturas electronicas mexico reypcs Varios 0 20-01-2011 16:26:10
Tabla de Facturas vs Detalles de Facturas magnu9 Conexión con bases de datos 9 27-07-2007 17:27:37
Comunicaciones electronicas EDI Toni Conexión con bases de datos 0 18-04-2006 13:06:34
Campos calculados, facturas y detalles de facturas. Letty Conexión con bases de datos 7 07-11-2003 11:19:44


La franja horaria es GMT +2. Ahora son las 19:17:17.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi