Commit 5906e45e654c496a800950a6c3e1efcec2fc4cce

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

Adequacoes ao uso de library unica, para reaproveitamento de codigos, propriedad…

…es e metodos, faxina de codigo.

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@765 fecfc0c7-e812-0410-ae72-849f08638ee7
CACIC_Library.pas
@@ -46,9 +46,15 @@ unit CACIC_Library; @@ -46,9 +46,15 @@ unit CACIC_Library;
46 46
47 interface 47 interface
48 48
49 -uses  
50 - Windows, SysUtils, StrUtils, md5;  
51 - 49 +uses
  50 + Windows,
  51 + Classes,
  52 + SysUtils,
  53 + StrUtils,
  54 + MD5,
  55 + DCPcrypt2,
  56 + DCPrijndael,
  57 + DCPbase64;
52 type 58 type
53 59
54 { ------------------------------------------------------------------------------ 60 { ------------------------------------------------------------------------------
@@ -84,19 +90,20 @@ type @@ -84,19 +90,20 @@ type
84 g_osVersionInfoExtended: boolean; 90 g_osVersionInfoExtended: boolean;
85 91
86 public 92 public
87 - function isWindowsVista() : boolean;  
88 - function isWindowsGEVista() : boolean;  
89 - function isWindowsXP() : boolean;  
90 - function isWindowsGEXP() : boolean;  
91 - function isWindowsNTPlataform() : boolean;  
92 - function isWindows2000() : boolean;  
93 - function isWindowsNT() : boolean;  
94 - function isWindows9xME() : boolean;  
95 - function getWindowsStrId() : string;  
96 - function isWindowsAdmin(): Boolean;  
97 - function createSampleProcess(p_cmd: string; p_wait: boolean ): boolean; 93 + function isWindowsVista() : boolean;
  94 + function isWindowsGEVista() : boolean;
  95 + function isWindowsXP() : boolean;
  96 + function isWindowsGEXP() : boolean;
  97 + function isWindowsNTPlataform() : boolean;
  98 + function isWindows2000() : boolean;
  99 + function isWindowsNT() : boolean;
  100 + function isWindows9xME() : boolean;
  101 + function getWindowsStrId() : string;
  102 + function getWinDir() : string;
  103 + function getHomeDrive : string;
  104 + function isWindowsAdmin() : boolean;
  105 + function createSampleProcess(p_cmd: string; p_wait: boolean ) : boolean;
98 procedure showTrayIcon(p_visible:boolean); 106 procedure showTrayIcon(p_visible:boolean);
99 - function GetFileHash(strFileName : String) : String;  
100 end; 107 end;
101 108
102 {*------------------------------------------------------------------------------ 109 {*------------------------------------------------------------------------------
@@ -128,16 +135,49 @@ type @@ -128,16 +135,49 @@ type
128 135
129 public 136 public
130 Windows : TCACIC_Windows; /// objeto de informacoes de windows 137 Windows : TCACIC_Windows; /// objeto de informacoes de windows
131 - Debug : TCACIC_Debug; /// objeto de tratamento de debug 138 + Debug : TCACIC_Debug; /// objeto de tratamento de debug
132 procedure setCacicPath(p_cacic_path: string); 139 procedure setCacicPath(p_cacic_path: string);
133 - function getCacicPath(): string;  
134 - function trimEspacosExcedentes(p_str: string): string;  
135 - function isAppRunning( p_app_name: PAnsiChar ): boolean; 140 + function deCrypt(p_Data : String) : String;
  141 + function enCrypt(p_Data : String) : String;
  142 + function explode(p_String, p_Separador : String) : TStrings;
  143 + function implode(p_Array : TStrings ; p_Separador : String) : String;
  144 + function getCacicPath() : String;
  145 + function getCipherKey() : String;
  146 + function getIV() : String;
  147 + function getKeySize() : integer;
  148 + function getBlockSize() : integer;
  149 + function getDatFileName() : String;
  150 + function getSeparatorKey() : String;
  151 + function getFileHash(strFileName : String) : String;
  152 + function isAppRunning( p_app_name: PAnsiChar ) : boolean;
  153 + function padWithZeros(const str : string; size : integer) : String;
  154 + function trimEspacosExcedentes(p_str: string) : String;
  155 +
136 end; 156 end;
137 157
138 // Declaração de constantes para a biblioteca 158 // Declaração de constantes para a biblioteca
139 -const CACIC_PROCESS_WAIT = true; // aguardar fim do processo  
140 -const CACIC_PROCESS_NOWAIT = false; // não aguardar o fim do processo 159 +const
  160 + CACIC_PROCESS_WAIT = true; // aguardar fim do processo
  161 + CACIC_PROCESS_NOWAIT = false; // não aguardar o fim do processo
  162 +
  163 +// Some constants that are dependant on the cipher being used
  164 +// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)
  165 +const
  166 + CACIC_KEYSIZE = 32; // 32 bytes = 256 bits
  167 + CACIC_BLOCKSIZE = 16; // 16 bytes = 128 bits
  168 +
  169 +// Chave AES. Recomenda-se que cada empresa altere a sua chave.
  170 +// Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez,
  171 +// passa para o Inicializador de Coletas e este passa para os coletores...
  172 +const
  173 + CACIC_CIPHERKEY = 'CacicBrasil';
  174 + CACIC_IV = 'abcdefghijklmnop';
  175 + CACIC_SEPARATORKEY = '=CacicIsFree='; // Usada apenas para o cacic2.dat
  176 +
  177 +// Arquivo local para armazenamento de configurações e informações coletadas
  178 +const
  179 + CACIC_DATFILENAME = 'cacic2.dat';
  180 +
141 var 181 var
142 P_OSVersionInfo: POSVersionInfo; 182 P_OSVersionInfo: POSVersionInfo;
143 183
@@ -178,6 +218,80 @@ begin @@ -178,6 +218,80 @@ begin
178 end; 218 end;
179 219
180 {*------------------------------------------------------------------------------ 220 {*------------------------------------------------------------------------------
  221 + Retorna a pasta de instalação do MS-Windows
  222 +-------------------------------------------------------------------------------}
  223 +function TCACIC_Windows.getWinDir : string;
  224 +var
  225 + WinPath: array[0..MAX_PATH + 1] of char;
  226 +begin
  227 + GetWindowsDirectory(WinPath,MAX_PATH);
  228 + Result := StrPas(WinPath)+'\';
  229 +end;
  230 +
  231 +{*------------------------------------------------------------------------------
  232 + Retorna a unidade de instalação do MS-Windows
  233 +-------------------------------------------------------------------------------}
  234 +function TCACIC_Windows.getHomeDrive : string;
  235 +begin
  236 + Result := MidStr(getWinDir,1,3); //x:\
  237 +end;
  238 +
  239 +{*------------------------------------------------------------------------------
  240 + Retorna array de elementos com base em separador
  241 +
  242 + @param p_String String contendo campos e valores separados por caracter ou string
  243 + @param p_Separador String separadora de campos e valores
  244 +-------------------------------------------------------------------------------}
  245 +Function TCACIC.explode(p_String, p_Separador : String) : TStrings;
  246 +var
  247 + strItem : String;
  248 + ListaAuxUTILS : TStrings;
  249 + NumCaracteres,
  250 + TamanhoSeparador,
  251 + I : Integer;
  252 +Begin
  253 + ListaAuxUTILS := TStringList.Create;
  254 + strItem := '';
  255 + NumCaracteres := Length(p_String);
  256 + TamanhoSeparador := Length(p_Separador);
  257 + I := 1;
  258 + While I <= NumCaracteres Do
  259 + Begin
  260 + If (Copy(p_String,I,TamanhoSeparador) = p_Separador) or (I = NumCaracteres) Then
  261 + Begin
  262 + if (I = NumCaracteres) then strItem := strItem + p_String[I];
  263 + ListaAuxUTILS.Add(trim(strItem));
  264 + strItem := '';
  265 + I := I + (TamanhoSeparador-1);
  266 + end
  267 + Else
  268 + strItem := strItem + p_String[I];
  269 +
  270 + I := I + 1;
  271 + End;
  272 + Explode := ListaAuxUTILS;
  273 +end;
  274 +
  275 +{*------------------------------------------------------------------------------
  276 + Retorna string com campos e valores separados por caracter ou string
  277 +
  278 + @param p_Array Array contendo campos e valores
  279 + @param p_Separador String separadora de campos e valores
  280 +-------------------------------------------------------------------------------}
  281 +Function TCACIC.implode(p_Array : TStrings ; p_Separador : String) : String;
  282 +var intAux : integer;
  283 + strAux : string;
  284 +Begin
  285 + strAux := '';
  286 + For intAux := 0 To p_Array.Count -1 do
  287 + Begin
  288 + if (strAux<>'') then strAux := strAux + p_Separador;
  289 + strAux := strAux + p_Array[intAux];
  290 + End;
  291 + Implode := strAux;
  292 +end;
  293 +
  294 +{*------------------------------------------------------------------------------
181 Elimina espacos excedentes na string 295 Elimina espacos excedentes na string
182 296
183 @param p_str String a excluir espacos 297 @param p_str String a excluir espacos
@@ -537,7 +651,7 @@ end; @@ -537,7 +651,7 @@ end;
537 @autor: Anderson Peterle 651 @autor: Anderson Peterle
538 @param p_strFileName - Nome do arquivo para extração do HashCode 652 @param p_strFileName - Nome do arquivo para extração do HashCode
539 -------------------------------------------------------------------------------} 653 -------------------------------------------------------------------------------}
540 -function TCACIC_Windows.GetFileHash(strFileName : String) : String; 654 +function TCACIC.GetFileHash(strFileName : String) : String;
541 Begin 655 Begin
542 Result := 'Arquivo "'+strFileName+'" Inexistente!'; 656 Result := 'Arquivo "'+strFileName+'" Inexistente!';
543 if (FileExists(strFileName)) then 657 if (FileExists(strFileName)) then
@@ -575,4 +689,149 @@ procedure TCACIC_Windows.showTrayIcon(p_visible:boolean); @@ -575,4 +689,149 @@ procedure TCACIC_Windows.showTrayIcon(p_visible:boolean);
575 End; 689 End;
576 End; 690 End;
577 691
  692 +{*------------------------------------------------------------------------------
  693 + Obter a chave para criptografia simétrica
  694 +
  695 + @return String contendo a chave simétrica
  696 +-------------------------------------------------------------------------------}
  697 +function TCACIC.getCipherKey(): string;
  698 +begin
  699 + Result := CACIC_CIPHERKEY;
  700 +end;
  701 +
  702 +{*------------------------------------------------------------------------------
  703 + Obter o vetor de inicialização para criptografia
  704 +
  705 + @return String contendo o vetor de inicialização
  706 +-------------------------------------------------------------------------------}
  707 +function TCACIC.getIV(): string;
  708 +begin
  709 + Result := CACIC_IV;
  710 +end;
  711 +
  712 +{*------------------------------------------------------------------------------
  713 + Obter o valor para tamanho da chave de criptografia
  714 +
  715 + @return Integer contendo o tamanho para chave de criptografia
  716 +-------------------------------------------------------------------------------}
  717 +function TCACIC.getKeySize(): Integer;
  718 +begin
  719 + Result := CACIC_KEYSIZE;
  720 +end;
  721 +
  722 +{*------------------------------------------------------------------------------
  723 + Obter o valor para tamanho do bloco de criptografia
  724 +
  725 + @return Integer contendo o tamanho para bloco de criptografia
  726 +-------------------------------------------------------------------------------}
  727 +function TCACIC.getBlockSize(): Integer;
  728 +begin
  729 + Result := CACIC_BLOCKSIZE;
  730 +end;
  731 +
  732 +{*------------------------------------------------------------------------------
  733 + Obter o nome do arquivo de informações de configurações e dados locais
  734 +
  735 + @return String contendo o nome do arquivo de configurações e dados locais
  736 +-------------------------------------------------------------------------------}
  737 +function TCACIC.getDatFileName(): string;
  738 +begin
  739 + Result := CACIC_DATFILENAME;
  740 +end;
  741 +
  742 +{*------------------------------------------------------------------------------
  743 + Obter o separador para criação de listas locais
  744 +
  745 + @return String contendo o separador de campos e valores
  746 +-------------------------------------------------------------------------------}
  747 +function TCACIC.getSeparatorKey(): string;
  748 +begin
  749 + Result := CACIC_SEPARATORKEY;
  750 +end;
  751 +
  752 +// Encrypt a string and return the Base64 encoded result
  753 +function TCACIC.enCrypt(p_Data : String) : String;
  754 +var
  755 + l_Cipher : TDCP_rijndael;
  756 + l_Data, l_Key, l_IV : string;
  757 +begin
  758 + Try
  759 + // Pad Key, IV and Data with zeros as appropriate
  760 + l_Key := PadWithZeros(CACIC_CIPHERKEY,CACIC_KEYSIZE);
  761 + l_IV := PadWithZeros(CACIC_IV,CACIC_BLOCKSIZE);
  762 + l_Data := PadWithZeros(p_Data,CACIC_BLOCKSIZE);
  763 +
  764 + // Create the cipher and initialise according to the key length
  765 + l_Cipher := TDCP_rijndael.Create(nil);
  766 + if Length(CACIC_CIPHERKEY) <= 16 then
  767 + l_Cipher.Init(l_Key[1],128,@l_IV[1])
  768 + else if Length(CACIC_CIPHERKEY) <= 24 then
  769 + l_Cipher.Init(l_Key[1],192,@l_IV[1])
  770 + else
  771 + l_Cipher.Init(l_Key[1],256,@l_IV[1]);
  772 +
  773 + // Encrypt the data
  774 + l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));
  775 +
  776 + // Free the cipher and clear sensitive information
  777 + l_Cipher.Free;
  778 + FillChar(l_Key[1],Length(l_Key),0);
  779 +
  780 + // Return the Base64 encoded result
  781 + Result := Base64EncodeStr(l_Data);
  782 + Except
  783 +// LogDiario('Erro no Processo de Criptografia');
  784 + End;
  785 +end;
  786 +
  787 +function TCACIC.deCrypt(p_Data : String) : String;
  788 +var
  789 + l_Cipher : TDCP_rijndael;
  790 + l_Data, l_Key, l_IV : string;
  791 +begin
  792 + Try
  793 + // Pad Key and IV with zeros as appropriate
  794 + l_Key := PadWithZeros(CACIC_CIPHERKEY,CACIC_KEYSIZE);
  795 + l_IV := PadWithZeros(CACIC_IV,CACIC_BLOCKSIZE);
  796 +
  797 + // Decode the Base64 encoded string
  798 + l_Data := Base64DecodeStr(p_Data);
  799 +
  800 + // Create the cipher and initialise according to the key length
  801 + l_Cipher := TDCP_rijndael.Create(nil);
  802 + if Length(CACIC_CIPHERKEY) <= 16 then
  803 + l_Cipher.Init(l_Key[1],128,@l_IV[1])
  804 + else if Length(CACIC_CIPHERKEY) <= 24 then
  805 + l_Cipher.Init(l_Key[1],192,@l_IV[1])
  806 + else
  807 + l_Cipher.Init(l_Key[1],256,@l_IV[1]);
  808 +
  809 + // Decrypt the data
  810 + l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));
  811 +
  812 + // Free the cipher and clear sensitive information
  813 + l_Cipher.Free;
  814 + FillChar(l_Key[1],Length(l_Key),0);
  815 +
  816 + // Return the result
  817 + Result := l_Data;
  818 + Except
  819 +// LogDiario('Erro no Processo de Decriptografia');
  820 + End;
  821 +end;
  822 +
  823 +// Pad a string with zeros so that it is a multiple of size
  824 +function TCACIC.padWithZeros(const str : string; size : integer) : string;
  825 +var origsize, i : integer;
  826 +begin
  827 + Result := str;
  828 + origsize := Length(Result);
  829 + if ((origsize mod size) <> 0) or (origsize = 0) then
  830 + begin
  831 + SetLength(Result,((origsize div size)+1)*size);
  832 + for i := origsize+1 to Length(Result) do
  833 + Result[i] := #0;
  834 + end;
  835 +end;
  836 +
578 end. 837 end.
@@ -32,9 +32,6 @@ uses Windows, @@ -32,9 +32,6 @@ uses Windows,
32 registry, 32 registry,
33 dialogs, 33 dialogs,
34 PJVersionInfo, 34 PJVersionInfo,
35 - DCPcrypt2,  
36 - DCPrijndael,  
37 - DCPbase64,  
38 ComCtrls, 35 ComCtrls,
39 IdBaseComponent, 36 IdBaseComponent,
40 IdComponent, 37 IdComponent,
@@ -48,16 +45,9 @@ uses Windows, @@ -48,16 +45,9 @@ uses Windows,
48 const WM_MYMESSAGE = WM_USER+100; 45 const WM_MYMESSAGE = WM_USER+100;
49 46
50 // Declaração das variáveis globais. 47 // Declaração das variáveis globais.
51 -var p_path_cacic,  
52 - p_path_cacic_ini,  
53 - p_Shell_Command, 48 +var p_Shell_Command,
54 p_Shell_Path, 49 p_Shell_Path,
55 v_versao, 50 v_versao,
56 - g_te_so,  
57 - v_CipherKey,  
58 - v_SeparatorKey,  
59 - v_IV,  
60 - v_DatFileName,  
61 v_DataCacic2DAT, 51 v_DataCacic2DAT,
62 v_Tamanho_Arquivo, 52 v_Tamanho_Arquivo,
63 strConfigsPatrimonio : string; 53 strConfigsPatrimonio : string;
@@ -235,9 +225,6 @@ type @@ -235,9 +225,6 @@ type
235 Function Explode(Texto, Separador : String) : TStrings; 225 Function Explode(Texto, Separador : String) : TStrings;
236 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String; 226 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
237 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings); 227 Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String; p_tstrCipherOpened : TStrings);
238 - function PadWithZeros(const str : string; size : integer) : string;  
239 - function EnCrypt(p_Data : String) : String;  
240 - function DeCrypt(p_Data : String) : String;  
241 function URLDecode(const S: string): string; 228 function URLDecode(const S: string): string;
242 Function XML_RetornaValor(Tag : String; Fonte : String): String; 229 Function XML_RetornaValor(Tag : String; Fonte : String): String;
243 end; 230 end;
@@ -245,11 +232,6 @@ type @@ -245,11 +232,6 @@ type
245 var FormularioGeral : TFormularioGeral; 232 var FormularioGeral : TFormularioGeral;
246 boolServerON : Boolean; 233 boolServerON : Boolean;
247 234
248 -// Some constants that are dependant on the cipher being used  
249 -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)  
250 -const KeySize = 32; // 32 bytes = 256 bits  
251 - BlockSize = 16; // 16 bytes = 128 bits  
252 -  
253 implementation 235 implementation
254 236
255 237
@@ -287,20 +269,6 @@ var VetorUON1 : TVetorUON1; @@ -287,20 +269,6 @@ var VetorUON1 : TVetorUON1;
287 VetorUON1a : TVetorUON1a; 269 VetorUON1a : TVetorUON1a;
288 VetorUON2 : TVetorUON2; 270 VetorUON2 : TVetorUON2;
289 271
290 -// Pad a string with zeros so that it is a multiple of size  
291 -function TFormularioGeral.PadWithZeros(const str : string; size : integer) : string;  
292 -var  
293 - origsize, i : integer;  
294 -begin  
295 - Result := str;  
296 - origsize := Length(Result);  
297 - if ((origsize mod size) <> 0) or (origsize = 0) then  
298 - begin  
299 - SetLength(Result,((origsize div size)+1)*size);  
300 - for i := origsize+1 to Length(Result) do  
301 - Result[i] := #0;  
302 - end;  
303 -end;  
304 Function TFormularioGeral.RetornaValorVetorUON1(id1 : string) : String; 272 Function TFormularioGeral.RetornaValorVetorUON1(id1 : string) : String;
305 var I : Integer; 273 var I : Integer;
306 begin 274 begin
@@ -355,7 +323,7 @@ begin @@ -355,7 +323,7 @@ begin
355 strTagName := '' 323 strTagName := ''
356 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then 324 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then
357 Begin 325 Begin
358 - strAux1 := DeCrypt(Parser.CurContent); 326 + strAux1 := g_oCacic.deCrypt(Parser.CurContent);
359 if (strItemName = 'ID1') then 327 if (strItemName = 'ID1') then
360 Begin 328 Begin
361 VetorUON1[i].id1 := strAux1; 329 VetorUON1[i].id1 := strAux1;
@@ -387,7 +355,7 @@ begin @@ -387,7 +355,7 @@ begin
387 strTagName := '' 355 strTagName := ''
388 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then 356 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then
389 Begin 357 Begin
390 - strAux1 := DeCrypt(Parser.CurContent); 358 + strAux1 := g_oCacic.deCrypt(Parser.CurContent);
391 if (strItemName = 'ID1') then 359 if (strItemName = 'ID1') then
392 Begin 360 Begin
393 VetorUON1a[i].id1 := strAux1; 361 VetorUON1a[i].id1 := strAux1;
@@ -433,7 +401,7 @@ begin @@ -433,7 +401,7 @@ begin
433 strTagName := '' 401 strTagName := ''
434 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then 402 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then
435 Begin 403 Begin
436 - strAux1 := DeCrypt(Parser.CurContent); 404 + strAux1 := g_oCacic.deCrypt(Parser.CurContent);
437 if (strItemName = 'ID1A') then 405 if (strItemName = 'ID1A') then
438 Begin 406 Begin
439 VetorUON2[i].id1a := strAux1; 407 VetorUON2[i].id1a := strAux1;
@@ -460,89 +428,6 @@ begin @@ -460,89 +428,6 @@ begin
460 Parser.Free; 428 Parser.Free;
461 end; 429 end;
462 430
463 -// Encrypt a string and return the Base64 encoded result  
464 -function TFormularioGeral.EnCrypt(p_Data : String) : String;  
465 -var  
466 - l_Cipher : TDCP_rijndael;  
467 - l_Data, l_Key, l_IV : string;  
468 -begin  
469 - if boolCrypt then  
470 - Begin  
471 - Try  
472 - // Pad Key, IV and Data with zeros as appropriate  
473 - l_Key := PadWithZeros(v_CipherKey,KeySize);  
474 - log_DEBUG('Encrypt: l_Key => "'+l_Key+'"');  
475 - l_IV := PadWithZeros(v_IV,BlockSize);  
476 - log_DEBUG('Encrypt: l_IV => "'+l_IV+'"');  
477 - l_Data := PadWithZeros(p_Data,BlockSize);  
478 - log_DEBUG('Encrypt: l_Data antes CBC => "'+l_Data+'"');  
479 - // Create the cipher and initialise according to the key length  
480 - l_Cipher := TDCP_rijndael.Create(nil);  
481 - if Length(v_CipherKey) <= 16 then  
482 - l_Cipher.Init(l_Key[1],128,@l_IV[1])  
483 - else if Length(v_CipherKey) <= 24 then  
484 - l_Cipher.Init(l_Key[1],192,@l_IV[1])  
485 - else  
486 - l_Cipher.Init(l_Key[1],256,@l_IV[1]);  
487 -  
488 - // Encrypt the data  
489 - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));  
490 - log_DEBUG('Encrypt: l_Data após CBC e Antes do Base64Encode=> "'+l_Data+'"');  
491 - // Free the cipher and clear sensitive information  
492 - l_Cipher.Free;  
493 - FillChar(l_Key[1],Length(l_Key),0);  
494 -  
495 - // Return the Base64 encoded result  
496 - Result := Base64EncodeStr(l_Data);  
497 - log_DEBUG('Encrypt: l_Data após Base64Encode=> "'+l_Data+'"');  
498 - Except  
499 - log_diario('Erro no Processo de Criptografia');  
500 - End;  
501 - End  
502 - else  
503 - Result := p_Data;  
504 -end;  
505 -  
506 -function TFormularioGeral.DeCrypt(p_Data : String) : String;  
507 -var  
508 - l_Cipher : TDCP_rijndael;  
509 - l_Data, l_Key, l_IV : string;  
510 -begin  
511 - if boolCrypt then  
512 - Begin  
513 - Try  
514 - // Pad Key and IV with zeros as appropriate  
515 - l_Key := PadWithZeros(v_CipherKey,KeySize);  
516 - l_IV := PadWithZeros(v_IV,BlockSize);  
517 -  
518 - // Decode the Base64 encoded string  
519 - l_Data := Base64DecodeStr(p_Data);  
520 -  
521 - // Create the cipher and initialise according to the key length  
522 - l_Cipher := TDCP_rijndael.Create(nil);  
523 - if Length(v_CipherKey) <= 16 then  
524 - l_Cipher.Init(l_Key[1],128,@l_IV[1])  
525 - else if Length(v_CipherKey) <= 24 then  
526 - l_Cipher.Init(l_Key[1],192,@l_IV[1])  
527 - else  
528 - l_Cipher.Init(l_Key[1],256,@l_IV[1]);  
529 -  
530 - // Decrypt the data  
531 - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));  
532 -  
533 - // Free the cipher and clear sensitive information  
534 - l_Cipher.Free;  
535 - FillChar(l_Key[1],Length(l_Key),0);  
536 -  
537 - // Return the result  
538 - Result := trim(RemoveZerosFimString(l_Data));  
539 - Except  
540 - log_diario('Erro no Processo de Decriptografia');  
541 - End;  
542 - End  
543 - else  
544 - Result := p_Data;  
545 -end;  
546 431
547 function Pode_Coletar : boolean; 432 function Pode_Coletar : boolean;
548 var v_JANELAS_EXCECAO, v_plural1, v_plural2 : string; 433 var v_JANELAS_EXCECAO, v_plural1, v_plural2 : string;
@@ -551,15 +436,15 @@ var v_JANELAS_EXCECAO, v_plural1, v_plural2 : string; @@ -551,15 +436,15 @@ var v_JANELAS_EXCECAO, v_plural1, v_plural2 : string;
551 v_contador, intContaJANELAS, intAux : integer; 436 v_contador, intContaJANELAS, intAux : integer;
552 Begin 437 Begin
553 // Se eu conseguir matar o arquivo abaixo é porque Ger_Cols e Ini_Cols já finalizaram suas atividades... 438 // Se eu conseguir matar o arquivo abaixo é porque Ger_Cols e Ini_Cols já finalizaram suas atividades...
554 - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_SRCACIC.txt');  
555 - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_GER.txt');  
556 - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_INI.txt'); 439 + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_SRCACIC.txt');
  440 + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_GER.txt');
  441 + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_INI.txt');
557 intContaJANELAS := 0; 442 intContaJANELAS := 0;
558 h := 0; 443 h := 0;
559 444
560 - if (not FileExists(p_path_cacic + 'temp\aguarde_GER.txt') and  
561 - not FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt') and  
562 - not FileExists(p_path_cacic + 'temp\aguarde_INI.txt')) then 445 + if (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_GER.txt') and
  446 + not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt') and
  447 + not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_INI.txt')) then
563 Begin 448 Begin
564 FormularioGeral.CipherOpen; 449 FormularioGeral.CipherOpen;
565 // Verificação das janelas abertas para que não aconteça coletas caso haja aplicações pesadas rodando (configurado no Módulo Gerente) 450 // Verificação das janelas abertas para que não aconteça coletas caso haja aplicações pesadas rodando (configurado no Módulo Gerente)
@@ -611,19 +496,19 @@ Begin @@ -611,19 +496,19 @@ Begin
611 496
612 if (intContaJANELAS = 0) and 497 if (intContaJANELAS = 0) and
613 (h = 0) and 498 (h = 0) and
614 - (not FileExists(p_path_cacic + 'temp\aguarde_GER.txt')) and  
615 - (not FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt')) and  
616 - (not FileExists(p_path_cacic + 'temp\aguarde_INI.txt')) then 499 + (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_GER.txt')) and
  500 + (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt')) and
  501 + (not FileExists(g_oCacic.getCacicPath + 'temp\aguarde_INI.txt')) then
617 Result := true 502 Result := true
618 else 503 else
619 Begin 504 Begin
620 FormularioGeral.log_DEBUG('Ação NEGADA!'); 505 FormularioGeral.log_DEBUG('Ação NEGADA!');
621 if (intContaJANELAS=0) then 506 if (intContaJANELAS=0) then
622 - if (FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt')) then 507 + if (FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt')) then
623 FormularioGeral.log_DEBUG('Suporte Remoto em atividade.') 508 FormularioGeral.log_DEBUG('Suporte Remoto em atividade.')
624 - else if (FileExists(p_path_cacic + 'temp\aguarde_GER.txt')) then 509 + else if (FileExists(g_oCacic.getCacicPath + 'temp\aguarde_GER.txt')) then
625 FormularioGeral.log_DEBUG('Gerente de Coletas em atividade.') 510 FormularioGeral.log_DEBUG('Gerente de Coletas em atividade.')
626 - else if (FileExists(p_path_cacic + 'temp\aguarde_INI.txt')) then 511 + else if (FileExists(g_oCacic.getCacicPath + 'temp\aguarde_INI.txt')) then
627 FormularioGeral.log_DEBUG('Inicializador de Coletas em atividade.') 512 FormularioGeral.log_DEBUG('Inicializador de Coletas em atividade.')
628 else FormularioGeral.CipherClose; 513 else FormularioGeral.CipherClose;
629 Result := false; 514 Result := false;
@@ -680,33 +565,33 @@ var v_DatFile : TextFile; @@ -680,33 +565,33 @@ var v_DatFile : TextFile;
680 v_strCipherClosed : string; 565 v_strCipherClosed : string;
681 begin 566 begin
682 567
683 - log_DEBUG('Fechando '+v_DatFileName); 568 + log_DEBUG('Fechando '+g_oCacic.getDatFileName);
684 if boolDebugs then 569 if boolDebugs then
685 for intAux := 0 to (v_tstrCipherOpened.Count-1) do 570 for intAux := 0 to (v_tstrCipherOpened.Count-1) do
686 log_DEBUG('Posição ['+inttostr(intAux)+']='+v_tstrCipherOpened[intAux]); 571 log_DEBUG('Posição ['+inttostr(intAux)+']='+v_tstrCipherOpened[intAux]);
687 572
688 try 573 try
689 - FileSetAttr (v_DatFileName,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 574 + FileSetAttr (g_oCacic.getDatFileName,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
690 575
691 - log_DEBUG('Localizando arquivo: '+v_DatFileName);  
692 - AssignFile(v_DatFile,v_DatFileName); {Associa o arquivo a uma variável do tipo TextFile} 576 + log_DEBUG('Localizando arquivo: '+g_oCacic.getDatFileName);
  577 + AssignFile(v_DatFile,g_oCacic.getDatFileName); {Associa o arquivo a uma variável do tipo TextFile}
693 {$IOChecks off} 578 {$IOChecks off}
694 - log_DEBUG('Abrindo arquivo: '+v_DatFileName); 579 + log_DEBUG('Abrindo arquivo: '+g_oCacic.getDatFileName);
695 ReWrite(v_DatFile); {Abre o arquivo texto} 580 ReWrite(v_DatFile); {Abre o arquivo texto}
696 {$IOChecks on} 581 {$IOChecks on}
697 - log_DEBUG('Append(2) no arquivo: '+v_DatFileName); 582 + log_DEBUG('Append(2) no arquivo: '+g_oCacic.getDatFileName);
698 Append(v_DatFile); 583 Append(v_DatFile);
699 log_DEBUG('Criando vetor para criptografia.'); 584 log_DEBUG('Criando vetor para criptografia.');
700 - v_strCipherOpenImploded := Implode(v_tstrCipherOpened,v_SeparatorKey); 585 + v_strCipherOpenImploded := Implode(v_tstrCipherOpened,g_oCacic.getSeparatorKey);
701 586
702 - log_DEBUG('Salvando a string "'+v_strCipherOpenImploded+'" em '+v_DatFileName);  
703 - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded); 587 + log_DEBUG('Salvando a string "'+v_strCipherOpenImploded+'" em '+g_oCacic.getDatFileName);
  588 + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded);
704 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto} 589 Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto}
705 CloseFile(v_DatFile); 590 CloseFile(v_DatFile);
706 except 591 except
707 - log_diario('ERRO NA GRAVAÇÃO DO ARQUIVO DE CONFIGURAÇÕES.('+v_DatFileName+')'); 592 + log_diario('ERRO NA GRAVAÇÃO DO ARQUIVO DE CONFIGURAÇÕES.('+g_oCacic.getDatFileName+')');
708 end; 593 end;
709 - log_DEBUG(v_DatFileName+' fechado com sucesso!'); 594 + log_DEBUG(g_oCacic.getDatFileName+' fechado com sucesso!');
710 end; 595 end;
711 596
712 function TFormularioGeral.Get_File_Size(sFileToExamine: string; bInKBytes: Boolean): string; 597 function TFormularioGeral.Get_File_Size(sFileToExamine: string; bInKBytes: Boolean): string;
@@ -734,22 +619,22 @@ var v_DatFile : TextFile; @@ -734,22 +619,22 @@ var v_DatFile : TextFile;
734 v_strCipherClosed : string; 619 v_strCipherClosed : string;
735 begin 620 begin
736 621
737 - if (v_DataCacic2DAT = '') or (v_DataCacic2DAT <> FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(p_path_cacic + 'cacic2.dat'))) then 622 + if (v_DataCacic2DAT = '') or (v_DataCacic2DAT <> FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(g_oCacic.getCacicPath + 'cacic2.dat'))) then
738 Begin 623 Begin
739 - v_DataCacic2DAT := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(p_path_cacic + 'cacic2.dat'));  
740 - log_DEBUG('Abrindo '+v_DatFileName +' - DateTime Cacic2.dat=> '+v_DataCacic2DAT); 624 + v_DataCacic2DAT := FormatDateTime('ddmmyyyyhhnnsszzz', GetFolderDate(g_oCacic.getCacicPath + 'cacic2.dat'));
  625 + log_DEBUG('Abrindo '+g_oCacic.getDatFileName +' - DateTime Cacic2.dat=> '+v_DataCacic2DAT);
741 v_strCipherOpened := ''; 626 v_strCipherOpened := '';
742 627
743 - v_Tamanho_Arquivo := Get_File_Size(v_DatFileName,true); 628 + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getDatFileName,true);
744 629
745 if (v_Tamanho_Arquivo = '0') or 630 if (v_Tamanho_Arquivo = '0') or
746 - (v_Tamanho_Arquivo = '-1') then FormularioGeral.Matar(p_path_cacic,'cacic2.dat'); 631 + (v_Tamanho_Arquivo = '-1') then FormularioGeral.Matar(g_oCacic.getCacicPath,'cacic2.dat');
747 632
748 - if FileExists(v_DatFileName) then 633 + if FileExists(g_oCacic.getDatFileName) then
749 begin 634 begin
750 - log_DEBUG(v_DatFileName+' já existe!');  
751 - AssignFile(v_DatFile,v_DatFileName);  
752 - log_DEBUG('Abrindo '+v_DatFileName); 635 + log_DEBUG(g_oCacic.getDatFileName+' já existe!');
  636 + AssignFile(v_DatFile,g_oCacic.getDatFileName);
  637 + log_DEBUG('Abrindo '+g_oCacic.getDatFileName);
753 638
754 {$IOChecks off} 639 {$IOChecks off}
755 Reset(v_DatFile); 640 Reset(v_DatFile);
@@ -758,30 +643,30 @@ begin @@ -758,30 +643,30 @@ begin
758 log_DEBUG('Verificação de Existência.'); 643 log_DEBUG('Verificação de Existência.');
759 if (IOResult <> 0)then // Arquivo não existe, será recriado. 644 if (IOResult <> 0)then // Arquivo não existe, será recriado.
760 begin 645 begin
761 - log_DEBUG('Recriando "'+v_DatFileName+'"'); 646 + log_DEBUG('Recriando "'+g_oCacic.getDatFileName+'"');
762 Rewrite (v_DatFile); 647 Rewrite (v_DatFile);
763 log_DEBUG('Inserindo Primeira Linha.'); 648 log_DEBUG('Inserindo Primeira Linha.');
764 Append(v_DatFile); 649 Append(v_DatFile);
765 end; 650 end;
766 651
767 - log_DEBUG('Lendo '+v_DatFileName); 652 + log_DEBUG('Lendo '+g_oCacic.getDatFileName);
768 653
769 Readln(v_DatFile,v_strCipherClosed); 654 Readln(v_DatFile,v_strCipherClosed);
770 655
771 log_DEBUG('Povoando Variável'); 656 log_DEBUG('Povoando Variável');
772 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed); 657 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed);
773 - log_DEBUG('Fechando '+v_DatFileName); 658 + log_DEBUG('Fechando '+g_oCacic.getDatFileName);
774 CloseFile(v_DatFile); 659 CloseFile(v_DatFile);
775 log_DEBUG('Chamando Criptografia de conteúdo'); 660 log_DEBUG('Chamando Criptografia de conteúdo');
776 - v_strCipherOpened:= Decrypt(v_strCipherClosed); 661 + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed);
777 end; 662 end;
778 if (trim(v_strCipherOpened)<>'') then 663 if (trim(v_strCipherOpened)<>'') then
779 - v_tstrCipherOpened := explode(v_strCipherOpened,v_SeparatorKey) 664 + v_tstrCipherOpened := explode(v_strCipherOpened,g_oCacic.getSeparatorKey)
780 else 665 else
781 Begin 666 Begin
782 - v_tstrCipherOpened := explode('Configs.ID_SO'+v_SeparatorKey+ g_oCacic.getWindowsStrId() +v_SeparatorKey+  
783 - 'Configs.Endereco_WS'+v_SeparatorKey+'/cacic2/ws/',v_SeparatorKey);  
784 - log_DEBUG(v_DatFileName+' Inexistente. Criado o DAT em memória.'); 667 + v_tstrCipherOpened := explode('Configs.ID_SO'+g_oCacic.getSeparatorKey+ g_oCacic.getWindowsStrId() +g_oCacic.getSeparatorKey+
  668 + 'Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorKey);
  669 + log_DEBUG(g_oCacic.getDatFileName+' Inexistente. Criado o DAT em memória.');
785 End; 670 End;
786 671
787 Result := v_tstrCipherOpened; 672 Result := v_tstrCipherOpened;
@@ -920,7 +805,7 @@ Begin @@ -920,7 +805,7 @@ Begin
920 Result := true; 805 Result := true;
921 806
922 log_DEBUG('Verificando existência e tamanho do Gerente de Coletas...'); 807 log_DEBUG('Verificando existência e tamanho do Gerente de Coletas...');
923 - v_Tamanho_Arquivo := Get_File_Size(p_path_cacic + 'modulos\ger_cols.exe',true); 808 + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getCacicPath + 'modulos\ger_cols.exe',true);
924 809
925 log_DEBUG('Resultado: #'+v_Tamanho_Arquivo); 810 log_DEBUG('Resultado: #'+v_Tamanho_Arquivo);
926 811
@@ -928,7 +813,7 @@ Begin @@ -928,7 +813,7 @@ Begin
928 Begin 813 Begin
929 Result := false; 814 Result := false;
930 815
931 - Matar(p_path_cacic + 'modulos,'ger_cols.exe'); 816 + Matar(g_oCacic.getCacicPath + 'modulos,'ger_cols.exe');
932 817
933 InicializaTray; 818 InicializaTray;
934 819
@@ -937,7 +822,7 @@ Begin @@ -937,7 +822,7 @@ Begin
937 WinExec(PChar(HomeDrive + '\chksis.exe'),SW_HIDE); 822 WinExec(PChar(HomeDrive + '\chksis.exe'),SW_HIDE);
938 823
939 sleep(30000); // 30 segundos de espera para download do ger_cols.exe 824 sleep(30000); // 30 segundos de espera para download do ger_cols.exe
940 - v_Tamanho_Arquivo := Get_File_Size(p_path_cacic + 'modulos\ger_cols.exe',true); 825 + v_Tamanho_Arquivo := Get_File_Size(g_oCacic.getCacicPath + 'modulos\ger_cols.exe',true);
941 if not(v_Tamanho_Arquivo = '0') and not(v_Tamanho_Arquivo = '-1') then 826 if not(v_Tamanho_Arquivo = '0') and not(v_Tamanho_Arquivo = '-1') then
942 Begin 827 Begin
943 log_diario('Módulo Gerente de Coletas RECUPERADO COM SUCESSO!'); 828 log_diario('Módulo Gerente de Coletas RECUPERADO COM SUCESSO!');
@@ -1142,20 +1027,20 @@ Begin @@ -1142,20 +1027,20 @@ Begin
1142 1027
1143 log_debug('Verificando concomitância de sessões'); 1028 log_debug('Verificando concomitância de sessões');
1144 // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) ) 1029 // Se eu conseguir matar o arquivo abaixo é porque não há outra sessão deste agente aberta... (POG? Nããão! :) )
1145 - FormularioGeral.Matar(p_path_cacic,'aguarde_CACIC.txt');  
1146 - if (not (FileExists(p_path_cacic + 'aguarde_CACIC.txt'))) then 1030 + FormularioGeral.Matar(g_oCacic.getCacicPath,'aguarde_CACIC.txt');
  1031 + if (not (FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt'))) then
1147 result := true; 1032 result := true;
1148 End; 1033 End;
1149 1034
1150 procedure TFormularioGeral.VerificaDebugs; 1035 procedure TFormularioGeral.VerificaDebugs;
1151 Begin 1036 Begin
1152 boolDebugs := false; 1037 boolDebugs := false;
1153 - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then 1038 + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then
1154 Begin 1039 Begin
1155 - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then 1040 + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
1156 Begin 1041 Begin
1157 boolDebugs := true; 1042 boolDebugs := true;
1158 - log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); 1043 + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
1159 End; 1044 End;
1160 End; 1045 End;
1161 End; 1046 End;
@@ -1174,7 +1059,7 @@ begin @@ -1174,7 +1059,7 @@ begin
1174 Application.ShowMainForm:=false; 1059 Application.ShowMainForm:=false;
1175 g_oCacic := TCACIC.Create; 1060 g_oCacic := TCACIC.Create;
1176 //g_oCacic.showTrayIcon(false); 1061 //g_oCacic.showTrayIcon(false);
1177 - boolCrypt := true; 1062 + boolCrypt := true;
1178 1063
1179 Try 1064 Try
1180 // De acordo com a versão do OS, determino o ShellCommand para chamadas externas. 1065 // De acordo com a versão do OS, determino o ShellCommand para chamadas externas.
@@ -1197,30 +1082,30 @@ begin @@ -1197,30 +1082,30 @@ begin
1197 1082
1198 // Caminho do aplicativo 1083 // Caminho do aplicativo
1199 if (v_cacic_dir <> '') then 1084 if (v_cacic_dir <> '') then
1200 - p_path_cacic := v_cacic_dir 1085 + g_oCacic.setCacicPath(v_cacic_dir)
1201 else 1086 else
1202 - p_path_cacic := ExtractFilePath(Application.Exename) ; 1087 + g_oCacic.setCacicPath(ExtractFilePath(Application.Exename)) ;
1203 1088
1204 - if not DirectoryExists(p_path_cacic + 'Temp') then 1089 + if not DirectoryExists(g_oCacic.getCacicPath + 'Temp') then
1205 begin 1090 begin
1206 - ForceDirectories(p_path_cacic + 'Temp');  
1207 - Log_Diario('Criando pasta '+p_path_cacic + 'Temp'); 1091 + ForceDirectories(g_oCacic.getCacicPath + 'Temp');
  1092 + Log_Diario('Criando pasta '+g_oCacic.getCacicPath + 'Temp');
1208 end; 1093 end;
1209 1094
1210 - if not DirectoryExists(p_path_cacic + 'Modulos') then 1095 + if not DirectoryExists(g_oCacic.getCacicPath + 'Modulos') then
1211 begin 1096 begin
1212 - ForceDirectories(p_path_cacic + 'Modulos');  
1213 - Log_Diario('Criando pasta '+p_path_cacic + 'Modulos'); 1097 + ForceDirectories(g_oCacic.getCacicPath + 'Modulos');
  1098 + Log_Diario('Criando pasta '+g_oCacic.getCacicPath + 'Modulos');
1214 end; 1099 end;
1215 1100
1216 VerificaDebugs; 1101 VerificaDebugs;
1217 1102
1218 - log_DEBUG('Pasta do Sistema: "' + p_path_cacic + '"'); 1103 + log_DEBUG('Pasta do Sistema: "' + g_oCacic.getCacicPath + '"');
1219 1104
1220 if Posso_Rodar then 1105 if Posso_Rodar then
1221 Begin 1106 Begin
1222 // Uma forma fácil de evitar que outra sessão deste agente seja iniciada! (POG? Nããããooo!) :)))) 1107 // Uma forma fácil de evitar que outra sessão deste agente seja iniciada! (POG? Nããããooo!) :))))
1223 - AssignFile(v_Aguarde,p_path_cacic + 'aguarde_CACIC.txt'); {Associa o arquivo a uma variável do tipo TextFile} 1108 + AssignFile(v_Aguarde,g_oCacic.getCacicPath + 'aguarde_CACIC.txt'); {Associa o arquivo a uma variável do tipo TextFile}
1224 {$IOChecks off} 1109 {$IOChecks off}
1225 Reset(v_Aguarde); {Abre o arquivo texto} 1110 Reset(v_Aguarde); {Abre o arquivo texto}
1226 {$IOChecks on} 1111 {$IOChecks on}
@@ -1233,36 +1118,29 @@ begin @@ -1233,36 +1118,29 @@ begin
1233 Writeln(v_Aguarde,'Futuramente penso em colocar aqui o pID, para possibilitar finalização via software externo...'); 1118 Writeln(v_Aguarde,'Futuramente penso em colocar aqui o pID, para possibilitar finalização via software externo...');
1234 Append(v_Aguarde); 1119 Append(v_Aguarde);
1235 1120
1236 - // Chave AES. Recomenda-se que cada empresa altere a sua chave.  
1237 - // Esta chave é passada como parâmetro para o Gerente de Coletas que, por sua vez,  
1238 - // passa para o Inicializador de Coletas e este passa para os coletores...  
1239 - v_CipherKey := 'CacicBrasil';  
1240 - v_IV := 'abcdefghijklmnop';  
1241 - v_SeparatorKey := '=CacicIsFree='; // Usada apenas para o cacic2.dat  
1242 - v_DatFileName := p_path_cacic + 'cacic2.dat';  
1243 v_DataCacic2DAT := ''; 1121 v_DataCacic2DAT := '';
1244 v_tstrCipherOpened := TStrings.Create; 1122 v_tstrCipherOpened := TStrings.Create;
1245 v_tstrCipherOpened := CipherOpen; 1123 v_tstrCipherOpened := CipherOpen;
1246 1124
1247 - if FileExists(p_path_cacic + 'cacic2.ini') then 1125 + if FileExists(g_oCacic.getCacicPath + 'cacic2.ini') then
1248 Begin 1126 Begin
1249 - log_DEBUG('O arquivo "'+p_path_cacic + 'cacic2.ini" ainda existe. Vou resgatar algumas chaves/valores');  
1250 - SetValorDatMemoria('Configs.EnderecoServidor' ,getValorChaveRegIni('Configs' ,'EnderecoServidor' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1251 - SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,getValorChaveRegIni('Configs' ,'IN_EXIBE_BANDEJA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1252 - SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,getValorChaveRegIni('Configs' ,'TE_JANELAS_EXCECAO' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1253 - SetValorDatMemoria('Configs.NU_EXEC_APOS' ,getValorChaveRegIni('Configs' ,'NU_EXEC_APOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1254 - SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_EXEC' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1255 - SetValorDatMemoria('Configs.Endereco_WS' ,getValorChaveRegIni('Configs' ,'Endereco_WS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1256 - SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,getValorChaveRegIni('Configs' ,'TE_SENHA_ADM_AGENTE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1257 - SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_RENOVACAO_PATRIM' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1258 - SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA' ,getValorChaveRegIni('Configs' ,'DT_HR_ULTIMA_COLETA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1259 - SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,getValorChaveRegIni('TcpIp' ,'TE_ENDERECOS_MAC_INVALIDOS' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1260 - SetValorDatMemoria('TcpIp.ID_IP_REDE' ,getValorChaveRegIni('TcpIp' ,'ID_IP_REDE' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1261 - SetValorDatMemoria('TcpIp.TE_IP' ,getValorChaveRegIni('TcpIp' ,'TE_IP' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1262 - SetValorDatMemoria('TcpIp.TE_MASCARA' ,getValorChaveRegIni('TcpIp' ,'TE_MASCARA' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1263 - SetValorDatMemoria('Patrimonio.ultima_rede_obtida' ,getValorChaveRegIni('Patrimonio' ,'ultima_rede_obtida' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1264 - SetValorDatMemoria('Patrimonio.dt_ultima_renovacao' ,getValorChaveRegIni('Patrimonio' ,'dt_ultima_renovacao' ,p_path_cacic + 'cacic2.ini'),v_tstrCipherOpened);  
1265 - Matar(p_path_cacic,'cacic2.ini'); 1127 + log_DEBUG('O arquivo "'+g_oCacic.getCacicPath + 'cacic2.ini" ainda existe. Vou resgatar algumas chaves/valores');
  1128 + SetValorDatMemoria('Configs.EnderecoServidor' ,getValorChaveRegIni('Configs' ,'EnderecoServidor' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1129 + SetValorDatMemoria('Configs.IN_EXIBE_BANDEJA' ,getValorChaveRegIni('Configs' ,'IN_EXIBE_BANDEJA' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1130 + SetValorDatMemoria('Configs.TE_JANELAS_EXCECAO' ,getValorChaveRegIni('Configs' ,'TE_JANELAS_EXCECAO' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1131 + SetValorDatMemoria('Configs.NU_EXEC_APOS' ,getValorChaveRegIni('Configs' ,'NU_EXEC_APOS' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1132 + SetValorDatMemoria('Configs.NU_INTERVALO_EXEC' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_EXEC' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1133 + SetValorDatMemoria('Configs.Endereco_WS' ,getValorChaveRegIni('Configs' ,'Endereco_WS' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1134 + SetValorDatMemoria('Configs.TE_SENHA_ADM_AGENTE' ,getValorChaveRegIni('Configs' ,'TE_SENHA_ADM_AGENTE' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1135 + SetValorDatMemoria('Configs.NU_INTERVALO_RENOVACAO_PATRIM' ,getValorChaveRegIni('Configs' ,'NU_INTERVALO_RENOVACAO_PATRIM' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1136 + SetValorDatMemoria('Configs.DT_HR_ULTIMA_COLETA' ,getValorChaveRegIni('Configs' ,'DT_HR_ULTIMA_COLETA' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1137 + SetValorDatMemoria('TcpIp.TE_ENDERECOS_MAC_INVALIDOS' ,getValorChaveRegIni('TcpIp' ,'TE_ENDERECOS_MAC_INVALIDOS' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1138 + SetValorDatMemoria('TcpIp.ID_IP_REDE' ,getValorChaveRegIni('TcpIp' ,'ID_IP_REDE' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1139 + SetValorDatMemoria('TcpIp.TE_IP' ,getValorChaveRegIni('TcpIp' ,'TE_IP' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1140 + SetValorDatMemoria('TcpIp.TE_MASCARA' ,getValorChaveRegIni('TcpIp' ,'TE_MASCARA' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1141 + SetValorDatMemoria('Patrimonio.ultima_rede_obtida' ,getValorChaveRegIni('Patrimonio' ,'ultima_rede_obtida' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1142 + SetValorDatMemoria('Patrimonio.dt_ultima_renovacao' ,getValorChaveRegIni('Patrimonio' ,'dt_ultima_renovacao' ,g_oCacic.getCacicPath + 'cacic2.ini'),v_tstrCipherOpened);
  1143 + Matar(g_oCacic.getCacicPath,'cacic2.ini');
1266 End; 1144 End;
1267 1145
1268 if (ParamCount > 0) then //Caso o Cacic2 seja chamado com passagem de parâmetros... 1146 if (ParamCount > 0) then //Caso o Cacic2 seja chamado com passagem de parâmetros...
@@ -1388,8 +1266,8 @@ var @@ -1388,8 +1266,8 @@ var
1388 strDataArqLocal, strDataAtual : string; 1266 strDataArqLocal, strDataAtual : string;
1389 begin 1267 begin
1390 try 1268 try
1391 - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000  
1392 - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} 1269 + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  1270 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile}
1393 {$IOChecks off} 1271 {$IOChecks off}
1394 Reset(HistoricoLog); {Abre o arquivo texto} 1272 Reset(HistoricoLog); {Abre o arquivo texto}
1395 {$IOChecks on} 1273 {$IOChecks on}
@@ -1401,7 +1279,7 @@ begin @@ -1401,7 +1279,7 @@ begin
1401 end; 1279 end;
1402 if (trim(strMsg) <> '') then 1280 if (trim(strMsg) <> '') then
1403 begin 1281 begin
1404 - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log'))); 1282 + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log')));
1405 DateTimeToString(strDataAtual , 'yyyymmdd', Date); 1283 DateTimeToString(strDataAtual , 'yyyymmdd', Date);
1406 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... 1284 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
1407 begin 1285 begin
@@ -1444,8 +1322,8 @@ end; @@ -1444,8 +1322,8 @@ end;
1444 procedure TFormularioGeral.Invoca_GerCols(Sender: TObject;p_acao:string); 1322 procedure TFormularioGeral.Invoca_GerCols(Sender: TObject;p_acao:string);
1445 var v_versao : string; 1323 var v_versao : string;
1446 begin 1324 begin
1447 - Matar(p_path_cacic + 'temp\','*.txt');  
1448 - Matar(p_path_cacic + 'temp\','*.ini'); 1325 + Matar(g_oCacic.getCacicPath + 'temp\','*.txt');
  1326 + Matar(g_oCacic.getCacicPath + 'temp\','*.ini');
1449 1327
1450 // Caso exista o Gerente de Coletas será verificada a versão e excluída caso antiga(Uma forma de ação pró-ativa) 1328 // Caso exista o Gerente de Coletas será verificada a versão e excluída caso antiga(Uma forma de ação pró-ativa)
1451 if ChecaGERCOLS then 1329 if ChecaGERCOLS then
@@ -1454,7 +1332,7 @@ begin @@ -1454,7 +1332,7 @@ begin
1454 CipherClose; 1332 CipherClose;
1455 log_diario('Invocando Gerente de Coletas com ação: "'+p_acao+'"'); 1333 log_diario('Invocando Gerente de Coletas com ação: "'+p_acao+'"');
1456 Timer_Nu_Exec_Apos.Enabled := False; 1334 Timer_Nu_Exec_Apos.Enabled := False;
1457 - WinExec(PChar(p_path_cacic + 'modulos\GER_COLS.EXE /'+p_acao+' /p_CipherKey='+v_CipherKey),SW_HIDE); 1335 + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\GER_COLS.EXE /'+p_acao+' /p_CipherKey='+g_oCacic.getCipherKey),SW_HIDE);
1458 End 1336 End
1459 else 1337 else
1460 log_diario('Não foi possível invocar o Gerente de Coletas!'); 1338 log_diario('Não foi possível invocar o Gerente de Coletas!');
@@ -1501,7 +1379,7 @@ begin @@ -1501,7 +1379,7 @@ begin
1501 1379
1502 CipherOpen; 1380 CipherOpen;
1503 1381
1504 - SetValorDatMemoria('Configs.TE_SO',g_te_so,v_tstrCipherOpened); 1382 + SetValorDatMemoria('Configs.TE_SO',g_oCacic.getWindowsStrId,v_tstrCipherOpened);
1505 1383
1506 try 1384 try
1507 if FindCmdLineSwitch('execute', True) or 1385 if FindCmdLineSwitch('execute', True) or
@@ -1511,26 +1389,26 @@ begin @@ -1511,26 +1389,26 @@ begin
1511 log_DEBUG('Preparando chamada ao Gerente de Coletas...'); 1389 log_DEBUG('Preparando chamada ao Gerente de Coletas...');
1512 // Se foi gerado o arquivo ger_erro.txt o Log conterá a mensagem alí gravada como valor de chave 1390 // Se foi gerado o arquivo ger_erro.txt o Log conterá a mensagem alí gravada como valor de chave
1513 // O Gerente de Coletas deverá ser eliminado para que seja baixado novamente por ChecaGERCOLS 1391 // O Gerente de Coletas deverá ser eliminado para que seja baixado novamente por ChecaGERCOLS
1514 - if (FileExists(p_path_cacic + 'ger_erro.txt')) then 1392 + if (FileExists(g_oCacic.getCacicPath + 'ger_erro.txt')) then
1515 Begin 1393 Begin
1516 log_diario('Gerente de Coletas eliminado devido a falha:'); 1394 log_diario('Gerente de Coletas eliminado devido a falha:');
1517 log_diario(getValorDatMemoria('Erro_Fatal_Descricao',v_tstrCipherOpened)); 1395 log_diario(getValorDatMemoria('Erro_Fatal_Descricao',v_tstrCipherOpened));
1518 SetaVariaveisGlobais; 1396 SetaVariaveisGlobais;
1519 - Matar(p_path_cacic,'ger_erro.txt');  
1520 - Matar(p_path_cacic+'modulos\','ger_cols.exe'); 1397 + Matar(g_oCacic.getCacicPath,'ger_erro.txt');
  1398 + Matar(g_oCacic.getCacicPath+'modulos\','ger_cols.exe');
1521 End; 1399 End;
1522 1400
1523 - if (FileExists(p_path_cacic + 'temp\reset.txt')) then 1401 + if (FileExists(g_oCacic.getCacicPath + 'temp\reset.txt')) then
1524 Begin 1402 Begin
1525 - Matar(p_path_cacic+'temp,'reset.txt'); 1403 + Matar(g_oCacic.getCacicPath+'temp,'reset.txt');
1526 log_diario('Reinicializando...'); 1404 log_diario('Reinicializando...');
1527 SetaVariaveisGlobais; 1405 SetaVariaveisGlobais;
1528 End; 1406 End;
1529 Timer_Nu_Exec_Apos.Enabled := False; 1407 Timer_Nu_Exec_Apos.Enabled := False;
1530 1408
1531 intContaExec := 1; 1409 intContaExec := 1;
1532 - If (FileExists(p_path_cacic + 'temp\cacic2.bat') or  
1533 - FileExists(p_path_cacic + 'temp\ger_cols.exe')) Then 1410 + If (FileExists(g_oCacic.getCacicPath + 'temp\cacic2.bat') or
  1411 + FileExists(g_oCacic.getCacicPath + 'temp\ger_cols.exe')) Then
1534 intContaExec := 2; 1412 intContaExec := 2;
1535 1413
1536 // Muda HINT 1414 // Muda HINT
@@ -1632,33 +1510,33 @@ begin @@ -1632,33 +1510,33 @@ begin
1632 End; 1510 End;
1633 1511
1634 // Caso tenha sido baixada nova cópia do Gerente de Coletas, esta deverá ser movida para cima da atual 1512 // Caso tenha sido baixada nova cópia do Gerente de Coletas, esta deverá ser movida para cima da atual
1635 - if (FileExists(p_path_cacic + 'temp\ger_cols.exe')) then 1513 + if (FileExists(g_oCacic.getCacicPath + 'temp\ger_cols.exe')) then
1636 Begin 1514 Begin
1637 - log_diario('Atualizando versão do Gerente de Coletas para '+getVersionInfo(p_path_cacic + 'temp\ger_cols.exe')); 1515 + log_diario('Atualizando versão do Gerente de Coletas para '+getVersionInfo(g_oCacic.getCacicPath + 'temp\ger_cols.exe'));
1638 // O MoveFileEx não se deu bem no Win98! :| 1516 // O MoveFileEx não se deu bem no Win98! :|
1639 - // MoveFileEx(PChar(p_path_cacic + 'temp\ger_cols.exe'),PChar(p_path_cacic + 'modulos\ger_cols.exe'),MOVEFILE_REPLACE_EXISTING); 1517 + // MoveFileEx(PChar(g_oCacic.getCacicPath + 'temp\ger_cols.exe'),PChar(g_oCacic.getCacicPath + 'modulos\ger_cols.exe'),MOVEFILE_REPLACE_EXISTING);
1640 1518
1641 - CopyFile(PChar(p_path_cacic + 'temp\ger_cols.exe'),PChar(p_path_cacic + 'modulos\ger_cols.exe'),false); 1519 + CopyFile(PChar(g_oCacic.getCacicPath + 'temp\ger_cols.exe'),PChar(g_oCacic.getCacicPath + 'modulos\ger_cols.exe'),false);
1642 sleep(2000); // 2 segundos de espera pela cópia! :) (Rwindows!) 1520 sleep(2000); // 2 segundos de espera pela cópia! :) (Rwindows!)
1643 1521
1644 - Matar(p_path_cacic+'temp,'ger_cols.exe'); 1522 + Matar(g_oCacic.getCacicPath+'temp,'ger_cols.exe');
1645 sleep(2000); // 2 segundos de espera pela deleção! 1523 sleep(2000); // 2 segundos de espera pela deleção!
1646 1524
1647 intContaExec := 2; // Forçará uma reexecução de Ger_Cols... 1525 intContaExec := 2; // Forçará uma reexecução de Ger_Cols...
1648 End; 1526 End;
1649 1527
1650 // Caso tenha sido baixada nova cópia do Agente Principal, esta deverá ser movida para cima da atual pelo Gerente de Coletas... 1528 // Caso tenha sido baixada nova cópia do Agente Principal, esta deverá ser movida para cima da atual pelo Gerente de Coletas...
1651 - if (FileExists(p_path_cacic + 'temp\cacic2.exe')) then //AutoUpdate! 1529 + if (FileExists(g_oCacic.getCacicPath + 'temp\cacic2.exe')) then //AutoUpdate!
1652 Begin 1530 Begin
1653 // Verifico e excluo o Gerente de Coletas caso a versão seja anterior ao 1º release 1531 // Verifico e excluo o Gerente de Coletas caso a versão seja anterior ao 1º release
1654 - v_versao := getVersionInfo(p_path_cacic + 'modulos\ger_cols.exe'); 1532 + v_versao := getVersionInfo(g_oCacic.getCacicPath + 'modulos\ger_cols.exe');
1655 if ((copy(v_versao,1,5)='2.0.0') or // Versões anteriores ao 1º Release... 1533 if ((copy(v_versao,1,5)='2.0.0') or // Versões anteriores ao 1º Release...
1656 (v_versao = '2.0.1.2') or // Tivemos alguns problemas nas versões 2.0.1.2, 2.0.1.3 e 2.0.1.4 1534 (v_versao = '2.0.1.2') or // Tivemos alguns problemas nas versões 2.0.1.2, 2.0.1.3 e 2.0.1.4
1657 (v_versao = '2.0.1.3') or 1535 (v_versao = '2.0.1.3') or
1658 (v_versao = '2.0.1.4') or 1536 (v_versao = '2.0.1.4') or
1659 (v_versao = '0.0.0.0')) then // Provavelmente arquivo corrompido ou versão muito antiga 1537 (v_versao = '0.0.0.0')) then // Provavelmente arquivo corrompido ou versão muito antiga
1660 Begin 1538 Begin
1661 - Matar(p_path_cacic+'modulos,'ger_cols.exe'); 1539 + Matar(g_oCacic.getCacicPath+'modulos,'ger_cols.exe');
1662 sleep(2000); // 2 segundos de espera pela deleção! 1540 sleep(2000); // 2 segundos de espera pela deleção!
1663 End; 1541 End;
1664 1542
@@ -1672,8 +1550,8 @@ begin @@ -1672,8 +1550,8 @@ begin
1672 // A existência de "temp\cacic2.bat" significa AutoUpdate já executado! 1550 // A existência de "temp\cacic2.bat" significa AutoUpdate já executado!
1673 // Essa verificação foi usada no modelo antigo de AutoUpdate e deve ser mantida 1551 // Essa verificação foi usada no modelo antigo de AutoUpdate e deve ser mantida
1674 // até a total convergência de versões para 2.0.1.16+... 1552 // até a total convergência de versões para 2.0.1.16+...
1675 - if (FileExists(p_path_cacic + 'temp\cacic2.bat')) then  
1676 - Matar(p_path_cacic+'temp\','cacic2.bat'); 1553 + if (FileExists(g_oCacic.getCacicPath + 'temp\cacic2.bat')) then
  1554 + Matar(g_oCacic.getCacicPath+'temp\','cacic2.bat');
1677 1555
1678 // O loop 1 foi dedicado a atualizações de versões e afins... 1556 // O loop 1 foi dedicado a atualizações de versões e afins...
1679 // O loop 2 deverá invocar as coletas propriamente ditas... 1557 // O loop 2 deverá invocar as coletas propriamente ditas...
@@ -1785,14 +1663,14 @@ begin @@ -1785,14 +1663,14 @@ begin
1785 NotifyStruc.uCallbackMessage := WM_MYMESSAGE; //User defined message 1663 NotifyStruc.uCallbackMessage := WM_MYMESSAGE; //User defined message
1786 1664
1787 // Tento apagar os arquivos indicadores de ações de coletas 1665 // Tento apagar os arquivos indicadores de ações de coletas
1788 - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_GER.txt');  
1789 - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_INI.txt'); 1666 + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_GER.txt');
  1667 + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_INI.txt');
1790 1668
1791 v_intStatus := NORMAL; 1669 v_intStatus := NORMAL;
1792 1670
1793 // Caso os indicadores de ações de coletas não existam, ativo o ícone normal/desconectado... 1671 // Caso os indicadores de ações de coletas não existam, ativo o ícone normal/desconectado...
1794 - if not FileExists(p_path_cacic+'temp\aguarde_GER.txt') and  
1795 - not FileExists(p_path_cacic+'temp\aguarde_INI.txt') then 1672 + if not FileExists(g_oCacic.getCacicPath+'temp\aguarde_GER.txt') and
  1673 + not FileExists(g_oCacic.getCacicPath+'temp\aguarde_INI.txt') then
1796 Begin 1674 Begin
1797 if not (FormularioGeral.getValorDatMemoria('Configs.ConexaoOK',v_tstrCipherOpened)='S') then 1675 if not (FormularioGeral.getValorDatMemoria('Configs.ConexaoOK',v_tstrCipherOpened)='S') then
1798 Begin 1676 Begin
@@ -2017,26 +1895,26 @@ begin @@ -2017,26 +1895,26 @@ begin
2017 else 1895 else
2018 lbSemInformacoesPatrimoniais.Visible := false; 1896 lbSemInformacoesPatrimoniais.Visible := false;
2019 1897
2020 - st_lb_Etiqueta1.Caption := DeCrypt(XML_RetornaValor('te_etiqueta1', strConfigsPatrimonio)); 1898 + st_lb_Etiqueta1.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta1', strConfigsPatrimonio));
2021 st_lb_Etiqueta1.Caption := st_lb_Etiqueta1.Caption + IfThen(st_lb_Etiqueta1.Caption='','',':'); 1899 st_lb_Etiqueta1.Caption := st_lb_Etiqueta1.Caption + IfThen(st_lb_Etiqueta1.Caption='','',':');
2022 st_vl_Etiqueta1.Caption := RetornaValorVetorUON1(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',v_tstrCipherOpened)); 1900 st_vl_Etiqueta1.Caption := RetornaValorVetorUON1(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',v_tstrCipherOpened));
2023 1901
2024 - st_lb_Etiqueta1a.Caption := DeCrypt(XML_RetornaValor('te_etiqueta1a', strConfigsPatrimonio)); 1902 + st_lb_Etiqueta1a.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta1a', strConfigsPatrimonio));
2025 st_lb_Etiqueta1a.Caption := st_lb_Etiqueta1a.Caption + IfThen(st_lb_Etiqueta1a.Caption='','',':'); 1903 st_lb_Etiqueta1a.Caption := st_lb_Etiqueta1a.Caption + IfThen(st_lb_Etiqueta1a.Caption='','',':');
2026 st_vl_Etiqueta1a.Caption := RetornaValorVetorUON1a(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',v_tstrCipherOpened)); 1904 st_vl_Etiqueta1a.Caption := RetornaValorVetorUON1a(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',v_tstrCipherOpened));
2027 1905
2028 - st_lb_Etiqueta2.Caption := DeCrypt(XML_RetornaValor('te_etiqueta2', strConfigsPatrimonio)); 1906 + st_lb_Etiqueta2.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta2', strConfigsPatrimonio));
2029 st_lb_Etiqueta2.Caption := st_lb_Etiqueta2.Caption + IfThen(st_lb_Etiqueta2.Caption='','',':'); 1907 st_lb_Etiqueta2.Caption := st_lb_Etiqueta2.Caption + IfThen(st_lb_Etiqueta2.Caption='','',':');
2030 st_vl_Etiqueta2.Caption := RetornaValorVetorUON2(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',v_tstrCipherOpened),GetValorDatMemoria('Patrimonio.id_local',v_tstrCipherOpened)); 1908 st_vl_Etiqueta2.Caption := RetornaValorVetorUON2(GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',v_tstrCipherOpened),GetValorDatMemoria('Patrimonio.id_local',v_tstrCipherOpened));
2031 1909
2032 - st_lb_Etiqueta3.Caption := DeCrypt(XML_RetornaValor('te_etiqueta3', strConfigsPatrimonio)); 1910 + st_lb_Etiqueta3.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta3', strConfigsPatrimonio));
2033 st_lb_Etiqueta3.Caption := st_lb_Etiqueta3.Caption + IfThen(st_lb_Etiqueta3.Caption='','',':'); 1911 st_lb_Etiqueta3.Caption := st_lb_Etiqueta3.Caption + IfThen(st_lb_Etiqueta3.Caption='','',':');
2034 st_vl_Etiqueta3.Caption := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',v_tstrCipherOpened); 1912 st_vl_Etiqueta3.Caption := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',v_tstrCipherOpened);
2035 1913
2036 1914
2037 - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta4', strConfigsPatrimonio)) = 'S') then 1915 + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta4', strConfigsPatrimonio)) = 'S') then
2038 begin 1916 begin
2039 - st_lb_Etiqueta4.Caption := DeCrypt(XML_RetornaValor('te_etiqueta4', strConfigsPatrimonio)); 1917 + st_lb_Etiqueta4.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta4', strConfigsPatrimonio));
2040 st_lb_Etiqueta4.Caption := st_lb_Etiqueta4.Caption + IfThen(st_lb_Etiqueta4.Caption='','',':'); 1918 st_lb_Etiqueta4.Caption := st_lb_Etiqueta4.Caption + IfThen(st_lb_Etiqueta4.Caption='','',':');
2041 st_lb_Etiqueta4.Visible := true; 1919 st_lb_Etiqueta4.Visible := true;
2042 st_vl_etiqueta4.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',v_tstrCipherOpened); 1920 st_vl_etiqueta4.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',v_tstrCipherOpened);
@@ -2047,9 +1925,9 @@ begin @@ -2047,9 +1925,9 @@ begin
2047 st_vl_etiqueta4.Visible := false; 1925 st_vl_etiqueta4.Visible := false;
2048 End; 1926 End;
2049 1927
2050 - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta5', strConfigsPatrimonio)) = 'S') then 1928 + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta5', strConfigsPatrimonio)) = 'S') then
2051 begin 1929 begin
2052 - st_lb_Etiqueta5.Caption := DeCrypt(XML_RetornaValor('te_etiqueta5', strConfigsPatrimonio)); 1930 + st_lb_Etiqueta5.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta5', strConfigsPatrimonio));
2053 st_lb_Etiqueta5.Caption := st_lb_Etiqueta5.Caption + IfThen(st_lb_Etiqueta5.Caption='','',':'); 1931 st_lb_Etiqueta5.Caption := st_lb_Etiqueta5.Caption + IfThen(st_lb_Etiqueta5.Caption='','',':');
2054 st_lb_Etiqueta5.Visible := true; 1932 st_lb_Etiqueta5.Visible := true;
2055 st_vl_etiqueta5.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',v_tstrCipherOpened); 1933 st_vl_etiqueta5.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',v_tstrCipherOpened);
@@ -2061,9 +1939,9 @@ begin @@ -2061,9 +1939,9 @@ begin
2061 End; 1939 End;
2062 1940
2063 1941
2064 - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta6', strConfigsPatrimonio)) = 'S') then 1942 + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta6', strConfigsPatrimonio)) = 'S') then
2065 begin 1943 begin
2066 - st_lb_Etiqueta6.Caption := DeCrypt(XML_RetornaValor('te_etiqueta6', strConfigsPatrimonio)); 1944 + st_lb_Etiqueta6.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta6', strConfigsPatrimonio));
2067 st_lb_Etiqueta6.Caption := st_lb_Etiqueta6.Caption + IfThen(st_lb_Etiqueta6.Caption='','',':'); 1945 st_lb_Etiqueta6.Caption := st_lb_Etiqueta6.Caption + IfThen(st_lb_Etiqueta6.Caption='','',':');
2068 st_lb_Etiqueta6.Visible := true; 1946 st_lb_Etiqueta6.Visible := true;
2069 st_vl_etiqueta6.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',v_tstrCipherOpened); 1947 st_vl_etiqueta6.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',v_tstrCipherOpened);
@@ -2075,9 +1953,9 @@ begin @@ -2075,9 +1953,9 @@ begin
2075 End; 1953 End;
2076 1954
2077 1955
2078 - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta7', strConfigsPatrimonio)) = 'S') then 1956 + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta7', strConfigsPatrimonio)) = 'S') then
2079 begin 1957 begin
2080 - st_lb_Etiqueta7.Caption := DeCrypt(XML_RetornaValor('te_etiqueta7', strConfigsPatrimonio)); 1958 + st_lb_Etiqueta7.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta7', strConfigsPatrimonio));
2081 st_lb_Etiqueta7.Caption := st_lb_Etiqueta7.Caption + IfThen(st_lb_Etiqueta7.Caption='','',':'); 1959 st_lb_Etiqueta7.Caption := st_lb_Etiqueta7.Caption + IfThen(st_lb_Etiqueta7.Caption='','',':');
2082 st_lb_Etiqueta7.Visible := true; 1960 st_lb_Etiqueta7.Visible := true;
2083 st_vl_etiqueta7.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',v_tstrCipherOpened); 1961 st_vl_etiqueta7.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',v_tstrCipherOpened);
@@ -2089,9 +1967,9 @@ begin @@ -2089,9 +1967,9 @@ begin
2089 End; 1967 End;
2090 1968
2091 1969
2092 - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta8', strConfigsPatrimonio)) = 'S') then 1970 + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta8', strConfigsPatrimonio)) = 'S') then
2093 begin 1971 begin
2094 - st_lb_Etiqueta8.Caption := DeCrypt(XML_RetornaValor('te_etiqueta8', strConfigsPatrimonio)); 1972 + st_lb_Etiqueta8.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta8', strConfigsPatrimonio));
2095 st_lb_Etiqueta8.Caption := st_lb_Etiqueta8.Caption + IfThen(st_lb_Etiqueta8.Caption='','',':'); 1973 st_lb_Etiqueta8.Caption := st_lb_Etiqueta8.Caption + IfThen(st_lb_Etiqueta8.Caption='','',':');
2096 st_lb_Etiqueta8.Visible := true; 1974 st_lb_Etiqueta8.Visible := true;
2097 st_vl_etiqueta8.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',v_tstrCipherOpened); 1975 st_vl_etiqueta8.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',v_tstrCipherOpened);
@@ -2103,9 +1981,9 @@ begin @@ -2103,9 +1981,9 @@ begin
2103 End; 1981 End;
2104 1982
2105 1983
2106 - if (DeCrypt(XML_RetornaValor('in_exibir_etiqueta9', strConfigsPatrimonio)) = 'S') then 1984 + if (g_oCacic.deCrypt(XML_RetornaValor('in_exibir_etiqueta9', strConfigsPatrimonio)) = 'S') then
2107 begin 1985 begin
2108 - st_lb_Etiqueta9.Caption := DeCrypt(XML_RetornaValor('te_etiqueta9', strConfigsPatrimonio)); 1986 + st_lb_Etiqueta9.Caption := g_oCacic.deCrypt(XML_RetornaValor('te_etiqueta9', strConfigsPatrimonio));
2109 st_lb_Etiqueta9.Caption := st_lb_Etiqueta9.Caption + IfThen(st_lb_Etiqueta9.Caption='','',':'); 1987 st_lb_Etiqueta9.Caption := st_lb_Etiqueta9.Caption + IfThen(st_lb_Etiqueta9.Caption='','',':');
2110 st_lb_Etiqueta9.Visible := true; 1988 st_lb_Etiqueta9.Visible := true;
2111 st_vl_etiqueta9.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',v_tstrCipherOpened); 1989 st_vl_etiqueta9.Caption := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',v_tstrCipherOpened);
@@ -2254,7 +2132,7 @@ begin @@ -2254,7 +2132,7 @@ begin
2254 strXML := URLDecode(ARequestInfo.UnparsedParams); 2132 strXML := URLDecode(ARequestInfo.UnparsedParams);
2255 intAux := Pos('=',strXML); 2133 intAux := Pos('=',strXML);
2256 strXML := copy(strXML,(intAux+1),StrLen(PAnsiChar(strXML))-intAux); 2134 strXML := copy(strXML,(intAux+1),StrLen(PAnsiChar(strXML))-intAux);
2257 - strXML := DeCrypt(strXML); 2135 + strXML := g_oCacic.deCrypt(strXML);
2258 2136
2259 2137
2260 2138
@@ -2307,42 +2185,44 @@ begin @@ -2307,42 +2185,44 @@ begin
2307 if boolServerON then // Ordeno ao SrCACICsrv que auto-finalize 2185 if boolServerON then // Ordeno ao SrCACICsrv que auto-finalize
2308 Begin 2186 Begin
2309 Log_Diario('Desativando Suporte Remoto Seguro.'); 2187 Log_Diario('Desativando Suporte Remoto Seguro.');
2310 - WinExec(PChar(p_path_cacic + 'modulos\srcacicsrv.exe -kill'),SW_HIDE); 2188 + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -kill'),SW_HIDE);
2311 boolServerON := false; 2189 boolServerON := false;
2312 End 2190 End
2313 else 2191 else
2314 Begin 2192 Begin
2315 - log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe"...'); 2193 + log_DEBUG('Invocando "'+g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe"...');
2316 Log_Diario('Ativando Suporte Remoto Seguro.'); 2194 Log_Diario('Ativando Suporte Remoto Seguro.');
2317 boolAux := boolCrypt; 2195 boolAux := boolCrypt;
2318 boolCrypt := true; 2196 boolCrypt := true;
2319 2197
2320 // Alguns cuidados necessários ao tráfego e recepção de valores pelo Gerente WEB 2198 // Alguns cuidados necessários ao tráfego e recepção de valores pelo Gerente WEB
2321 // Some cares about send and receive at Gerente WEB 2199 // Some cares about send and receive at Gerente WEB
2322 - strPalavraChave := StringReplace(FormularioGeral.getValorDatMemoria('Configs.te_palavra_chave', v_tstrCipherOpened),'+','<MAIS>' ,[rfReplaceAll]); 2200 + strPalavraChave := FormularioGeral.getValorDatMemoria('Configs.te_palavra_chave', v_tstrCipherOpened);
2323 strPalavraChave := StringReplace(strPalavraChave,' ' ,'<ESPACE>' ,[rfReplaceAll]); 2201 strPalavraChave := StringReplace(strPalavraChave,' ' ,'<ESPACE>' ,[rfReplaceAll]);
2324 strPalavraChave := StringReplace(strPalavraChave,'"' ,'<AD>' ,[rfReplaceAll]); 2202 strPalavraChave := StringReplace(strPalavraChave,'"' ,'<AD>' ,[rfReplaceAll]);
2325 strPalavraChave := StringReplace(strPalavraChave,'''' ,'<AS>' ,[rfReplaceAll]); 2203 strPalavraChave := StringReplace(strPalavraChave,'''' ,'<AS>' ,[rfReplaceAll]);
2326 strPalavraChave := StringReplace(strPalavraChave,'\' ,'<BarrInv>' ,[rfReplaceAll]); 2204 strPalavraChave := StringReplace(strPalavraChave,'\' ,'<BarrInv>' ,[rfReplaceAll]);
2327 - strPalavraChave := StringReplace(EnCrypt(strPalavraChave),'+','<MAIS>',[rfReplaceAll]); 2205 + strPalavraChave := g_oCacic.enCrypt(strPalavraChave);
  2206 + strPalavraChave := StringReplace(strPalavraChave,'+','<MAIS>',[rfReplaceAll]);
2328 2207
2329 - strTeSO := StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','<ESPACE>',[rfReplaceAll]);  
2330 - strTeSO := StringReplace(EnCrypt(strTeSO),'+','<MAIS>',[rfReplaceAll]); 2208 + strTeSO := trim(StringReplace(FormularioGeral.getValorDatMemoria('Configs.TE_SO', v_tstrCipherOpened),' ','<ESPACE>',[rfReplaceAll]));
  2209 + strTeSO := g_oCacic.enCrypt(strTeSO);
  2210 + strTeSO := StringReplace(strTeSO,'+','<MAIS>',[rfReplaceAll]);
2331 2211
2332 - strTeNodeAddress := StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','<ESPACE>' ,[rfReplaceAll]);  
2333 - strTeNodeAddress := StringReplace(EnCrypt(strTeNodeAddress),'+','<MAIS>',[rfReplaceAll]); 2212 + strTeNodeAddress := trim(StringReplace(FormularioGeral.getValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , v_tstrCipherOpened),' ','<ESPACE>' ,[rfReplaceAll]));
  2213 + strTeNodeAddress := g_oCacic.enCrypt(strTeNodeAddress);
  2214 + strTeNodeAddress := StringReplace(strTeNodeAddress,'+','<MAIS>',[rfReplaceAll]);
2334 2215
2335 - log_DEBUG('Invocando "'+p_path_cacic + 'modulos\srcacicsrv.exe -start [' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' +  
2336 - '[' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + 2216 + log_DEBUG('Invocando "'+g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' +
  2217 + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' +
2337 '[' + strTeSO + ']' + 2218 '[' + strTeSO + ']' +
2338 '[' + strTeNodeAddress + ']' + 2219 '[' + strTeNodeAddress + ']' +
2339 '[' + strPalavraChave + ']' + 2220 '[' + strPalavraChave + ']' +
2340 - '[' + p_path_cacic + 'Temp\aguarde_srCACIC.txt' + ']');  
2341 - 2221 + '[' + g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt' + ']');
2342 2222
2343 // Detectar versão do Windows antes de fazer a chamada seguinte... 2223 // Detectar versão do Windows antes de fazer a chamada seguinte...
2344 try 2224 try
2345 - AssignFile(fileAguarde,p_path_cacic + 'Temp\aguarde_srCACIC.txt'); 2225 + AssignFile(fileAguarde,g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt');
2346 {$IOChecks off} 2226 {$IOChecks off}
2347 Reset(fileAguarde); {Abre o arquivo texto} 2227 Reset(fileAguarde); {Abre o arquivo texto}
2348 {$IOChecks on} 2228 {$IOChecks on}
@@ -2357,12 +2237,12 @@ begin @@ -2357,12 +2237,12 @@ begin
2357 Finally 2237 Finally
2358 End; 2238 End;
2359 2239
2360 - WinExec(PChar(p_path_cacic + 'modulos\srcacicsrv.exe -start [' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' +  
2361 - '[' + EnCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' + 2240 + WinExec(PChar(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe -start [' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.EnderecoServidor', v_tstrCipherOpened)) + ']' +
  2241 + '[' + g_oCacic.enCrypt(FormularioGeral.getValorDatMemoria('Configs.Endereco_WS' , v_tstrCipherOpened)) + ']' +
2362 '[' + strTeSO + ']' + 2242 '[' + strTeSO + ']' +
2363 '[' + strTeNodeAddress + ']' + 2243 '[' + strTeNodeAddress + ']' +
2364 '[' + strPalavraChave + ']' + 2244 '[' + strPalavraChave + ']' +
2365 - '[' + p_path_cacic + 'Temp\aguarde_srCACIC.txt' + ']'),SW_NORMAL); 2245 + '[' + g_oCacic.getCacicPath + 'Temp\aguarde_srCACIC.txt' + ']'),SW_NORMAL);
2366 2246
2367 boolCrypt := boolAux; 2247 boolCrypt := boolAux;
2368 BoolServerON := true; 2248 BoolServerON := true;
@@ -2374,20 +2254,24 @@ procedure TFormularioGeral.Popup_Menu_ContextoPopup(Sender: TObject); @@ -2374,20 +2254,24 @@ procedure TFormularioGeral.Popup_Menu_ContextoPopup(Sender: TObject);
2374 begin 2254 begin
2375 VerificaDebugs; 2255 VerificaDebugs;
2376 if (getValorDatMemoria('Configs.CS_SUPORTE_REMOTO',v_tstrCipherOpened) = 'S') and 2256 if (getValorDatMemoria('Configs.CS_SUPORTE_REMOTO',v_tstrCipherOpened) = 'S') and
2377 - (FileExists(p_path_cacic + 'modulos\srcacicsrv.exe')) then 2257 + (FileExists(g_oCacic.getCacicPath + 'modulos\srcacicsrv.exe')) then
2378 Mnu_SuporteRemoto.Enabled := true 2258 Mnu_SuporteRemoto.Enabled := true
2379 else 2259 else
2380 Mnu_SuporteRemoto.Enabled := false; 2260 Mnu_SuporteRemoto.Enabled := false;
2381 2261
2382 boolServerON := false; 2262 boolServerON := false;
2383 - FormularioGeral.Matar(p_path_cacic+'temp\','aguarde_SRCACIC.txt');  
2384 - if FileExists(p_path_cacic + 'temp\aguarde_SRCACIC.txt') then 2263 + FormularioGeral.Matar(g_oCacic.getCacicPath+'temp\','aguarde_SRCACIC.txt');
  2264 + if FileExists(g_oCacic.getCacicPath + 'temp\aguarde_SRCACIC.txt') then
2385 Begin 2265 Begin
2386 - Mnu_SuporteRemoto.Caption := 'Desativar Suporte Remoto'; 2266 + Mnu_SuporteRemoto.Caption := 'Suporte Remoto Ativo!';
  2267 + Mnu_SuporteRemoto.Enabled := false;
2387 boolServerON := true; 2268 boolServerON := true;
2388 End 2269 End
2389 else 2270 else
2390 - Mnu_SuporteRemoto.Caption := 'Ativar Suporte Remoto'; 2271 + Begin
  2272 + Mnu_SuporteRemoto.Caption := 'Ativar Suporte Remoto';
  2273 + Mnu_SuporteRemoto.Enabled := true;
  2274 + End;
2391 2275
2392 end; 2276 end;
2393 2277
mapa/acesso.pas
@@ -20,8 +20,17 @@ unit acesso; @@ -20,8 +20,17 @@ unit acesso;
20 interface 20 interface
21 21
22 uses 22 uses
23 - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  
24 - StdCtrls, ExtCtrls, dialogs; 23 + Windows,
  24 + Messages,
  25 + SysUtils,
  26 + Variants,
  27 + Classes,
  28 + Graphics,
  29 + Controls,
  30 + Forms,
  31 + StdCtrls,
  32 + ExtCtrls,
  33 + dialogs;
25 34
26 type 35 type
27 TfrmAcesso = class(TForm) 36 TfrmAcesso = class(TForm)
@@ -54,7 +63,8 @@ type @@ -54,7 +63,8 @@ type
54 { Public declarations } 63 { Public declarations }
55 end; 64 end;
56 65
57 -var frmAcesso: TfrmAcesso; 66 +var
  67 + frmAcesso: TfrmAcesso;
58 68
59 implementation 69 implementation
60 uses main_mapa; 70 uses main_mapa;
@@ -71,24 +81,24 @@ begin @@ -71,24 +81,24 @@ begin
71 lbMsg_Erro_Senha.Caption := str_local_Aux; 81 lbMsg_Erro_Senha.Caption := str_local_Aux;
72 82
73 // Envio dos dados ao DataBase... 83 // Envio dos dados ao DataBase...
74 - Request_mapa.Values['nm_acesso'] := frmMapaCacic.EnCrypt(edNomeUsuarioAcesso.Text);  
75 - Request_mapa.Values['te_senha'] := frmMapaCacic.EnCrypt(edSenhaAcesso.Text);  
76 - Request_mapa.Values['cs_MapaCacic'] := frmMapaCacic.EnCrypt('S');  
77 - Request_mapa.Values['te_versao_mapa'] := frmMapaCacic.EnCrypt(frmMapaCacic.getVersionInfo(ParamStr(0))); 84 + Request_mapa.Values['nm_acesso'] := frmMapaCacic.g_oCacic.enCrypt(edNomeUsuarioAcesso.Text);
  85 + Request_mapa.Values['te_senha'] := frmMapaCacic.g_oCacic.EnCrypt(edSenhaAcesso.Text);
  86 + Request_mapa.Values['cs_MapaCacic'] := frmMapaCacic.g_oCacic.EnCrypt('S');
  87 + Request_mapa.Values['te_versao_mapa'] := frmMapaCacic.g_oCacic.EnCrypt(frmMapaCacic.getVersionInfo(ParamStr(0)));
78 88
79 strRetorno := frmMapaCacic.ComunicaServidor('mapa_acesso.php', Request_mapa, 'Autenticando o Acesso...'); 89 strRetorno := frmMapaCacic.ComunicaServidor('mapa_acesso.php', Request_mapa, 'Autenticando o Acesso...');
80 Request_mapa.free; 90 Request_mapa.free;
81 91
82 if (frmMapaCacic.XML_RetornaValor('STATUS', strRetorno)='OK') then 92 if (frmMapaCacic.XML_RetornaValor('STATUS', strRetorno)='OK') then
83 Begin 93 Begin
84 - str_local_Aux := trim(frmMapaCacic.DeCrypt(frmMapaCacic.XML_RetornaValor('TE_VERSAO_MAPA',strRetorno))); 94 + str_local_Aux := trim(frmMapaCacic.g_oCacic.deCrypt(frmMapaCacic.XML_RetornaValor('TE_VERSAO_MAPA',strRetorno)));
85 if (str_local_Aux <> '') then 95 if (str_local_Aux <> '') then
86 Begin 96 Begin
87 MessageDLG(#13#10#13#10+'ATENÇÃO! Foi disponibilizada a versão "'+str_local_Aux+'".'+#13#10#13#10+'Acesse o gerente cacic na opção "Repositório" e baixe o programa "MapaCACIC"!'+#13#10,mtWarning,[mbOK],0); 97 MessageDLG(#13#10#13#10+'ATENÇÃO! Foi disponibilizada a versão "'+str_local_Aux+'".'+#13#10#13#10+'Acesse o gerente cacic na opção "Repositório" e baixe o programa "MapaCACIC"!'+#13#10,mtWarning,[mbOK],0);
88 btCancela.Click; 98 btCancela.Click;
89 End; 99 End;
90 100
91 - str_local_Aux := trim(frmMapaCacic.DeCrypt(frmMapaCacic.XML_RetornaValor('ID_USUARIO',strRetorno))); 101 + str_local_Aux := trim(frmMapaCacic.g_oCacic.deCrypt(frmMapaCacic.XML_RetornaValor('ID_USUARIO',strRetorno)));
92 if (str_local_Aux <> '') then 102 if (str_local_Aux <> '') then
93 Begin 103 Begin
94 frmMapaCacic.strId_usuario := str_local_Aux; 104 frmMapaCacic.strId_usuario := str_local_Aux;
@@ -109,7 +119,7 @@ begin @@ -109,7 +119,7 @@ begin
109 119
110 if (frmMapaCacic.boolAcessoOK) then 120 if (frmMapaCacic.boolAcessoOK) then
111 Begin 121 Begin
112 - lbAviso.Caption := 'USUÁRIO AUTENTICADO: "' + trim(frmMapaCacic.DeCrypt(frmMapaCacic.XML_RetornaValor('NM_USUARIO_COMPLETO',strRetorno)))+'"'; 122 + lbAviso.Caption := 'USUÁRIO AUTENTICADO: "' + trim(frmMapaCacic.g_oCacic.deCrypt(frmMapaCacic.XML_RetornaValor('NM_USUARIO_COMPLETO',strRetorno)))+'"';
113 lbAviso.Font.Style := [fsBold]; 123 lbAviso.Font.Style := [fsBold];
114 lbAviso.Font.Color := clGreen; 124 lbAviso.Font.Color := clGreen;
115 Application.ProcessMessages; 125 Application.ProcessMessages;
@@ -145,7 +155,7 @@ procedure TfrmAcesso.FormCreate(Sender: TObject); @@ -145,7 +155,7 @@ procedure TfrmAcesso.FormCreate(Sender: TObject);
145 begin 155 begin
146 intPausaPadrao := 3000; //(3 mil milisegundos = 3 segundos) 156 intPausaPadrao := 3000; //(3 mil milisegundos = 3 segundos)
147 frmAcesso.lbVersao.Caption := 'Versão: ' + frmMapaCacic.GetVersionInfo(ParamStr(0)); 157 frmAcesso.lbVersao.Caption := 'Versão: ' + frmMapaCacic.GetVersionInfo(ParamStr(0));
148 - frmMapaCacic.tStringsCipherOpened := frmMapaCacic.CipherOpen(frmMapaCacic.strDatFileName); 158 + frmMapaCacic.tStringsCipherOpened := frmMapaCacic.CipherOpen(frmMapaCacic.g_oCacic.getDatFileName);
149 frmMapaCacic.lbNomeServidorWEB.Caption := 'Servidor: '+frmMapaCacic.GetValorDatMemoria('Configs.EnderecoServidor', frmMapaCacic.tStringsCipherOpened); 159 frmMapaCacic.lbNomeServidorWEB.Caption := 'Servidor: '+frmMapaCacic.GetValorDatMemoria('Configs.EnderecoServidor', frmMapaCacic.tStringsCipherOpened);
150 frmMapaCacic.lbMensagens.Caption := 'Entrada de Dados para Autenticação no Módulo Gerente WEB Cacic'; 160 frmMapaCacic.lbMensagens.Caption := 'Entrada de Dados para Autenticação no Módulo Gerente WEB Cacic';
151 if (frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)='') then 161 if (frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened)='') then
mapa/main_mapa.pas
@@ -19,57 +19,40 @@ unit main_mapa; @@ -19,57 +19,40 @@ unit main_mapa;
19 19
20 interface 20 interface
21 21
22 -uses IniFiles,  
23 - Windows,  
24 - Sysutils, // Deve ser colocado após o Windows acima, nunca antes  
25 - strutils,  
26 - Registry,  
27 - LibXmlParser,  
28 - XML,  
29 - IdTCPConnection,  
30 - IdTCPClient,  
31 - IdHTTP,  
32 - IdBaseComponent,  
33 - IdComponent,  
34 - WinSock,  
35 - NB30,  
36 - StdCtrls,  
37 - Controls,  
38 - Classes,  
39 - Forms,  
40 - PJVersionInfo,  
41 - DCPcrypt2,  
42 - DCPrijndael,  
43 - DCPbase64,  
44 - ExtCtrls,  
45 - Graphics,  
46 - Dialogs,  
47 - CACIC_Library;  
48 -  
49 -var strCipherClosed,  
50 - strCipherOpened,  
51 - strPathCacic : string;  
52 -  
53 -var intPausaPadrao : integer;  
54 -  
55 -var boolDebugs : boolean;  
56 -  
57 -var g_oCacic : TCACIC;  
58 -  
59 -// Some constants that are dependant on the cipher being used  
60 -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize)  
61 -const constKeySize = 32; // 32 bytes = 256 bits  
62 - constBlockSize = 16; // 16 bytes = 128 bits  
63 -  
64 -// Constantes a serem usadas pela função IsAdmin...  
65 -const constSECURITY_NT_AUTHORITY: TSIDIdentifierAuthority = (Value: (0, 0, 0, 0, 0, 5));  
66 - constSECURITY_BUILTIN_DOMAIN_RID = $00000020;  
67 - constDOMAIN_ALIAS_RID_ADMINS = $00000220;  
68 -  
69 -const constCipherKey = 'CacicBrasil';  
70 - constIV = 'abcdefghijklmnop';  
71 - constSeparatorKey = '=CacicIsFree='; // Usada apenas para o cacic2.dat 22 +uses
  23 + IniFiles,
  24 + Windows,
  25 + Sysutils, // Deve ser colocado após o Windows acima, nunca antes
  26 + strutils,
  27 + Registry,
  28 + LibXmlParser,
  29 + XML,
  30 + IdTCPConnection,
  31 + IdTCPClient,
  32 + IdHTTP,
  33 + IdBaseComponent,
  34 + IdComponent,
  35 + WinSock,
  36 + NB30,
  37 + StdCtrls,
  38 + Controls,
  39 + Classes,
  40 + Forms,
  41 + PJVersionInfo,
  42 + ExtCtrls,
  43 + Graphics,
  44 + Dialogs,
  45 + CACIC_Library;
72 46
  47 +var
  48 + strCipherClosed,
  49 + strCipherOpened : string;
  50 +
  51 +var
  52 + intPausaPadrao : integer;
  53 +
  54 +var
  55 + boolDebugs : boolean;
73 56
74 type 57 type
75 TfrmMapaCacic = class(TForm) 58 TfrmMapaCacic = class(TForm)
@@ -109,15 +92,9 @@ type @@ -109,15 +92,9 @@ type
109 function GetValorChaveRegEdit(Chave: String): Variant; 92 function GetValorChaveRegEdit(Chave: String): Variant;
110 function GetRootKey(strRootKey: String): HKEY; 93 function GetRootKey(strRootKey: String): HKEY;
111 Function RemoveCaracteresEspeciais(Texto, p_Fill : String; p_start, p_end:integer) : String; 94 Function RemoveCaracteresEspeciais(Texto, p_Fill : String; p_start, p_end:integer) : String;
112 - function HomeDrive : string;  
113 - Function Implode(p_Array : TStrings ; p_Separador : String) : String;  
114 Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; 95 Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String;
115 - Function Explode(Texto, Separador : String) : TStrings;  
116 Function CipherOpen(p_DatFileName : string) : TStrings; 96 Function CipherOpen(p_DatFileName : string) : TStrings;
117 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String; 97 Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String;
118 - function PadWithZeros(const str : string; size : integer) : string;  
119 - function EnCrypt(p_Data : String) : String;  
120 - function DeCrypt(p_Data : String) : String;  
121 procedure MontaCombos(p_strConfigs : String); 98 procedure MontaCombos(p_strConfigs : String);
122 procedure MontaInterface(p_strConfigs : String); 99 procedure MontaInterface(p_strConfigs : String);
123 procedure FormClose(Sender: TObject; var Action: TCloseAction); 100 procedure FormClose(Sender: TObject; var Action: TCloseAction);
@@ -131,7 +108,6 @@ type @@ -131,7 +108,6 @@ type
131 function VerFmt(const MS, LS: DWORD): string; 108 function VerFmt(const MS, LS: DWORD): string;
132 function GetFolderDate(Folder: string): TDateTime; 109 function GetFolderDate(Folder: string): TDateTime;
133 procedure CriaFormSenha(Sender: TObject); 110 procedure CriaFormSenha(Sender: TObject);
134 - function IsAdmin: Boolean;  
135 Function ComunicaServidor(URL : String; Request : TStringList; MsgAcao: String) : String; 111 Function ComunicaServidor(URL : String; Request : TStringList; MsgAcao: String) : String;
136 Function XML_RetornaValor(Tag : String; Fonte : String): String; 112 Function XML_RetornaValor(Tag : String; Fonte : String): String;
137 function Parse(p_ClassName, p_SectionName, p_DataName:string; p_Report : TStringList) : String; 113 function Parse(p_ClassName, p_SectionName, p_DataName:string; p_Report : TStringList) : String;
@@ -166,8 +142,8 @@ type @@ -166,8 +142,8 @@ type
166 strTe_info_patrimonio6 : String; 142 strTe_info_patrimonio6 : String;
167 public 143 public
168 boolAcessoOK : boolean; 144 boolAcessoOK : boolean;
169 - strId_usuario,  
170 - strDatFileName : String; 145 + strId_usuario : String;
  146 + g_oCacic : TCACIC;
171 tStringsDadosPatrimonio, 147 tStringsDadosPatrimonio,
172 tStringsCipherOpened, 148 tStringsCipherOpened,
173 tStringsTripa1 : TStrings; 149 tStringsTripa1 : TStrings;
@@ -266,8 +242,8 @@ var @@ -266,8 +242,8 @@ var
266 strDataArqLocal, strDataAtual : string; 242 strDataArqLocal, strDataAtual : string;
267 begin 243 begin
268 try 244 try
269 - FileSetAttr (strPathCacic + 'MapaCacic.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000  
270 - AssignFile(HistoricoLog,strPathCacic + 'MapaCacic.log'); {Associa o arquivo a uma variável do tipo TextFile} 245 + FileSetAttr (g_oCacic.getCacicPath + 'MapaCacic.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
  246 + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'MapaCacic.log'); {Associa o arquivo a uma variável do tipo TextFile}
271 {$IOChecks off} 247 {$IOChecks off}
272 Reset(HistoricoLog); {Abre o arquivo texto} 248 Reset(HistoricoLog); {Abre o arquivo texto}
273 {$IOChecks on} 249 {$IOChecks on}
@@ -277,7 +253,7 @@ begin @@ -277,7 +253,7 @@ begin
277 Append(HistoricoLog); 253 Append(HistoricoLog);
278 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log <======================='); 254 Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log <=======================');
279 end; 255 end;
280 - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(strPathCacic + 'MapaCacic.log'))); 256 + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'MapaCacic.log')));
281 DateTimeToString(strDataAtual , 'yyyymmdd', Date); 257 DateTimeToString(strDataAtual , 'yyyymmdd', Date);
282 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... 258 if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual...
283 begin 259 begin
@@ -317,7 +293,7 @@ var @@ -317,7 +293,7 @@ var
317 strDataArqLocal, strDataAtual, v_file_debugs : string; 293 strDataArqLocal, strDataAtual, v_file_debugs : string;
318 begin 294 begin
319 try 295 try
320 - v_file_debugs := strPathCacic + '\debug_mapa.txt'; 296 + v_file_debugs := g_oCacic.getCacicPath + '\debug_mapa.txt';
321 FileSetAttr (v_file_debugs,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 297 FileSetAttr (v_file_debugs,0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000
322 AssignFile(DebugsFile,v_file_debugs); {Associa o arquivo a uma variável do tipo TextFile} 298 AssignFile(DebugsFile,v_file_debugs); {Associa o arquivo a uma variável do tipo TextFile}
323 299
@@ -349,38 +325,6 @@ begin @@ -349,38 +325,6 @@ begin
349 end; 325 end;
350 end; 326 end;
351 327
352 -  
353 -//  
354 -Function TfrmMapaCacic.Explode(Texto, Separador : String) : TStrings;  
355 -var  
356 - strItem : String;  
357 - ListaAuxUTILS : TStrings;  
358 - NumCaracteres,  
359 - TamanhoSeparador,  
360 - I : Integer;  
361 -Begin  
362 - ListaAuxUTILS := TStringList.Create;  
363 - strItem := '';  
364 - NumCaracteres := Length(Texto);  
365 - TamanhoSeparador := Length(Separador);  
366 - I := 1;  
367 - While I <= NumCaracteres Do  
368 - Begin  
369 - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then  
370 - Begin  
371 - if (I = NumCaracteres) then strItem := strItem + Texto[I];  
372 - ListaAuxUTILS.Add(trim(strItem));  
373 - strItem := '';  
374 - I := I + (TamanhoSeparador-1);  
375 - end  
376 - Else  
377 - strItem := strItem + Texto[I];  
378 -  
379 - I := I + 1;  
380 - End;  
381 - Explode := ListaAuxUTILS;  
382 -end;  
383 -  
384 // Função criada devido a divergências entre os valores retornados pelos métodos dos componentes MSI e seus Reports. 328 // Função criada devido a divergências entre os valores retornados pelos métodos dos componentes MSI e seus Reports.
385 function TfrmMapaCacic.Parse(p_ClassName, p_SectionName, p_DataName:string; p_Report : TStringList) : String; 329 function TfrmMapaCacic.Parse(p_ClassName, p_SectionName, p_DataName:string; p_Report : TStringList) : String;
386 var intClasses, intSections, intDatas, v_achei_SectionName, v_array_SectionName_Count : integer; 330 var intClasses, intSections, intDatas, v_achei_SectionName, v_array_SectionName_Count : integer;
@@ -390,7 +334,7 @@ begin @@ -390,7 +334,7 @@ begin
390 Result := ''; 334 Result := '';
391 if (p_SectionName <> '') then 335 if (p_SectionName <> '') then
392 Begin 336 Begin
393 - v_array_SectionName := explode(p_SectionName,'/'); 337 + v_array_SectionName := g_oCacic.explode(p_SectionName,'/');
394 v_array_SectionName_Count := v_array_SectionName.Count; 338 v_array_SectionName_Count := v_array_SectionName.Count;
395 End 339 End
396 else v_array_SectionName_Count := 0; 340 else v_array_SectionName_Count := 0;
@@ -464,15 +408,16 @@ procedure TfrmMapaCacic.Finalizar(p_pausa:boolean); @@ -464,15 +408,16 @@ procedure TfrmMapaCacic.Finalizar(p_pausa:boolean);
464 Begin 408 Begin
465 Mensagem('Finalizando MapaCacic...',false,0); 409 Mensagem('Finalizando MapaCacic...',false,0);
466 410
467 - CipherClose(strDatFileName, tStringsCipherOpened); 411 + CipherClose(g_oCacic.getDatFileName, tStringsCipherOpened);
468 Apaga_Temps; 412 Apaga_Temps;
469 if p_pausa then sleep(2000); // Pausa de 2 segundos para conclusão de operações de arquivos. 413 if p_pausa then sleep(2000); // Pausa de 2 segundos para conclusão de operações de arquivos.
470 Sair; 414 Sair;
471 End; 415 End;
  416 +
472 procedure TfrmMapaCacic.Apaga_Temps; 417 procedure TfrmMapaCacic.Apaga_Temps;
473 begin 418 begin
474 - Matar(strPathCacic + 'temp\','*.vbs');  
475 - Matar(strPathCacic + 'temp\','*.txt'); 419 + Matar(g_oCacic.getCacicPath + 'temp\','*.vbs');
  420 + Matar(g_oCacic.getCacicPath + 'temp\','*.txt');
476 end; 421 end;
477 // 422 //
478 function TfrmMapaCacic.LastPos(SubStr, S: string): Integer; 423 function TfrmMapaCacic.LastPos(SubStr, S: string): Integer;
@@ -547,7 +492,7 @@ Begin @@ -547,7 +492,7 @@ Begin
547 strEnderecoWS := '/cacic2/ws/'; 492 strEnderecoWS := '/cacic2/ws/';
548 493
549 if (trim(strEnderecoServidor)='') then 494 if (trim(strEnderecoServidor)='') then
550 - strEnderecoServidor := Trim(GetValorChaveRegIni('Cacic2','ip_serv_cacic',strPathCacic + 'MapaCacic.ini')); 495 + strEnderecoServidor := Trim(GetValorChaveRegIni('Cacic2','ip_serv_cacic',g_oCacic.getCacicPath + 'MapaCacic.ini'));
551 496
552 strEndereco := 'http://' + strEnderecoServidor + strEnderecoWS + URL; 497 strEndereco := 'http://' + strEnderecoServidor + strEnderecoWS + URL;
553 498
@@ -574,9 +519,9 @@ Begin @@ -574,9 +519,9 @@ Begin
574 idHTTP1.ReadTimeout := 0; 519 idHTTP1.ReadTimeout := 0;
575 idHTTP1.RecvBufferSize := 32768; 520 idHTTP1.RecvBufferSize := 32768;
576 idHTTP1.RedirectMaximum := 15; 521 idHTTP1.RedirectMaximum := 15;
577 - idHTTP1.Request.UserAgent := EnCrypt('AGENTE_CACIC');  
578 - idHTTP1.Request.Username := EnCrypt('USER_CACIC');  
579 - idHTTP1.Request.Password := EnCrypt('PW_CACIC'); 522 + idHTTP1.Request.UserAgent := g_oCacic.enCrypt('AGENTE_CACIC');
  523 + idHTTP1.Request.Username := g_oCacic.enCrypt('USER_CACIC');
  524 + idHTTP1.Request.Password := g_oCacic.enCrypt('PW_CACIC');
580 idHTTP1.Request.Accept := 'text/html, */*'; 525 idHTTP1.Request.Accept := 'text/html, */*';
581 idHTTP1.Request.BasicAuthentication := true; 526 idHTTP1.Request.BasicAuthentication := true;
582 idHTTP1.Request.ContentLength := -1; 527 idHTTP1.Request.ContentLength := -1;
@@ -665,22 +610,6 @@ var @@ -665,22 +610,6 @@ var
665 end; 610 end;
666 end; 611 end;
667 612
668 -  
669 -// Pad a string with zeros so that it is a multiple of size  
670 -function TfrmMapaCacic.PadWithZeros(const str : string; size : integer) : string;  
671 -var  
672 - origsize, i : integer;  
673 -begin  
674 - Result := str;  
675 - origsize := Length(Result);  
676 - if ((origsize mod size) <> 0) or (origsize = 0) then  
677 - begin  
678 - SetLength(Result,((origsize div size)+1)*size);  
679 - for i := origsize+1 to Length(Result) do  
680 - Result[i] := #0;  
681 - end;  
682 -end;  
683 -  
684 function TfrmMapaCacic.GetFolderDate(Folder: string): TDateTime; 613 function TfrmMapaCacic.GetFolderDate(Folder: string): TDateTime;
685 var 614 var
686 Rec: TSearchRec; 615 Rec: TSearchRec;
@@ -702,98 +631,6 @@ begin @@ -702,98 +631,6 @@ begin
702 end; 631 end;
703 end; 632 end;
704 633
705 -// Encrypt a string and return the Base64 encoded result  
706 -function TfrmMapaCacic.EnCrypt(p_Data : String) : String;  
707 -var  
708 - l_Cipher : TDCP_rijndael;  
709 - l_Data, l_Key, l_IV : string;  
710 -begin  
711 - Try  
712 - // Pad Key, IV and Data with zeros as appropriate  
713 - l_Key := PadWithZeros(constCipherKey,constKeySize);  
714 - l_IV := PadWithZeros(constIV,constBlockSize);  
715 - l_Data := PadWithZeros(p_Data,constBlockSize);  
716 -  
717 - // Create the cipher and initialise according to the key length  
718 - l_Cipher := TDCP_rijndael.Create(nil);  
719 - if Length(constCipherKey) <= 16 then  
720 - l_Cipher.Init(l_Key[1],128,@l_IV[1])  
721 - else if Length(constCipherKey) <= 24 then  
722 - l_Cipher.Init(l_Key[1],192,@l_IV[1])  
723 - else  
724 - l_Cipher.Init(l_Key[1],256,@l_IV[1]);  
725 -  
726 - // Encrypt the data  
727 - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data));  
728 -  
729 - // Free the cipher and clear sensitive information  
730 - l_Cipher.Free;  
731 - FillChar(l_Key[1],Length(l_Key),0);  
732 -  
733 - // Return the Base64 encoded result  
734 - Result := Base64EncodeStr(l_Data);  
735 - Except  
736 - log_diario('Erro no Processo de Criptografia');  
737 - End;  
738 -end;  
739 -  
740 -function TfrmMapaCacic.DeCrypt(p_Data : String) : String;  
741 -var  
742 - l_Cipher : TDCP_rijndael;  
743 - l_Data, l_Key, l_IV : string;  
744 -begin  
745 - Try  
746 - // Pad Key and IV with zeros as appropriate  
747 - l_Key := PadWithZeros(constCipherKey,constKeySize);  
748 - l_IV := PadWithZeros(constIV,constBlockSize);  
749 -  
750 - // Decode the Base64 encoded string  
751 - l_Data := Base64DecodeStr(p_Data);  
752 -  
753 - // Create the cipher and initialise according to the key length  
754 - l_Cipher := TDCP_rijndael.Create(nil);  
755 - if Length(constCipherKey) <= 16 then  
756 - l_Cipher.Init(l_Key[1],128,@l_IV[1])  
757 - else if Length(constCipherKey) <= 24 then  
758 - l_Cipher.Init(l_Key[1],192,@l_IV[1])  
759 - else  
760 - l_Cipher.Init(l_Key[1],256,@l_IV[1]);  
761 -  
762 - // Decrypt the data  
763 - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data));  
764 -  
765 - // Free the cipher and clear sensitive information  
766 - l_Cipher.Free;  
767 - FillChar(l_Key[1],Length(l_Key),0);  
768 - log_DEBUG('DeCriptografia(ATIVADA) de "'+p_Data+'" => "'+l_Data+'"');  
769 - // Return the result  
770 - Result := trim(l_Data);  
771 - Except  
772 - log_diario('Erro no Processo de Decriptografia');  
773 - End;  
774 -end;  
775 -  
776 -function TfrmMapaCacic.HomeDrive : string;  
777 -var  
778 -WinDir : array [0..144] of char;  
779 -begin  
780 - GetWindowsDirectory (WinDir, 144);  
781 - Result := StrPas (WinDir);  
782 -end;  
783 -  
784 -Function TfrmMapaCacic.Implode(p_Array : TStrings ; p_Separador : String) : String;  
785 -var intAux : integer;  
786 - strAux : string;  
787 -Begin  
788 - strAux := '';  
789 - For intAux := 0 To p_Array.Count -1 do  
790 - Begin  
791 - if (strAux<>'') then strAux := strAux + p_Separador;  
792 - strAux := strAux + p_Array[intAux];  
793 - End;  
794 - Implode := strAux;  
795 -end;  
796 -  
797 Function TfrmMapaCacic.CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; 634 Function TfrmMapaCacic.CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String;
798 var strCipherOpenImploded : string; 635 var strCipherOpenImploded : string;
799 txtFileDatFile : TextFile; 636 txtFileDatFile : TextFile;
@@ -806,9 +643,9 @@ begin @@ -806,9 +643,9 @@ begin
806 Rewrite (txtFileDatFile); 643 Rewrite (txtFileDatFile);
807 Append(txtFileDatFile); 644 Append(txtFileDatFile);
808 645
809 - strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree='); 646 + strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,'=CacicIsFree=');
810 log_DEBUG('Rotina de Fechamento do cacic2.dat ATIVANDO criptografia.'); 647 log_DEBUG('Rotina de Fechamento do cacic2.dat ATIVANDO criptografia.');
811 - strCipherClosed := EnCrypt(strCipherOpenImploded); 648 + strCipherClosed := g_oCacic.enCrypt(strCipherOpenImploded);
812 log_DEBUG('Rotina de Fechamento do cacic2.dat RESTAURANDO estado da criptografia.'); 649 log_DEBUG('Rotina de Fechamento do cacic2.dat RESTAURANDO estado da criptografia.');
813 650
814 Writeln(txtFileDatFile,strCipherClosed); {Grava a string Texto no arquivo texto} 651 Writeln(txtFileDatFile,strCipherClosed); {Grava a string Texto no arquivo texto}
@@ -840,12 +677,12 @@ begin @@ -840,12 +677,12 @@ begin
840 Readln(v_DatFile,v_strCipherClosed); 677 Readln(v_DatFile,v_strCipherClosed);
841 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed); 678 while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed);
842 CloseFile(v_DatFile); 679 CloseFile(v_DatFile);
843 - strCipherOpened:= DeCrypt(v_strCipherClosed); 680 + strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed);
844 end; 681 end;
845 if (trim(strCipherOpened)<>'') then 682 if (trim(strCipherOpened)<>'') then
846 - Result := explode(strCipherOpened,'=CacicIsFree=') 683 + Result := g_oCacic.explode(strCipherOpened,'=CacicIsFree=')
847 else 684 else
848 - Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); 685 + Result := g_oCacic.explode('Configs.ID_SO'+g_oCacic.getSeparatorKey+g_oCacic.getWindowsStrId() +g_oCacic.getSeparatorKey+'Configs.Endereco_WS'+g_oCacic.getSeparatorKey+'/cacic2/ws/',g_oCacic.getSeparatorKey);
849 686
850 if Result.Count mod 2 = 0 then 687 if Result.Count mod 2 = 0 then
851 Result.Add(''); 688 Result.Add('');
@@ -886,7 +723,7 @@ var RegEditSet: TRegistry; @@ -886,7 +723,7 @@ var RegEditSet: TRegistry;
886 ListaAuxSet : TStrings; 723 ListaAuxSet : TStrings;
887 I : Integer; 724 I : Integer;
888 begin 725 begin
889 - ListaAuxSet := Explode(Chave, '); 726 + ListaAuxSet := g_oCacic.explode(Chave, ');
890 strRootKey := ListaAuxSet[0]; 727 strRootKey := ListaAuxSet[0];
891 For I := 1 To ListaAuxSet.Count - 2 Do strKey := strKey + ListaAuxSet[I] + '\'; 728 For I := 1 To ListaAuxSet.Count - 2 Do strKey := strKey + ListaAuxSet[I] + '\';
892 strValue := ListaAuxSet[ListaAuxSet.Count - 1]; 729 strValue := ListaAuxSet[ListaAuxSet.Count - 1];
@@ -924,7 +761,6 @@ begin @@ -924,7 +761,6 @@ begin
924 RegEditSet.Free; 761 RegEditSet.Free;
925 end; 762 end;
926 763
927 -  
928 function TfrmMapaCacic.GetRootKey(strRootKey: String): HKEY; 764 function TfrmMapaCacic.GetRootKey(strRootKey: String): HKEY;
929 begin 765 begin
930 if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE 766 if Trim(strRootKey) = 'HKEY_LOCAL_MACHINE' Then Result := HKEY_LOCAL_MACHINE
@@ -963,19 +799,19 @@ begin @@ -963,19 +799,19 @@ begin
963 799
964 strId_unid_organizacional_nivel1 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',tStringsCipherOpened); 800 strId_unid_organizacional_nivel1 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',tStringsCipherOpened);
965 if (strId_unid_organizacional_nivel1='') then 801 if (strId_unid_organizacional_nivel1='') then
966 - strId_unid_organizacional_nivel1 := DeCrypt(XML.XML_RetornaValor('ID_UON1', p_strConfigs)); 802 + strId_unid_organizacional_nivel1 := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON1', p_strConfigs));
967 803
968 strId_unid_organizacional_nivel1a := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',tStringsCipherOpened); 804 strId_unid_organizacional_nivel1a := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',tStringsCipherOpened);
969 if (strId_unid_organizacional_nivel1a='') then 805 if (strId_unid_organizacional_nivel1a='') then
970 - strId_unid_organizacional_nivel1a := DeCrypt(XML.XML_RetornaValor('ID_UON1a', p_strConfigs)); 806 + strId_unid_organizacional_nivel1a := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON1a', p_strConfigs));
971 807
972 strId_unid_organizacional_nivel2 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',tStringsCipherOpened); 808 strId_unid_organizacional_nivel2 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',tStringsCipherOpened);
973 if (strId_unid_organizacional_nivel2='') then 809 if (strId_unid_organizacional_nivel2='') then
974 - strId_unid_organizacional_nivel2 := DeCrypt(XML.XML_RetornaValor('ID_UON2', p_strConfigs)); 810 + strId_unid_organizacional_nivel2 := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON2', p_strConfigs));
975 811
976 strId_Local := GetValorDatMemoria('Patrimonio.id_local',tStringsCipherOpened); 812 strId_Local := GetValorDatMemoria('Patrimonio.id_local',tStringsCipherOpened);
977 if (strId_Local='') then 813 if (strId_Local='') then
978 - strId_Local := DeCrypt(XML.XML_RetornaValor('ID_LOCAL', p_strConfigs)); 814 + strId_Local := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_LOCAL', p_strConfigs));
979 815
980 Try 816 Try
981 cb_id_unid_organizacional_nivel1.ItemIndex := cb_id_unid_organizacional_nivel1.Items.IndexOf(RetornaValorVetorUON1(strId_unid_organizacional_nivel1)); 817 cb_id_unid_organizacional_nivel1.ItemIndex := cb_id_unid_organizacional_nivel1.Items.IndexOf(RetornaValorVetorUON1(strId_unid_organizacional_nivel1));
@@ -991,11 +827,11 @@ begin @@ -991,11 +827,11 @@ begin
991 Except 827 Except
992 end; 828 end;
993 829
994 - lbEtiqueta1.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs));  
995 - lbEtiqueta1a.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs)); 830 + lbEtiqueta1.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs));
  831 + lbEtiqueta1a.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs));
996 832
997 strTe_localizacao_complementar := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',tStringsCipherOpened); 833 strTe_localizacao_complementar := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',tStringsCipherOpened);
998 - if (strTe_localizacao_complementar='') then strTe_localizacao_complementar := DeCrypt(XML.XML_RetornaValor('TE_LOC_COMPL', p_strConfigs)); 834 + if (strTe_localizacao_complementar='') then strTe_localizacao_complementar := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_LOC_COMPL', p_strConfigs));
999 835
1000 // Tentarei buscar informação gravada no Registry 836 // Tentarei buscar informação gravada no Registry
1001 strTe_info_patrimonio1 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio1'); 837 strTe_info_patrimonio1 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio1');
@@ -1003,13 +839,13 @@ begin @@ -1003,13 +839,13 @@ begin
1003 Begin 839 Begin
1004 strTe_info_patrimonio1 := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',tStringsCipherOpened); 840 strTe_info_patrimonio1 := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',tStringsCipherOpened);
1005 End; 841 End;
1006 - if (strTe_info_patrimonio1='') then strTe_info_patrimonio1 := DeCrypt(XML.XML_RetornaValor('TE_INFO1', p_strConfigs)); 842 + if (strTe_info_patrimonio1='') then strTe_info_patrimonio1 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO1', p_strConfigs));
1007 843
1008 strTe_info_patrimonio2 := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',tStringsCipherOpened); 844 strTe_info_patrimonio2 := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',tStringsCipherOpened);
1009 - if (strTe_info_patrimonio2='') then strTe_info_patrimonio2 := DeCrypt(XML.XML_RetornaValor('TE_INFO2', p_strConfigs)); 845 + if (strTe_info_patrimonio2='') then strTe_info_patrimonio2 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO2', p_strConfigs));
1010 846
1011 strTe_info_patrimonio3 := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',tStringsCipherOpened); 847 strTe_info_patrimonio3 := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',tStringsCipherOpened);
1012 - if (strTe_info_patrimonio3='') then strTe_info_patrimonio3 := DeCrypt(XML.XML_RetornaValor('TE_INFO3', p_strConfigs)); 848 + if (strTe_info_patrimonio3='') then strTe_info_patrimonio3 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO3', p_strConfigs));
1013 849
1014 // Tentarei buscar informação gravada no Registry 850 // Tentarei buscar informação gravada no Registry
1015 strTe_info_patrimonio4 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio4'); 851 strTe_info_patrimonio4 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio4');
@@ -1017,13 +853,13 @@ begin @@ -1017,13 +853,13 @@ begin
1017 Begin 853 Begin
1018 strTe_info_patrimonio4 := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',tStringsCipherOpened); 854 strTe_info_patrimonio4 := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',tStringsCipherOpened);
1019 End; 855 End;
1020 - if (strTe_info_patrimonio4='') then strTe_info_patrimonio4 := DeCrypt(XML.XML_RetornaValor('TE_INFO4', p_strConfigs)); 856 + if (strTe_info_patrimonio4='') then strTe_info_patrimonio4 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO4', p_strConfigs));
1021 857
1022 strTe_info_patrimonio5 := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',tStringsCipherOpened); 858 strTe_info_patrimonio5 := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',tStringsCipherOpened);
1023 - if (strTe_info_patrimonio5='') then strTe_info_patrimonio5 := DeCrypt(XML.XML_RetornaValor('TE_INFO5', p_strConfigs)); 859 + if (strTe_info_patrimonio5='') then strTe_info_patrimonio5 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO5', p_strConfigs));
1024 860
1025 strTe_info_patrimonio6 := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',tStringsCipherOpened); 861 strTe_info_patrimonio6 := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',tStringsCipherOpened);
1026 - if (strTe_info_patrimonio6='') then strTe_info_patrimonio6 := DeCrypt(XML.XML_RetornaValor('TE_INFO6', p_strConfigs)); 862 + if (strTe_info_patrimonio6='') then strTe_info_patrimonio6 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO6', p_strConfigs));
1027 end; 863 end;
1028 864
1029 procedure TfrmMapaCacic.MontaCombos(p_strConfigs : String); 865 procedure TfrmMapaCacic.MontaCombos(p_strConfigs : String);
@@ -1057,7 +893,7 @@ begin @@ -1057,7 +893,7 @@ begin
1057 strTagName := '' 893 strTagName := ''
1058 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then 894 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then
1059 Begin 895 Begin
1060 - strAux1 := DeCrypt(Parser.CurContent); 896 + strAux1 := g_oCacic.deCrypt(Parser.CurContent);
1061 if (strItemName = 'ID1') then 897 if (strItemName = 'ID1') then
1062 Begin 898 Begin
1063 VetorUON1[i].id1 := strAux1; 899 VetorUON1[i].id1 := strAux1;
@@ -1089,7 +925,7 @@ begin @@ -1089,7 +925,7 @@ begin
1089 strTagName := '' 925 strTagName := ''
1090 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then 926 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then
1091 Begin 927 Begin
1092 - strAux1 := DeCrypt(Parser.CurContent); 928 + strAux1 := g_oCacic.deCrypt(Parser.CurContent);
1093 if (strItemName = 'ID1') then 929 if (strItemName = 'ID1') then
1094 Begin 930 Begin
1095 VetorUON1a[i].id1 := strAux1; 931 VetorUON1a[i].id1 := strAux1;
@@ -1135,7 +971,7 @@ begin @@ -1135,7 +971,7 @@ begin
1135 strTagName := '' 971 strTagName := ''
1136 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then 972 else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then
1137 Begin 973 Begin
1138 - strAux1 := DeCrypt(Parser.CurContent); 974 + strAux1 := g_oCacic.deCrypt(Parser.CurContent);
1139 if (strItemName = 'ID1A') then 975 if (strItemName = 'ID1A') then
1140 Begin 976 Begin
1141 VetorUON2[i].id1a := strAux1; 977 VetorUON2[i].id1a := strAux1;
@@ -1250,7 +1086,7 @@ begin @@ -1250,7 +1086,7 @@ begin
1250 Log_debug('cb_id_unid_organizacional_nivel1a.ItemIndex = '+intToStr(cb_id_unid_organizacional_nivel1a.ItemIndex)); 1086 Log_debug('cb_id_unid_organizacional_nivel1a.ItemIndex = '+intToStr(cb_id_unid_organizacional_nivel1a.ItemIndex));
1251 1087
1252 tstrAux := TStrings.Create; 1088 tstrAux := TStrings.Create;
1253 - tstrAux := Explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#'); 1089 + tstrAux := g_oCacic.explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#');
1254 1090
1255 strIdUON1a := tstrAux[0]; 1091 strIdUON1a := tstrAux[0];
1256 strIdLocal := tstrAux[1]; 1092 strIdLocal := tstrAux[1];
@@ -1297,15 +1133,15 @@ var strIdUON1, @@ -1297,15 +1133,15 @@ var strIdUON1,
1297 tstrListAux : TStringList; 1133 tstrListAux : TStringList;
1298 tstrAux : TStrings; 1134 tstrAux : TStrings;
1299 begin 1135 begin
1300 - Matar(strPathCacic,'aguarde_CACIC.txt'); 1136 + Matar(g_oCacic.getCacicPath,'aguarde_CACIC.txt');
1301 1137
1302 - if FileExists(strPathCacic + 'aguarde_CACIC.txt') then 1138 + if FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt') then
1303 MessageDLG(#13#10+'ATENÇÃO!'+#13#10#13#10+ 1139 MessageDLG(#13#10+'ATENÇÃO!'+#13#10#13#10+
1304 'Para o envio das informações, é necessário finalizar o Agente Principal do CACIC.',mtError,[mbOK],0) 1140 'Para o envio das informações, é necessário finalizar o Agente Principal do CACIC.',mtError,[mbOK],0)
1305 else 1141 else
1306 Begin 1142 Begin
1307 tstrAux := TStrings.Create; 1143 tstrAux := TStrings.Create;
1308 - tstrAux := explode(VetorUON2Filtrado[cb_id_unid_organizacional_nivel2.ItemIndex],'#'); 1144 + tstrAux := g_oCacic.explode(VetorUON2Filtrado[cb_id_unid_organizacional_nivel2.ItemIndex],'#');
1309 Try 1145 Try
1310 strIdUON1 := VetorUON1[cb_id_unid_organizacional_nivel1.ItemIndex].id1; 1146 strIdUON1 := VetorUON1[cb_id_unid_organizacional_nivel1.ItemIndex].id1;
1311 strIdUON2 := tstrAux[0]; 1147 strIdUON2 := tstrAux[0];
@@ -1313,65 +1149,37 @@ begin @@ -1313,65 +1149,37 @@ begin
1313 Except 1149 Except
1314 end; 1150 end;
1315 1151
1316 - tstrAux := explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#'); 1152 + tstrAux := g_oCacic.explode(VetorUON1aFiltrado[cb_id_unid_organizacional_nivel1a.ItemIndex],'#');
1317 Try 1153 Try
1318 strIdUON1a := tstrAux[0]; 1154 strIdUON1a := tstrAux[0];
1319 Except 1155 Except
1320 end; 1156 end;
1321 1157
1322 -<<<<<<< .mine  
1323 tstrAux.Free; 1158 tstrAux.Free;
1324 1159
1325 -=======  
1326 ->>>>>>> .r729  
1327 - // Assim, o envio será incondicional! - 01/12/2006 - Anderson Peterle  
1328 - // if (strAux1 <> strId_unid_organizacional_nivel1) or  
1329 - // (strAux2 <> strId_unid_organizacional_nivel2) or  
1330 - // (ed_te_localizacao_complementar.Text <> strTe_localizacao_complementar) or  
1331 - // (ed_te_info_patrimonio1.Text <> strTe_info_patrimonio1) or  
1332 - // (ed_te_info_patrimonio2.Text <> strTe_info_patrimonio2) or  
1333 - // (ed_te_info_patrimonio3.Text <> strTe_info_patrimonio3) or  
1334 - // (ed_te_info_patrimonio4.Text <> strTe_info_patrimonio4) or  
1335 - // (ed_te_info_patrimonio5.Text <> strTe_info_patrimonio5) or  
1336 - // (ed_te_info_patrimonio6.Text <> strTe_info_patrimonio6) then  
1337 - // begin  
1338 -  
1339 -<<<<<<< .mine  
1340 - Mensagem('Enviando Informações Coletadas ao Banco de Dados...',false,intPausaPadrao div 3);  
1341 -======= 1160 + Mensagem('Enviando Informações Coletadas ao Banco de Dados...',false,intPausaPadrao div 3);
  1161 +
1342 // Envio dos Dados Coletados ao Banco de Dados 1162 // Envio dos Dados Coletados ao Banco de Dados
1343 tstrListAux := TStringList.Create; 1163 tstrListAux := TStringList.Create;
1344 - tstrListAux.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));  
1345 - tstrListAux.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));  
1346 - tstrListAux.Values['te_so'] := frmMapaCacic.EnCrypt(g_oCacic.getWindowsStrId());  
1347 - tstrListAux.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));  
1348 - tstrListAux.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));  
1349 - tstrListAux.Values['te_nome_computador'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened));  
1350 - tstrListAux.Values['te_workgroup'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened));  
1351 - tstrListAux.Values['id_usuario'] := frmMapaCacic.EnCrypt(frmMapaCacic.strId_usuario);  
1352 ->>>>>>> .r729  
1353 -  
1354 - // Envio dos Dados Coletados ao Banco de Dados  
1355 - tstrListAux := TStringList.Create;  
1356 - tstrListAux.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));  
1357 - tstrListAux.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));  
1358 - tstrListAux.Values['te_so'] := frmMapaCacic.EnCrypt(str_te_so);  
1359 - tstrListAux.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));  
1360 - tstrListAux.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));  
1361 - tstrListAux.Values['te_nome_computador'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened));  
1362 - tstrListAux.Values['te_workgroup'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened));  
1363 - tstrListAux.Values['id_usuario'] := frmMapaCacic.EnCrypt(frmMapaCacic.strId_usuario);  
1364 -  
1365 - tstrListAux.Values['id_unid_organizacional_nivel1'] := frmMapaCacic.EnCrypt(strIdUON1);  
1366 - tstrListAux.Values['id_unid_organizacional_nivel1a']:= frmMapaCacic.EnCrypt(strIdUON1A);  
1367 - tstrListAux.Values['id_unid_organizacional_nivel2'] := frmMapaCacic.EnCrypt(strIdUON2);  
1368 - tstrListAux.Values['te_localizacao_complementar' ] := frmMapaCacic.EnCrypt(ed_te_localizacao_complementar.Text);  
1369 - tstrListAux.Values['te_info_patrimonio1' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio1.Text);  
1370 - tstrListAux.Values['te_info_patrimonio2' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio2.Text);  
1371 - tstrListAux.Values['te_info_patrimonio3' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio3.Text);  
1372 - tstrListAux.Values['te_info_patrimonio4' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio4.Text);  
1373 - tstrListAux.Values['te_info_patrimonio5' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio5.Text);  
1374 - tstrListAux.Values['te_info_patrimonio6' ] := frmMapaCacic.EnCrypt(ed_te_info_patrimonio6.Text); 1164 + tstrListAux.Values['te_node_address'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));
  1165 + tstrListAux.Values['id_so'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));
  1166 + tstrListAux.Values['te_so'] := g_oCacic.enCrypt(g_oCacic.getWindowsStrId());
  1167 + tstrListAux.Values['id_ip_rede'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));
  1168 + tstrListAux.Values['te_ip'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));
  1169 + tstrListAux.Values['te_nome_computador'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR' , frmMapaCacic.tStringsCipherOpened));
  1170 + tstrListAux.Values['te_workgroup'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened));
  1171 + tstrListAux.Values['id_usuario'] := g_oCacic.enCrypt(frmMapaCacic.strId_usuario);
  1172 +
  1173 + tstrListAux.Values['id_unid_organizacional_nivel1'] := g_oCacic.enCrypt(strIdUON1);
  1174 + tstrListAux.Values['id_unid_organizacional_nivel1a']:= g_oCacic.enCrypt(strIdUON1A);
  1175 + tstrListAux.Values['id_unid_organizacional_nivel2'] := g_oCacic.enCrypt(strIdUON2);
  1176 + tstrListAux.Values['te_localizacao_complementar' ] := g_oCacic.enCrypt(ed_te_localizacao_complementar.Text);
  1177 + tstrListAux.Values['te_info_patrimonio1' ] := g_oCacic.enCrypt(ed_te_info_patrimonio1.Text);
  1178 + tstrListAux.Values['te_info_patrimonio2' ] := g_oCacic.enCrypt(ed_te_info_patrimonio2.Text);
  1179 + tstrListAux.Values['te_info_patrimonio3' ] := g_oCacic.enCrypt(ed_te_info_patrimonio3.Text);
  1180 + tstrListAux.Values['te_info_patrimonio4' ] := g_oCacic.enCrypt(ed_te_info_patrimonio4.Text);
  1181 + tstrListAux.Values['te_info_patrimonio5' ] := g_oCacic.enCrypt(ed_te_info_patrimonio5.Text);
  1182 + tstrListAux.Values['te_info_patrimonio6' ] := g_oCacic.enCrypt(ed_te_info_patrimonio6.Text);
1375 1183
1376 log_DEBUG('Informações para contato com mapa_set_patrimonio:'); 1184 log_DEBUG('Informações para contato com mapa_set_patrimonio:');
1377 log_DEBUG('te_node_address: '+tstrListAux.Values['te_node_address']); 1185 log_DEBUG('te_node_address: '+tstrListAux.Values['te_node_address']);
@@ -1416,76 +1224,76 @@ procedure TfrmMapaCacic.MontaInterface(p_strConfigs : String); @@ -1416,76 +1224,76 @@ procedure TfrmMapaCacic.MontaInterface(p_strConfigs : String);
1416 Begin 1224 Begin
1417 Mensagem('Montando Interface para Coleta de Informações...',false,intPausaPadrao div 3); 1225 Mensagem('Montando Interface para Coleta de Informações...',false,intPausaPadrao div 3);
1418 1226
1419 - lbEtiqueta1.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs)); 1227 + lbEtiqueta1.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1', p_strConfigs));
1420 lbEtiqueta1.Visible := true; 1228 lbEtiqueta1.Visible := true;
1421 - cb_id_unid_organizacional_nivel1.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta1', p_strConfigs)); 1229 + cb_id_unid_organizacional_nivel1.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta1', p_strConfigs));
1422 cb_id_unid_organizacional_nivel1.Visible := true; 1230 cb_id_unid_organizacional_nivel1.Visible := true;
1423 1231
1424 - lbEtiqueta1a.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs)); 1232 + lbEtiqueta1a.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1a', p_strConfigs));
1425 lbEtiqueta1a.Visible := true; 1233 lbEtiqueta1a.Visible := true;
1426 - cb_id_unid_organizacional_nivel1a.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta1a', p_strConfigs)); 1234 + cb_id_unid_organizacional_nivel1a.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta1a', p_strConfigs));
1427 cb_id_unid_organizacional_nivel1a.Visible := true; 1235 cb_id_unid_organizacional_nivel1a.Visible := true;
1428 1236
1429 - lbEtiqueta2.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta2', p_strConfigs)); 1237 + lbEtiqueta2.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta2', p_strConfigs));
1430 lbEtiqueta2.Visible := true; 1238 lbEtiqueta2.Visible := true;
1431 - cb_id_unid_organizacional_nivel2.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta2', p_strConfigs)); 1239 + cb_id_unid_organizacional_nivel2.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta2', p_strConfigs));
1432 cb_id_unid_organizacional_nivel2.Visible := true; 1240 cb_id_unid_organizacional_nivel2.Visible := true;
1433 1241
1434 - lbEtiqueta3.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta3', p_strConfigs)); 1242 + lbEtiqueta3.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta3', p_strConfigs));
1435 lbEtiqueta3.Visible := true; 1243 lbEtiqueta3.Visible := true;
1436 ed_te_localizacao_complementar.Text := strTe_localizacao_complementar; 1244 ed_te_localizacao_complementar.Text := strTe_localizacao_complementar;
1437 ed_te_localizacao_complementar.Visible := true; 1245 ed_te_localizacao_complementar.Visible := true;
1438 1246
1439 - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta4', p_strConfigs)) = 'S') then 1247 + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta4', p_strConfigs)) = 'S') then
1440 begin 1248 begin
1441 - lbEtiqueta4.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta4', p_strConfigs)); 1249 + lbEtiqueta4.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta4', p_strConfigs));
1442 lbEtiqueta4.Visible := true; 1250 lbEtiqueta4.Visible := true;
1443 - ed_te_info_patrimonio1.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta4', p_strConfigs)); 1251 + ed_te_info_patrimonio1.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta4', p_strConfigs));
1444 ed_te_info_patrimonio1.Text := strTe_info_patrimonio1; 1252 ed_te_info_patrimonio1.Text := strTe_info_patrimonio1;
1445 ed_te_info_patrimonio1.visible := True; 1253 ed_te_info_patrimonio1.visible := True;
1446 end; 1254 end;
1447 1255
1448 - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta5', p_strConfigs)) = 'S') then 1256 + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta5', p_strConfigs)) = 'S') then
1449 begin 1257 begin
1450 - lbEtiqueta5.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta5', p_strConfigs)); 1258 + lbEtiqueta5.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta5', p_strConfigs));
1451 lbEtiqueta5.Visible := true; 1259 lbEtiqueta5.Visible := true;
1452 - ed_te_info_patrimonio2.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta5', p_strConfigs)); 1260 + ed_te_info_patrimonio2.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta5', p_strConfigs));
1453 ed_te_info_patrimonio2.Text := strTe_info_patrimonio2; 1261 ed_te_info_patrimonio2.Text := strTe_info_patrimonio2;
1454 ed_te_info_patrimonio2.visible := True; 1262 ed_te_info_patrimonio2.visible := True;
1455 end; 1263 end;
1456 1264
1457 - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta6', p_strConfigs)) = 'S') then 1265 + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta6', p_strConfigs)) = 'S') then
1458 begin 1266 begin
1459 - lbEtiqueta6.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta6', p_strConfigs)); 1267 + lbEtiqueta6.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta6', p_strConfigs));
1460 lbEtiqueta6.Visible := true; 1268 lbEtiqueta6.Visible := true;
1461 - ed_te_info_patrimonio3.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta6', p_strConfigs)); 1269 + ed_te_info_patrimonio3.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta6', p_strConfigs));
1462 ed_te_info_patrimonio3.Text := strTe_info_patrimonio3; 1270 ed_te_info_patrimonio3.Text := strTe_info_patrimonio3;
1463 ed_te_info_patrimonio3.visible := True; 1271 ed_te_info_patrimonio3.visible := True;
1464 end; 1272 end;
1465 1273
1466 - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta7', p_strConfigs)) = 'S') then 1274 + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta7', p_strConfigs)) = 'S') then
1467 begin 1275 begin
1468 - lbEtiqueta7.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta7', p_strConfigs)); 1276 + lbEtiqueta7.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta7', p_strConfigs));
1469 lbEtiqueta7.Visible := true; 1277 lbEtiqueta7.Visible := true;
1470 - ed_te_info_patrimonio4.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta7', p_strConfigs)); 1278 + ed_te_info_patrimonio4.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta7', p_strConfigs));
1471 ed_te_info_patrimonio4.Text := strTe_info_patrimonio4; 1279 ed_te_info_patrimonio4.Text := strTe_info_patrimonio4;
1472 ed_te_info_patrimonio4.visible := True; 1280 ed_te_info_patrimonio4.visible := True;
1473 end; 1281 end;
1474 1282
1475 - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta8', p_strConfigs)) = 'S') then 1283 + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta8', p_strConfigs)) = 'S') then
1476 begin 1284 begin
1477 - lbEtiqueta8.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta8', p_strConfigs)); 1285 + lbEtiqueta8.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta8', p_strConfigs));
1478 lbEtiqueta8.Visible := true; 1286 lbEtiqueta8.Visible := true;
1479 - ed_te_info_patrimonio5.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta8', p_strConfigs)); 1287 + ed_te_info_patrimonio5.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta8', p_strConfigs));
1480 ed_te_info_patrimonio5.Text := strTe_info_patrimonio5; 1288 ed_te_info_patrimonio5.Text := strTe_info_patrimonio5;
1481 ed_te_info_patrimonio5.visible := True; 1289 ed_te_info_patrimonio5.visible := True;
1482 end; 1290 end;
1483 1291
1484 - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta9', p_strConfigs)) = 'S') then 1292 + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta9', p_strConfigs)) = 'S') then
1485 begin 1293 begin
1486 - lbEtiqueta9.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta9', p_strConfigs)); 1294 + lbEtiqueta9.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta9', p_strConfigs));
1487 lbEtiqueta9.Visible := true; 1295 lbEtiqueta9.Visible := true;
1488 - ed_te_info_patrimonio6.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta9', p_strConfigs)); 1296 + ed_te_info_patrimonio6.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta9', p_strConfigs));
1489 ed_te_info_patrimonio6.Text := strTe_info_patrimonio6; 1297 ed_te_info_patrimonio6.Text := strTe_info_patrimonio6;
1490 ed_te_info_patrimonio6.visible := True; 1298 ed_te_info_patrimonio6.visible := True;
1491 end; 1299 end;
@@ -1508,7 +1316,7 @@ var RegEditGet: TRegistry; @@ -1508,7 +1316,7 @@ var RegEditGet: TRegistry;
1508 begin 1316 begin
1509 try 1317 try
1510 Result := ''; 1318 Result := '';
1511 - ListaAuxGet := Explode(Chave, '); 1319 + ListaAuxGet := g_oCacic.explode(Chave, ');
1512 1320
1513 strRootKey := ListaAuxGet[0]; 1321 strRootKey := ListaAuxGet[0];
1514 For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; 1322 For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\';
@@ -1562,45 +1370,6 @@ begin @@ -1562,45 +1370,6 @@ begin
1562 Application.CreateForm(TfrmAcesso, frmAcesso); 1370 Application.CreateForm(TfrmAcesso, frmAcesso);
1563 end; 1371 end;
1564 1372
1565 -function TfrmMapaCacic.IsAdmin: Boolean;  
1566 -var hAccessToken: THandle;  
1567 - ptgGroups: PTokenGroups;  
1568 - dwInfoBufferSize: DWORD;  
1569 - psidAdministrators: PSID;  
1570 - x: Integer;  
1571 - bSuccess: BOOL;  
1572 -begin  
1573 - Result := False;  
1574 - bSuccess := OpenThreadToken(GetCurrentThread, TOKEN_QUERY, True, hAccessToken);  
1575 - if not bSuccess then  
1576 - begin  
1577 - if GetLastError = ERROR_NO_TOKEN then  
1578 - bSuccess := OpenProcessToken(GetCurrentProcess, TOKEN_QUERY, hAccessToken);  
1579 - end;  
1580 - if bSuccess then  
1581 - begin  
1582 - GetMem(ptgGroups, 1024);  
1583 - bSuccess := GetTokenInformation(hAccessToken, TokenGroups, ptgGroups, 1024, dwInfoBufferSize);  
1584 - CloseHandle(hAccessToken);  
1585 - if bSuccess then  
1586 - begin  
1587 - AllocateAndInitializeSid(constSECURITY_NT_AUTHORITY, 2,  
1588 - constSECURITY_BUILTIN_DOMAIN_RID,  
1589 - constDOMAIN_ALIAS_RID_ADMINS,  
1590 - 0, 0, 0, 0, 0, 0, psidAdministrators);  
1591 - {$R-}  
1592 - for x := 0 to ptgGroups.GroupCount - 1 do  
1593 - if EqualSid(psidAdministrators, ptgGroups.Groups[x].Sid) then  
1594 - begin  
1595 - Result := True;  
1596 - Break;  
1597 - end;  
1598 - {$R+}  
1599 - FreeSid(psidAdministrators);  
1600 - end;  
1601 - FreeMem(ptgGroups);  
1602 - end;  
1603 -end;  
1604 // Baixada de http://www.infoeng.hpg.ig.com.br/borland_delphi_dicas_2.htm 1373 // Baixada de http://www.infoeng.hpg.ig.com.br/borland_delphi_dicas_2.htm
1605 function TfrmMapaCacic.LetrasDrives: string; 1374 function TfrmMapaCacic.LetrasDrives: string;
1606 var 1375 var
@@ -1693,7 +1462,8 @@ End; @@ -1693,7 +1462,8 @@ End;
1693 procedure TfrmMapaCacic.FormActivate(Sender: TObject); 1462 procedure TfrmMapaCacic.FormActivate(Sender: TObject);
1694 var intAux : integer; 1463 var intAux : integer;
1695 strLetrasDrives, 1464 strLetrasDrives,
1696 - strRetorno : String; 1465 + strRetorno,
  1466 + v_strCacicPath : String;
1697 Request_mapa : TStringList; 1467 Request_mapa : TStringList;
1698 begin 1468 begin
1699 g_oCacic := TCACIC.Create(); 1469 g_oCacic := TCACIC.Create();
@@ -1708,15 +1478,16 @@ begin @@ -1708,15 +1478,16 @@ begin
1708 Begin 1478 Begin
1709 // Varrer unidades C:\, D:\ e E:\ ... em busca da estrutura Cacic\cacic2.dat 1479 // Varrer unidades C:\, D:\ e E:\ ... em busca da estrutura Cacic\cacic2.dat
1710 strLetrasDrives := LetrasDrives; 1480 strLetrasDrives := LetrasDrives;
1711 - strPathCacic := ''; 1481 +
  1482 + v_strCacicPath := '';
1712 for intAux := 1 to length(strLetrasDrives) do 1483 for intAux := 1 to length(strLetrasDrives) do
1713 Begin 1484 Begin
1714 lbMensagens.Caption := 'Procurando Estrutura do Sistema CACIC em "'+strLetrasDrives[intAux] + ':\"'; 1485 lbMensagens.Caption := 'Procurando Estrutura do Sistema CACIC em "'+strLetrasDrives[intAux] + ':\"';
1715 1486
1716 Log_Debug('Testando "'+strLetrasDrives[intAux] + ':\Cacic\cacic2.dat'+'"'); 1487 Log_Debug('Testando "'+strLetrasDrives[intAux] + ':\Cacic\cacic2.dat'+'"');
1717 - if (strPathCacic='') and (SearchFile(strLetrasDrives[intAux] + ':','\Cacic\cacic2.dat')) then 1488 + if (v_strCacicPath='') and (SearchFile(strLetrasDrives[intAux] + ':','\Cacic\cacic2.dat')) then
1718 Begin 1489 Begin
1719 - strPathCacic := strLetrasDrives[intAux] + ':\Cacic; 1490 + v_strCacicPath := strLetrasDrives[intAux] + ':\Cacic;
1720 lbMensagens.Caption := 'Estrutura Encontrada!'; 1491 lbMensagens.Caption := 'Estrutura Encontrada!';
1721 Log_Debug('Validado "'+strLetrasDrives[intAux] + ':\Cacic\cacic2.dat'+'"'); 1492 Log_Debug('Validado "'+strLetrasDrives[intAux] + ':\Cacic\cacic2.dat'+'"');
1722 End 1493 End
@@ -1725,25 +1496,24 @@ begin @@ -1725,25 +1496,24 @@ begin
1725 application.ProcessMessages; 1496 application.ProcessMessages;
1726 End; 1497 End;
1727 1498
1728 - if not (strPathCacic = '') then 1499 + if not (v_strCacicPath = '') then
1729 Begin 1500 Begin
1730 - Matar(strPathCacic,'aguarde_CACIC.txt'); 1501 + g_oCacic.setCacicPath(v_strCacicPath);
  1502 + Matar(g_oCacic.getCacicPath,'aguarde_CACIC.txt');
1731 1503
1732 - if FileExists(strPathCacic + 'aguarde_CACIC.txt') then 1504 + if FileExists(g_oCacic.getCacicPath + 'aguarde_CACIC.txt') then
1733 Begin 1505 Begin
1734 MessageDLG(#13#10+'ATENÇÃO! É necessário finalizar o Agente Principal do CACIC.',mtError,[mbOK],0); 1506 MessageDLG(#13#10+'ATENÇÃO! É necessário finalizar o Agente Principal do CACIC.',mtError,[mbOK],0);
1735 Sair; 1507 Sair;
1736 End; 1508 End;
1737 1509
1738 - strDatFileName := strPathCacic + 'cacic2.dat'; // Algo como X:\Cacic\cacic2.dat  
1739 -  
1740 boolDebugs := false; 1510 boolDebugs := false;
1741 - if DirectoryExists(strPathCacic + 'Temp\Debugs') then 1511 + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then
1742 Begin 1512 Begin
1743 - if (FormatDateTime('ddmmyyyy', GetFolderDate(strPathCacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then 1513 + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then
1744 Begin 1514 Begin
1745 boolDebugs := true; 1515 boolDebugs := true;
1746 - log_DEBUG('Pasta "' + strPathCacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(strPathCacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); 1516 + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.');
1747 End; 1517 End;
1748 End; 1518 End;
1749 1519
@@ -1762,14 +1532,14 @@ begin @@ -1762,14 +1532,14 @@ begin
1762 // Povoamento com dados de configurações da interface patrimonial 1532 // Povoamento com dados de configurações da interface patrimonial
1763 // Solicita ao servidor as configurações para a Coleta de Informações de Patrimônio 1533 // Solicita ao servidor as configurações para a Coleta de Informações de Patrimônio
1764 Request_mapa := TStringList.Create; 1534 Request_mapa := TStringList.Create;
1765 - Request_mapa.Values['te_node_address'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));  
1766 - Request_mapa.Values['id_so'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));  
1767 - Request_mapa.Values['te_so'] := frmMapaCacic.EnCrypt(g_oCacic.getWindowsStrId());  
1768 - Request_mapa.Values['id_ip_rede'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));  
1769 - Request_mapa.Values['te_ip'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));  
1770 - Request_mapa.Values['te_nome_computador']:= frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', frmMapaCacic.tStringsCipherOpened));  
1771 - Request_mapa.Values['te_workgroup'] := frmMapaCacic.EnCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened));  
1772 - Request_mapa.Values['id_usuario'] := frmMapaCacic.EnCrypt(frmMapaCacic.strId_usuario); 1535 + Request_mapa.Values['te_node_address'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NODE_ADDRESS' , frmMapaCacic.tStringsCipherOpened));
  1536 + Request_mapa.Values['id_so'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('Configs.ID_SO' , frmMapaCacic.tStringsCipherOpened));
  1537 + Request_mapa.Values['te_so'] := g_oCacic.enCrypt(g_oCacic.getWindowsStrId());
  1538 + Request_mapa.Values['id_ip_rede'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.ID_IP_REDE' , frmMapaCacic.tStringsCipherOpened));
  1539 + Request_mapa.Values['te_ip'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_IP' , frmMapaCacic.tStringsCipherOpened));
  1540 + Request_mapa.Values['te_nome_computador']:= g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_NOME_COMPUTADOR', frmMapaCacic.tStringsCipherOpened));
  1541 + Request_mapa.Values['te_workgroup'] := g_oCacic.enCrypt(frmMapaCacic.GetValorDatMemoria('TcpIp.TE_WORKGROUP' , frmMapaCacic.tStringsCipherOpened));
  1542 + Request_mapa.Values['id_usuario'] := g_oCacic.enCrypt(frmMapaCacic.strId_usuario);
1773 1543
1774 strRetorno := frmMapaCacic.ComunicaServidor('mapa_get_patrimonio.php', Request_mapa, '.'); 1544 strRetorno := frmMapaCacic.ComunicaServidor('mapa_get_patrimonio.php', Request_mapa, '.');
1775 1545