CACIC_VerifyAndGetModules.pas
4.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
unit CACIC_VerifyAndGetModules;
interface
uses CACIC_Library,
CACIC_Comm,
SysUtils,
Forms,
Windows;
function verifyAndGetModules(pStrFileName,
pStrFileHash,
pStrTargetFolderName,
pStrLocalFolderName : String;
pObjCacicVGM : TCACIC;
pStrIniFileName : String = '') : String;
implementation
function verifyAndGetModules(pStrFileName,
pStrFileHash,
pStrTargetFolderName,
pStrLocalFolderName : String;
pObjCacicVGM : TCACIC;
pStrIniFileName : String = '') : String;
var strTargetFolderName : String;
Begin
Result := 'Oops! "' + pStrTargetFolderName + '\' + pStrFileName + '" Já Existe!';
Try
strTargetFolderName := pStrTargetFolderName;
pObjCacicVGM.writeDebugLog('verifyAndGetModules: pStrFileName -> "'+pStrFileName+'"');
pObjCacicVGM.writeDebugLog('verifyAndGetModules: pStrFileHash -> "'+pStrFileHash+'"');
pObjCacicVGM.writeDebugLog('verifyAndGetModules: oCacicVGM.getFileHash-> "'+pObjCacicVGM.getFileHash(pStrTargetFolderName + '\' + pStrFileName)+'"');
pObjCacicVGM.writeDebugLog('verifyAndGetModules: pStrTargetFolderName -> "'+strTargetFolderName+'"');
If (pObjCacicVGM.getFileHash(pStrTargetFolderName + '\' + pStrFileName) <> pStrFileHash) then
Begin
pObjCacicVGM.deleteFileOrFolder(strTargetFolderName + '\' + pStrFileName);
sleep(1000);
If FileExists(strTargetFolderName + '\' + pStrFileName) Then
strTargetFolderName := pStrLocalFolderName + 'Temp';
Result := FTPdown( pObjCacicVGM.getValueFromFile('Configs', 'TeServUpdates' , pStrIniFileName),
pObjCacicVGM.deCrypt(pObjCacicVGM.getValueFromFile('Configs', 'NmUsuarioLoginServUpdates', pStrIniFileName),false,true),
pObjCacicVGM.deCrypt(pObjCacicVGM.getValueFromFile('Configs', 'TeSenhaLoginServUpdates' , pStrIniFileName),false,true),
pObjCacicVGM.getValueFromFile('Configs', 'TePathServUpdates' , pStrIniFileName),
pStrFileName,
strTargetFolderName,
pStrFileName,
'BIN',
pStrLocalFolderName,
strToInt(pObjCacicVGM.deCrypt(pObjCacicVGM.getValueFromFile('Configs', 'NuPortaServUpdates', pStrIniFileName))));
if not FileExists(strTargetFolderName + '\' + pStrFileName) Then
Begin
pObjCacicVGM.writeDebugLog('verifyAndGetModules: Problemas Efetuando Download de '+ strTargetFolderName + '\' + pStrFileName+' (FTP)');
pObjCacicVGM.writeDebugLog('verifyAndGetModules: Conexão:');
pObjCacicVGM.writeDebugLog('verifyAndGetModules: TeServUpdates => ' + pObjCacicVGM.getValueFromFile('Configs', 'TeServUpdates' , pStrIniFileName) );
pObjCacicVGM.writeDebugLog('verifyAndGetModules: NmUsuarioLoginServUpdates => ' + pObjCacicVGM.deCrypt(pObjCacicVGM.getValueFromFile('Configs', 'NmUsuarioLoginServUpdates' , pStrIniFileName),false,true));
pObjCacicVGM.writeDebugLog('verifyAndGetModules: TeSenhaLoginServUpdates => ' + pObjCacicVGM.deCrypt(pObjCacicVGM.getValueFromFile('Configs', 'TeSenhaLoginServUpdates' , pStrIniFileName),false,true));
pObjCacicVGM.writeDebugLog('verifyAndGetModules: TePathServUpdates => ' + pObjCacicVGM.getValueFromFile('Configs', 'TePathServUpdates' , pStrIniFileName) );
pObjCacicVGM.writeDebugLog('verifyAndGetModules: NuPortaServUpdates => ' + pObjCacicVGM.getValueFromFile('Configs', 'NuPortaServUpdates' , pStrIniFileName) );
End
else
pObjCacicVGM.setValueToFile('Hash-Codes',pStrFileName , pObjCacicVGM.enCrypt(pObjCacicVGM.getFileHash(strTargetFolderName + '\' + pStrFileName),false,true), pStrIniFileName);
End;
Finally
pObjCacicVGM.writeDebugLog('verifyAndGetModules: Liberando objeto oCacicVGM');
End;
End;
end.