Commit 98900483c9b7ca5f35112912f8b3e31e9b7560a3

Authored by anderson.peterle@previdencia.gov.br
1 parent 6b9b0bbe
Exists in master

Contem identificacao dinamica do S.O. da estacao; Correcao de coleta de sistemas…

… monitorados; Inclusao em Informacoes Gerais da sessao Coletas Realizadas nesta Data

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@142 fecfc0c7-e812-0410-ae72-849f08638ee7
ChangeLog.txt
No preview for this file type
cacic2.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=9
  118 +Build=26
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,16 +124,16 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev - Escritório do ES
  127 +CompanyName=Dataprev - Unidade Regional Espírito Santo
128 128 FileDescription=Configurador Automático e Coletor de Informações Computacionais
129   -FileVersion=2.2.0.9
  129 +FileVersion=2.2.0.26
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.0.0
136   -Comments=
  134 +ProductName=Cacic - Agente Principal
  135 +ProductVersion=2.2.0.26
  136 +Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlUnitAliases]
138 138 Count=1
139 139 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
... ...
cacic2.res
No preview for this file type
chkcacic/chkcacic.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=17
  118 +Build=24
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,16 +124,16 @@ DLL=0
124 124 Locale=2070
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
128   -FileDescription=
129   -FileVersion=2.2.0.17
  127 +CompanyName=Dataprev - Unidade Regional Espírito Santo (URES)
  128 +FileDescription=Módulo Verificador/Instalador dos Agentes Principais para o Sistema CACIC
  129 +FileVersion=2.2.0.24
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=1.0.0.0
136   -Comments=Verificador/Instalador dos Agentes Principais para o Sistema CACIC
  134 +ProductName=ChkCACIC
  135 +ProductVersion=2.2.0.24
  136 +Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlUnitAliases]
138 138 Count=1
139 139 Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
... ...
chkcacic/chkcacic.res
No preview for this file type
chkcacic/main.dcu
No preview for this file type
chkcacic/main.pas
... ... @@ -17,6 +17,18 @@ Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 17 =====================================================================================================
18 18 ChkCacic.exe : Verificador/Instalador dos agentes principais Cacic2.exe e Ger_Cols.exe
19 19 =====================================================================================================
  20 +
  21 +v 2.2.0.17
  22 ++ Acrescentado o tratamento da passagem de opções em linha de comando
  23 + * chkcacic /serv=<ip_server> /dir=<local_path>c:\%windir%\cacic
  24 + Exemplo de uso: chkcacic /serv=UXbra001 /dir=Cacic
  25 +
  26 +v 2.2.0.16
  27 +* Corrigido o fechamento do arquivo de configurações de ChkSis
  28 +
  29 +v 2.2.0.15
  30 +* Substituída a mensagem "File System diferente de "NTFS" por 'File System: "<NomeFileSystem>" - Ok!'
  31 +
20 32 v 2.2.0.14
21 33 + Críticas/mensagens:
22 34 "ATENÇÃO! Não foi possível estabelecer comunicação com o módulo Gerente WEB em <servidor>." e
... ... @@ -49,7 +61,6 @@ uses Windows,
49 61 XML,
50 62 LibXmlParser,
51 63 IdHTTP,
52   - dialogs,
53 64 PJVersionInfo,
54 65 Controls,
55 66 StdCtrls,
... ... @@ -62,7 +73,8 @@ uses Windows,
62 73 DCPrijndael,
63 74 DCPbase64,
64 75 NTFileSecurity, IdFTP,
65   - Tlhelp32;
  76 + Tlhelp32,
  77 + dialogs;
66 78  
67 79 var v_ip_serv_cacic,
68 80 v_cacic_dir,
... ... @@ -72,14 +84,20 @@ var v_ip_serv_cacic,
72 84 v_te_instala_informacoes_extras,
73 85 v_exibe_informacoes,
74 86 v_versao_local,
75   - v_versao_remota_inteira,
76   - v_versao_remota_capada,
  87 + v_versao_remota,
77 88 v_CipherKey,
78 89 v_SeparatorKey,
79 90 v_IV,
80 91 v_strCipherClosed,
81 92 v_strCipherOpened,
82   - v_DatFileName : String;
  93 + v_DatFileName,
  94 + v_retorno,
  95 + v_versao_REM,
  96 + v_versao_LOC,
  97 + v_te_so : String;
  98 +
  99 + intWinVer : integer;
  100 + v_Debugs : boolean;
83 101  
84 102 var v_tstrCipherOpened : TStrings;
85 103  
... ... @@ -99,23 +117,29 @@ Procedure MostraFormConfigura;
99 117 Procedure GravaConfiguracoes;
100 118 Procedure DelValorReg(Chave: String);
101 119 procedure log_diario(strMsg : String);
  120 +procedure log_DEBUG(p_msg:string);
  121 +procedure KillProcess(hWindowHandle: HWND); // 2.2.0.15
  122 +procedure Matar(v_dir,v_files: string); // 2.2.0.16
  123 +procedure GravaIni(strFullPath : STring);
102 124 Function ListFileDir(Path: string):string;
103 125 Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
104 126 Function Explode(Texto, Separador : String) : TStrings;
105 127 Function GetRootKey(strRootKey: String): HKEY;
106 128 Function SetValorChaveRegEdit(Chave: String; Dado: Variant): Variant;
107 129 Function GetValorChaveRegEdit(Chave: String): Variant;
108   -function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String;
109   -function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
110   -function HomeDrive : string;
  130 +Function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String;
  131 +Function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String;
  132 +Function HomeDrive : string;
111 133 Function RemoveCaracteresEspeciais(Texto : String) : String;
112   -function FindWindowByTitle(WindowTitle: string): Hwnd;
113   -function GetVersionInfo(p_File: string):string;
114   -function VerFmt(const MS, LS: DWORD): string;
115   -function GetWinVer: Integer;
116   -function KillTask(ExeFileName: string): Integer;
117   -procedure KillProcess(hWindowHandle: HWND);
118   -
  134 +Function FindWindowByTitle(WindowTitle: string): Hwnd;
  135 +Function GetVersionInfo(p_File: string):string;
  136 +Function VerFmt(const MS, LS: DWORD): string;
  137 +Function GetWinVer: Integer;
  138 +Function KillTask(ExeFileName: string): Integer;
  139 +Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16
  140 +function Posso_Rodar_CACIC : boolean;
  141 +function GetFolderDate(Folder: string): TDateTime;
  142 +function abstraiCSD(p_te_so : String) : integer;
119 143 type
120 144 TForm1 = class(TForm)
121 145 PJVersionInfo1: TPJVersionInfo;
... ... @@ -134,6 +158,7 @@ implementation
134 158 uses FormConfig;
135 159  
136 160 {$R *.dfm}
  161 +
137 162 function IsAdmin: Boolean;
138 163 var hAccessToken: THandle;
139 164 ptgGroups: PTokenGroups;
... ... @@ -201,6 +226,15 @@ begin
201 226 end;
202 227 end;
203 228  
  229 +procedure log_DEBUG(p_msg:string);
  230 +Begin
  231 + if v_Debugs then
  232 + Begin
  233 + ShowMessage('DEBUG - '+p_msg);
  234 + log_diario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg);
  235 + End;
  236 +End;
  237 +
204 238 // Pad a string with zeros so that it is a multiple of size
205 239 function PadWithZeros(const str : string; size : integer) : string;
206 240 var
... ... @@ -350,7 +384,7 @@ begin
350 384 if (trim(v_strCipherOpened)<>'') then
351 385 Result := explode(v_strCipherOpened,v_SeparatorKey)
352 386 else
353   - Result := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(GetWinVer)+v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
  387 + Result := explode('Configs.ID_SO'+v_SeparatorKey+inttostr(intWinVer)+v_SeparatorKey+'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);
354 388  
355 389  
356 390 if Result.Count mod 2 <> 0 then
... ... @@ -360,7 +394,7 @@ end;
360 394  
361 395 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String);
362 396 begin
363   - log_diario('Setando Chave "'+p_Chave+'" com "'+p_Valor+'"');
  397 + log_DEBUG('Setando Chave "'+p_Chave+'" com "'+p_Valor+'"');
364 398 // Exemplo: p_Chave => Configs.nu_ip_servidor : p_Valor => 10.71.0.120
365 399 if (v_tstrCipherOpened.IndexOf(p_Chave)<>-1) then
366 400 v_tstrCipherOpened[v_tstrCipherOpened.IndexOf(p_Chave)+1] := p_Valor
... ... @@ -402,15 +436,21 @@ const
402 436 cOsServer2003 = 13;
403 437 var
404 438 osVerInfo: TOSVersionInfo;
405   - majorVer, minorVer: Integer;
  439 + platformID,
  440 + majorVer,
  441 + minorVer: Integer;
  442 + CSDVersion : String;
406 443 begin
407 444 Result := cOsUnknown;
408 445 { set operating system type flag }
409 446 osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
410 447 if GetVersionEx(osVerInfo) then
411 448 begin
412   - majorVer := osVerInfo.dwMajorVersion;
413   - minorVer := osVerInfo.dwMinorVersion;
  449 + platformId := osVerInfo.dwPlatformId;
  450 + majorVer := osVerInfo.dwMajorVersion;
  451 + minorVer := osVerInfo.dwMinorVersion;
  452 + CSDVersion := trim(osVerInfo.szCSDVersion);
  453 +
414 454 case osVerInfo.dwPlatformId of
415 455 VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
416 456 begin
... ... @@ -447,9 +487,25 @@ begin
447 487 end
448 488 else
449 489 Result := cOsUnknown;
450   -end;
451 490  
  491 + // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
  492 + v_te_so := IntToStr(platformId) + '.' +
  493 + IntToStr(majorVer) + '.' +
  494 + IntToStr(minorVer) +
  495 + IfThen(CSDVersion='','','.'+CSDVersion);
  496 + if (Result = 0) then
  497 + Result := abstraiCSD(v_te_so);
452 498  
  499 + log_DEBUG('GetWinVer => ID_interna: '+ v_te_so + ' ID_Externa: ' + IntToStr(Result));
  500 +end;
  501 +
  502 +function abstraiCSD(p_te_so : String) : integer;
  503 + var tstrTe_so : tstrings;
  504 + Begin
  505 + tstrTe_so := Explode(p_te_so, '.');
  506 + Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
  507 + log_DEBUG('abstraiCSD=> '+ tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
  508 + End;
453 509  
454 510 function GetVersionInfo(p_File: string):string;
455 511 begin
... ... @@ -511,6 +567,7 @@ begin
511 567 end;
512 568 ListaAuxSet.Free;
513 569 RegEditSet.Free;
  570 + log_DEBUG('Setando valor "'+Dado+'" para chave "'+Chave+'"');
514 571 end;
515 572  
516 573 Function RemoveCaracteresEspeciais(Texto : String) : String;
... ... @@ -648,7 +705,7 @@ end;
648 705 Procedure CriaFormConfigura;
649 706 begin
650 707 Application.CreateForm(TConfigs, FormConfig.Configs);
651   - FormConfig.Configs.Label2.Caption := 'v: ' + getVersionInfo(ParamStr(0));
  708 + FormConfig.Configs.lbVersao.Caption := 'v: ' + getVersionInfo(ParamStr(0));
652 709 end;
653 710  
654 711 Procedure MostraFormConfigura;
... ... @@ -685,32 +742,54 @@ Begin
685 742 Explode := ListaAuxUTILS;
686 743 end;
687 744  
688   -
689 745 Function FTP(p_Host : String; p_Port : String; p_Username : String; p_Password : String; p_PathServer : String; p_File : String; p_Dest : String) : Boolean;
690 746 var IdFTP : TIdFTP;
691 747 begin
692 748 Try
693   - IdFTP := TIdFTP.Create(IdFTP);
  749 + Log_Debug('FTP: Criando instance');
  750 + IdFTP := TIdFTP.Create(nil);
  751 +
  752 + Log_Debug('FTP: Host => "'+p_Host+'"');
694 753 IdFTP.Host := p_Host;
  754 +
  755 + Log_Debug('FTP: UserName => "'+p_Username+'"');
695 756 IdFTP.Username := p_Username;
  757 +
  758 + Log_Debug('FTP: PassWord => "'+p_Password+'"');
696 759 IdFTP.Password := p_Password;
  760 +
  761 + Log_Debug('FTP: PathServer => "'+p_PathServer+'"');
697 762 IdFTP.Port := strtoint(p_Port);
  763 +
  764 + Log_Debug('FTP: Setando TransferType para "ftBinary"');
698 765 IdFTP.TransferType := ftBinary;
  766 +
  767 + Log_Debug('FTP: Change to "'+p_PathServer+'"');
699 768 Try
700 769 if IdFTP.Connected = true then
701 770 begin
  771 + Log_Debug('FTP: Connected => Desconectando...');
702 772 IdFTP.Disconnect;
703 773 end;
  774 + Log_Debug('FTP: Efetuando Conexão...');
704 775 IdFTP.Connect(true);
  776 + Log_Debug('FTP: Change to "'+p_PathServer+'"');
705 777 IdFTP.ChangeDir(p_PathServer);
706 778 Try
  779 + Log_Debug('Iniciando FTP de "'+p_Dest + '\' + p_File+'"');
707 780 IdFTP.Get(p_File, p_Dest + '\' + p_File, True);
708 781 result := true;
709 782 Except
710   - result := false;
  783 + Begin
  784 + Log_Debug('Oops! Problemas Após Início de Operação...');
  785 + result := false;
  786 + end;
711 787 End;
712 788 Except
  789 + Begin
  790 + Log_Debug('Oops! Problemas Sem Início de Operação...');
713 791 result := false;
  792 + End;
714 793 end;
715 794 Except
716 795 result := false;
... ... @@ -831,6 +910,23 @@ begin
831 910 end;
832 911 end;
833 912  
  913 +procedure GravaIni(strFullPath : STring);
  914 +var iniFile : TextFile;
  915 +begin
  916 + try
  917 + FileSetAttr (strFullPath,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  918 + AssignFile(iniFile,strFullPath); {Associa o arquivo a uma variável do tipo TextFile}
  919 + Rewrite (iniFile); // Recria o arquivo...
  920 + Append(iniFile);
  921 + Writeln(iniFile,'');
  922 + Writeln(iniFile,'[Cacic2]');
  923 + Writeln(iniFile,'ip_serv_cacic='+v_ip_serv_cacic);
  924 + Writeln(iniFile,'cacic_dir='+v_cacic_dir);
  925 + CloseFile(iniFile); {Fecha o arquivo texto}
  926 + except
  927 + end;
  928 +end;
  929 +
834 930 Function ListFileDir(Path: string):string;
835 931 var
836 932 SR: TSearchRec;
... ... @@ -851,19 +947,20 @@ begin
851 947 end;
852 948 procedure LiberaFireWall(p_objeto:string);
853 949 begin
  950 + log_DEBUG('Rotina para Liberação de FireWall...');
854 951 Try
855 952 if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll])))='') then
856 953 Begin
857 954 SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List\'+StringReplace(p_objeto+'.exe','\','?\',[rfReplaceAll]),p_objeto+'.exe:*:Enabled:'+p_objeto);
858   - log_diario('Liberação de FireWall para "'+p_objeto+'" efetivada!');
859 955 End
860   - else log_diario('Liberação de FireWall para "'+p_objeto+'" já existente.');
  956 + else log_DEBUG('Exceção para "'+p_objeto+'" já existente.');
861 957 Except
862   - log_diario('Problema Liberando FireWall para "'+p_objeto+'"!');
  958 + log_DEBUG('Problema adicionando "'+p_objeto+'" à lista de exceções do FireWall!');
863 959 End;
864 960  
865 961 end;
866 962  
  963 +{
867 964 // Dica obtida em http://www.webmundi.com/delphi/dfuncaof.asp?SubTipo=Sistema
868 965 Function DriveType(Unidade: String):String;
869 966 Var StrDrive,
... ... @@ -886,12 +983,192 @@ begin
886 983 end;
887 984 Result := StrDriveType;
888 985 End;
  986 +}
  987 +
  988 +Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer; // 2.2.0.16
  989 +var strNomeAgente : String;
  990 + v_array_NomeAgente : TStrings;
  991 + intAux : integer;
  992 +Begin
  993 + v_array_NomeAgente := explode(p_strNomeAgente,'\');
  994 +
  995 + v_versao_REM := XML_RetornaValor(StringReplace(StrUpper(PChar(v_array_NomeAgente[v_array_NomeAgente.count-1])),'.EXE','',[rfReplaceAll]), v_retorno);
  996 + v_versao_LOC := GetVersionInfo(p_strNomeAgente);
  997 +
  998 + log_DEBUG('Checando versão de "'+p_strNomeAgente+'"');
  999 +
  1000 + intAux := v_array_NomeAgente.Count;
  1001 +
  1002 + // V: 2.2.0.16
  1003 + // Verifico existência do arquivo "versoes_agentes.ini" para comparação das versões dos agentes principais
  1004 + if (v_versao_REM = '') AND FileExists(ExtractFilePath(Application.Exename)+'versoes_agentes.ini') then
  1005 + Begin
  1006 + if (GetValorChaveRegIni('versoes_agentes',v_array_NomeAgente[intAux-1],ExtractFilePath(Application.Exename)+'versoes_agentes.ini')<>'') then
  1007 + Begin
  1008 + log_DEBUG('Encontrado arquivo "'+(ExtractFilePath(Application.Exename)+'versoes_agentes.ini')+'"');
  1009 + v_versao_REM := GetValorChaveRegIni('versoes_agentes',v_array_NomeAgente[intAux-1],ExtractFilePath(Application.Exename)+'versoes_agentes.ini');
  1010 + End;
  1011 + End;
  1012 +
  1013 + log_DEBUG('Versão Remota: "'+v_versao_REM+'" - Versão Local: "'+v_versao_LOC+'"');
  1014 +
  1015 + if (v_versao_REM + v_versao_LOC <> '') and
  1016 + (v_versao_LOC <> '0000') then
  1017 + Begin
  1018 + if (v_versao_REM = v_versao_LOC) then
  1019 + Result := 1
  1020 + else
  1021 + Result := 2;
  1022 + End
  1023 + else
  1024 + Result := 0;
  1025 +End;
  1026 +
  1027 +// Dica baixada de http://procedure.blig.ig.com.br/
  1028 +// Adaptada por Anderson Peterle - v:2.2.0.16 - 03/2007
  1029 +procedure Matar(v_dir,v_files: string);
  1030 +var SearchRec: TSearchRec;
  1031 + Result: Integer;
  1032 + strFileName : String;
  1033 +begin
  1034 + strFileName := StringReplace(v_dir + '\' + v_files,'\\','\',[rfReplaceAll]);
  1035 + Result:=FindFirst(strFileName, faAnyFile, SearchRec);
  1036 +
  1037 + while result=0 do
  1038 + begin
  1039 + strFileName := StringReplace(v_dir + '\' + SearchRec.Name,'\\','\',[rfReplaceAll]);
  1040 + log_DEBUG('Tentando Excluir: '+strFileName);
  1041 + if DeleteFile(strFileName) then
  1042 + log_DEBUG('Exclusão de ' + strFileName + ' efetuada com sucesso!')
  1043 + else
  1044 + Begin
  1045 + log_DEBUG('Exclusão não efetuada! Provavelmente já esteja sendo executado...');
  1046 + log_DEBUG('Tentarei finalizar Tarefa/Processo...');
  1047 + if ((intWinVer <> 0) and (intWinVer <= 5)) or
  1048 + (abstraiCSD(v_te_so) < 250) then // Menor que NT Like
  1049 + KillTask(SearchRec.Name)
  1050 + else
  1051 + KillProcess(FindWindow(PChar(SearchRec.Name),nil));
  1052 +
  1053 + if DeleteFile(strFileName) then
  1054 + log_DEBUG('Exclusão Impossibilitada de ' + strFileName + '!');
  1055 + End;
  1056 +
  1057 + Result:=FindNext(SearchRec);
  1058 + end;
  1059 +end;
  1060 +
  1061 +function Posso_Rodar_CACIC : boolean;
  1062 +Begin
  1063 + result := false;
  1064 +
  1065 + // Se o aguarde_CACIC.txt existir é porque refere-se a uma versão mais atual: 2.2.0.20 ou maior
  1066 + if (FileExists(v_cacic_dir + 'aguarde_CACIC.txt')) then
  1067 + Begin
  1068 + // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) )
  1069 + Matar(v_cacic_dir,'aguarde_CACIC.txt');
  1070 + if (not (FileExists(v_cacic_dir + 'aguarde_CACIC.txt'))) then
  1071 + result := true;
  1072 + End;
  1073 +End;
  1074 +function GetFolderDate(Folder: string): TDateTime;
  1075 +var
  1076 + Rec: TSearchRec;
  1077 + Found: Integer;
  1078 + Date: TDateTime;
  1079 +begin
  1080 + if Folder[Length(folder)] = '\' then
  1081 + Delete(Folder, Length(folder), 1);
  1082 + Result := 0;
  1083 + Found := FindFirst(Folder, faDirectory, Rec);
  1084 + try
  1085 + if Found = 0 then
  1086 + begin
  1087 + Date := FileDateToDateTime(Rec.Time);
  1088 + Result := Date;
  1089 + end;
  1090 + finally
  1091 + FindClose(Rec);
  1092 + end;
  1093 +end;
  1094 +
  1095 +function Get_File_Size(sFileToExamine: string): integer;
  1096 +var
  1097 + SearchRec: TSearchRec;
  1098 + sgPath: string;
  1099 + inRetval, I1: Integer;
  1100 +begin
  1101 + sgPath := ExpandFileName(sFileToExamine);
  1102 + try
  1103 + inRetval := FindFirst(ExpandFileName(sFileToExamine), faAnyFile, SearchRec);
  1104 + if inRetval = 0 then
  1105 + I1 := SearchRec.Size
  1106 + else
  1107 + I1 := -1;
  1108 + finally
  1109 + SysUtils.FindClose(SearchRec);
  1110 + end;
  1111 + Result := I1;
  1112 +end;
  1113 +
  1114 +procedure verifyAndGet(strModuleName,
  1115 + strDestinationFolderName,
  1116 + strServUpdates,
  1117 + strPortaServUpdates,
  1118 + strNomeUsuarioLoginServUpdates,
  1119 + strSenhaLoginServUpdates,
  1120 + strPathServUpdates,
  1121 + strExibeInformacoes : String);
  1122 + var intFileSize : integer;
  1123 + Begin
  1124 +
  1125 + // Verifico validade do Módulo e mato-o em caso negativo.
  1126 + intFileSize := Get_File_Size(strDestinationFolderName + '\'+strModuleName);
  1127 +
  1128 + log_DEBUG('verifyAndGet - intFileSize de "'+strDestinationFolderName + '\'+strModuleName+'": ' + IntToStr(intFileSize));
  1129 +
  1130 + If (intFileSize <= 0) then
  1131 + Matar(strDestinationFolderName, strModuleName);
  1132 +
  1133 + If not FileExists(strDestinationFolderName + '\'+strModuleName) Then
  1134 + Begin
  1135 + if (FileExists(ExtractFilePath(Application.Exename) + '\modulos\'+strModuleName)) then
  1136 + Begin
  1137 + log_diario('Copiando '+strModuleName+' de '+ExtractFilePath(Application.Exename)+'modulos\');
  1138 + CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\'+strModuleName), PChar(strDestinationFolderName + '\'+strModuleName),false);
  1139 + FileSetAttr (PChar(strDestinationFolderName + '\' + strModuleName),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED
  1140 + End
  1141 + else
  1142 + begin
  1143 + Try
  1144 + if not FTP(strServUpdates,
  1145 + strPortaServUpdates,
  1146 + strNomeUsuarioLoginServUpdates,
  1147 + strSenhaLoginServUpdates,
  1148 + strPathServUpdates,
  1149 + strModuleName,
  1150 + strDestinationFolderName) and (strExibeInformacoes = 'S') then
  1151 + MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+strDestinationFolderName + '\'+strModuleName+'".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
  1152 + Except
  1153 + log_DEBUG('FTP de "'+ strDestinationFolderName + '\' + strModuleName+'" Interrompido.');
  1154 + End;
  1155 +
  1156 + if not FileExists(strDestinationFolderName + '\' + strModuleName) Then
  1157 + Begin
  1158 + log_DEBUG('Problemas Efetuando Download de '+ strDestinationFolderName + '\' + strModuleName+' (FTP)');
  1159 + log_DEBUG('Conexão:');
  1160 + log_DEBUG(strServUpdates+', '+strPortaServUpdates+', '+strNomeUsuarioLoginServUpdates+', '+strSenhaLoginServUpdates+', '+strPathServUpdates);
  1161 + End
  1162 + else
  1163 + log_diario('Download Concluído de "'+strModuleName+'" (FTP)');
  1164 + end;
  1165 + End;
  1166 + End;
889 1167  
890 1168 procedure chkcacic;
891   -var bool_download_CACIC2,
892   - bool_download_GER_COLS,
893   - bool_configura,
894   - bool_ExistsAutoRun : boolean;
  1169 +var bool_configura,
  1170 + bool_ExistsAutoRun,
  1171 + bool_CommandLine : boolean;
895 1172  
896 1173 v_te_serv_updates,
897 1174 v_nu_porta_serv_updates,
... ... @@ -900,37 +1177,87 @@ var bool_download_CACIC2,
900 1177 v_te_path_serv_updates,
901 1178 v_te_texto_janela_instalacao,
902 1179 v_modulos,
903   - v_retorno,
904   - strAux : String;
  1180 + strAux,
  1181 + strDataHoraCACIC2_INI,
  1182 + strDataHoraGERCOLS_INI,
  1183 + strDataHoraCACIC2_FIM,
  1184 + strDataHoraGERCOLS_FIM : String;
905 1185  
906 1186 Request_Config : TStringList;
907 1187 v_array_modulos : TStrings;
908 1188 Response_Config : TStringStream;
909 1189 IdHTTP1: TIdHTTP;
  1190 + intDownload_CACIC2,
  1191 + intDownload_GER_COLS,
910 1192 intAux : integer;
911 1193 begin
  1194 + strDataHoraCACIC2_INI := '';
  1195 + strDataHoraCACIC2_FIM := '';
  1196 + strDataHoraGERCOLS_INI := '';
  1197 + strDataHoraGERCOLS_FIM := '';
912 1198 v_te_instala_frase_sucesso := 'INSTALAÇÃO/ATUALIZAÇÃO EFETUADA COM SUCESSO!';
913 1199 v_te_instala_frase_insucesso := '***** INSTALAÇÃO/ATUALIZAÇÃO NÃO EFETUADA COM SUCESSO *****';
  1200 + bool_CommandLine := false;
914 1201  
915 1202 Try
916 1203 v_home_drive := MidStr(HomeDrive,1,3); //x:\
917   - If not (FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini')) then
918   - Begin
919   - log_diario('Abrindo formulário de configurações');
920   - CriaFormConfigura;
921   - MostraFormConfigura;
922   - End;
923 1204  
924   - bool_download_CACIC2 := false;
925   - bool_download_GER_COLS := false;
926   - v_ip_serv_cacic := GetValorChaveRegIni('Cacic2', 'ip_serv_cacic' , ExtractFilePath(Application.Exename) + '\chkcacic.ini');
927   - v_cacic_dir := GetValorChaveRegIni('Cacic2', 'cacic_dir' , ExtractFilePath(Application.Exename) + '\chkcacic.ini');
928   - v_exibe_informacoes := GetValorChaveRegIni('Cacic2', 'exibe_informacoes', ExtractFilePath(Application.Exename) + '\chkcacic.ini');
929   - v_te_instala_informacoes_extras := StringReplace(GetValorChaveRegIni('Cacic2', 'te_instala_informacoes_extras', ExtractFilePath(Application.Exename) + '\chkcacic.ini'),'*13*10',#13#10,[rfReplaceAll]);
  1205 + // 2.2.0.17 - Tratamento de opções passadas em linha de comando
  1206 + // Grande dica do grande Cláudio Filho (OpenOffice.org)
  1207 + if (ParamCount > 0) then
  1208 + Begin
  1209 + For intAux := 1 to ParamCount do
  1210 + Begin
  1211 + if LowerCase(Copy(ParamStr(intAux),1,6)) = '/serv=' then
  1212 + begin
  1213 + strAux := Trim(Copy(ParamStr(intAux),7,Length((ParamStr(intAux)))));
  1214 + v_ip_serv_cacic := Trim(Copy(strAux,0,Pos('/', strAux) - 1));
  1215 + If v_ip_serv_cacic = '' Then v_ip_serv_cacic := strAux;
  1216 + end;
  1217 + if LowerCase(Copy(ParamStr(intAux),1,5)) = '/dir=' then
  1218 + begin
  1219 + strAux := Trim(Copy(ParamStr(intAux),6,Length((ParamStr(intAux)))));
  1220 + v_cacic_dir := Trim(Copy(strAux,0,Pos('/', strAux) - 1));
  1221 + If v_cacic_dir = '' Then v_cacic_dir := strAux;
  1222 + end;
  1223 +
  1224 + end;
  1225 + if not(v_ip_serv_cacic='') and
  1226 + not(v_cacic_dir='')then
  1227 + bool_CommandLine := true;
  1228 + End;
  1229 +
  1230 + if not bool_CommandLine then
  1231 + Begin
  1232 + If not (FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini')) then
  1233 + Begin
  1234 + log_diario('Abrindo formulário de configurações');
  1235 + CriaFormConfigura;
  1236 + MostraFormConfigura;
  1237 + End;
  1238 +
  1239 + v_ip_serv_cacic := GetValorChaveRegIni('Cacic2', 'ip_serv_cacic' , ExtractFilePath(Application.Exename) + '\chkcacic.ini');
  1240 + v_cacic_dir := GetValorChaveRegIni('Cacic2', 'cacic_dir' , ExtractFilePath(Application.Exename) + '\chkcacic.ini');
  1241 + v_exibe_informacoes := GetValorChaveRegIni('Cacic2', 'exibe_informacoes', ExtractFilePath(Application.Exename) + '\chkcacic.ini');
  1242 + v_te_instala_informacoes_extras := StringReplace(GetValorChaveRegIni('Cacic2', 'te_instala_informacoes_extras', ExtractFilePath(Application.Exename) + '\chkcacic.ini'),'*13*10',#13#10,[rfReplaceAll]);
  1243 + End;
  1244 +
930 1245 Dir := v_home_drive + v_cacic_dir; // Ex.: c:\cacic\
931 1246  
  1247 + if DirectoryExists(Dir + '\Temp\Debugs') then
  1248 + Begin
  1249 + if (FormatDateTime('ddmmyyyy', GetFolderDate(Dir + '\Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
  1250 + Begin
  1251 + v_Debugs := true;
  1252 + log_DEBUG('Pasta "' + Dir + '\Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(Dir + '\Temp\Debugs'))+' encontrada. DEBUG ativado.');
  1253 + End;
  1254 + End;
  1255 +
  1256 + intWinVer := GetWinVer;
  1257 +
932 1258 // Verifico se o S.O. é NT Like e se o Usuário está com privilégio administrativo...
933   - if (GetWinVer >= 6) and
  1259 + if (((intWinVer <> 0) and (intWinVer >= 6)) or
  1260 + (abstraiCSD(v_te_so) >= 250)) and
934 1261 (v_exibe_informacoes = 'S') and
935 1262 not IsAdmin then // Se NT/2000/XP/...
936 1263 Begin
... ... @@ -938,13 +1265,13 @@ begin
938 1265 End
939 1266 else
940 1267 Begin
941   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
942   - log_diario(':::::::::::::: OBTENDO VALORES DO "chkcacic.ini" ::::::::::::::');
943   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
944   - log_diario('Drive de instalação......................: '+v_home_drive);
945   - log_diario('Pasta para instalação....................: '+Dir);
946   - log_diario('IP do servidor...........................: '+v_ip_serv_cacic);
947   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1268 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1269 + log_DEBUG(':::::::::::::: OBTENDO VALORES DO "chkcacic.ini" ::::::::::::::');
  1270 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1271 + log_DEBUG('Drive de instalação......................: '+v_home_drive);
  1272 + log_DEBUG('Pasta para instalação....................: '+Dir);
  1273 + log_DEBUG('IP do servidor...........................: '+v_ip_serv_cacic);
  1274 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
948 1275 bool_configura := false;
949 1276  
950 1277 //chave AES. Recomenda-se que cada empresa/órgão altere a sua chave.
... ... @@ -955,19 +1282,48 @@ begin
955 1282 v_tstrCipherOpened := CipherOpen(v_DatFileName);
956 1283  
957 1284  
958   - if (GetWinVer >= 8) then // Se >= WinXP...
  1285 + if ((intWinVer <> 0) and (intWinVer >= 8)) or
  1286 + (abstraiCSD(v_te_so) >= 250) then // Se >= WinXP...
959 1287 Begin
960 1288 Try
961   - // Acrescento os valores para uso do FireWall nativo...
  1289 + // Libero as policies do FireWall (testes)
  1290 + Try
  1291 + Begin
  1292 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DisableStatefulFTP" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DisableStatefulFTP')));
  1293 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DisableStatefulFTP'))='0') then
  1294 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DisableStatefulFTP','1');
962 1295  
963   - {chkcacic}
964   - LiberaFireWall(ExtractFilePath(Application.Exename) + 'chkcacic');
  1296 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\EnableFirewall" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\EnableFirewall')));
  1297 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\EnableFirewall'))='1') then
  1298 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\EnableFirewall','0');
965 1299  
966   - {chksis}
967   - LiberaFireWall(HomeDrive + '\chksis');
  1300 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\DisableNotifications" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\DisableNotifications')));
  1301 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\DisableNotifications'))='0') then
  1302 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\DisableNotifications','1');
968 1303  
969   - {ger_cols}
970   - LiberaFireWall(Dir + '\modulos\ger_cols');
  1304 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\DisableNotifications" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\DisableNotifications')));
  1305 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\DisableNotifications'))='0') then
  1306 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\DisableNotifications','1');
  1307 +
  1308 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\EnableFirewall" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\EnableFirewall')));
  1309 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\EnableFirewall'))='1') then
  1310 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\DomainProfile\EnableFirewall','0');
  1311 +
  1312 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\DisableNotifications" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\DisableNotifications')));
  1313 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\DisableNotifications'))='0') then
  1314 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\DisableNotifications','1');
  1315 +
  1316 + Log_DEBUG('Valor de "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\EnableFirewall" => '+trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\EnableFirewall')));
  1317 + if (trim(GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\EnableFirewall'))='1') then
  1318 + SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile\EnableFirewall','0');
  1319 + End
  1320 + Except
  1321 + log_DEBUG('Problema Liberando Policies de FireWall!');
  1322 + End;
  1323 +
  1324 + // Acrescento o ChkCacic às exceções do FireWall nativo...
  1325 + {chkcacic}
  1326 + LiberaFireWall(ExtractFilePath(Application.Exename) + 'chkcacic');
971 1327  
972 1328 Except
973 1329 End;
... ... @@ -993,10 +1349,6 @@ begin
993 1349  
994 1350 if (ParamCount > 0) and (LowerCase(Copy(ParamStr(1),1,7)) = '/config') then application.Terminate;
995 1351  
996   - // Caso o parâmetro rem_cacic_v0x seja "S/s" removo a chave/valor de execução do Cacic antigo
997   - //if (LowerCase(v_rem_cacic_v0x)='s') then
998   - // DelValorReg('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic');
999   -
1000 1352 // Verifico a existência do diretório configurado para o Cacic, normalmente CACIC
1001 1353 if not DirectoryExists(Dir) then
1002 1354 begin
... ... @@ -1007,20 +1359,7 @@ begin
1007 1359 // Para eliminar versão 20014 e anteriores que provavelmente não fazem corretamente o AutoUpdate
1008 1360 if not DirectoryExists(Dir+'\modulos') then
1009 1361 begin
1010   - if DeleteFile(Dir + '\cacic2.exe') then
1011   - log_diario('Exclusão de '+Dir + '\cacic2.exe' + ' efetuada com sucesso!')
1012   - else
1013   - Begin
1014   - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');
1015   - log_diario('Tentarei finalizar Tarefa/Processo...');
1016   - if (GetWinVer <= 5) then // Até
1017   - KillTask('cacic2.exe')
1018   - else
1019   - KillProcess(FindWindow('cacic2.exe',nil));
1020   - if DeleteFile(Dir + '\cacic2.exe') then
1021   - log_diario('Exclusão Impossibilitada de '+Dir + '\cacic2.exe' + '!');
1022   - End;
1023   -
  1362 + Matar(Dir, '\cacic2.exe');
1024 1363 ForceDirectories(Dir + '\modulos');
1025 1364 log_diario('Criando pasta '+Dir+'\modulos');
1026 1365 end;
... ... @@ -1070,16 +1409,20 @@ begin
1070 1409 v_te_senha_login_serv_updates := XML_RetornaValor('te_senha_login_serv_updates' , v_retorno);
1071 1410 v_te_path_serv_updates := XML_RetornaValor('te_path_serv_updates' , v_retorno);
1072 1411  
1073   - //log_diario('Retorno da comunicação: '+v_retorno);
1074   -
1075   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1076   - log_diario(':::::::::::::::: VALORES OBTIDOS NO Gerente WEB :::::::::::::::');
1077   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1078   - log_diario('Servidor de updates......................: '+v_te_serv_updates);
1079   - log_diario('Porta do servidor de updates.............: '+v_nu_porta_serv_updates);
1080   - log_diario('Usuário para login no servidor de updates: '+v_nm_usuario_login_serv_updates);
1081   - log_diario('Pasta no servidor de updates.............: '+v_te_path_serv_updates);
1082   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1412 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1413 + log_DEBUG(':::::::::::::::: VALORES OBTIDOS NO Gerente WEB :::::::::::::::');
  1414 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1415 + log_DEBUG('Servidor de updates......................: '+v_te_serv_updates);
  1416 + log_DEBUG('Porta do servidor de updates.............: '+v_nu_porta_serv_updates);
  1417 + log_DEBUG('Usuário para login no servidor de updates: '+v_nm_usuario_login_serv_updates);
  1418 + log_DEBUG('Pasta no servidor de updates.............: '+v_te_path_serv_updates);
  1419 + log_DEBUG(' ');
  1420 + log_DEBUG('Versões dos Agentes Principais:');
  1421 + log_DEBUG('------------------------------');
  1422 + log_DEBUG('Cacic2 - Agente do Systray.........: '+XML_RetornaValor('CACIC2', v_retorno));
  1423 + log_DEBUG('Ger_Cols - Gerente de Coletas........: '+XML_RetornaValor('GER_COLS', v_retorno));
  1424 + log_DEBUG('ChkSis - Verificador de Integridade: '+XML_RetornaValor('CHKSIS', v_retorno));
  1425 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1083 1426 Except
1084 1427 Begin
1085 1428 if v_exibe_informacoes = 'S' then
... ... @@ -1092,151 +1435,129 @@ begin
1092 1435 Request_Config.Free;
1093 1436 Response_Config.Free;
1094 1437  
1095   - // Verificação de versão do cacic2.exe e exclusão em caso de versão antiga
1096   - If (FileExists(Dir + '\cacic2.exe')) Then
1097   - Begin
1098   - v_versao_local := trim(GetVersionInfo(Dir + '\cacic2.exe'));
1099   - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
1100   -
1101   - v_versao_remota_inteira := XML_RetornaValor('CACIC2' , v_retorno);
1102   - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
1103   -
1104   - if not (v_versao_remota_inteira = '') then
1105   - log_diario('Versão remota de "cacic2.exe": '+v_versao_remota_capada + '('+v_versao_remota_inteira+')');
  1438 + // Se NTFS em NT/2K/XP...
  1439 + // If NTFS on NT Like...
  1440 + if ((intWinVer <> 0) and (intWinVer > 5)) or
  1441 + (abstraiCSD(v_te_so) >= 250) then
  1442 + Begin
  1443 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1444 + log_DEBUG('::::::: VERIFICANDO FILE SYSTEM E ATRIBUINDO PERMISSÕES :::::::');
  1445 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1106 1446  
1107   - if (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida
1108   - (v_versao_local ='2208') then
1109   -// (v_versao_local <> v_versao_remota_capada) then
1110   - Begin
1111   - log_diario('Excluindo versão "'+v_versao_local+'" de Cacic2.exe');
1112   - if DeleteFile(Dir + '\cacic2.exe') then
1113   - log_diario('Exclusão de '+Dir + '\cacic2.exe'+' efetuada com sucesso!')
1114   - else
1115   - Begin
1116   - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');
1117   - log_diario('Tentarei finalizar Tarefa/Processo...');
1118   - if (GetWinVer <= 5) then // Até
1119   - KillTask('cacic2.exe')
1120   - else
1121   - KillProcess(FindWindow('cacic2.exe',nil));
1122   - if DeleteFile(Dir + '\cacic2.exe') then
1123   - log_diario('Exclusão Impossibilitada de '+Dir + '\cacic2.exe' + '!');
1124   - End;
1125   - End;
1126   - End;
  1447 + Form1.FS_SetSecurity(Dir);
  1448 + Form1.FS_SetSecurity(Dir + '\cacic2.exe');
  1449 + Form1.FS_SetSecurity(Dir + '\cacic2.dat');
  1450 + Form1.FS_SetSecurity(Dir + '\cacic2.log');
  1451 + Form1.FS_SetSecurity(Dir + '\modulos');
  1452 + Form1.FS_SetSecurity(Dir + '\temp');
1127 1453  
1128   - // Verificação de versão do ger_cols.exe e exclusão em caso de versão antiga
1129   - If (FileExists(Dir + '\modulos\ger_cols.exe')) Then
1130   - Begin
1131   - v_versao_local := trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe'));
1132   - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
  1454 + // Atribuição de acesso a todos os módulos para permissão de atualizações de versão
  1455 + Form1.FS_SetSecurity(Dir + '\modulos\ger_cols.exe');
  1456 + Form1.FS_SetSecurity(Dir + '\modulos\col_anvi.exe');
  1457 + Form1.FS_SetSecurity(Dir + '\modulos\col_comp.exe');
  1458 + Form1.FS_SetSecurity(Dir + '\modulos\col_hard.exe');
  1459 + Form1.FS_SetSecurity(Dir + '\modulos\col_moni.exe');
  1460 + Form1.FS_SetSecurity(Dir + '\modulos\col_patr.exe');
  1461 + Form1.FS_SetSecurity(Dir + '\modulos\col_soft.exe');
  1462 + Form1.FS_SetSecurity(Dir + '\modulos\col_undi.exe');
  1463 + Form1.FS_SetSecurity(Dir + '\modulos\ini_cols.exe');
  1464 + Form1.FS_SetSecurity(Dir + '\modulos\wscript.exe');
1133 1465  
1134   - v_versao_remota_inteira := XML_RetornaValor('GER_COLS' , v_retorno);
1135   - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
  1466 + // Atribuição de acesso para atualização do módulo verificador de integridade do sistema e seus arquivos
  1467 + Form1.FS_SetSecurity(HomeDrive + '\chksis.exe');
  1468 + Form1.FS_SetSecurity(HomeDrive + '\chksis.log');
  1469 + Form1.FS_SetSecurity(HomeDrive + '\chksis.dat');
1136 1470  
1137   - if not (v_versao_remota_inteira = '') then
1138   - log_diario('Versão remota de "ger_cols.exe": '+v_versao_remota_capada+ '('+v_versao_remota_inteira+')');
  1471 + // Atribuição de acesso para atualização/exclusão de log do instalador
  1472 + Form1.FS_SetSecurity(v_home_drive + 'chkcacic.log');
  1473 + log_DEBUG(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
  1474 + End;
1139 1475  
1140   - if (v_versao_local ='0000') then //or // Provavelmente versão muito antiga ou corrompida
1141   -// (v_versao_local <> v_versao_remota_capada) then
  1476 + // Verificação de versão do cacic2.exe e exclusão em caso de versão antiga/diferente da atual
  1477 + If (FileExists(Dir + '\cacic2.exe')) Then
  1478 + Begin
  1479 + // Pego as informações de dia/mês/ano/horas/minutos/segundos/milésimos que identificam o agente Cacic2
  1480 + strDataHoraCACIC2_INI := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\cacic2.exe'));
  1481 +
  1482 + intAux := ChecaVersoesAgentes(Dir + '\cacic2.exe');
  1483 + // 0 => Arquivo de versões ou informação inexistente
  1484 + // 1 => Versões iguais
  1485 + // 2 => Versões diferentes
  1486 + if (intAux = 0) then
1142 1487 Begin
1143   - log_diario('Excluindo versão "'+v_versao_local+'" de Ger_Cols.exe');
1144   - if DeleteFile(Dir + '\modulos\ger_cols.exe') then
1145   - log_diario('Exclusão de '+Dir + '\modulos\ger_cols.exe'+' efetuada com sucesso!')
1146   - else
1147   - Begin
1148   - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');
1149   - log_diario('Tentarei finalizar Tarefa/Processo...');
1150   - if (GetWinVer <= 5) then // Até
1151   - KillTask('ger_cols.exe')
1152   - else
1153   - KillProcess(FindWindow('ger_cols.exe',nil));
1154   - if DeleteFile(Dir + '\modulos\ger_cols.exe') then
1155   - log_diario('Exclusão Impossibilitada de '+Dir + '\modulos\ger_cols.exe' + '!');
1156   - End;
  1488 + v_versao_local := StringReplace(trim(GetVersionInfo(Dir + '\cacic2.exe')),'.','',[rfReplaceAll]);
  1489 + v_versao_remota := StringReplace(XML_RetornaValor('CACIC2' , v_retorno),'0103','',[rfReplaceAll]);
1157 1490 End;
1158   - End;
1159 1491  
  1492 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  1493 + (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida
  1494 + (v_versao_local ='2208') then
  1495 + Matar(Dir, '\cacic2.exe');
  1496 + End;
1160 1497  
1161   - // Verificação de versão do chksis.exe e exclusão em caso de versão antiga
1162   - If (FileExists(HomeDrive + '\chksis.exe')) Then
1163   - Begin
1164   - v_versao_local := trim(GetVersionInfo(HomeDrive + '\chksis.exe'));
1165   - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
  1498 + // Verificação de versão do ger_cols.exe e exclusão em caso de versão antiga/diferente da atual
  1499 + If (FileExists(Dir + '\modulos\ger_cols.exe')) Then
  1500 + Begin
  1501 + // Pego as informações de dia/mês/ano/horas/minutos/segundos/milésimos que identificam o agente Ger_Cols
  1502 + strDataHoraGERCOLS_INI := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\modulos\ger_cols.exe'));
  1503 +
  1504 + intAux := ChecaVersoesAgentes(Dir + '\modulos\ger_cols.exe');
  1505 + // 0 => Arquivo de versões ou informação inexistente
  1506 + // 1 => Versões iguais
  1507 + // 2 => Versões diferentes
  1508 + if (intAux = 0) then
  1509 + Begin
  1510 + v_versao_local := StringReplace(trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe')),'.','',[rfReplaceAll]);
  1511 + v_versao_remota := StringReplace(XML_RetornaValor('GER_COLS' , v_retorno),'0103','',[rfReplaceAll]);
  1512 + End;
1166 1513  
1167   - v_versao_remota_inteira := XML_RetornaValor('CHKSIS' , v_retorno);
1168   - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
  1514 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  1515 + (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida
  1516 + Matar(Dir + '\modulos\', 'ger_cols.exe');
  1517 + End;
1169 1518  
1170   - if not (v_versao_remota_inteira = '') then
1171   - log_diario('Versão remota de "chksis.exe": '+v_versao_remota_capada+ '('+v_versao_remota_inteira+')');
1172 1519  
1173   - if (v_versao_local ='0000') then //or // Provavelmente versão muito antiga ou corrompida
1174   -// (v_versao_local <> v_versao_remota_capada) then
1175   - Begin
1176   - log_diario('Excluindo versão "'+v_versao_local+'" de ChkSis.exe');
1177   - if DeleteFile(HomeDrive + '\chksis.exe') then
1178   - log_diario('Exclusão de '+HomeDrive + '\chksis.exe'+' efetuada com sucesso!')
1179   - else
1180   - Begin
1181   - log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...');
1182   - log_diario('Tentarei finalizar Tarefa/Processo...');
1183   - if (GetWinVer <= 5) then // Até
1184   - KillTask('chksis.exe')
1185   - else
1186   - KillProcess(FindWindow('chksis.exe',nil));
1187   - if DeleteFile(HomeDrive + '\chksis.exe') then
1188   - log_diario('Exclusão Impossibilitada de '+HomeDrive + '\chksis.exe' + '!');
1189   - End;
  1520 + // Verificação de versão do chksis.exe e exclusão em caso de versão antiga/diferente da atual
  1521 + If (FileExists(HomeDrive + '\chksis.exe')) Then
  1522 + Begin
  1523 + intAux := ChecaVersoesAgentes(HomeDrive + '\chksis.exe');
  1524 + // 0 => Arquivo de versões ou informação inexistente
  1525 + // 1 => Versões iguais
  1526 + // 2 => Versões diferentes
  1527 + if (intAux = 0) then
  1528 + Begin
  1529 + v_versao_local := StringReplace(trim(GetVersionInfo(HomeDrive + '\chksis.exe')),'.','',[rfReplaceAll]);
  1530 + v_versao_remota := StringReplace(XML_RetornaValor('CHKSIS' , v_retorno),'0103','',[rfReplaceAll]);
  1531 + End;
1190 1532  
1191   - End;
1192   - End;
  1533 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  1534 + (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida
  1535 + Matar(HomeDrive,'chksis.exe');
  1536 + End;
1193 1537  
1194 1538 // Tento detectar o ChkSis.EXE e copio ou faço FTP caso não exista
1195   - If not FileExists(HomeDrive + '\chksis.exe') Then
1196   - begin
1197   - if (FileExists(ExtractFilePath(Application.Exename) + 'modulos\chksis.exe')) then
1198   - Begin
1199   - log_diario('Copiando ChkSis.exe de '+ExtractFilePath(Application.Exename)+'modulos\');
1200   - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\chksis.exe'), PChar(HomeDrive + '\chksis.exe'),false);
1201   - FileSetAttr (PChar(HomeDrive + '\chksis.exe'),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
1202   - End
1203   - else
1204   - Begin
1205   - if not FTP(v_te_serv_updates,
1206   - v_nu_porta_serv_updates,
1207   - v_nm_usuario_login_serv_updates,
1208   - v_te_senha_login_serv_updates,
1209   - v_te_path_serv_updates,
1210   - 'chksis.exe',
1211   - HomeDrive) and (v_exibe_informacoes = 'S') then
1212   - MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+HomeDrive + '\chksis.exe".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
1213   -
1214   - If not FileExists(HomeDrive + '\chksis.exe') Then
1215   - Begin
1216   - log_diario('Problemas Efetuando Download de ChkSis.exe(FTP):');
1217   - log_diario('v_te_serv_updates:'+v_te_serv_updates);
1218   - log_diario('v_nu_porta_serv_updates:'+v_nu_porta_serv_updates);
1219   - log_diario('v_nm_usuario_login_serv_updates:'+v_nm_usuario_login_serv_updates);
1220   - log_diario('v_te_senha_login_serv_updates:'+v_te_senha_login_serv_updates);
1221   - log_diario('v_te_path_serv_updates:'+v_te_path_serv_updates);
1222   - End
1223   - else log_diario('Download Concluído de ChkSis.exe (FTP)');
1224   -
1225   - End;
1226   - end;
1227   -
1228   - // Tento detectar o ChkSis.INI e crio-o apartir do chkcacic.ini
  1539 + verifyAndGet('chksis.exe',
  1540 + HomeDrive,
  1541 + v_te_serv_updates,
  1542 + v_nu_porta_serv_updates,
  1543 + v_nm_usuario_login_serv_updates,
  1544 + v_te_senha_login_serv_updates,
  1545 + v_te_path_serv_updates,
  1546 + v_exibe_informacoes);
  1547 +
  1548 + // Tento detectar o ChkSis.INI e crio-o caso necessário
1229 1549 If not FileExists(HomeDrive + '\chksis.ini') Then
1230 1550 begin
1231   - log_diario('Criando ChkSis.ini');
1232   - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'chkcacic.ini'), PChar(HomeDrive + '\chksis.ini'),false);
  1551 + log_DEBUG('Criando '+HomeDrive + '\chksis.ini');
  1552 + GravaIni(HomeDrive + '\chksis.ini');
1233 1553 FileSetAttr ( PChar(HomeDrive + '\chksis.ini'),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
1234 1554 end;
1235 1555  
1236   - // Tento detectar o cacic2.INI e crio-o apartir do chkcacic.ini
  1556 + // Tento detectar o cacic2.INI e crio-o caso necessário
1237 1557 If not FileExists(Dir + '\cacic2.ini') Then
1238 1558 begin
1239   - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'chkcacic.ini'), PChar(Dir + '\cacic2.ini'),false)
  1559 + log_DEBUG('Criando/Recriando '+Dir + '\cacic2.ini');
  1560 + GravaIni(Dir + '\cacic2.ini');
1240 1561 end;
1241 1562  
1242 1563 // Verifico se existe a pasta "modulos"
... ... @@ -1244,78 +1565,23 @@ begin
1244 1565 if (v_modulos <> '') then log_diario('Pasta "Modulos" encontrada..');
1245 1566  
1246 1567 // Tento detectar o Agente Principal e copio ou faço FTP caso não exista
1247   - If not FileExists(Dir + '\cacic2.exe') Then
1248   - Begin
1249   - if (FileExists(ExtractFilePath(Application.Exename) + '\modulos\cacic2.exe')) then
1250   - Begin
1251   - log_diario('Copiando Cacic2.exe de '+ExtractFilePath(Application.Exename)+'modulos\');
1252   - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\cacic2.exe'), PChar(Dir + '\cacic2.exe'),false);
1253   - FileSetAttr (PChar(Dir + '\cacic2.exe'),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
1254   - bool_download_CACIC2 := true;
1255   - End
1256   - else
1257   - begin
1258   - if not FTP(v_te_serv_updates,
1259   - v_nu_porta_serv_updates,
1260   - v_nm_usuario_login_serv_updates,
1261   - v_te_senha_login_serv_updates,
1262   - v_te_path_serv_updates,
1263   - 'cacic2.exe',
1264   - Dir) and (v_exibe_informacoes = 'S') then
1265   - MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+Dir + '\cacic2.exe".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
1266   -
1267   - bool_download_CACIC2 := true;
1268   -
1269   - If not FileExists(Dir + '\cacic2.exe') Then
1270   - Begin
1271   - log_diario('Problemas Efetuando Download de Cacic2.exe(FTP):');
1272   - log_diario('v_te_serv_updates:'+v_te_serv_updates);
1273   - log_diario('v_nu_porta_serv_updates:'+v_nu_porta_serv_updates);
1274   - log_diario('v_nm_usuario_login_serv_updates:'+v_nm_usuario_login_serv_updates);
1275   - log_diario('v_te_senha_login_serv_updates:'+v_te_senha_login_serv_updates);
1276   - log_diario('v_te_path_serv_updates:'+v_te_path_serv_updates);
1277   - bool_download_CACIC2 := false;
1278   - End
1279   - else log_diario('Download Concluído de Cacic2.exe (FTP)');
1280   -
1281   - end;
1282   - End;
1283   - // Tento detectar o Gerente de Coletas e copio ou faço FTP caso não exista
1284   - If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then
1285   - Begin
1286   - if (FileExists(ExtractFilePath(Application.Exename) + '\modulos\ger_cols.exe')) then
1287   - Begin
1288   - log_diario('Copiando Ger_Cols.exe de '+ExtractFilePath(Application.Exename)+'modulos\');
1289   - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\ger_cols.exe'), PChar(Dir + '\modulos\ger_cols.exe'),false);
1290   - FileSetAttr (PChar(Dir + '\modulos\ger_cols.exe'),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
1291   - bool_download_GER_COLS := true;
1292   - End
1293   - else
1294   - begin
1295   - if not FTP(v_te_serv_updates,
1296   - v_nu_porta_serv_updates,
1297   - v_nm_usuario_login_serv_updates,
1298   - v_te_senha_login_serv_updates,
1299   - v_te_path_serv_updates,
1300   - 'ger_cols.exe',
1301   - Dir + '\modulos') and (v_exibe_informacoes = 'S') then
1302   - MessageDLG(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+Dir + '\modulos\ger_cols.exe".'+#13#10+'Verifique o Servidor de Updates.',mtError,[mbOK],0);
1303   -
1304   - bool_download_GER_COLS := true;
1305   - If (not FileExists(Dir + '\modulos\ger_cols.exe')) Then
1306   - Begin
1307   - log_diario('Problemas Efetuando Download de Ger_Cols.exe(FTP):');
1308   - log_diario('v_te_serv_updates:'+v_te_serv_updates);
1309   - log_diario('v_nu_porta_serv_updates:'+v_nu_porta_serv_updates);
1310   - log_diario('v_nm_usuario_login_serv_updates:'+v_nm_usuario_login_serv_updates);
1311   - log_diario('v_te_senha_login_serv_updates:'+v_te_senha_login_serv_updates);
1312   - log_diario('v_te_path_serv_updates:'+v_te_path_serv_updates);
1313   - bool_download_GER_COLS := false;
1314   - End
1315   - else log_diario('Download Concluído de Ger_Cols.exe (FTP)');
1316   -
1317   - end;
1318   - End;
  1568 + verifyAndGet('cacic2.exe',
  1569 + Dir,
  1570 + v_te_serv_updates,
  1571 + v_nu_porta_serv_updates,
  1572 + v_nm_usuario_login_serv_updates,
  1573 + v_te_senha_login_serv_updates,
  1574 + v_te_path_serv_updates,
  1575 + v_exibe_informacoes);
  1576 +
  1577 + verifyAndGet('ger_cols.exe',
  1578 + Dir + '\modulos',
  1579 + v_te_serv_updates,
  1580 + v_nu_porta_serv_updates,
  1581 + v_nm_usuario_login_serv_updates,
  1582 + v_te_senha_login_serv_updates,
  1583 + v_te_path_serv_updates,
  1584 + v_exibe_informacoes);
1319 1585  
1320 1586 // Caso exista a pasta "modulos", copio todos os executáveis para a pasta Cacic\modulos, exceto cacic2.exe, ger_cols.exe e chksis.exe
1321 1587 if (v_modulos <> '') then
... ... @@ -1334,7 +1600,56 @@ begin
1334 1600 End;
1335 1601 End;
1336 1602  
1337   - log_diario('Gravando registros para auto-execução');
  1603 + // ATENÇÃO:
  1604 + // Após testes no Vista, percebí que o firewall nativo interrompia o FTP e truncava o agente com tamanho zero...
  1605 + // A nova tentativa abaixo ajudará a sobrepor o agente truncado e corrompido
  1606 +
  1607 + // Tento detectar (de novo) o ChkSis.EXE e copio ou faço FTP caso não exista
  1608 + verifyAndGet('chksis.exe',
  1609 + HomeDrive,
  1610 + v_te_serv_updates,
  1611 + v_nu_porta_serv_updates,
  1612 + v_nm_usuario_login_serv_updates,
  1613 + v_te_senha_login_serv_updates,
  1614 + v_te_path_serv_updates,
  1615 + v_exibe_informacoes);
  1616 +
  1617 + // Tento detectar (de novo) o Agente Principal e copio ou faço FTP caso não exista
  1618 + verifyAndGet('cacic2.exe',
  1619 + Dir,
  1620 + v_te_serv_updates,
  1621 + v_nu_porta_serv_updates,
  1622 + v_nm_usuario_login_serv_updates,
  1623 + v_te_senha_login_serv_updates,
  1624 + v_te_path_serv_updates,
  1625 + v_exibe_informacoes);
  1626 +
  1627 + verifyAndGet('ger_cols.exe',
  1628 + Dir + '\modulos',
  1629 + v_te_serv_updates,
  1630 + v_nu_porta_serv_updates,
  1631 + v_nm_usuario_login_serv_updates,
  1632 + v_te_senha_login_serv_updates,
  1633 + v_te_path_serv_updates,
  1634 + v_exibe_informacoes);
  1635 +
  1636 + if ((intWinVer <> 0) and (intWinVer >= 8)) or
  1637 + (abstraiCSD(v_te_so) >= 250) then // Se >= WinXP...
  1638 + Begin
  1639 + Try
  1640 + // Acrescento o ChkSis e o Ger_Cols às exceções do FireWall nativo...
  1641 +
  1642 + {chksis}
  1643 + LiberaFireWall(HomeDrive + '\chksis');
  1644 +
  1645 + {ger_cols}
  1646 + LiberaFireWall(Dir + '\modulos\ger_cols');
  1647 +
  1648 + Except
  1649 + End;
  1650 + End;
  1651 +
  1652 + log_DEBUG('Gravando registros para auto-execução');
1338 1653  
1339 1654 // Crio a chave/valor cacic2 para autoexecução do Cacic, caso não exista esta chave/valor
1340 1655 // Crio a chave/valor chksis para autoexecução do ChkSIS, caso não exista esta chave/valor
... ... @@ -1348,43 +1663,30 @@ begin
1348 1663  
1349 1664 // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini!
1350 1665 SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic);
1351   - log_diario('Fechando Arquivo de Configurações do CACIC');
  1666 + log_DEBUG('Fechando Arquivo de Configurações do Cacic');
1352 1667 CipherClose(v_DatFileName);
1353   - log_diario('Abrindo Arquivo de Configurações do CHKSIS');
  1668 +
  1669 + log_DEBUG('Abrindo Arquivo de Configurações do ChkSis');
1354 1670 CipherOpen(HomeDrive + '\chksis.dat');
1355 1671 SetValorDatMemoria('Cacic2.ip_serv_cacic', v_ip_serv_cacic);
1356   - // SetValorChaveRegIni('Cacic2', 'ip_serv_cacic', v_ip_serv_cacic, HomeDrive + '\chksis.ini');
  1672 + CipherClose(HomeDrive + '\chksis.dat');
1357 1673  
  1674 + // Volto a gravar o chksis.ini para o difícil caso de leitura por versões antigas
  1675 + SetValorChaveRegIni('Cacic2', 'ip_serv_cacic', v_ip_serv_cacic, HomeDrive + '\chksis.ini');
  1676 + log_DEBUG('Fechando Arquivo de Configurações do ChkSis');
1358 1677  
1359   - // Se NT/2K/XP...
1360   - // If NT Like...
1361   - if (GetWinVer > 5) then
1362   - Begin
1363   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1364   - log_diario('::::::: VERIFICANDO FILE SYSTEM E ATRIBUINDO PERMISSÕES :::::::');
1365   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1366   - Form1.FS_SetSecurity(Dir);
1367   - Form1.FS_SetSecurity(Dir + '\cacic2.exe');
1368   - Form1.FS_SetSecurity(Dir + '\modulos');
1369   - Form1.FS_SetSecurity(Dir + '\temp');
1370   - Form1.FS_SetSecurity(v_DatFileName) ; // cacic2.dat
  1678 + log_DEBUG('Resgatando informações para identificação de alteração do agente CACIC2');
  1679 + // Pego as informações de dia/mês/ano/horas/minutos/segundos/milésimos que identificam os agentes
  1680 + strDataHoraCACIC2_FIM := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\cacic2.exe'));
  1681 + log_DEBUG('Inicial => "' + strDataHoraCACIC2_INI + '" Final => "' + strDataHoraCACIC2_FIM + '"');
1371 1682  
1372   - // Atribuição de acesso a todos os módulos para permissão de atualizações de versão
1373   - Form1.FS_SetSecurity(Dir + '\modulos\ger_cols.exe');
1374   - Form1.FS_SetSecurity(Dir + '\modulos\col_anvi.exe');
1375   - Form1.FS_SetSecurity(Dir + '\modulos\col_comp.exe');
1376   - Form1.FS_SetSecurity(Dir + '\modulos\col_hard.exe');
1377   - Form1.FS_SetSecurity(Dir + '\modulos\col_moni.exe');
1378   - Form1.FS_SetSecurity(Dir + '\modulos\col_patr.exe');
1379   - Form1.FS_SetSecurity(Dir + '\modulos\col_soft.exe');
1380   - Form1.FS_SetSecurity(Dir + '\modulos\col_undi.exe');
1381   - Form1.FS_SetSecurity(Dir + '\modulos\ini_cols.exe');
1382   - Form1.FS_SetSecurity(Dir + '\modulos\wscript.exe');
1383   - log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::');
1384   - End;
  1683 + log_DEBUG('Resgatando informações para identificação de alteração do agente GER_COLS');
  1684 + strDataHoraGERCOLS_FIM := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(Dir + '\modulos\ger_cols.exe'));
  1685 + log_DEBUG('Inicial => "' + strDataHoraGERCOLS_INI + '" Final => "' + strDataHoraGERCOLS_FIM + '"');
1385 1686  
1386 1687 // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor
1387   - if (bool_download_CACIC2) or (bool_download_GER_COLS) then
  1688 + if ((strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) OR
  1689 + (strDataHoraGERCOLS_INI <> strDataHoraGERCOLS_FIM)) then
1388 1690 Begin
1389 1691 v_te_texto_janela_instalacao := v_te_instala_informacoes_extras;
1390 1692 if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then
... ... @@ -1395,26 +1697,26 @@ begin
1395 1697 else if (v_exibe_informacoes = 'S') then
1396 1698 MessageDlg(#13#10+#13#10+v_te_instala_frase_insucesso+#13#10+#13#10+#13#10 + '======================================================' + #13#10 + v_te_texto_janela_instalacao+ '======================================================',mtInformation,[mbok],0);
1397 1699  
1398   - // Se eu não encontrei a chave de autoexecução ou
1399   - // Se a unidade origem de chamada ao ChkCacic refere-se a Floppy, CDROM ou Flash
1400   - // Eu executo o agente principal
1401   - strAux := DriveType(Copy(ExtractFilePath(Application.Exename),1,1));
1402   - if not bool_ExistsAutoRun or
1403   - (not(strAux = 'ERRO') and
1404   - not(strAux = 'REDE')) then
1405   - Begin
1406   - log_diario('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic);
1407   - WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE);
1408   - End
1409   - else
1410   - log_diario('Não Executei. Chave de AutoExecução já existente...');
1411   -
1412 1700 End
1413 1701 else
1414   - log_diario('ATENÇÃO: A Instalação NÃO Foi Realizada com Sucesso ou Atualização Desnecessária!');
  1702 + log_diario('ATENÇÃO: Instalação NÃO REALIZADA ou ATUALIZAÇÃO DESNECESSÁRIA!');
  1703 +
  1704 + if Posso_Rodar_CACIC or not bool_ExistsAutoRun then
  1705 + Begin
  1706 + log_DEBUG('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic);
  1707 +
  1708 + // Caso tenha havido download de agentes principais, executar coletas imediatamente...
  1709 + if ((strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) OR
  1710 + (strDataHoraGERCOLS_INI <> strDataHoraGERCOLS_FIM)) then
  1711 + WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE)
  1712 + else
  1713 + WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE);
  1714 + End
  1715 + else
  1716 + log_DEBUG('Chave de Auto-Execução já existente ou Execução já iniciada...');
1415 1717 End;
1416 1718 Except
1417   - log_diario('Falha na instalação');
  1719 + log_diario('Falha na Instalação/Atualização');
1418 1720 End;
1419 1721  
1420 1722 end;
... ... @@ -1508,10 +1810,12 @@ end;
1508 1810 procedure TForm1.FormCreate(Sender: TObject);
1509 1811 begin
1510 1812 Application.ShowMainForm:=false;
1511   - if (FindWindowByTitle('chksis') = 0) then
1512   - chkcacic
1513   - else
1514   - log_diario('Não executei devido execução em paralelo de "chksis"');
  1813 + v_Debugs := false;
  1814 +
  1815 +// if (FindWindowByTitle('chksis') = 0) then
  1816 + chkcacic;
  1817 +// else
  1818 +// log_diario('Não executei devido execução em paralelo de "chksis"');
1515 1819  
1516 1820 Application.Terminate;
1517 1821 end;
... ... @@ -1519,6 +1823,7 @@ end;
1519 1823 procedure TForm1.FS_SetSecurity(p_Target : String);
1520 1824 var intAux : integer;
1521 1825 v_FS_Security : TNTFileSecurity;
  1826 + boolFound : boolean;
1522 1827 begin
1523 1828 v_FS_Security := TNTFileSecurity.Create(nil);
1524 1829 v_FS_Security.FileName := '';
... ... @@ -1529,21 +1834,13 @@ begin
1529 1834 Begin
1530 1835 for intAux := 0 to Pred(v_FS_Security.EntryCount) do
1531 1836 begin
1532   - case v_FS_Security.EntryType[intAux] of
1533   - seAlias : Try
1534   - // Atribuo total privilégio aos grupos locais sobre a pasta "CACIC"
1535   - // Set all privilegies to local groups on p_Target
1536   - case v_FS_Security.EntryType[intAux] of
1537   - seAlias : // Se for grupo local...
1538   - Begin // If local group...
1539   - v_FS_Security.FileRights[intAux] := [faAll];
1540   - v_FS_Security.DirectoryRights[intAux] := [faAll];
1541   - log_diario(p_Target + ' [Full Access] >> '+v_FS_Security.EntryName[intAux]);
1542   - //Setting total access on p_Target to local groups.
1543   - End;
1544   - end;
1545   - Except
1546   - End;
  1837 + case v_FS_Security.EntryType[intAux] of seAlias, seDomain, seGroup :
  1838 + Begin // If local group, alias or user...
  1839 + v_FS_Security.FileRights[intAux] := [faAll];
  1840 + v_FS_Security.DirectoryRights[intAux] := [faAll];
  1841 + log_DEBUG(p_Target + ' [Full Access] >> '+v_FS_Security.EntryName[intAux]);
  1842 + //Setting total access on p_Target to local groups.
  1843 + End;
1547 1844 End;
1548 1845 end;
1549 1846  
... ... @@ -1551,7 +1848,7 @@ begin
1551 1848 // Set total permissions to local groups
1552 1849 v_FS_Security.SetSecurity;
1553 1850 end
1554   - else Log_diario('File System diferente de "NTFS"');
  1851 + else Log_diario('File System: "' + v_FS_Security.FileSystemName+'" - Ok!');
1555 1852  
1556 1853 v_FS_Security.Free;
1557 1854 end;
... ...
chksis/chksis.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=8
  118 +Build=20
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev - Unidade Regional Espírito Santo (URES)
128 128 FileDescription=Módulo Verificador de Integridade do Sistema CACIC
129   -FileVersion=2.2.0.8
  129 +FileVersion=2.2.0.20
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.1
  134 +ProductName=ChkSIS
  135 +ProductVersion=2.2.0.20
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
chksis/chksis.dpr
... ... @@ -38,7 +38,8 @@ uses Windows,
38 38 Winsock,
39 39 DCPcrypt2,
40 40 DCPrijndael,
41   - DCPbase64;
  41 + DCPbase64,
  42 + Tlhelp32;
42 43  
43 44 var PJVersionInfo1: TPJVersionInfo;
44 45 Dir,
... ... @@ -48,8 +49,7 @@ var PJVersionInfo1: TPJVersionInfo;
48 49 v_strCipherClosed,
49 50 v_DatFileName,
50 51 v_versao_local,
51   - v_versao_remota_inteira,
52   - v_versao_remota_capada,
  52 + v_versao_remota,
53 53 v_retorno : String;
54 54  
55 55 var v_tstrCipherOpened : TStrings;
... ... @@ -632,6 +632,156 @@ begin
632 632 Result := 0;
633 633 end;
634 634  
  635 +// Rotina obtida em http://www.swissdelphicenter.ch/torry/showcode.php?id=266
  636 +{For Windows 9x/ME/2000/XP }
  637 +function KillTask(ExeFileName: string): Integer;
  638 +const
  639 + PROCESS_TERMINATE = $0001;
  640 +var
  641 + ContinueLoop: BOOL;
  642 + FSnapshotHandle: THandle;
  643 + FProcessEntry32: TProcessEntry32;
  644 +begin
  645 + Result := 0;
  646 + FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  647 + FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  648 + ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  649 +
  650 + while Integer(ContinueLoop) <> 0 do
  651 + begin
  652 + if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
  653 + UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
  654 + UpperCase(ExeFileName))) then
  655 + Result := Integer(TerminateProcess(
  656 + OpenProcess(PROCESS_TERMINATE,
  657 + BOOL(0),
  658 + FProcessEntry32.th32ProcessID),
  659 + 0));
  660 + ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  661 + end;
  662 + CloseHandle(FSnapshotHandle);
  663 +end;
  664 +
  665 +// Rotina obtida em http://www.swissdelphicenter.ch/torry/showcode.php?id=266
  666 +{ For Windows NT/2000/XP }
  667 +procedure KillProcess(hWindowHandle: HWND);
  668 +var
  669 + hprocessID: INTEGER;
  670 + processHandle: THandle;
  671 + DWResult: DWORD;
  672 +begin
  673 + SendMessageTimeout(hWindowHandle, WM_DDE_TERMINATE, 0, 0,
  674 + SMTO_ABORTIFHUNG or SMTO_NORMAL, 5000, DWResult);
  675 +
  676 + if isWindow(hWindowHandle) then
  677 + begin
  678 + // PostMessage(hWindowHandle, WM_QUIT, 0, 0);
  679 +
  680 + { Get the process identifier for the window}
  681 + GetWindowThreadProcessID(hWindowHandle, @hprocessID);
  682 + if hprocessID <> 0 then
  683 + begin
  684 + { Get the process handle }
  685 + processHandle := OpenProcess(PROCESS_TERMINATE or PROCESS_QUERY_INFORMATION,
  686 + False, hprocessID);
  687 + if processHandle <> 0 then
  688 + begin
  689 + { Terminate the process }
  690 + TerminateProcess(processHandle, 0);
  691 + CloseHandle(ProcessHandle);
  692 + end;
  693 + end;
  694 + end;
  695 +end;
  696 +
  697 +
  698 +// Dica baixada de http://procedure.blig.ig.com.br/
  699 +// Adaptada por Anderson Peterle - v:2.2.0.16 - 03/2007
  700 +procedure Matar(v_dir,v_files: string);
  701 +var SearchRec: TSearchRec;
  702 + Result: Integer;
  703 + strFileName : String;
  704 +begin
  705 + strFileName := StringReplace(v_dir + '\' + v_files,'\\','\',[rfReplaceAll]);
  706 + Result:=FindFirst(strFileName, faAnyFile, SearchRec);
  707 + while result=0 do
  708 + begin
  709 + strFileName := StringReplace(v_dir + '\' + SearchRec.Name,'\\','\',[rfReplaceAll]);
  710 + log_diario('Tentando Excluir: '+strFileName,ExtractFilePath(ParamStr(0)));
  711 + if DeleteFile(strFileName) then
  712 + log_diario('Exclusão de ' + strFileName + ' efetuada com sucesso!',ExtractFilePath(ParamStr(0)))
  713 + else
  714 + Begin
  715 + log_diario('Exclusão não efetuada! Provavelmente já esteja sendo executado...',ExtractFilePath(ParamStr(0)));
  716 + log_diario('Tentarei finalizar Tarefa/Processo...',ExtractFilePath(ParamStr(0)));
  717 + if (GetWinVer <= 5) then // Até
  718 + KillTask(SearchRec.Name)
  719 + else
  720 + KillProcess(FindWindow(PChar(SearchRec.Name),nil));
  721 +
  722 + if DeleteFile(strFileName) then
  723 + log_diario('Exclusão Impossibilitada de ' + strFileName + '!',ExtractFilePath(ParamStr(0)));
  724 + End;
  725 +
  726 + Result:=FindNext(SearchRec);
  727 + end;
  728 +end;
  729 +
  730 +function Posso_Rodar_CACIC : boolean;
  731 +Begin
  732 + result := false;
  733 +
  734 + // Se o aguarde_CACIC.txt existir é porque refere-se a uma versão mais atual: 2.2.0.20 ou maior
  735 + if (FileExists(Dir + 'aguarde_CACIC.txt')) then
  736 + Begin
  737 + // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) )
  738 + Matar(Dir,'aguarde_CACIC.txt');
  739 + if (not (FileExists(Dir + 'aguarde_CACIC.txt'))) then
  740 + result := true;
  741 + End;
  742 +End;
  743 +
  744 +Function ChecaVersoesAgentes(p_strNomeAgente : String) : integer;
  745 +var v_versao_REM,
  746 + v_versao_LOC,
  747 + strNomeAgente : String;
  748 + v_array_NomeAgente : TStrings;
  749 + intAux : integer;
  750 +Begin
  751 + v_array_NomeAgente := explode(p_strNomeAgente,'\');
  752 +
  753 + v_versao_REM := XML_RetornaValor(StringReplace(StrUpper(PChar(v_array_NomeAgente[v_array_NomeAgente.count-1])),'.EXE','',[rfReplaceAll]), v_retorno);
  754 + v_versao_LOC := GetVersionInfo(p_strNomeAgente);
  755 +
  756 + log_diario('Checando versão de "'+p_strNomeAgente+'"',ExtractFilePath(ParamStr(0)));
  757 +
  758 + intAux := v_array_NomeAgente.Count;
  759 +
  760 + // V: 2.2.0.16
  761 + // Verifico existência do arquivo "versoes_agentes.ini" para comparação das versões dos agentes principais
  762 + if (v_versao_REM = '') AND FileExists(ExtractFilePath(Application.Exename)+'versoes_agentes.ini') then
  763 + Begin
  764 + if (GetValorChaveRegIni('versoes_agentes',v_array_NomeAgente[intAux-1],ExtractFilePath(Application.Exename)+'versoes_agentes.ini')<>'') then
  765 + Begin
  766 + log_diario('Encontrado arquivo "'+(ExtractFilePath(Application.Exename)+'versoes_agentes.ini')+'"',ExtractFilePath(ParamStr(0)));
  767 + v_versao_REM := GetValorChaveRegIni('versoes_agentes',v_array_NomeAgente[intAux-1],ExtractFilePath(Application.Exename)+'versoes_agentes.ini');
  768 + End;
  769 + End;
  770 +
  771 + log_diario('Versão Remota: "'+v_versao_REM+'" - Versão Local: "'+v_versao_LOC+'"',ExtractFilePath(ParamStr(0)));
  772 +
  773 + if (v_versao_REM + v_versao_LOC <> '') and
  774 + (v_versao_LOC <> '0000') then
  775 + Begin
  776 + if (v_versao_REM = v_versao_LOC) then
  777 + Result := 1
  778 + else
  779 + Result := 2;
  780 + End
  781 + else
  782 + Result := 0;
  783 +End;
  784 +
635 785 procedure executa_chksis;
636 786 var
637 787 bool_download_CACIC2,
... ... @@ -642,6 +792,7 @@ var
642 792 Request_Config : TStringList;
643 793 Response_Config : TStringStream;
644 794 IdHTTP1: TIdHTTP;
  795 + intAux : integer;
645 796 begin
646 797 bool_download_CACIC2 := false;
647 798 v_home_drive := MidStr(HomeDrive,1,3); //x:\
... ... @@ -670,7 +821,7 @@ begin
670 821 if not DirectoryExists(Dir+'\modulos') then
671 822 begin
672 823 log_diario('Excluindo '+ Dir + '\cacic2.exe',ExtractFilePath(ParamStr(0)));
673   - DeleteFile(Dir + '\cacic2.exe');
  824 + Matar(Dir,'\cacic2.exe');
674 825 log_diario('Criando diretório ' + Dir + '\modulos',ExtractFilePath(ParamStr(0)));
675 826 ForceDirectories(Dir + '\modulos');
676 827 end;
... ... @@ -688,7 +839,7 @@ begin
688 839 // SetValorChaveRegIni('Configs', 'EnderecoServidor', v_ip_serv_cacic, Dir + '\cacic2.ini');
689 840  
690 841 //chave AES. Recomenda-se que cada empresa altere a sua chave.
691   - v_CipherKey := 'CacicES2005';
  842 + v_CipherKey := 'CacicBrasil';
692 843 v_IV := 'abcdefghijklmnop';
693 844 v_SeparatorKey := '=CacicIsFree=';
694 845 v_DatFileName := Dir + '\cacic2.dat';
... ... @@ -722,11 +873,19 @@ begin
722 873 v_te_senha_login_serv_updates := XML_RetornaValor('te_senha_login_serv_updates' , Response_Config.DataString);
723 874 v_te_path_serv_updates := XML_RetornaValor('te_path_serv_updates' , Response_Config.DataString);
724 875  
725   - log_diario(':::::::::::::: PARÂMETROS OBTIDOS NO Gerente WEB ::::::::::::::',ExtractFilePath(ParamStr(0)));
  876 + log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::',ExtractFilePath(ParamStr(0)));
  877 + log_diario(':::::::::::::::: VALORES OBTIDOS NO Gerente WEB :::::::::::::::',ExtractFilePath(ParamStr(0)));
  878 + log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::',ExtractFilePath(ParamStr(0)));
726 879 log_diario('Servidor de updates......................: '+v_te_serv_updates,ExtractFilePath(ParamStr(0)));
727 880 log_diario('Porta do servidor de updates.............: '+v_nu_porta_serv_updates,ExtractFilePath(ParamStr(0)));
728 881 log_diario('Usuário para login no servidor de updates: '+v_nm_usuario_login_serv_updates,ExtractFilePath(ParamStr(0)));
729 882 log_diario('Pasta no servidor de updates.............: '+v_te_path_serv_updates,ExtractFilePath(ParamStr(0)));
  883 + log_diario(' ',ExtractFilePath(ParamStr(0)));
  884 + log_diario('Versões dos Agentes Principais:',ExtractFilePath(ParamStr(0)));
  885 + log_diario('------------------------------',ExtractFilePath(ParamStr(0)));
  886 + log_diario('Cacic2 - Agente do Systray.........: '+XML_RetornaValor('CACIC2', v_retorno),ExtractFilePath(ParamStr(0)));
  887 + log_diario('Ger_Cols - Gerente de Coletas........: '+XML_RetornaValor('GER_COLS', v_retorno),ExtractFilePath(ParamStr(0)));
  888 + log_diario('ChkSis - Verificador de Integridade: '+XML_RetornaValor('CHKSIS', v_retorno),ExtractFilePath(ParamStr(0)));
730 889 log_diario(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::',ExtractFilePath(ParamStr(0)));
731 890  
732 891 Except log_diario('Falha no contato com ' + 'http://' + v_ip_serv_cacic + '/cacic2/ws/get_config.php',ExtractFilePath(ParamStr(0)));
... ... @@ -738,37 +897,39 @@ begin
738 897 // Verificação de versão do cacic2.exe e exclusão em caso de versão antiga
739 898 If (FileExists(Dir + '\cacic2.exe')) Then
740 899 Begin
741   - v_versao_local := trim(GetVersionInfo(Dir + '\cacic2.exe'));
742   - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
743   -
744   - v_versao_remota_inteira := XML_RetornaValor('CACIC2' , v_retorno);
745   - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
746   -
747   - if (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida
748   - (v_versao_local <> v_versao_remota_capada) then
  900 + intAux := ChecaVersoesAgentes(Dir + '\cacic2.exe');
  901 + // 0 => Arquivo de versões ou informação inexistente
  902 + // 1 => Versões iguais
  903 + // 2 => Versões diferentes
  904 + if (intAux = 0) then
749 905 Begin
750   - //log_diario('Excluindo versão "'+v_versao_local+'" de Cacic2.exe',ExtractFilePath(ParamStr(0)));
751   - DeleteFile(Dir + '\cacic2.exe');
  906 + v_versao_local := StringReplace(trim(GetVersionInfo(Dir + '\cacic2.exe')),'.','',[rfReplaceAll]);
  907 + v_versao_remota := StringReplace(XML_RetornaValor('CACIC2' , v_retorno),'0103','',[rfReplaceAll]);
752 908 End;
  909 +
  910 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  911 + (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida
  912 + (v_versao_local ='2208') then
  913 + Matar(Dir, '\cacic2.exe');
753 914 End;
754 915  
755 916 // Verificação de versão do ger_cols.exe e exclusão em caso de versão antiga
756 917 If (FileExists(Dir + '\modulos\ger_cols.exe')) Then
757 918 Begin
758   - v_versao_local := trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe'));
759   - v_versao_local := StringReplace(v_versao_local,'.','',[rfReplaceAll]);
760   -
761   - v_versao_remota_inteira := XML_RetornaValor('GER_COLS' , v_retorno);
762   - v_versao_remota_capada := Copy(v_versao_remota_inteira,1,StrLen(PAnsiChar(v_versao_remota_inteira))-4);
763   -
764   - //log_diario('Versão remota de "ger_cols.exe": '+v_versao_remota_capada + ' ('+v_versao_remota_inteira+')',ExtractFilePath(ParamStr(0)));
765   -
766   - if (v_versao_local ='0000') or // Provavelmente versão muito antiga ou corrompida
767   - (v_versao_local <> v_versao_remota_capada) then
  919 + intAux := ChecaVersoesAgentes(Dir + '\modulos\ger_cols.exe');
  920 + // 0 => Arquivo de versões ou informação inexistente
  921 + // 1 => Versões iguais
  922 + // 2 => Versões diferentes
  923 + if (intAux = 0) then
768 924 Begin
769   - //log_diario('Excluindo versão "'+v_versao_local+'" de Ger_Cols.exe',ExtractFilePath(ParamStr(0)));
770   - DeleteFile(Dir + '\modulos\ger_cols.exe');
  925 + v_versao_local := StringReplace(trim(GetVersionInfo(Dir + '\modulos\ger_cols.exe')),'.','',[rfReplaceAll]);
  926 + v_versao_remota := StringReplace(XML_RetornaValor('GER_COLS' , v_retorno),'0103','',[rfReplaceAll]);
771 927 End;
  928 +
  929 + if (intAux = 2) or // Caso haja diferença na comparação de versões com "versoes_agentes.ini"...
  930 + (v_versao_local ='0000') then // Provavelmente versão muito antiga ou corrompida
  931 + Matar(Dir + '\modulos\', 'ger_cols.exe');
  932 +
772 933 End;
773 934  
774 935 // Tento detectar o Agente Principal e faço FTP caso não exista
... ... @@ -822,18 +983,25 @@ begin
822 983 SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2', Dir + '\cacic2.exe');
823 984  
824 985 // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor
825   - if (bool_download_CACIC2) then
826   - Begin
827   - if not bool_ExistsAutoRun then
828   - Begin
829   - log_diario('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic,ExtractFilePath(ParamStr(0)));
830   - WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE);
831   - End
832   - else
833   - log_diario('Não Executei. Chave de AutoExecução já existente...',ExtractFilePath(ParamStr(0)));
834   - End
835   -end;
  986 + //if (bool_download_CACIC2) then
  987 + //Begin
  988 + //if not bool_ExistsAutoRun then
  989 + // Begin
  990 + if Posso_Rodar_CACIC or not bool_ExistsAutoRun then
  991 + Begin
  992 + log_diario('Executando '+Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic,ExtractFilePath(ParamStr(0)));
836 993  
  994 + // Caso tenha havido download de agentes principais, executar coletas imediatamente...
  995 + if (bool_download_CACIC2) then
  996 + WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE)
  997 + else
  998 + WinExec(PChar(Dir + '\cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE);
  999 + End;
  1000 + // End
  1001 + // else
  1002 + // log_diario('Não Executei. Chave de AutoExecução já existente...',ExtractFilePath(ParamStr(0)));
  1003 + //End
  1004 +end;
837 1005  
838 1006 begin
839 1007 // Application.ShowMainForm:=false;
... ...
chksis/chksis.res
No preview for this file type
col_anvi/col_anvi.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=1
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=2070
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Coletor de Informações de AntiVírus do Sistema CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.1
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.1
  134 +ProductName=Col_ANVI
  135 +ProductVersion=2.2.0.1
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_anvi/col_anvi.dpr
... ... @@ -493,6 +493,7 @@ var Lista1_RCO : TStringList;
493 493 searchResult : TSearchRec; // Necessário apenas para Win9x
494 494 begin
495 495 Try
  496 + SetValorDatMemoria('Col_Anvi.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
496 497 nu_versao_engine := '';
497 498 nu_versao_pattern := '';
498 499 log_diario('Coletando informações de Antivírus OfficeScan.');
... ... @@ -552,6 +553,9 @@ begin
552 553 in_ativo);
553 554 // Obtenho do registro o valor que foi previamente armazenado
554 555 ValorChaveRegistro := Trim(GetValorDatMemoria('Coletas.OfficeScan',v_tstrCipherOpened));
  556 +
  557 + SetValorDatMemoria('Col_Anvi.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  558 +
555 559 log_DEBUG('Registro Anterior: ' + ValorChaveRegistro);
556 560 log_DEBUG('Registro Atual...: ' + UVC);
557 561 // Se essas informações forem diferentes significa que houve alguma alteração
... ... @@ -576,6 +580,7 @@ begin
576 580 Except
577 581 Begin
578 582 SetValorDatMemoria('Col_Anvi.nada', 'nada', v_tstrCipherOpened1);
  583 + SetValorDatMemoria('Col_Anvi.Fim', '99999999', v_tstrCipherOpened1);
579 584 CipherClose(p_path_cacic + 'temp\col_anvi.dat', v_tstrCipherOpened1);
580 585 End;
581 586 End;
... ...
col_anvi/col_anvi.res
No preview for this file type
col_comp/col_comp.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=1
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=2070
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Coletor de Informações de Compartilhamento do Sistema CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.1
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.1
  134 +ProductName=Col_COMP
  135 +ProductVersion=2.2.0.1
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_comp/col_comp.dpr
... ... @@ -438,6 +438,7 @@ var Reg_RCC : TRegistry;
438 438 Lista_RCC : TStringList;
439 439 Begin
440 440 Try
  441 + SetValorDatMemoria('Col_Comp.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
441 442 nm_compartilhamento := '';
442 443 nm_dir_compart := '';
443 444 cs_tipo_compart := ' ';
... ... @@ -530,6 +531,8 @@ Begin
530 531 // Obtenho do registro o valor que foi previamente armazenado
531 532 ValorChaveRegistro := Trim(GetValorDatMemoria('Coletas.Compartilhamentos'));
532 533  
  534 + SetValorDatMemoria('Col_Comp.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  535 +
533 536 // Se essas informações forem diferentes significa que houve alguma alteração
534 537 // na configuração. Nesse caso, gravo as informações no BD Central e, se não houver
535 538 // problemas durante esse procedimento, atualizo as informações no registro.
... ... @@ -548,6 +551,7 @@ Begin
548 551 Except
549 552 Begin
550 553 SetValorDatMemoria('Col_Comp.nada', 'nada', v_tstrCipherOpened1);
  554 + SetValorDatMemoria('Col_Comp.Fim', '99999999', v_tstrCipherOpened1);
551 555 CipherClose(p_path_cacic + 'temp\col_comp.dat', v_tstrCipherOpened1);
552 556 End;
553 557 End;
... ...
col_comp/col_comp.res
No preview for this file type
col_hard/col_hard.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=1
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=2070
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Coletor de Informações de Hardware do Sistema CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.1
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.2
  134 +ProductName=Col_Hard
  135 +ProductVersion=2.2.0.1
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_hard/col_hard.dpr
... ... @@ -664,6 +664,7 @@ var v_te_cpu_freq, v_te_cpu_fabricante, v_te_cpu_desc, v_te_cpu_serial, v_te_pla
664 664 v_Report : TStringList;
665 665 begin
666 666 Try
  667 + SetValorDatMemoria('Col_Hard.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
667 668 v_Report := TStringList.Create;
668 669 log_diario('Coletando informações de Hardware.');
669 670  
... ... @@ -936,6 +937,8 @@ begin
936 937 // Obtenho do registro o valor que foi previamente armazenado
937 938 ValorChaveRegistro := Trim(GetValorDatMemoria('Coletas.Hardware',v_tstrCipherOpened));
938 939  
  940 + SetValorDatMemoria('Col_Hard.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  941 +
939 942 // Se essas informações forem diferentes significa que houve alguma alteração
940 943 // na configuração de hardware. Nesse caso, gravo as informações no BD Central
941 944 // e, se não houver problemas durante esse procedimento, atualizo as
... ... @@ -973,11 +976,13 @@ begin
973 976 else
974 977 Begin
975 978 SetValorDatMemoria('Col_Hard.nada','nada', v_tstrCipherOpened1);
  979 + SetValorDatMemoria('Col_Hard.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
976 980 CipherClose(p_path_cacic + 'temp\col_hard.dat', v_tstrCipherOpened1);
977 981 End;
978 982 Except
979 983 Begin
980 984 SetValorDatMemoria('Col_Hard.nada','nada', v_tstrCipherOpened1);
  985 + SetValorDatMemoria('Col_Hard.Fim' , '99999999', v_tstrCipherOpened1);
981 986 CipherClose(p_path_cacic + 'temp\col_hard.dat', v_tstrCipherOpened1);
982 987 log_diario('Problema na execução => ' + v_mensagem);
983 988 End;
... ...
col_hard/col_hard.res
No preview for this file type
col_moni/col_moni.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=2
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -126,13 +126,13 @@ CodePage=1252
126 126 [Version Info Keys]
127 127 CompanyName=Dataprev/ES
128 128 FileDescription=Coletor de Informações de Sistemas Monitorados do pelo CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.2
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.1
  134 +ProductName=Col_MONI
  135 +ProductVersion=2.2.0.2
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_moni/col_moni.dpr
... ... @@ -575,6 +575,7 @@ var tstrTripa2, tstrTripa3, v_array1, v_array2, v_array3, v_array4 : TStrings;
575 575  
576 576 begin
577 577 Try
  578 + SetValorDatMemoria('Col_Moni.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
578 579 // Verifica se deverá ser realizada a coleta de informações de sistemas monitorados neste
579 580 // computador, perguntando ao agente gerente.
580 581 log_diario('Coletando informações de Sistemas Monitorados.');
... ... @@ -727,8 +728,8 @@ begin
727 728 Begin
728 729 strAux1 := '';
729 730 Try
730   - log_debug('Buscando informação de INSTALAÇÃO em '+tstrTripa2[5]);
731   - strAux1 := Trim(GetValorChaveRegEdit(trim(tstrTripa2[5])));
  731 + log_debug('Buscando informação de INSTALAÇÃO em '+tstrTripa2[6]);
  732 + strAux1 := Trim(GetValorChaveRegEdit(trim(tstrTripa2[6])));
732 733 Except
733 734 End;
734 735 if (strAux1 <> '') then strAux := strAux + 'S,';
... ... @@ -1006,6 +1007,8 @@ begin
1006 1007  
1007 1008 UVC := Trim(GetValorDatMemoria('Coletas.Sistemas_Monitorados',v_tstrCipherOpened));
1008 1009  
  1010 + SetValorDatMemoria('Col_Moni.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  1011 +
1009 1012 If (GetValorDatMemoria('Configs.IN_COLETA_FORCADA_MONI',v_tstrCipherOpened)='S') or (trim(strAux) <> trim(UVC)) Then
1010 1013 Begin
1011 1014 if (trim(UVC) <> '') then
... ... @@ -1044,6 +1047,7 @@ begin
1044 1047 Except
1045 1048 Begin
1046 1049 SetValorDatMemoria('Col_Moni.nada', 'nada', v_tstrCipherOpened1);
  1050 + SetValorDatMemoria('Col_Moni.Fim', '99999999', v_tstrCipherOpened1);
1047 1051 CipherClose(p_path_cacic + 'temp\col_moni.dat', v_tstrCipherOpened1);
1048 1052 End;
1049 1053 End;
... ...
col_moni/col_moni.res
No preview for this file type
col_patr/col_patr.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=1
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Coletor de Informações de Patrimônio do Sistema CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.1
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=1.0.0.0
  134 +ProductName=Col_PATR
  135 +ProductVersion=2.2.0.1
136 136 Comments=Baseado na Licença GPL(General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_patr/col_patr.res
No preview for this file type
col_patr/main_col_patr.dcu
No preview for this file type
col_patr/main_col_patr.pas
... ... @@ -739,6 +739,7 @@ begin
739 739 strAux2 := VetorUON2Filtrado[id_unid_organizacional_nivel2.ItemIndex];
740 740 Except
741 741 end;
  742 + SetValorDatMemoria('Col_Patr.Fim', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
742 743 if (strAux1 <> var_id_unid_organizacional_nivel1) or
743 744 (strAux2 <> var_id_unid_organizacional_nivel2) or
744 745 (te_localizacao_complementar.Text <> var_te_localizacao_complementar) or
... ... @@ -997,15 +998,19 @@ Begin
997 998  
998 999 if boolColeta then
999 1000 Begin
  1001 + SetValorDatMemoria('Col_Patr.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
1000 1002 log_diario('Coletando informações de Patrimônio e Localização Física.');
1001 1003 v_configs := GetValorDatMemoria('Patrimonio.Configs',v_tstrCipherOpened);
1002 1004 log_DEBUG('Configurações obtidas: '+v_configs);
  1005 +
1003 1006 MontaInterface;
1004 1007 MontaCombos;
1005 1008 RecuperaValoresAnteriores;
  1009 +
1006 1010 End;
1007 1011 Except
1008 1012 SetValorDatMemoria('Col_Patr.nada','nada', v_tstrCipherOpened1);
  1013 + SetValorDatMemoria('Col_Patr.Fim', '99999999', v_tstrCipherOpened1);
1009 1014 CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1);
1010 1015 Application.Terminate;
1011 1016 End;
... ...
col_soft/col_soft.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=1
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Coletor de Informações de Softwares Básicos do Sistema CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.1
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.1
  134 +ProductName=Col_SOFT
  135 +ProductVersion=2.2.0.1
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_soft/col_soft.dpr
... ... @@ -633,7 +633,7 @@ var te_versao_mozilla, te_versao_ie, te_versao_jre, te_versao_acrobat_reader,
633 633 begin
634 634 Try
635 635 log_diario('Coletando informações de Softwares Básicos.');
636   -
  636 + SetValorDatMemoria('Col_Soft.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
637 637 te_versao_mozilla := GetVersaoMozilla;
638 638 te_versao_ie := GetVersaoIE;
639 639 te_versao_jre := GetVersaoJRE;
... ... @@ -719,6 +719,8 @@ begin
719 719 // Obtenho do registro o valor que foi previamente armazenado
720 720 ValorChaveRegistro := Trim(GetValorDatMemoria('Coletas.Software',v_tstrCipherOpened));
721 721  
  722 + SetValorDatMemoria('Col_Soft.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  723 +
722 724 // Se essas informações forem diferentes significa que houve alguma alteração
723 725 // na configuração. Nesse caso, gravo as informações no BD Central
724 726 // e, se não houver problemas durante esse procedimento, atualizo as
... ... @@ -761,6 +763,7 @@ begin
761 763 Except
762 764 Begin
763 765 SetValorDatMemoria('Col_Soft.nada', 'nada', v_tstrCipherOpened1);
  766 + SetValorDatMemoria('Col_Soft.Fim' , '99999999', v_tstrCipherOpened1);
764 767 CipherClose(p_path_cacic + 'temp\col_soft.dat', v_tstrCipherOpened1);
765 768 End;
766 769 End;
... ...
col_soft/col_soft.res
No preview for this file type
col_undi/col_undi.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=0
  118 +Build=1
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Coletor de Informações de Unidades de Disco do Sistema CACIC
129   -FileVersion=2.2.0.0
  129 +FileVersion=2.2.0.1
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.1
  134 +ProductName=Col_UNDI
  135 +ProductVersion=2.2.0.1
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
col_undi/col_undi.dpr
... ... @@ -492,7 +492,8 @@ var strXML, strAux, id_tipo_unid_disco, ValorChaveRegistro : String;
492 492 v_DISK : TMiTeC_Disk;
493 493 v_Report : TstringList;
494 494 Begin
495   - log_diario('Coletando informações de Unidades de Disco.');
  495 + SetValorDatMemoria('Col_Undi.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  496 + log_diario('Coletando informações de Unidades de Disco.');
496 497 Try
497 498 strXML := '<?xml version="1.0" encoding="ISO-8859-1"?><unidades>';
498 499 v_DISK := TMiTeC_Disk.Create(nil);
... ... @@ -540,6 +541,8 @@ Begin
540 541 // Obtenho do registro o valor que foi previamente armazenado
541 542 ValorChaveRegistro := Trim(GetValorDatMemoria('Coletas.UnidadesDisco',v_tstrCipherOpened));
542 543  
  544 + SetValorDatMemoria('Col_Undi.Fim' , FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1);
  545 +
543 546 // Se essas informações forem diferentes significa que houve alguma alteração
544 547 // na configuração. Nesse caso, gravo as informações no BD Central e, se não houver
545 548 // problemas durante esse procedimento, atualizo as informações no registro.
... ... @@ -566,6 +569,7 @@ Begin
566 569 End;
567 570 Except
568 571 SetValorDatMemoria('Col_Undi.nada', 'nada', v_tstrCipherOpened1);
  572 + SetValorDatMemoria('Col_Undi.Fim', '99999999', v_tstrCipherOpened1);
569 573 CipherClose(p_path_cacic + 'temp\col_undi.dat', v_tstrCipherOpened1);
570 574 log_diario('Problema na coleta de informações de discos.');
571 575 End;
... ...
col_undi/col_undi.res
No preview for this file type
frmConfiguracoes.dcu
No preview for this file type
frmlog.dcu
No preview for this file type
frmsenha.dcu
No preview for this file type
ger_cols/ger_cols.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=23
  118 +Build=27
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev-ES
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Módulo Gerente de Coletas do Sistema CACIC
129   -FileVersion=2.2.0.23
  129 +FileVersion=2.2.0.27
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.6
  134 +ProductName=Ger_COLS
  135 +ProductVersion=2.2.0.27
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=2
... ...
ger_cols/ger_cols.dpr
... ... @@ -76,7 +76,8 @@ var CountUPD,
76 76  
77 77 var tstrTripa1,
78 78 v_tstrCipherOpened,
79   - v_tstrCipherOpened1 : TStrings;
  79 + v_tstrCipherOpened1,
  80 + tstringsAux : TStrings;
80 81  
81 82 var v_Debugs,
82 83 l_cs_cipher,
... ... @@ -140,7 +141,6 @@ begin
140 141 end;
141 142 end;
142 143  
143   -
144 144 function VerFmt(const MS, LS: DWORD): string;
145 145 // Format the version number from the given DWORDs containing the info
146 146 begin
... ... @@ -284,6 +284,12 @@ Begin
284 284 End;
285 285 Implode := strAux;
286 286 end;
  287 +function abstraiCSD(p_te_so : String) : integer;
  288 + var tstrTe_so : tstrings;
  289 + Begin
  290 + tstrTe_so := Explode(p_te_so, '.');
  291 + Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
  292 + End;
287 293  
288 294 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings);
289 295 var v_Aux : string;
... ... @@ -472,10 +478,13 @@ begin
472 478 else
473 479 Result := cOsUnknown;
474 480  
  481 + // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
475 482 v_te_so := IntToStr(platformId) + '.' +
476 483 IntToStr(majorVer) + '.' +
477 484 IntToStr(minorVer) +
478 485 IfThen(CSDVersion='','','.'+CSDVersion);
  486 + if (Result = 0) then
  487 + Result := abstraiCSD(v_te_so);
479 488 end;
480 489  
481 490 procedure Matar(v_dir,v_files: string);
... ... @@ -1250,6 +1259,7 @@ Begin
1250 1259 Request_Ger_Cols:=TStringList.Create;
1251 1260 Request_Ger_Cols.Values['te_node_address'] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),l_cs_compress);
1252 1261 Request_Ger_Cols.Values['id_so'] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' , v_tstrCipherOpened),l_cs_compress);
  1262 + Request_Ger_Cols.Values['te_so'] := EnCrypt(v_te_so,l_cs_compress);
1253 1263 Request_Ger_Cols.Values['te_ip'] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' , v_tstrCipherOpened),l_cs_compress);
1254 1264 Request_Ger_Cols.Values['id_ip_rede'] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' , v_tstrCipherOpened),l_cs_compress);
1255 1265 Request_Ger_Cols.Values['te_workgroup'] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' , v_tstrCipherOpened),l_cs_compress);
... ... @@ -1472,7 +1482,8 @@ Begin
1472 1482 Begin
1473 1483 if (v_Tamanho_Arquivo = '0') or (v_Tamanho_Arquivo = '-1') or (trim(GetVersionInfo(p_Dir_Inst + p_File + '.exe'))='0.0.0.0') then
1474 1484 Begin
1475   - if (p_Medir_FTP) then Result := 1
  1485 + if (p_Medir_FTP) then
  1486 + Result := 1
1476 1487 else
1477 1488 Begin
1478 1489 log_diario(p_Nome_Modulo + ' corrompido');
... ... @@ -2000,6 +2011,8 @@ Begin
2000 2011 Batchfile.SaveToFile(p_path_cacic + 'Temp\ipconfig.vbs');
2001 2012 BatchFile.Free;
2002 2013 v_acao_gercols := 'Invocando execução de VBS para obtenção de IPCONFIG...';
  2014 + log_DEBUG('Executando "'+p_path_cacic + 'modulos\' + v_scripter + ' //b ' + p_path_cacic + 'temp\ipconfig.vbs"');
  2015 +
2003 2016 WinExec(PChar(p_path_cacic + 'modulos\' + v_scripter + ' //b ' + p_path_cacic + 'temp\ipconfig.vbs'), SW_HIDE);
2004 2017 Except
2005 2018 Begin
... ... @@ -2130,7 +2143,8 @@ Begin
2130 2143 if (te_wins_primario='') then Try te_wins_primario := PegaDadosIPConfig(v_array_campos,v_array_valores,'servidor,wins,prim;wins,server,primary','') Except te_wins_primario := ''; end;
2131 2144 if (te_wins_secundario='') then Try te_wins_secundario := PegaDadosIPConfig(v_array_campos,v_array_valores,'servidor,wins,secund;wins,server,secondary','') Except te_wins_secundario := ''; end;
2132 2145  
2133   - if (GetWinVer > 5) then //Se NT/2K/XP
  2146 + if ((GetWinVer <> 0) and (GetWinVer > 5)) or
  2147 + (abstraiCSD(v_te_so) >= 250) then //Se NT/2K/XP
2134 2148 Try te_dominio_windows := PegaDadosIPConfig(v_array_campos,v_array_valores,'usu,rio,logado;usu,rio,logado','') Except te_dominio_windows := 'Não Identificado'; end
2135 2149 else
2136 2150 Try te_dominio_windows := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MSNP32\NetworkProvider\AuthenticatingAgent') + '\' + GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Network\Logon\username') Except te_dominio_windows := 'Não Identificado'; end
... ... @@ -2411,7 +2425,8 @@ Begin
2411 2425 if (te_dominio_windows = '') then
2412 2426 Begin
2413 2427 Try
2414   - if (GetWinVer > 5) then //Se NT/2K/XP
  2428 + if ((GetWinVer <> 0) and (GetWinVer > 5)) or
  2429 + (abstraiCSD(v_te_so) >= 250) then //Se NT/2K/XP
2415 2430 te_dominio_windows := GetDomainName + '\' + GetNetworkUserName
2416 2431 else
2417 2432 te_dominio_windows := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\MSNP32\NetworkProvider\AuthenticatingAgent') + '\' + GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Network\Logon\username');
... ... @@ -2422,6 +2437,7 @@ Begin
2422 2437 Request_SVG := TStringList.Create;
2423 2438 Request_SVG.Values['te_node_address'] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),l_cs_compress);
2424 2439 Request_SVG.Values['id_so'] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' , v_tstrCipherOpened),l_cs_compress);
  2440 + Request_SVG.Values['te_so'] := EnCrypt(v_te_so,l_cs_compress);
2425 2441 Request_SVG.Values['id_ip_rede'] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' , v_tstrCipherOpened),l_cs_compress);
2426 2442 Request_SVG.Values['te_nome_computador'] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', v_tstrCipherOpened),l_cs_compress);
2427 2443 Request_SVG.Values['te_ip'] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' , v_tstrCipherOpened),l_cs_compress);
... ... @@ -2525,7 +2541,8 @@ Begin
2525 2541 Begin
2526 2542 v_acao_gercols := 'Configurando diretório para o CACIC. (Registry para w95/95OSR2/98/98SE/ME)';
2527 2543 // Identifico a versão do Windows
2528   - If (GetWinVer <= 5) then
  2544 + If ((GetWinVer <> 0) and (GetWinVer <= 5)) or
  2545 + (abstraiCSD(v_te_so) < 250) then
2529 2546 begin
2530 2547 //Se for 95/95OSR2/98/98SE/ME faço aqui... (Em NT Like isto é feito no LoginScript)
2531 2548 SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2', Trim(Copy(ParamStr(intAux),12,Length((ParamStr(intAux))))) + '\cacic2.exe');
... ... @@ -2568,6 +2585,12 @@ Begin
2568 2585 log_DEBUG('Parâmetro(opção) /coletas recebido...');
2569 2586 v_acao_gercols := 'Ger_Cols invocado para coletas...';
2570 2587  
  2588 + // Verificando o registro de coletas do dia e eliminando datas diferentes...
  2589 + strAux := GetValorDatMemoria('Coletas.HOJE', v_tstrCipherOpened);
  2590 + if (strAux = '') or
  2591 + (copy(strAux,0,8) <> FormatDateTime('yyyymmdd', Date)) then
  2592 + SetValorDatMemoria('Coletas.HOJE', FormatDateTime('yyyymmdd', Date),v_tstrCipherOpened);
  2593 +
2571 2594 BuscaConfigs(true);
2572 2595  
2573 2596 // Abaixo eu testo se existe um endereço configurado para não disparar os procedimentos de coleta em vão.
... ... @@ -2782,6 +2805,7 @@ Begin
2782 2805 Request_Ger_Cols.Values['in_chkcacic'] := EnCrypt('chkcacic',l_cs_compress);
2783 2806 Request_Ger_Cols.Values['te_fila_ftp'] := EnCrypt('2',l_cs_compress); // Indicará sucesso na operação de FTP e liberará lugar para o próximo
2784 2807 Request_Ger_Cols.Values['id_ftp'] := EnCrypt(GetValorDatMemoria('Configs.ID_FTP',v_tstrCipherOpened),l_cs_compress); // Indicará sucesso na operação de FTP e liberará lugar para o próximo
  2808 + Request_Ger_Cols.Values['te_so'] := EnCrypt(v_te_so,l_cs_compress);
2785 2809 Request_Ger_Cols.Values['id_ip_estacao'] := EnCrypt(GetIP,l_cs_compress); // Informará o IP para registro na tabela redes_grupos_FTP
2786 2810 ComunicaServidor('get_config.php', Request_Ger_Cols, '>> Liberando Grupo FTP!...');
2787 2811 Request_Ger_Cols.Free;
... ... @@ -2804,7 +2828,7 @@ Begin
2804 2828 if not FileExists(p_path_cacic + 'Temp\ger_cols.exe') and
2805 2829 not FileExists(p_path_cacic + 'modulos\ger_cols.exe') then
2806 2830 log_diario('Módulo Gerente de Coletas inexistente.')
2807   - else log_diario('Nenhuma coleta configurada para essa subrede.');
  2831 + else log_diario('Nenhuma coleta configurada para essa subrede / estação / S.O.');
2808 2832 end;
2809 2833 End;
2810 2834 end;
... ... @@ -2824,11 +2848,21 @@ Begin
2824 2848 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_anvi.dat encontrado.');
2825 2849 v_acao_gercols := '* Preparando envio de informações de Anti-Vírus.';
2826 2850 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_anvi.dat');
  2851 +
  2852 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  2853 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Anti-Vírus OfficeScan', v_tstrCipherOpened);
  2854 +
  2855 + // Armazeno as horas de início e fim das coletas
  2856 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Anvi.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  2857 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Anvi.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  2858 +
2827 2859 if (GetValorDatMemoria('Col_Anvi.nada',v_tstrCipherOpened1)='') then
2828 2860 Begin
  2861 +
2829 2862 // Dados para uso do Gerente WEB...
2830 2863 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
2831 2864 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  2865 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
2832 2866 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
2833 2867 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
2834 2868 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -2847,13 +2881,24 @@ Begin
2847 2881  
2848 2882 if (ComunicaServidor('set_officescan.php', Request_Ger_Cols, '>> Enviando informações de Antivírus OfficeScan para o Gerente WEB.') <> '0') Then
2849 2883 Begin
  2884 + // Armazeno o Status Positivo de Envio
  2885 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  2886 +
2850 2887 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
2851 2888 //Sobreponho a informação no registro para posterior comparação, na próxima execução.
2852 2889 strAux := GetValorDatMemoria('Col_Anvi.UVC',v_tstrCipherOpened1);
2853 2890 SetValorDatMemoria('Coletas.OfficeScan',strAux, v_tstrCipherOpened) ;
2854 2891 intAux := 1;
2855   - End;
2856   - End;
  2892 + End
  2893 + else
  2894 + // Armazeno o Status Negativo de Envio
  2895 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  2896 +
  2897 + End
  2898 + Else
  2899 + // Armazeno o Status Nulo de Envio
  2900 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  2901 +
2857 2902 Request_Ger_Cols.Clear;
2858 2903 Matar(p_path_cacic+'Temp\','col_anvi.dat');
2859 2904 End;
... ... @@ -2863,11 +2908,20 @@ Begin
2863 2908 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_comp.dat encontrado.');
2864 2909 v_acao_gercols := '* Preparando envio de informações de Compartilhamentos.';
2865 2910 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_comp.dat');
  2911 +
  2912 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  2913 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Compartilhamentos', v_tstrCipherOpened);
  2914 +
  2915 + // Armazeno as horas de início e fim das coletas
  2916 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Comp.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  2917 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Comp.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  2918 +
2866 2919 if (GetValorDatMemoria('Col_Comp.nada',v_tstrCipherOpened1)='') then
2867 2920 Begin
2868 2921 // Dados para uso do Gerente WEB...
2869 2922 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
2870 2923 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  2924 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
2871 2925 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
2872 2926 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
2873 2927 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -2881,13 +2935,23 @@ Begin
2881 2935  
2882 2936 if (ComunicaServidor('set_compart.php', Request_Ger_Cols, '>> Enviando informações de Compartilhamentos para o Gerente WEB.') <> '0') Then
2883 2937 Begin
  2938 + // Armazeno o Status Positivo de Envio
  2939 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  2940 +
2884 2941 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
2885 2942 //Sobreponho a informação no registro para posterior comparação, na próxima execução.
2886 2943 strAux := GetValorDatMemoria('Col_Comp.UVC',v_tstrCipherOpened1);
2887 2944 SetValorDatMemoria('Coletas.Compartilhamentos', strAux, v_tstrCipherOpened);
2888 2945 intAux := 1;
2889   - End;
2890   - End;
  2946 + End
  2947 + Else
  2948 + // Armazeno o Status Negativo de Envio
  2949 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  2950 + End
  2951 + else
  2952 + // Armazeno o Status Nulo de Envio
  2953 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  2954 +
2891 2955 Request_Ger_Cols.Clear;
2892 2956 Matar(p_path_cacic+'Temp\','col_comp.dat');
2893 2957 End;
... ... @@ -2897,11 +2961,20 @@ Begin
2897 2961 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_hard.dat encontrado.');
2898 2962 v_acao_gercols := '* Preparando envio de informações de Hardware.';
2899 2963 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_hard.dat');
  2964 +
  2965 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  2966 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Hardware', v_tstrCipherOpened);
  2967 +
  2968 + // Armazeno as horas de início e fim das coletas
  2969 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Hard.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  2970 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Hard.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  2971 +
2900 2972 if (GetValorDatMemoria('Col_Hard.nada',v_tstrCipherOpened1)='') then
2901 2973 Begin
2902 2974 // Dados para uso do Gerente WEB...
2903 2975 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
2904 2976 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  2977 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
2905 2978 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
2906 2979 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
2907 2980 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -2935,13 +3008,23 @@ Begin
2935 3008  
2936 3009 if (ComunicaServidor('set_hardware.php', Request_Ger_Cols, '>> Enviando informações de Hardware para o Gerente WEB.') <> '0') Then
2937 3010 Begin
  3011 + // Armazeno o Status Positivo de Envio
  3012 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  3013 +
2938 3014 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
2939 3015 //Sobreponho a informação no registro para posterior comparação, na próxima execução.
2940 3016 strAux :=GetValorDatMemoria('Col_Hard.UVC',v_tstrCipherOpened1);
2941 3017 SetValorDatMemoria('Coletas.Hardware', strAux, v_tstrCipherOpened);
2942 3018 intAux := 1;
2943   - End;
2944   - End;
  3019 + End
  3020 + else
  3021 + // Armazeno o Status Negativo de Envio
  3022 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  3023 + End
  3024 + else
  3025 + // Armazeno o Status Nulo de Envio
  3026 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  3027 +
2945 3028 Request_Ger_Cols.Clear;
2946 3029 Matar(p_path_cacic+'Temp\','col_hard.dat');
2947 3030 End;
... ... @@ -2951,11 +3034,20 @@ Begin
2951 3034 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_patr.dat encontrado.');
2952 3035 v_acao_gercols := '* Preparando envio de informações de Patrimônio.';
2953 3036 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_patr.dat');
  3037 +
  3038 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  3039 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações Patrimoniais', v_tstrCipherOpened);
  3040 +
  3041 + // Armazeno as horas de início e fim das coletas
  3042 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Patr.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  3043 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Patr.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  3044 +
2954 3045 if (GetValorDatMemoria('Col_Patr.nada',v_tstrCipherOpened1)='') then
2955 3046 Begin
2956 3047 // Dados para uso do Gerente WEB...
2957 3048 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
2958 3049 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  3050 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
2959 3051 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
2960 3052 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
2961 3053 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -2978,6 +3070,9 @@ Begin
2978 3070  
2979 3071 if (ComunicaServidor('set_patrimonio.php', Request_Ger_Cols, '>> Enviando informações de Patrimônio para o Gerente WEB.') <> '0') Then
2980 3072 Begin
  3073 + // Armazeno o Status Positivo de Envio
  3074 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  3075 +
2981 3076 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
2982 3077 //Sobreponho a informação no registro para posterior comparação, na próxima execução.
2983 3078 SetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1', GetValorDatMemoria('Col_Patr.id_unid_organizacional_nivel1',v_tstrCipherOpened1), v_tstrCipherOpened);
... ... @@ -2991,9 +3086,15 @@ Begin
2991 3086 SetValorDatMemoria('Patrimonio.te_info_patrimonio6' , GetValorDatMemoria('Col_Patr.te_info_patrimonio6' ,v_tstrCipherOpened1), v_tstrCipherOpened);
2992 3087 SetValorDatMemoria('Patrimonio.ultima_rede_obtida' , GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened) , v_tstrCipherOpened);
2993 3088 intAux := 1;
2994   - End;
  3089 + End
  3090 + else
  3091 + // Armazeno o Status Negativo de Envio
  3092 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  3093 + End
  3094 + else
  3095 + // Armazeno o Status Nulo de Envio
  3096 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
2995 3097  
2996   - End;
2997 3098 Request_Ger_Cols.Clear;
2998 3099 Matar(p_path_cacic+'Temp\','col_patr.dat');
2999 3100 End;
... ... @@ -3003,11 +3104,20 @@ Begin
3003 3104 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_moni.dat encontrado.');
3004 3105 v_acao_gercols := '* Preparando envio de informações de Sistemas Monitorados.';
3005 3106 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_moni.dat');
  3107 +
  3108 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  3109 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Sistemas Monitorados', v_tstrCipherOpened);
  3110 +
  3111 + // Armazeno as horas de início e fim das coletas
  3112 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Moni.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  3113 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Moni.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  3114 +
3006 3115 if (GetValorDatMemoria('Col_Moni.nada',v_tstrCipherOpened1)='') then
3007 3116 Begin
3008 3117 // Dados para uso do Gerente WEB...
3009 3118 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
3010 3119 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  3120 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
3011 3121 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
3012 3122 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
3013 3123 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -3022,13 +3132,23 @@ Begin
3022 3132  
3023 3133 if (ComunicaServidor('set_monitorado.php', Request_Ger_Cols, '>> Enviando informações de Sistemas Monitorados para o Gerente WEB.') <> '0') Then
3024 3134 Begin
  3135 + // Armazeno o Status Positivo de Envio
  3136 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  3137 +
3025 3138 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
3026 3139 //Sobreponho a informação no registro para posterior comparação, na próxima execução.
3027 3140 strAux := GetValorDatMemoria('Col_Moni.UVC',v_tstrCipherOpened1);
3028 3141 SetValorDatMemoria('Coletas.Sistemas_Monitorados', strAux, v_tstrCipherOpened);
3029 3142 intAux := 1;
3030   - End;
3031   - End;
  3143 + End
  3144 + else
  3145 + // Armazeno o Status Negativo de Envio
  3146 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  3147 + End
  3148 + else
  3149 + // Armazeno o Status Nulo de Envio
  3150 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  3151 +
3032 3152 Request_Ger_Cols.Clear;
3033 3153 Matar(p_path_cacic+'Temp\','col_moni.dat');
3034 3154 End;
... ... @@ -3038,11 +3158,20 @@ Begin
3038 3158 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_soft.dat encontrado.');
3039 3159 v_acao_gercols := '* Preparando envio de informações de Softwares.';
3040 3160 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_soft.dat');
  3161 +
  3162 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  3163 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Softwares', v_tstrCipherOpened);
  3164 +
  3165 + // Armazeno as horas de início e fim das coletas
  3166 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Soft.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  3167 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Soft.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  3168 +
3041 3169 if (GetValorDatMemoria('Col_Soft.nada',v_tstrCipherOpened1)='') then
3042 3170 Begin
3043 3171 // Dados para uso do Gerente WEB...
3044 3172 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
3045 3173 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  3174 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
3046 3175 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
3047 3176 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
3048 3177 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -3069,13 +3198,23 @@ Begin
3069 3198  
3070 3199 if (ComunicaServidor('set_software.php', Request_Ger_Cols, '>> Enviando informações de Softwares Básicos para o Gerente WEB.') <> '0') Then
3071 3200 Begin
  3201 + // Armazeno o Status Positivo de Envio
  3202 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  3203 +
3072 3204 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
3073 3205 // Sobreponho a informação no registro para posterior comparação, na próxima execução.
3074 3206 strAux := GetValorDatMemoria('Col_Soft.UVC',v_tstrCipherOpened1);
3075 3207 SetValorDatMemoria('Coletas.Software', strAux, v_tstrCipherOpened);
3076 3208 intAux := 1;
3077   - End;
3078   - End;
  3209 + End
  3210 + else
  3211 + // Armazeno o Status Negativo de Envio
  3212 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  3213 + End
  3214 + else
  3215 + // Armazeno o Status Nulo de Envio
  3216 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  3217 +
3079 3218 Request_Ger_Cols.Clear;
3080 3219 Matar(p_path_cacic+'Temp\','col_soft.dat');
3081 3220 End;
... ... @@ -3085,11 +3224,20 @@ Begin
3085 3224 log_DEBUG('Indicador '+p_path_cacic + 'Temp\col_undi.dat encontrado.');
3086 3225 v_acao_gercols := '* Preparando envio de informações de Unidades de Disco.';
3087 3226 v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'Temp\col_undi.dat');
  3227 +
  3228 + // Armazeno dados para informações de coletas na data, via menu popup do Systray
  3229 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+'#Informações sobre Unidades de Disco', v_tstrCipherOpened);
  3230 +
  3231 + // Armazeno as horas de início e fim das coletas
  3232 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Undi.Inicio',v_tstrCipherOpened1), v_tstrCipherOpened);
  3233 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+','+GetValorDatMemoria('Col_Undi.Fim',v_tstrCipherOpened1), v_tstrCipherOpened);
  3234 +
3088 3235 if (GetValorDatMemoria('Col_Undi.nada',v_tstrCipherOpened1)='') then
3089 3236 Begin
3090 3237 // Dados para uso do Gerente WEB...
3091 3238 Request_Ger_Cols.Values['te_node_address' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' ,v_tstrCipherOpened),l_cs_compress);
3092 3239 Request_Ger_Cols.Values['id_so' ] := EnCrypt(GetValorDatMemoria('Configs.ID_SO' ,v_tstrCipherOpened),l_cs_compress);
  3240 + Request_Ger_Cols.Values['te_so' ] := EnCrypt(v_te_so,l_cs_compress);
3093 3241 Request_Ger_Cols.Values['te_ip' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened),l_cs_compress);
3094 3242 Request_Ger_Cols.Values['id_ip_rede' ] := EnCrypt(GetValorDatMemoria('TcpIp.ID_IP_REDE' ,v_tstrCipherOpened),l_cs_compress);
3095 3243 Request_Ger_Cols.Values['te_workgroup' ] := EnCrypt(GetValorDatMemoria('TcpIp.TE_WORKGROUP' ,v_tstrCipherOpened),l_cs_compress);
... ... @@ -3104,13 +3252,23 @@ Begin
3104 3252  
3105 3253 if (ComunicaServidor('set_unid_discos.php', Request_Ger_Cols, '>> Enviando informações de Unidades de Disco para o Gerente WEB.') <> '0') Then
3106 3254 Begin
  3255 + // Armazeno o Status Positivo de Envio
  3256 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',1', v_tstrCipherOpened);
  3257 +
3107 3258 // Somente atualizo o registro caso não tenha havido nenhum erro durante o envio das informações para o BD
3108 3259 //Sobreponho a informação no registro para posterior comparação, na próxima execução.
3109 3260 strAux := GetValorDatMemoria('Col_Undi.UVC',v_tstrCipherOpened1);
3110 3261 SetValorDatMemoria('Coletas.UnidadesDisco', strAux, v_tstrCipherOpened);
3111 3262 intAux := 1;
3112   - End;
3113   - End;
  3263 + End
  3264 + else
  3265 + // Armazeno o Status Negativo de Envio
  3266 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',-1', v_tstrCipherOpened);
  3267 + End
  3268 + else
  3269 + // Armazeno o Status Nulo de Envio
  3270 + SetValorDatMemoria('Coletas.HOJE',GetValorDatMemoria('Coletas.HOJE',v_tstrCipherOpened)+',0', v_tstrCipherOpened);
  3271 +
3114 3272 Request_Ger_Cols.Clear;
3115 3273 Matar(p_path_cacic+'Temp\','col_undi.dat');
3116 3274 End;
... ... @@ -3171,7 +3329,8 @@ begin
3171 3329  
3172 3330 // De acordo com a versão do OS, determino o ShellCommand para chamadas externas.
3173 3331 p_Shell_Command := 'command.com /c ';
3174   - if (GetWinVer > 5) then p_Shell_Command := 'cmd.exe /c '; //NT/2K/XP
  3332 + if ((GetWinVer <> 0) and (GetWinVer > 5)) or
  3333 + (abstraiCSD(v_te_so) >= 250) then p_Shell_Command := 'cmd.exe /c '; //NT/2K/XP
3175 3334  
3176 3335 if not DirectoryExists(p_path_cacic + 'Temp') then
3177 3336 ForceDirectories(p_path_cacic + 'Temp');
... ... @@ -3200,6 +3359,9 @@ begin
3200 3359 ChecaCipher;
3201 3360 ChecaCompress;
3202 3361  
  3362 + // Provoco a alimentação da variável v_te_so, para uso nas comunicações com o Gerente WEB.
  3363 + GetWinVer;
  3364 +
3203 3365 Executa_Ger_Cols;
3204 3366 Finalizar(true);
3205 3367 End;
... ...
ger_cols/ger_cols.res
No preview for this file type
ini_cols/ini_cols.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=2
116 116 MinorVer=2
117 117 Release=0
118   -Build=1
  118 +Build=2
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -124,15 +124,15 @@ DLL=0
124 124 Locale=1046
125 125 CodePage=1252
126 126 [Version Info Keys]
127   -CompanyName=Dataprev - ESES.P
  127 +CompanyName=Dataprev-Unidade Regional Espírito Santo
128 128 FileDescription=Inicializador de Coletas do Sistema CACIC
129   -FileVersion=2.2.0.1
  129 +FileVersion=2.2.0.2
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134   -ProductName=
135   -ProductVersion=2.0.1.2
  134 +ProductName=Ini_COLS
  135 +ProductVersion=2.2.0.2
136 136 Comments=Baseado na licença GPL (General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
ini_cols/ini_cols.res
No preview for this file type
No preview for this file type
No preview for this file type
main.pas
... ... @@ -34,7 +34,7 @@ uses Windows,
34 34 PJVersionInfo,
35 35 DCPcrypt2,
36 36 DCPrijndael,
37   - DCPbase64;
  37 + DCPbase64, ComCtrls;
38 38  
39 39  
40 40 const WM_MYMESSAGE = WM_USER+100;
... ... @@ -52,7 +52,8 @@ var p_path_cacic,
52 52 v_IV,
53 53 v_DatFileName,
54 54 v_DataCacic2DAT,
55   - v_Tamanho_Arquivo : string;
  55 + v_Tamanho_Arquivo,
  56 + v_te_so : string;
56 57 v_tstrCipherOpened : TStrings;
57 58 v_Debugs : Boolean;
58 59  
... ... @@ -62,52 +63,6 @@ type
62 63 Bt_Fechar_InfosGerais: TButton;
63 64 Pn_SisMoni: TPanel;
64 65 Lb_SisMoni: TLabel;
65   - GB_SisMoni: TGroupBox;
66   - Pn_Coluna2_SisMoni: TPanel;
67   - Pn_Coluna1_SisMoni: TPanel;
68   - ST_VL_Sistema1: TStaticText;
69   - ST_VL_Licenca10: TStaticText;
70   - ST_VL_Licenca9: TStaticText;
71   - ST_VL_Licenca8: TStaticText;
72   - ST_VL_Licenca7: TStaticText;
73   - ST_VL_Licenca6: TStaticText;
74   - ST_VL_Licenca5: TStaticText;
75   - ST_VL_Licenca4: TStaticText;
76   - ST_VL_Licenca3: TStaticText;
77   - ST_VL_Licenca2: TStaticText;
78   - ST_VL_Licenca1: TStaticText;
79   - ST_VL_Sistema10: TStaticText;
80   - ST_VL_Sistema9: TStaticText;
81   - ST_VL_Sistema8: TStaticText;
82   - ST_VL_Sistema7: TStaticText;
83   - ST_VL_Sistema6: TStaticText;
84   - ST_VL_Sistema5: TStaticText;
85   - ST_VL_Sistema4: TStaticText;
86   - ST_VL_Sistema3: TStaticText;
87   - ST_VL_Sistema2: TStaticText;
88   - St_LB_Versao: TStaticText;
89   - ST_LB_NomeSistema: TStaticText;
90   - St_LB_NumeroLicenca: TStaticText;
91   - ST_VL_Versao1: TStaticText;
92   - ST_VL_Versao4: TStaticText;
93   - ST_VL_Versao5: TStaticText;
94   - ST_VL_Versao6: TStaticText;
95   - ST_VL_Versao7: TStaticText;
96   - ST_VL_Versao8: TStaticText;
97   - ST_VL_Versao9: TStaticText;
98   - ST_VL_Versao10: TStaticText;
99   - ST_VL_Versao3: TStaticText;
100   - ST_VL_Versao2: TStaticText;
101   - Pn_Linha1_SisMoni: TPanel;
102   - Pn_Linha2_SisMoni: TPanel;
103   - Pn_Linha3_SisMoni: TPanel;
104   - Pn_Linha4_SisMoni: TPanel;
105   - Pn_Linha6_SisMoni: TPanel;
106   - Pn_Linha7_SisMoni: TPanel;
107   - Pn_Linha8_SisMoni: TPanel;
108   - Pn_Linha9_SisMoni: TPanel;
109   - Pn_Linha5_SisMoni: TPanel;
110   - Pn_Linha10_SisMoni: TPanel;
111 66 Pn_TCPIP: TPanel;
112 67 Lb_TCPIP: TLabel;
113 68 GB_InfosTCPIP: TGroupBox;
... ... @@ -150,6 +105,13 @@ type
150 105 Mnu_InfosTCP: TMenuItem;
151 106 Mnu_InfosPatrimoniais: TMenuItem;
152 107 Mnu_FinalizarCacic: TMenuItem;
  108 + listSistemasMonitorados: TListView;
  109 + Panel1: TPanel;
  110 + Label1: TLabel;
  111 + listaColetas: TListView;
  112 + lbDataColeta: TLabel;
  113 + Panel2: TPanel;
  114 + Panel3: TPanel;
153 115 procedure RemoveIconesMortos;
154 116 procedure ChecaCONFIGS;
155 117 procedure CriaFormSenha(Sender: TObject);
... ... @@ -178,6 +140,8 @@ type
178 140 procedure Mnu_InfosTCPClick(Sender: TObject);
179 141 procedure Bt_Fechar_InfosGeraisClick(Sender: TObject);
180 142 function Get_File_Size(sFileToExamine: string; bInKBytes: Boolean): string;
  143 + function Posso_Rodar : boolean;
  144 + function abstraiCSD(p_te_so : String) : integer;
181 145 private
182 146 ShutdownEmExecucao : Boolean;
183 147 IsMenuOpen : Boolean;
... ... @@ -705,6 +669,7 @@ Begin
705 669 strFraseVersao := 'CACIC V:' + getVersionInfo(ParamStr(0));
706 670 if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then
707 671 strFraseVersao := strFraseVersao + #13#10 + 'IP: '+getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened);
  672 +
708 673 InicializaTray(strFraseVersao);
709 674 log_diario('Acionando recuperador de Módulo Gerente de Coletas.');
710 675 WinExec(PChar(HomeDrive + '\chksis.exe'),SW_HIDE);
... ... @@ -713,7 +678,7 @@ Begin
713 678 if (FileExists(p_path_cacic + 'modulos\ger_cols.exe')) then
714 679 Begin
715 680 log_diario('Módulo Gerente de Coletas RECUPERADO COM SUCESSO!');
716   - InicializaTray('Aguarde...');
  681 + InicializaTray('');
717 682 End
718 683 else
719 684 log_diario('Módulo Gerente de Coletas NÃO RECUPERADO!');
... ... @@ -781,7 +746,7 @@ begin
781 746 Result:=FindFirst(v_dir+v_files, faAnyFile, SearchRec);
782 747 while result=0 do
783 748 begin
784   - log_DEBUG('Excluindo: '+v_dir + SearchRec.Name);
  749 + log_DEBUG('Tentativa de Exclusão de "'+v_dir + SearchRec.Name+'"');
785 750 DeleteFile(v_dir+SearchRec.Name);
786 751 Result:=FindNext(SearchRec);
787 752 end;
... ... @@ -910,15 +875,20 @@ const
910 875 cOsXP = 8;
911 876 var
912 877 osVerInfo: TOSVersionInfo;
913   - majorVer, minorVer: Integer;
  878 + platformID,
  879 + majorVer,
  880 + minorVer : Integer;
  881 + CSDVersion : String;
914 882 begin
915 883 Result := cOsUnknown;
916 884 { set operating system type flag }
917 885 osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
918 886 if GetVersionEx(osVerInfo) then
919 887 begin
920   - majorVer := osVerInfo.dwMajorVersion;
921   - minorVer := osVerInfo.dwMinorVersion;
  888 + platformId := osVerInfo.dwPlatformId;
  889 + majorVer := osVerInfo.dwMajorVersion;
  890 + minorVer := osVerInfo.dwMinorVersion;
  891 + CSDVersion := trim(osVerInfo.szCSDVersion);
922 892 case osVerInfo.dwPlatformId of
923 893 VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
924 894 begin
... ... @@ -953,22 +923,57 @@ begin
953 923 end
954 924 else
955 925 Result := cOsUnknown;
  926 + // A partir da versão 2.2.0.24, defino o valor da ID Interna e atribuo-a sem o CSDVersion à versão externa
  927 + v_te_so := IntToStr(platformId) + '.' +
  928 + IntToStr(majorVer) + '.' +
  929 + IntToStr(minorVer) +
  930 + IfThen(CSDVersion='','','.'+CSDVersion);
  931 + if (Result = 0) then
  932 + Result := abstraiCSD(v_te_so);
  933 +
956 934 end;
  935 +function TFormularioGeral.abstraiCSD(p_te_so : String) : integer;
  936 + var tstrTe_so : tstrings;
  937 + Begin
  938 + tstrTe_so := Explode(p_te_so, '.');
  939 + Result := StrToInt(tstrTe_so[0] + tstrTe_so[1] + tstrTe_so[2]);
  940 + End;
  941 +
  942 +procedure TFormularioGeral.log_DEBUG(p_msg:string);
  943 +Begin
  944 + if v_Debugs then log_diario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg);
  945 +End;
  946 +
  947 +function TFormularioGeral.Posso_Rodar : boolean;
  948 +Begin
  949 + result := false;
  950 +
  951 + log_debug('Verificando concomitância de sessões');
  952 + // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) )
  953 + FormularioGeral.Matar(p_path_cacic,'aguarde_CACIC.txt');
  954 + if (not (FileExists(p_path_cacic + 'aguarde_CACIC.txt'))) then
  955 + result := true;
  956 +End;
957 957  
958 958 procedure TFormularioGeral.FormCreate(Sender: TObject);
959 959 var strAux,
960 960 v_ip_serv_cacic,
  961 + v_cacic_dir,
961 962 v_windir,
962 963 strFraseVersao : string;
963 964 intAux : integer;
  965 + v_Aguarde : TextFile;
  966 + v_SystemDrive : TStrings;
964 967 begin
965 968 Try
966 969 // De acordo com a versão do OS, determino o ShellCommand para chamadas externas.
967   - if (GetWinVer > 5) then
  970 + if ((GetWinVer <> 0) and (GetWinVer > 5)) or
  971 + (abstraiCSD(v_te_so) >= 250) then //Se NT/2K/XP... then
968 972 Begin
969 973 //p_Shell_Command := GetEnvironmentVariable('SYSTEMROOT') + '\system32\cmd.exe /c '; //NT/2K/XP
970 974 p_Shell_Path := HomeDrive + '\system32\'; //NT/2K/XP
971 975 p_Shell_Command := 'cmd.exe'; //NT/2K/XP
  976 + strAux := HomeDrive + '\'; //Ex.: c:\windows\
972 977 End
973 978 else
974 979 Begin
... ... @@ -977,10 +982,17 @@ begin
977 982 //p_Shell_Command := v_windir + 'command.com /c ';
978 983 p_Shell_Path := v_windir;
979 984 p_Shell_Command := 'command.com';
  985 + strAux := GetEnvironmentVariable('windir') + '\'; //Ex.: c:\windows\
980 986 End;
981 987  
  988 + v_SystemDrive := explode(strAux,'\');
  989 + v_cacic_dir := v_SystemDrive[0] + '\' + getValorChaveRegIni('Cacic2','cacic_dir',strAux + 'chksis.ini') + '\';
  990 +
982 991 // Caminho do aplicativo
983   - p_path_cacic := ExtractFilePath(Application.Exename) ;
  992 + if (v_cacic_dir <> '') then
  993 + p_path_cacic := v_cacic_dir
  994 + else
  995 + p_path_cacic := ExtractFilePath(Application.Exename) ;
984 996  
985 997 v_Debugs := false;
986 998 if DirectoryExists(p_path_cacic + 'Temp\Debugs') then
... ... @@ -992,98 +1004,122 @@ begin
992 1004 End;
993 1005 End;
994 1006  
995   - // Chave AES. Recomenda-se que cada empresa altere a sua chave.
996   - // Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez,
997   - // passa para o Inicializador de Coletas e este passa para os coletores...
998   - v_CipherKey := 'CacicBrasil';
999   - v_IV := 'abcdefghijklmnop';
1000   - v_SeparatorKey := '=CacicIsFree='; // Usada apenas para o cacic2.dat
1001   - v_DatFileName := p_path_cacic + 'cacic2.dat';
1002   - v_DataCacic2DAT := '';
1003   - v_tstrCipherOpened := TStrings.Create;
1004   - v_tstrCipherOpened := CipherOpen;
1005   -
1006   - if FileExists(p_path_cacic + 'cacic2.ini') then
1007   - Begin
1008   - log_DEBUG('O arquivo "'+p_path_cacic + 'cacic2.ini" ainda existe. Vou resgatar algumas chaves/valores');
1009   - SetValorDatMemoria('Configs.EnderecoServidor' ,getValorChaveRegIni('Configs' ,'EnderecoServidor' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1010   - SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,getValorChaveRegIni('Configs' ,'IN_EXIBE_BANDEJA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1011   - SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,getValorChaveRegIni('Configs' ,'TE_JANELAS_EXCECAO' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1012   - SetValorDatMemoria('Configs.NU_EXEC_APOS' ,getValorChaveRegIni('Configs' ,'NU_EXEC_APOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1013   - SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_EXEC' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1014   - SetValorDatMemoria('Configs.Endereco_WS' ,getValorChaveRegIni('Configs' ,'Endereco_WS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1015   - SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,getValorChaveRegIni('Configs' ,'TE_SENHA_ADM_AGENTE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1016   - SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_RENOVACAO_PATRIM' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1017   - SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA' ,getValorChaveRegIni('Configs' ,'DT_HR_ULTIMA_COLETA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1018   - SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,getValorChaveRegIni('TcpIp' ,'TE_ENDERECOS_MAC_INVALIDOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1019   - SetValorDatMemoria('TcpIp.ID_IP_REDE' ,getValorChaveRegIni('TcpIp' ,'ID_IP_REDE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1020   - SetValorDatMemoria('TcpIp.TE_IP' ,getValorChaveRegIni('TcpIp' ,'TE_IP' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1021   - SetValorDatMemoria('TcpIp.TE_MASCARA' ,getValorChaveRegIni('TcpIp' ,'TE_MASCARA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1022   - SetValorDatMemoria('Patrimonio.ultima_rede_obtida' ,getValorChaveRegIni('Patrimonio' ,'ultima_rede_obtida' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1023   - SetValorDatMemoria('Patrimonio.dt_ultima_renovacao' ,getValorChaveRegIni('Patrimonio' ,'dt_ultima_renovacao' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
1024   - Matar(p_path_cacic,'cacic2.ini');
1025   - End;
  1007 + log_DEBUG('Pasta do Sistema: "' + p_path_cacic + '"');
1026 1008  
1027   - if (ParamCount > 0) then //Caso o Cacic2 seja chamado com passagem de parâmetros...
  1009 + if Posso_Rodar then
1028 1010 Begin
1029   - // Parâmetros possíveis (aceitos)
1030   - // /ip_serv_cacic => Endereço IP do Módulo Gerente. Ex.: 10.71.0.212
1031   - // /atualizacao => O CACIC foi chamado pelo batch de AutoUpdate e deve ir direto para o ExecutaCacic.
  1011 + // Uma forma fácil de evitar que outra sessão deste agente seja iniciada! (POG? Nããããooo!) :))))
  1012 + AssignFile(v_Aguarde,p_path_cacic + 'aguarde_CACIC.txt'); {Associa o arquivo a uma variável do tipo TextFile}
  1013 + {$IOChecks off}
  1014 + Reset(v_Aguarde); {Abre o arquivo texto}
  1015 + {$IOChecks on}
  1016 + if (IOResult <> 0) then // Arquivo não existe, será recriado.
  1017 + Rewrite (v_Aguarde);
  1018 +
  1019 + Append(v_Aguarde);
  1020 + Writeln(v_Aguarde,'Apenas um pseudo-cookie para evitar sessões concomitantes...');
  1021 + Append(v_Aguarde);
  1022 + Writeln(v_Aguarde,'Futuramente penso em colocar aqui o pID, para possibilitar finalização via software externo...');
  1023 + Append(v_Aguarde);
  1024 +
  1025 + // Chave AES. Recomenda-se que cada empresa altere a sua chave.
  1026 + // Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez,
  1027 + // passa para o Inicializador de Coletas e este passa para os coletores...
  1028 + v_CipherKey := 'CacicBrasil';
  1029 + v_IV := 'abcdefghijklmnop';
  1030 + v_SeparatorKey := '=CacicIsFree='; // Usada apenas para o cacic2.dat
  1031 + v_DatFileName := p_path_cacic + 'cacic2.dat';
  1032 + v_DataCacic2DAT := '';
  1033 + v_tstrCipherOpened := TStrings.Create;
  1034 + v_tstrCipherOpened := CipherOpen;
  1035 +
  1036 + if FileExists(p_path_cacic + 'cacic2.ini') then
  1037 + Begin
  1038 + log_DEBUG('O arquivo "'+p_path_cacic + 'cacic2.ini" ainda existe. Vou resgatar algumas chaves/valores');
  1039 + SetValorDatMemoria('Configs.EnderecoServidor' ,getValorChaveRegIni('Configs' ,'EnderecoServidor' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1040 + SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,getValorChaveRegIni('Configs' ,'IN_EXIBE_BANDEJA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1041 + SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,getValorChaveRegIni('Configs' ,'TE_JANELAS_EXCECAO' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1042 + SetValorDatMemoria('Configs.NU_EXEC_APOS' ,getValorChaveRegIni('Configs' ,'NU_EXEC_APOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1043 + SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_EXEC' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1044 + SetValorDatMemoria('Configs.Endereco_WS' ,getValorChaveRegIni('Configs' ,'Endereco_WS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1045 + SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,getValorChaveRegIni('Configs' ,'TE_SENHA_ADM_AGENTE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1046 + SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_RENOVACAO_PATRIM' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1047 + SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA' ,getValorChaveRegIni('Configs' ,'DT_HR_ULTIMA_COLETA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1048 + SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,getValorChaveRegIni('TcpIp' ,'TE_ENDERECOS_MAC_INVALIDOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1049 + SetValorDatMemoria('TcpIp.ID_IP_REDE' ,getValorChaveRegIni('TcpIp' ,'ID_IP_REDE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1050 + SetValorDatMemoria('TcpIp.TE_IP' ,getValorChaveRegIni('TcpIp' ,'TE_IP' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1051 + SetValorDatMemoria('TcpIp.TE_MASCARA' ,getValorChaveRegIni('TcpIp' ,'TE_MASCARA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1052 + SetValorDatMemoria('Patrimonio.ultima_rede_obtida' ,getValorChaveRegIni('Patrimonio' ,'ultima_rede_obtida' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1053 + SetValorDatMemoria('Patrimonio.dt_ultima_renovacao' ,getValorChaveRegIni('Patrimonio' ,'dt_ultima_renovacao' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);
  1054 + Matar(p_path_cacic,'cacic2.ini');
  1055 + End;
1032 1056  
1033   - // Chamada com parâmetros pelo chkcacic.exe ou linha de comando
1034   - For intAux := 1 to ParamCount do
  1057 + if (ParamCount > 0) then //Caso o Cacic2 seja chamado com passagem de parâmetros...
1035 1058 Begin
1036   - if LowerCase(Copy(ParamStr(intAux),1,15)) = '/ip_serv_cacic=' then
1037   - begin
1038   - log_DEBUG('Parâmetro /ip_serv_cacic recebido...');
1039   - strAux := Trim(Copy(ParamStr(intAux),16,Length((ParamStr(intAux)))));
1040   - v_ip_serv_cacic := Trim(Copy(strAux,0,Pos('/', strAux) - 1));
1041   - If (v_ip_serv_cacic = '') Then v_ip_serv_cacic := strAux;
1042   - SetValorDatMemoria('Configs.EnderecoServidor',v_ip_serv_cacic,v_tstrCipherOpened);
1043   - end;
1044   - end;
  1059 + // Parâmetros possíveis (aceitos)
  1060 + // /ip_serv_cacic => Endereço IP do Módulo Gerente. Ex.: 10.71.0.212
  1061 + // /atualizacao => O CACIC foi chamado pelo batch de AutoUpdate e deve ir direto para o ExecutaCacic.
1045 1062  
1046   - If FindCmdLineSwitch('execute', True) or
1047   - FindCmdLineSwitch('atualizacao', True) Then
1048   - begin
1049   - if FindCmdLineSwitch('atualizacao', True) then
1050   - begin
1051   - log_DEBUG('Opção /atualizacao recebida...');
1052   - Log_Diario('Reinicializando com versão '+getVersionInfo(ParamStr(0)));
1053   - end
1054   - else
  1063 + // Chamada com parâmetros pelo chkcacic.exe ou linha de comando
  1064 + For intAux := 1 to ParamCount do
  1065 + Begin
  1066 + if LowerCase(Copy(ParamStr(intAux),1,15)) = '/ip_serv_cacic=' then
1055 1067 begin
1056   - log_DEBUG('Opção /execute recebida...');
1057   - log_diario('Opção para execução imediata encontrada...');
  1068 + log_DEBUG('Parâmetro /ip_serv_cacic recebido...');
  1069 + strAux := Trim(Copy(ParamStr(intAux),16,Length((ParamStr(intAux)))));
  1070 + v_ip_serv_cacic := Trim(Copy(strAux,0,Pos('/', strAux) - 1));
  1071 + If (v_ip_serv_cacic = '') Then v_ip_serv_cacic := strAux;
  1072 + SetValorDatMemoria('Configs.EnderecoServidor',v_ip_serv_cacic,v_tstrCipherOpened);
1058 1073 end;
1059   - ExecutaCacic(nil);
1060 1074 end;
1061   - End;
1062 1075  
1063   - // Os timers iniciam-se desabilitados... Mais à frente receberão parâmetros de tempo para execução.
1064   - Timer_Nu_Exec_Apos.Enabled := False;
1065   - Timer_Nu_Intervalo.Enabled := False;
  1076 + If FindCmdLineSwitch('execute', True) or
  1077 + FindCmdLineSwitch('atualizacao', True) Then
  1078 + begin
  1079 + if FindCmdLineSwitch('atualizacao', True) then
  1080 + begin
  1081 + log_DEBUG('Opção /atualizacao recebida...');
  1082 + Log_Diario('Reinicializando com versão '+getVersionInfo(ParamStr(0)));
  1083 + end
  1084 + else
  1085 + begin
  1086 + log_DEBUG('Opção /execute recebida...');
  1087 + log_diario('Opção para execução imediata encontrada...');
  1088 + end;
  1089 + ExecutaCacic(nil);
  1090 + end;
  1091 + End;
  1092 +
  1093 + // Os timers iniciam-se desabilitados... Mais à frente receberão parâmetros de tempo para execução.
  1094 + Timer_Nu_Exec_Apos.Enabled := False;
  1095 + Timer_Nu_Intervalo.Enabled := False;
1066 1096  
1067   - // Derruba o cacic durante o shutdown do windows.
1068   - ShutdownEmExecucao := False;
  1097 + // Derruba o cacic durante o shutdown do windows.
  1098 + ShutdownEmExecucao := False;
1069 1099  
1070   - // Não mostrar o formulário...
1071   - Application.ShowMainForm:=false;
  1100 + // Não mostrar o formulário...
  1101 + Application.ShowMainForm:=false;
1072 1102  
1073   - Try
1074   - // A chamada abaixo define os valores usados pelo agente principal.
1075   - SetaVariaveisGlobais;
1076   - Except
1077   - log_diario('PROBLEMAS SETANDO VARIÁVEIS GLOBAIS!');
1078   - End;
  1103 + Try
  1104 + // A chamada abaixo define os valores usados pelo agente principal.
  1105 + SetaVariaveisGlobais;
  1106 + Except
  1107 + log_diario('PROBLEMAS SETANDO VARIÁVEIS GLOBAIS!');
  1108 + End;
1079 1109  
1080   - // Envia o ícone para a bandeja com HINT mostrando Versão...
1081   - strFraseVersao := 'CACIC V:' + getVersionInfo(ParamStr(0));
1082   - if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then
1083   - strFraseVersao := strFraseVersao + #13#10 + 'IP: '+ getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened);
1084   - InicializaTray(strFraseVersao);
1085   - CipherClose;
  1110 + // Envia o ícone para a bandeja com HINT mostrando Versão...
  1111 + strFraseVersao := 'CACIC V:' + getVersionInfo(ParamStr(0));
  1112 + if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then
  1113 + strFraseVersao := strFraseVersao + #13#10 + 'IP: '+ getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened);
1086 1114  
  1115 + InicializaTray(strFraseVersao);
  1116 + CipherClose;
  1117 + End
  1118 + else
  1119 + Begin
  1120 + log_DEBUG('Agente finalizado devido a concomitância de sessões...');
  1121 + Finaliza;
  1122 + End;
1087 1123 Except
1088 1124 log_diario('PROBLEMAS NA INICIALIZAÇÃO (2)');
1089 1125 End;
... ... @@ -1188,11 +1224,6 @@ Begin
1188 1224 Application.Terminate;
1189 1225 End;
1190 1226  
1191   -procedure TFormularioGeral.log_DEBUG(p_msg:string);
1192   -Begin
1193   - if v_Debugs then log_diario('(v.'+getVersionInfo(ParamStr(0))+') DEBUG - '+p_msg);
1194   -End;
1195   -
1196 1227 procedure TFormularioGeral.Sair(Sender: TObject);
1197 1228 begin
1198 1229 CriaFormSenha(nil);
... ... @@ -1299,7 +1330,7 @@ begin
1299 1330 intContaExec := 2;
1300 1331  
1301 1332 // Muda HINT
1302   - InicializaTray('Aguarde...');
  1333 + InicializaTray('');
1303 1334  
1304 1335 // Loop para possível necessidade de updates de Agente Principal e/ou Gerente de Coletas
1305 1336 For intAux := intContaExec to 2 do
... ... @@ -1500,6 +1531,7 @@ begin
1500 1531 strFraseVersao := 'CACIC V:' + getVersionInfo(ParamStr(0));
1501 1532 if not (getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened) = '') then
1502 1533 strFraseVersao := strFraseVersao + #13#10 + 'IP: '+getValorDatMemoria('TcpIp.TE_IP',v_tstrCipherOpened);
  1534 +
1503 1535 InicializaTray(strFraseVersao);
1504 1536  
1505 1537 except
... ... @@ -1573,7 +1605,7 @@ end;
1573 1605 //=======================================================================
1574 1606 procedure TFormularioGeral.InicializaTray(v_Hint:string);
1575 1607 begin
1576   - log_DEBUG('Setando o HINT do Systray para: "'+v_Hint+'"');
  1608 +
1577 1609 {Estrutura do tray icon sendo criada.}
1578 1610 NotifyStruc.cbSize := SizeOf(NotifyStruc);
1579 1611 NotifyStruc.Wnd := Handle;
... ... @@ -1582,7 +1614,12 @@ begin
1582 1614 NotifyStruc.uCallbackMessage := WM_MYMESSAGE; {User defined message}
1583 1615 NotifyStruc.hIcon := Application.Icon.Handle;
1584 1616  
1585   - // Coloca as informações de versão na barra de título e no tip da bandeja
  1617 + if (v_Hint = '') then
  1618 + v_Hint := 'Aguarde...';
  1619 +
  1620 + log_DEBUG('Setando o HINT do Systray para: "'+v_Hint+'"');
  1621 +
  1622 + // Atualiza o conteúdo do tip da bandeja
1586 1623 StrPCopy(NotifyStruc.szTip, v_Hint);
1587 1624  
1588 1625 if (getValorDatMemoria('Configs.IN_EXIBE_BANDEJA',v_tstrCipherOpened) <> 'N') Then
... ... @@ -1656,13 +1693,13 @@ begin
1656 1693 end;
1657 1694  
1658 1695 procedure TFormularioGeral.Mnu_InfosTCPClick(Sender: TObject);
1659   -var v_tripa_perfis, v_tripa_infos_coletadas, v_nome_campo_sistema, v_nome_campo_licenca, v_nome_campo_versao : string;
1660   - v_array_perfis, v_array_tripa_infos_coletadas, v_array_infos_coletadas : tstrings;
  1696 +var v_tripa_perfis, v_tripa_infos_coletadas,strAux : string;
  1697 + v_array_perfis, v_array_tripa_infos_coletadas, v_array_infos_coletadas,tstringsAux : tstrings;
1661 1698 v_conta_perfis, v_conta_infos_coletadas, intAux, intAux1 : integer;
1662 1699 v_achei : boolean;
1663 1700 begin
1664   - FormularioGeral.Enabled := true;
1665   - FormularioGeral.Visible := true;
  1701 + FormularioGeral.Enabled := true;
  1702 + FormularioGeral.Visible := true;
1666 1703  
1667 1704 ST_VL_NomeHost.Caption := getValorDatMemoria('TcpIp.TE_NOME_HOST' ,v_tstrCipherOpened);
1668 1705 ST_VL_IPEstacao.Caption := getValorDatMemoria('TcpIp.TE_IP' ,v_tstrCipherOpened);
... ... @@ -1677,18 +1714,9 @@ begin
1677 1714 ST_VL_WinsPrimario.Caption := getValorDatMemoria('TcpIp.TE_WINS_PRIMARIO' ,v_tstrCipherOpened);
1678 1715 ST_VL_WinsSecundario.Caption := getValorDatMemoria('TcpIp.TE_WINS_SECUNDARIO' ,v_tstrCipherOpened);
1679 1716  
1680   - // Inicialização dos valores das INFORMAÇÕES GERAIS
1681   - for intAux1 := 0 to (ComponentCount - 1) do
1682   - if (Components[intAux1].ClassName = 'TStaticText') and
1683   - ((Copy(Components[intAux1].Name,1,13)='ST_VL_Sistema') or
1684   - (Copy(Components[intAux1].Name,1,13)='ST_VL_Licenca') or
1685   - (Copy(Components[intAux1].Name,1,12)='ST_VL_Versao')) then
1686   - Begin
1687   - (Components[intAux1] as TStaticText).Caption := '';
1688   - End;
1689   -
  1717 + // Exibição das informações de Sistemas Monitorados...
1690 1718 v_conta_perfis := 1;
1691   - v_conta_infos_coletadas := 1;
  1719 + v_conta_infos_coletadas := 0;
1692 1720 v_tripa_perfis := '*';
1693 1721 while v_tripa_perfis <> '' do
1694 1722 begin
... ... @@ -1711,42 +1739,19 @@ begin
1711 1739 for intAux := 0 to v_array_tripa_infos_coletadas.Count-1 Do
1712 1740 Begin
1713 1741 v_array_infos_coletadas := explode(v_array_tripa_infos_coletadas[intAux],',');
  1742 +
1714 1743 if (v_array_infos_coletadas[0]=v_array_perfis[0]) then
1715 1744 Begin
1716 1745 if ((trim(v_array_infos_coletadas[1])<>'') and (trim(v_array_infos_coletadas[1])<>'?')) or
1717 1746 ((trim(v_array_infos_coletadas[3])<>'') and (trim(v_array_infos_coletadas[3])<>'?')) then
1718 1747 Begin
1719 1748 v_achei := false;
1720   - for intAux1 := 0 to (ComponentCount - 1) do
1721   - Begin
1722   - if (Components[intAux1].ClassName = 'TStaticText') and
1723   - ((copy(Components[intAux1].Name,1,13)='ST_VL_Sistema') or
1724   - (copy(Components[intAux1].Name,1,13)='ST_VL_Licenca') or
1725   - (copy(Components[intAux1].Name,1,12)='ST_VL_Versao')) then
1726   - Begin
1727   - v_nome_campo_sistema := 'ST_VL_Sistema' + inttostr(v_conta_infos_coletadas);
1728   - v_nome_campo_licenca := 'ST_VL_Licenca' + inttostr(v_conta_infos_coletadas);
1729   - v_nome_campo_versao := 'ST_VL_Versao' + inttostr(v_conta_infos_coletadas);
1730   - if (Components[intAux1].Name=v_nome_campo_sistema) then
1731   - Begin
1732   - (Components[intAux1] as TStaticText).Caption := v_array_perfis[12];
1733   - v_achei := true;
1734   - End;
1735   -
1736   - if (Components[intAux1].Name=v_nome_campo_licenca) then
1737   - Begin
1738   - (Components[intAux1] as TStaticText).Caption := v_array_infos_coletadas[1];
1739   - v_achei := true;
1740   - End;
1741   -
1742   - if (Components[intAux1].Name=v_nome_campo_versao) then
1743   - Begin
1744   - (Components[intAux1] as TStaticText).Caption := v_array_infos_coletadas[3];
1745   - v_achei := true;
1746   - End;
1747   - End;
1748   - End;
1749   - if v_achei then v_conta_infos_coletadas := v_conta_infos_coletadas + 1;
  1749 + listSistemasMonitorados.Items.Add;
  1750 + listSistemasMonitorados.Items[v_conta_infos_coletadas].Caption := Format('%2d', [v_conta_infos_coletadas+1])+') '+v_array_perfis[12];
  1751 + listSistemasMonitorados.Items[v_conta_infos_coletadas].SubItems.Add(v_array_infos_coletadas[1]);
  1752 + listSistemasMonitorados.Items[v_conta_infos_coletadas].SubItems.Add(v_array_infos_coletadas[3]);
  1753 + v_conta_infos_coletadas := v_conta_infos_coletadas + 1;
  1754 +
1750 1755 End;
1751 1756 End;
1752 1757 End;
... ... @@ -1754,6 +1759,49 @@ begin
1754 1759 End;
1755 1760 End;
1756 1761 end;
  1762 +
  1763 + lbDataColeta.Caption := '('+FormatDateTime('dd/mm/yyyy', now)+')';
  1764 +
  1765 + strAux := GetValorDatMemoria('Coletas.HOJE', v_tstrCipherOpened);
  1766 + if (strAux <> '') then
  1767 + Begin
  1768 + if (copy(strAux,0,8) = FormatDateTime('yyyymmdd', Date)) then
  1769 + Begin
  1770 + // Vamos reaproveitar algumas variáveis!...
  1771 +
  1772 + v_array_perfis := explode(strAux,'#');
  1773 + for intAux := 1 to v_array_perfis.Count-1 Do
  1774 + Begin
  1775 + v_array_infos_coletadas := explode(v_array_perfis[intAux],',');
  1776 + listaColetas.Items.Add;
  1777 + listaColetas.Items[intAux-1].Caption := v_array_infos_coletadas[0];
  1778 + listaColetas.Items[intAux-1].SubItems.Add(v_array_infos_coletadas[1]);
  1779 +
  1780 + // Verifico se houve problema na coleta...
  1781 + if (v_array_infos_coletadas[2]<>'99999999') then
  1782 + listaColetas.Items[intAux-1].SubItems.Add(v_array_infos_coletadas[2])
  1783 + else
  1784 + Begin
  1785 + listaColetas.Items[intAux-1].SubItems.Add('--------');
  1786 + v_array_infos_coletadas[3] := v_array_infos_coletadas[2];
  1787 + End;
  1788 +
  1789 + // Códigos Possíveis: -1 : Problema no Envio da Coleta
  1790 + // 1 : Coleta Enviada
  1791 + // 0 : Sem Coleta para Envio
  1792 + strAux := IfThen(v_array_infos_coletadas[3]='1','Coleta Enviada ao Gerente WEB!',
  1793 + IfThen(v_array_infos_coletadas[3]='-1','Problema Enviando Coleta ao Gerente WEB!',
  1794 + IfThen(v_array_infos_coletadas[3]='0','Sem Coleta para Envio ao Gerente WEB!',
  1795 + IfThen(v_array_infos_coletadas[3]='99999999','Problema no Processo de Coleta!','Status Desconhecido!'))));
  1796 + listaColetas.Items[intAux-1].SubItems.Add(strAux);
  1797 + End;
  1798 + End
  1799 + End
  1800 + else
  1801 + Begin
  1802 + listSistemasMonitorados.Items.Add;
  1803 + listSistemasMonitorados.Items[0].Caption := 'Não Há Coletas Registradas Nesta Data';
  1804 + End;
1757 1805 end;
1758 1806  
1759 1807 procedure TFormularioGeral.Bt_Fechar_InfosGeraisClick(Sender: TObject);
... ...
mapa/main_mapa.dcu
No preview for this file type
mapa/main_mapa.pas
... ... @@ -47,7 +47,8 @@ uses IniFiles,
47 47  
48 48 var strCipherClosed,
49 49 strCipherOpened,
50   - strPathCacic : string;
  50 + strPathCacic,
  51 + str_te_so : string;
51 52  
52 53 var boolDebugs,
53 54 boolUON2 : boolean;
... ... @@ -810,17 +811,24 @@ const
810 811 cOsWinNT = 6;
811 812 cOsWin2000 = 7;
812 813 cOsXP = 8;
  814 +
813 815 var
814 816 osVerInfo: TOSVersionInfo;
815   - majorVer, minorVer: Integer;
  817 + platformID,
  818 + majorVer,
  819 + minorVer: Integer;
  820 + CSDVersion : String;
816 821 begin
817 822 Result := cOsUnknown;
818 823 { set operating system type flag }
819 824 osVerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
820 825 if GetVersionEx(osVerInfo) then
821 826 begin
822   - majorVer := osVerInfo.dwMajorVersion;
823   - minorVer := osVerInfo.dwMinorVersion;
  827 + platformId := osVerInfo.dwPlatformId;
  828 + majorVer := osVerInfo.dwMajorVersion;
  829 + minorVer := osVerInfo.dwMinorVersion;
  830 + CSDVersion := trim(osVerInfo.szCSDVersion);
  831 +
824 832 case osVerInfo.dwPlatformId of
825 833 VER_PLATFORM_WIN32_NT: { Windows NT/2000 }
826 834 begin
... ... @@ -855,6 +863,13 @@ begin
855 863 end
856 864 else
857 865 Result := cOsUnknown;
  866 +
  867 + // Defino o valor da ID Interna
  868 + str_te_so := IntToStr(platformId) + '.' +
  869 + IntToStr(majorVer) + '.' +
  870 + IntToStr(minorVer) +
  871 + IfThen(CSDVersion='','','.'+CSDVersion);
  872 +
858 873 end;
859 874  
860 875  
... ... @@ -1158,6 +1173,7 @@ begin
1158 1173 Request_mapa := TStringList.Create;
1159 1174 Request_mapa.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));
1160 1175 Request_mapa.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));
  1176 + Request_mapa.Values['te_so'] := frmMapaCacic.EnCrypt(str_te_so);
1161 1177 Request_mapa.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));
1162 1178 Request_mapa.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));
1163 1179 Request_mapa.Values['te_nome_computador'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened));
... ... @@ -1539,6 +1555,7 @@ begin
1539 1555 Request_mapa := TStringList.Create;
1540 1556 Request_mapa.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));
1541 1557 Request_mapa.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));
  1558 + Request_mapa.Values['te_so'] := frmMapaCacic.EnCrypt(str_te_so);
1542 1559 Request_mapa.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));
1543 1560 Request_mapa.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));
1544 1561 Request_mapa.Values['te_nome_computador']:= frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', frmMapaCacic.tStringsCipherOpened));
... ...
mapa/mapacacic.dof
... ... @@ -115,7 +115,7 @@ AutoIncBuild=0
115 115 MajorVer=1
116 116 MinorVer=0
117 117 Release=0
118   -Build=3
  118 +Build=4
119 119 Debug=0
120 120 PreRelease=0
121 121 Special=0
... ... @@ -126,13 +126,13 @@ CodePage=1252
126 126 [Version Info Keys]
127 127 CompanyName=Dataprev-ES
128 128 FileDescription=MapaCacic - Módulo Avulso para Coleta de Informações Patrimoniais para o Sistema CACIC
129   -FileVersion=1.0.0.3
  129 +FileVersion=1.0.0.4
130 130 InternalName=
131 131 LegalCopyright=
132 132 LegalTrademarks=
133 133 OriginalFilename=
134 134 ProductName=
135   -ProductVersion=1.0.0.0
  135 +ProductVersion=1.0.0.4
136 136 Comments=Baseado na Licença GPL(General Public License)
137 137 [HistoryLists\hlDebugSourcePath]
138 138 Count=1
... ...
mapa/mapacacic.res
No preview for this file type
testacrypt/main_testacrypt.dcu
No preview for this file type
testacrypt/main_testacrypt.dfm
... ... @@ -57,7 +57,7 @@ object Form1: TForm1
57 57 MaxLength = 100
58 58 ParentFont = False
59 59 TabOrder = 0
60   - Text = 'http://10.0.135.167/cacic2/ws/testacrypt.php'
  60 + Text = 'http://192.168.0.1/cacic2/ws/testacrypt.php'
61 61 end
62 62 end
63 63 object GroupBox_TestesCliente: TGroupBox
... ...
vaca/main_vaca.dcu
No preview for this file type