///*******************************************************************************************
sPassword is string
sMiCertificado is string
sMiLlave is string
sMiArchivo1 is string
sMiArchivo2 is string
sMiXMLSellado is string
nOpcion is int = 0
nResultado is int
sP2buf is string = Charact(0)
sPbuf is string = Charact(0)
hInst is system int
nLongitud is int = 4096
nL2ongitud is int = 20
HReadSeekFirst(DB_Sat,Consecutivo,1,hGeneric)
IF HFound(DB_Sat) = True THEN
sPassword = DB_Sat.Contraseña
fSaveBuffer(fTempDir() + DB_Sat.CertificadoNombre + ".cer", DB_Sat.Certificado)
fSaveBuffer(fTempDir() + DB_Sat.LlaveNombre + ".key", DB_Sat.Llave)
sMiCertificado = fTempDir() + DB_Sat.CertificadoNombre + ".cer"
sMiLlave = fTempDir() + DB_Sat.LlaveNombre + ".key"
END
HReadSeekFirst(DB_Cfdi,IdDB_Cfdi,gsIdDB_Cfdi,hGeneric)
IF HFound(DB_Cfdi) = True THEN
fSaveBuffer(fTempDir() + "\" + DB_Cfdi.IdDB_Cfdi + ".xml", DB_Cfdi.Contenido)
sMiArchivo1 = fTempDir() + "\" + DB_Cfdi.IdDB_Cfdi + ".xml"
sMiArchivo2 = fTempDir() + "\" + "Se" + DB_Cfdi.IdDB_Cfdi + ".xml"
END
hInst = LoadDLL("diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll para colocar sello en el XML")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_ValidateXml", sMiArchivo1, nOpcion)
IF nResultado <> 0 THEN
Info("ERROR", "SAT_ValidateXML regresa el valor: " + nResultado + " fallidamente")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_SignXml", sMiArchivo2, sMiArchivo1, sMiLlave,sPassword,sMiCertificado,nOpcion)
IF nResultado <> 0 THEN
Info("ERROR AL SELLAR EL XML","RESULTADO :" + nResultado)
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_VerifySignature", sMiArchivo2, sP2buf,nOpcion)
IF nResultado <> 0 THEN
Info("Verificación Fallida de Firma" + sMiArchivo2, "returns: " + nResultado)
ELSE
sMiXMLSellado = fLoadBuffer(sMiArchivo2)
END
END
END
FreeDLL(hInst)
END
RESULT sMiXMLSellado
viernes, 27 de mayo de 2022
FirmaSat Sellado
Sellar con FirmaSAT
sMiArchivo1 is string = EDT_XMLFile
sMiArchivo2 is string = fExtractPath(sMiArchivo1, fDrive + fDirectory) + "miXMLSellado.xml"
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sP2buf is string = Charact(0)
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
nL2ongitud is int = 20
hInst = LoadDLL("diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll para colocar sello en el XML")
ELSE
//Info(Left(sPbuf,20))
nResultado = CallDLL32("diFirmaSAT2", "SAT_ValidateXml", sMiArchivo1, nOpcion)
IF nResultado <> 0 THEN
Info("ERROR", "SAT_ValidateXML regresa el valor: " + nResultado + " fallidamente")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_SignXml", sMiArchivo2, sMiArchivo1, EDT_Llave,EDT_password,EDT_Certificado,nOpcion)
IF nResultado <> 0 THEN
Info("ERROR AL SELLAR EL XML","RESULTADO :" + nResultado)
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_VerifySignature", sMiArchivo2, sP2buf,nOpcion)
IF nResultado <> 0 THEN
Info("Verificación Fallida de Firma" + sMiArchivo2, "returns: " + nResultado)
ELSE
Info("Verificación correcta de Firma" + sMiArchivo2, "returns: " + nResultado)
nResultado = CallDLL32("diFirmaSAT2", "SAT_FixBOM", sMiArchivo2, sMiArchivo2,nOpcion)
END
END
END
FreeDLL(hInst)
END
FirmSAT (funciones)
//OBTENER RFC
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
sConsulta is string = "rfc"
sNombreCertificado is string = EDT_Certificado
IF fFileExist(sNombreCertificado ) = False THEN
Error("Error al verificar existencia del certificado")
ReturnToCapture(EDT_Certificado)
END
//hInst = LoadDLL("diFirmaSAT2.DLL")
hInst = LoadDLL(fDataDir() + ["\"] + "diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud , sNombreCertificado, sConsulta,nOpcion)
IF nResultado < 0 THEN
Info("ERROR", "SAT_QueryCert regresa el valor: " + nResultado + " fallidamente")
ELSE
//nLongitud = Length(sPbuf)
nLongitud = nResultado
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud, sNombreCertificado, sConsulta, nOpcion)
IF nResultado < 0 THEN
Info("ERROR AL EXTRAER EL NOMBRE DEL RFC","RESULTADO :" + nResultado)
ELSE
Info(nLongitud, sPbuf)
END
END
FreeDLL(hInst)
END
///COMPAÑIA
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
sConsulta is string = "companyName"
sNombreCertificado is string = EDT_Certificado
IF fFileExist(sNombreCertificado ) = False THEN
Error("Error al verificar existencia del certificado")
ReturnToCapture(EDT_Certificado)
END
//hInst = LoadDLL("diFirmaSAT2.DLL")
hInst = LoadDLL(fDataDir() + ["\"] + "diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud , sNombreCertificado, sConsulta,nOpcion)
IF nResultado < 0 THEN
Info("ERROR", "SAT_QueryCert regresa el valor: " + nResultado + " fallidamente")
ELSE
//nLongitud = Length(sPbuf)
nLongitud = nResultado
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud, sNombreCertificado, sConsulta, nOpcion)
IF nResultado < 0 THEN
Info("ERROR AL EXTRAER EL NOMBRE DEL RFC","RESULTADO :" + nResultado)
ELSE
Info(nLongitud, sPbuf)
END
END
FreeDLL(hInst)
END
/// VIGENTE DESDE
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
sConsulta is string = "notBefore"
sNombreCertificado is string = EDT_Certificado
IF fFileExist(sNombreCertificado ) = False THEN
Error("Error al verificar existencia del certificado")
ReturnToCapture(EDT_Certificado)
END
//hInst = LoadDLL("diFirmaSAT2.DLL")
hInst = LoadDLL(fDataDir() + ["\"] + "diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud , sNombreCertificado, sConsulta,nOpcion)
IF nResultado < 0 THEN
Info("ERROR", "SAT_QueryCert regresa el valor: " + nResultado + " fallidamente")
ELSE
//nLongitud = Length(sPbuf)
nLongitud = nResultado
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud, sNombreCertificado, sConsulta, nOpcion)
IF nResultado < 0 THEN
Info("ERROR AL EXTRAER EL NOMBRE DEL RFC","RESULTADO :" + nResultado)
ELSE
Info(nLongitud, sPbuf)
END
END
FreeDLL(hInst)
END
/// VIGENCIA TERMINA
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
sConsulta is string = "notAfter"
sNombreCertificado is string = EDT_Certificado
IF fFileExist(sNombreCertificado ) = False THEN
Error("Error al verificar existencia del certificado")
ReturnToCapture(EDT_Certificado)
END
//hInst = LoadDLL("diFirmaSAT2.DLL")
hInst = LoadDLL(fDataDir() + ["\"] + "diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud , sNombreCertificado, sConsulta,nOpcion)
IF nResultado < 0 THEN
Info("ERROR", "SAT_QueryCert regresa el valor: " + nResultado + " fallidamente")
ELSE
//nLongitud = Length(sPbuf)
nLongitud = nResultado
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud, sNombreCertificado, sConsulta, nOpcion)
IF nResultado < 0 THEN
Info("ERROR AL EXTRAER EL NOMBRE DEL RFC","RESULTADO :" + nResultado)
ELSE
Info(nLongitud, sPbuf)
END
END
FreeDLL(hInst)
END
//NUMERO DE SERIE
///*******************************************************************************************
nOpcion is int = 0
nResultado is int
sPbuf is string = Charact(0)
hInst is int
nLongitud is int = 4096
sConsulta is string = "serialNumber"
sNombreCertificado is string = EDT_Certificado
IF fFileExist(sNombreCertificado ) = False THEN
Error("Error al verificar existencia del certificado")
ReturnToCapture(EDT_Certificado)
END
//hInst = LoadDLL("diFirmaSAT2.DLL")
hInst = LoadDLL(fDataDir() + ["\"] + "diFirmaSAT2.DLL")
IF hInst = 0 THEN
Error("Error al cargar dll")
ELSE
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud , sNombreCertificado, sConsulta,nOpcion)
IF nResultado < 0 THEN
Info("ERROR", "SAT_QueryCert regresa el valor: " + nResultado + " fallidamente")
ELSE
//nLongitud = Length(sPbuf)
nLongitud = nResultado
nResultado = CallDLL32("diFirmaSAT2", "SAT_QueryCert", sPbuf, nLongitud, sNombreCertificado, sConsulta, nOpcion)
IF nResultado < 0 THEN
Info("ERROR AL EXTRAER EL NOMBRE DEL RFC","RESULTADO :" + nResultado)
ELSE
Info(nLongitud, sPbuf)
END
END
FreeDLL(hInst)
END
XML
XML es UTF8, Basándonos en este discurso, generamos el XML y lo lanzamos en una cadena En este momento hice otra variable variavel_xml es b...
-
Una guía paso a paso para los perplejos: Presione la tecla de Windows Escribe " intl.cpl " y presiona Enter....
-
MyWorksheet is xlsDocument xlsAddWorksheet(MyWorksheet, "R04_C-0451") //MyWorksheet = xlsOpen(sNombreArchivoXLS, xlsWrite) ...
-
Copiado del blog de mi amigo Francisco Carabez En caso de que no se cuenta con la contraseña del HFSQL Control Center: Respalda o copia e...