Created
June 12, 2015 15:58
-
-
Save diegorocha/d72cdec5f6f7f523e463 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TFormPrincipal.Assinar(pArquivoXML, pTagAssinar: String): Boolean; | |
var | |
Fentrada:File; | |
NumRead,i, resultado:integer; | |
buf: char; | |
S: string; | |
Util: OleVariant; | |
XMLString, tagAssinatura, Atributo, XMLAssinado, msgResultado: Widestring; | |
SL: TStringList; | |
begin | |
SL := TStringList.Create; | |
AssignFile(Fentrada,pArquivoXML); | |
Reset(Fentrada,1); | |
S:=''; | |
for i:= 1 to FileSize(Fentrada) do | |
begin | |
Blockread(Fentrada,buf,1,NumRead); | |
S:=S+buf; | |
end; | |
CloseFile(Fentrada); | |
SL.Text := S; | |
XMLString := S; | |
tagAssinatura := pTagAssinar; // indica a tag a ser assinada (RPS), para assinar lote altere para LoteRps | |
Atributo := 'Id'; // indica o aributo que será utilizado como Id | |
msgResultado := ''; | |
// instancia a DLL | |
Util := CreateOleObject('NFSe_Util.util'); | |
// assinar | |
XMLAssinado := Util.Assinar(XMLString,tagAssinatura,Atributo, G_IdDigital, resultado, msgResultado); | |
SL.Text := XMLAssinado; | |
SL.SaveToFile(pArquivoXML); | |
SL.Free; | |
result := (resultado = 5300) | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment