Commit d3353de583cfab8af4a0c58a1d73a5effd0c445c
1 parent
4c2a85c7
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@763 fecfc0c7-e812-0410-ae72-849f08638ee7
Showing
17 changed files
with
234 additions
and
574 deletions
Show diff stats
cacic2.res
No preview for this file type
cacicservice/CACICsvc.res
No preview for this file type
chkcacic/chkcacic.res
No preview for this file type
chksis/chksis.res
No preview for this file type
col_anvi/col_anvi.res
No preview for this file type
col_comp/col_comp.res
No preview for this file type
col_hard/col_hard.res
No preview for this file type
col_moni/col_moni.dpr
... | ... | @@ -25,29 +25,32 @@ uses |
25 | 25 | Registry, |
26 | 26 | Classes, |
27 | 27 | PJVersionInfo, |
28 | - DCPcrypt2, | |
29 | - DCPrijndael, | |
30 | - DCPbase64, | |
31 | 28 | CACIC_Library in '..\CACIC_Library.pas'; |
32 | 29 | |
33 | -var p_path_cacic, v_Res_Search, v_Drive, v_File : string; | |
34 | - PJVersionInfo1: TPJVersionInfo; | |
35 | - v_CipherKey, | |
36 | - v_IV, | |
37 | - v_strCipherClosed, | |
38 | - v_DatFileName : String; | |
30 | +var | |
31 | + v_path_cacic, | |
32 | + v_Res_Search, | |
33 | + v_Drive, | |
34 | + v_File, | |
35 | + v_strCipherClosed : String; | |
36 | + PJVersionInfo1 : TPJVersionInfo; | |
39 | 37 | |
40 | -var v_Debugs : boolean; | |
38 | +var | |
39 | + v_Debugs : boolean; | |
41 | 40 | |
42 | -var v_tstrCipherOpened, | |
43 | - v_tstrCipherOpened1 : TStrings; | |
41 | +var | |
42 | + v_tstrCipherOpened, | |
43 | + v_tstrCipherOpened1, | |
44 | + tstrTripa1 : TStrings; | |
45 | + | |
46 | +var | |
47 | + intAux : integer; | |
44 | 48 | |
45 | -var g_oCacic : TCACIC; | |
49 | +var | |
50 | + g_oCacic : TCACIC; | |
46 | 51 | |
47 | -// Some constants that are dependant on the cipher being used | |
48 | -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) | |
49 | -const KeySize = 32; // 32 bytes = 256 bits | |
50 | - BlockSize = 16; // 16 bytes = 128 bits | |
52 | +const | |
53 | + CACIC_APP_NAME = 'col_moni'; | |
51 | 54 | |
52 | 55 | procedure GetSubDirs(Folder:string; sList:TStringList); |
53 | 56 | var |
... | ... | @@ -111,8 +114,8 @@ var |
111 | 114 | strDataArqLocal, strDataAtual : string; |
112 | 115 | begin |
113 | 116 | try |
114 | - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 | |
115 | - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} | |
117 | + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 | |
118 | + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} | |
116 | 119 | {$IOChecks off} |
117 | 120 | Reset(HistoricoLog); {Abre o arquivo texto} |
118 | 121 | {$IOChecks on} |
... | ... | @@ -122,7 +125,7 @@ begin |
122 | 125 | Append(HistoricoLog); |
123 | 126 | Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); |
124 | 127 | end; |
125 | - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log'))); | |
128 | + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log'))); | |
126 | 129 | DateTimeToString(strDataAtual , 'yyyymmdd', Date); |
127 | 130 | if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... |
128 | 131 | begin |
... | ... | @@ -208,116 +211,6 @@ begin |
208 | 211 | end; |
209 | 212 | end; |
210 | 213 | |
211 | - | |
212 | -function HomeDrive : string; | |
213 | -var | |
214 | -WinDir : array [0..144] of char; | |
215 | -begin | |
216 | -GetWindowsDirectory (WinDir, 144); | |
217 | -Result := StrPas (WinDir); | |
218 | -end; | |
219 | - | |
220 | -Function Implode(p_Array : TStrings ; p_Separador : String) : String; | |
221 | -var intAux : integer; | |
222 | - strAux : string; | |
223 | -Begin | |
224 | - strAux := ''; | |
225 | - For intAux := 0 To p_Array.Count -1 do | |
226 | - Begin | |
227 | - if (strAux<>'') then strAux := strAux + p_Separador; | |
228 | - strAux := strAux + p_Array[intAux]; | |
229 | - End; | |
230 | - Implode := strAux; | |
231 | -end; | |
232 | - | |
233 | - | |
234 | -// Pad a string with zeros so that it is a multiple of size | |
235 | -function PadWithZeros(const str : string; size : integer) : string; | |
236 | -var | |
237 | - origsize, i : integer; | |
238 | -begin | |
239 | - Result := str; | |
240 | - origsize := Length(Result); | |
241 | - if ((origsize mod size) <> 0) or (origsize = 0) then | |
242 | - begin | |
243 | - SetLength(Result,((origsize div size)+1)*size); | |
244 | - for i := origsize+1 to Length(Result) do | |
245 | - Result[i] := #0; | |
246 | - end; | |
247 | -end; | |
248 | - | |
249 | - | |
250 | -// Encrypt a string and return the Base64 encoded result | |
251 | -function EnCrypt(p_Data : String) : String; | |
252 | -var | |
253 | - l_Cipher : TDCP_rijndael; | |
254 | - l_Data, l_Key, l_IV : string; | |
255 | -begin | |
256 | - Try | |
257 | - // Pad Key, IV and Data with zeros as appropriate | |
258 | - l_Key := PadWithZeros(v_CipherKey,KeySize); | |
259 | - l_IV := PadWithZeros(v_IV,BlockSize); | |
260 | - l_Data := PadWithZeros(p_Data,BlockSize); | |
261 | - | |
262 | - // Create the cipher and initialise according to the key length | |
263 | - l_Cipher := TDCP_rijndael.Create(nil); | |
264 | - if Length(v_CipherKey) <= 16 then | |
265 | - l_Cipher.Init(l_Key[1],128,@l_IV[1]) | |
266 | - else if Length(v_CipherKey) <= 24 then | |
267 | - l_Cipher.Init(l_Key[1],192,@l_IV[1]) | |
268 | - else | |
269 | - l_Cipher.Init(l_Key[1],256,@l_IV[1]); | |
270 | - | |
271 | - // Encrypt the data | |
272 | - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data)); | |
273 | - | |
274 | - // Free the cipher and clear sensitive information | |
275 | - l_Cipher.Free; | |
276 | - FillChar(l_Key[1],Length(l_Key),0); | |
277 | - | |
278 | - // Return the Base64 encoded result | |
279 | - Result := Base64EncodeStr(l_Data); | |
280 | - Except | |
281 | - log_diario('Erro no Processo de Criptografia'); | |
282 | - End; | |
283 | -end; | |
284 | - | |
285 | -function DeCrypt(p_Data : String) : String; | |
286 | -var | |
287 | - l_Cipher : TDCP_rijndael; | |
288 | - l_Data, l_Key, l_IV : string; | |
289 | -begin | |
290 | - Try | |
291 | - // Pad Key and IV with zeros as appropriate | |
292 | - l_Key := PadWithZeros(v_CipherKey,KeySize); | |
293 | - l_IV := PadWithZeros(v_IV,BlockSize); | |
294 | - | |
295 | - // Decode the Base64 encoded string | |
296 | - l_Data := Base64DecodeStr(p_Data); | |
297 | - | |
298 | - // Create the cipher and initialise according to the key length | |
299 | - l_Cipher := TDCP_rijndael.Create(nil); | |
300 | - if Length(v_CipherKey) <= 16 then | |
301 | - l_Cipher.Init(l_Key[1],128,@l_IV[1]) | |
302 | - else if Length(v_CipherKey) <= 24 then | |
303 | - l_Cipher.Init(l_Key[1],192,@l_IV[1]) | |
304 | - else | |
305 | - l_Cipher.Init(l_Key[1],256,@l_IV[1]); | |
306 | - | |
307 | - // Decrypt the data | |
308 | - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data)); | |
309 | - | |
310 | - // Free the cipher and clear sensitive information | |
311 | - l_Cipher.Free; | |
312 | - FillChar(l_Key[1],Length(l_Key),0); | |
313 | - | |
314 | - // Return the result | |
315 | - Result := l_Data; | |
316 | - Except | |
317 | - log_diario('Erro no Processo de Decriptografia'); | |
318 | - End; | |
319 | -end; | |
320 | - | |
321 | 214 | Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; |
322 | 215 | var v_strCipherOpenImploded : string; |
323 | 216 | v_DatFile : TextFile; |
... | ... | @@ -330,13 +223,8 @@ begin |
330 | 223 | Rewrite (v_DatFile); |
331 | 224 | Append(v_DatFile); |
332 | 225 | |
333 | - //v_Cipher := TDCP_rijndael.Create(nil); | |
334 | - //v_Cipher.InitStr(v_CipherKey,TDCP_md5); | |
335 | - v_strCipherOpenImploded := Implode(p_tstrCipherOpened,'=CacicIsFree='); | |
336 | - //v_strCipherClosed := v_Cipher.EncryptString(v_strCipherOpenImploded); | |
337 | - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded); | |
338 | - //v_Cipher.Burn; | |
339 | - //v_Cipher.Free; | |
226 | + v_strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,g_oCacic.getSeparatorKey); | |
227 | + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded); | |
340 | 228 | |
341 | 229 | Writeln(v_DatFile,v_strCipherClosed); {Grava a string Texto no arquivo texto} |
342 | 230 | |
... | ... | @@ -345,37 +233,6 @@ begin |
345 | 233 | end; |
346 | 234 | end; |
347 | 235 | |
348 | -Function Explode(Texto, Separador : String) : TStrings; | |
349 | -var | |
350 | - strItem : String; | |
351 | - ListaAuxUTILS : TStrings; | |
352 | - NumCaracteres, | |
353 | - TamanhoSeparador, | |
354 | - I : Integer; | |
355 | -Begin | |
356 | - ListaAuxUTILS := TStringList.Create; | |
357 | - strItem := ''; | |
358 | - NumCaracteres := Length(Texto); | |
359 | - TamanhoSeparador := Length(Separador); | |
360 | - I := 1; | |
361 | - While I <= NumCaracteres Do | |
362 | - Begin | |
363 | - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then | |
364 | - Begin | |
365 | - if (I = NumCaracteres) then strItem := strItem + Texto[I]; | |
366 | - ListaAuxUTILS.Add(trim(strItem)); | |
367 | - strItem := ''; | |
368 | - I := I + (TamanhoSeparador-1); | |
369 | - end | |
370 | - Else | |
371 | - strItem := strItem + Texto[I]; | |
372 | - | |
373 | - I := I + 1; | |
374 | - End; | |
375 | - Explode := ListaAuxUTILS; | |
376 | -end; | |
377 | - | |
378 | - | |
379 | 236 | Function CipherOpen(p_DatFileName : string) : TStrings; |
380 | 237 | var v_DatFile : TextFile; |
381 | 238 | v_strCipherOpened, |
... | ... | @@ -397,12 +254,12 @@ begin |
397 | 254 | Readln(v_DatFile,v_strCipherClosed); |
398 | 255 | while not EOF(v_DatFile) do Readln(v_DatFile,v_strCipherClosed); |
399 | 256 | CloseFile(v_DatFile); |
400 | - v_strCipherOpened:= DeCrypt(v_strCipherClosed); | |
257 | + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed); | |
401 | 258 | end; |
402 | 259 | if (trim(v_strCipherOpened)<>'') then |
403 | - Result := explode(v_strCipherOpened,'=CacicIsFree=') | |
260 | + Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey) | |
404 | 261 | else |
405 | - Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); | |
262 | + 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); | |
406 | 263 | |
407 | 264 | if Result.Count mod 2 <> 0 then |
408 | 265 | Result.Add(''); |
... | ... | @@ -462,7 +319,7 @@ var RegEditGet: TRegistry; |
462 | 319 | begin |
463 | 320 | try |
464 | 321 | Result := ''; |
465 | - ListaAuxGet := Explode(Chave, '); | |
322 | + ListaAuxGet := g_oCacic.explode(Chave, '); | |
466 | 323 | |
467 | 324 | strRootKey := ListaAuxGet[0]; |
468 | 325 | For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; |
... | ... | @@ -496,8 +353,6 @@ begin |
496 | 353 | end; |
497 | 354 | end; |
498 | 355 | |
499 | - | |
500 | - | |
501 | 356 | function LastPos(SubStr, S: string): Integer; |
502 | 357 | var |
503 | 358 | Found, Len, Pos: integer; |
... | ... | @@ -542,7 +397,7 @@ begin |
542 | 397 | if (ValorChavePerfis <> '') then |
543 | 398 | Begin |
544 | 399 | //Atenção, OS ELEMENTOS DEVEM ESTAR DE ACORDO COM A ORDEM QUE SÃO TRATADOS NO MÓDULO GERENTE. |
545 | - tstrTripa2 := Explode(ValorChavePerfis,','); | |
400 | + tstrTripa2 := g_oCacic.explode(ValorChavePerfis,','); | |
546 | 401 | if (strAux <> '') then strAux := strAux + '#'; |
547 | 402 | strAux := strAux + trim(tstrTripa2[0]) + ','; |
548 | 403 | |
... | ... | @@ -577,7 +432,7 @@ begin |
577 | 432 | Try |
578 | 433 | if (LastPos('/',trim(tstrTripa2[3]))>0) then |
579 | 434 | Begin |
580 | - tstrTripa3 := Explode(trim(tstrTripa2[3]),'/'); | |
435 | + tstrTripa3 := g_oCacic.explode(trim(tstrTripa2[3]),'/'); | |
581 | 436 | // |
582 | 437 | for v1:=1 to length(v_LetrasDrives) do |
583 | 438 | Begin |
... | ... | @@ -762,7 +617,7 @@ begin |
762 | 617 | log_debug('Buscando informação de VERSÃO em '+tstrTripa2[8]); |
763 | 618 | if (LastPos('/',trim(tstrTripa2[8]))>0) then |
764 | 619 | Begin |
765 | - tstrTripa3 := Explode(trim(tstrTripa2[8]),'/'); | |
620 | + tstrTripa3 := g_oCacic.explode(trim(tstrTripa2[8]),'/'); | |
766 | 621 | // |
767 | 622 | for v1:=1 to length(v_LetrasDrives) do |
768 | 623 | Begin |
... | ... | @@ -897,7 +752,7 @@ begin |
897 | 752 | End; |
898 | 753 | if (strAux1 <> '') then |
899 | 754 | Begin |
900 | - tstrTripa3 := Explode(getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640. | |
755 | + tstrTripa3 := g_oCacic.explode(getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640. | |
901 | 756 | strAux := strAux + tstrTripa3[0] + '.' + tstrTripa3[1]; |
902 | 757 | End; |
903 | 758 | End; |
... | ... | @@ -943,7 +798,7 @@ begin |
943 | 798 | End; |
944 | 799 | if (strAux1 <> '') then |
945 | 800 | Begin |
946 | - tstrTripa3 := Explode(getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640. | |
801 | + tstrTripa3 := g_oCacic.explode(getVersionInfo(strAux1), '.'); // Pego só os dois primeiros dígitos. Por exemplo: 6.640.0.1001 vira 6.640. | |
947 | 802 | strAux := strAux + tstrTripa3[0] + '.' + tstrTripa3[1]; |
948 | 803 | End; |
949 | 804 | if (strAux1 = '') then strAux := strAux + ','; |
... | ... | @@ -960,16 +815,16 @@ begin |
960 | 815 | Begin |
961 | 816 | if (trim(UVC) <> '') then |
962 | 817 | begin |
963 | - v_array1 := Explode(strAux, '#'); | |
818 | + v_array1 := g_oCacic.explode(strAux, '#'); | |
964 | 819 | strAux := ''; |
965 | - v_array3 := Explode(UVC, '#'); | |
820 | + v_array3 := g_oCacic.explode(UVC, '#'); | |
966 | 821 | for v1 := 0 to (v_array1.count)-1 do |
967 | 822 | Begin |
968 | - v_array2 := Explode(v_array1[v1], ','); | |
823 | + v_array2 := g_oCacic.explode(v_array1[v1], ','); | |
969 | 824 | v_achei := 0; |
970 | 825 | for v3 := 0 to (v_array3.count)-1 do |
971 | 826 | Begin |
972 | - v_array4 := Explode(v_array3[v3], ','); | |
827 | + v_array4 := g_oCacic.explode(v_array3[v3], ','); | |
973 | 828 | if (v_array4=v_array2) then v_achei := 1; |
974 | 829 | End; |
975 | 830 | if (v_achei = 0) then |
... | ... | @@ -982,20 +837,20 @@ begin |
982 | 837 | log_debug('Coleta anterior: '+UVC); |
983 | 838 | log_debug('Coleta atual...: '+strAux); |
984 | 839 | SetValorDatMemoria('Col_Moni.UVC', strAux, v_tstrCipherOpened1); |
985 | - CipherClose(p_path_cacic + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
840 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
986 | 841 | end |
987 | 842 | else |
988 | 843 | Begin |
989 | 844 | log_debug('Nenhuma Coleta Efetuada'); |
990 | 845 | SetValorDatMemoria('Col_Moni.nada', 'nada', v_tstrCipherOpened1); |
991 | - CipherClose(p_path_cacic + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
846 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
992 | 847 | End; |
993 | 848 | |
994 | 849 | Except |
995 | 850 | Begin |
996 | 851 | SetValorDatMemoria('Col_Moni.nada', 'nada', v_tstrCipherOpened1); |
997 | 852 | SetValorDatMemoria('Col_Moni.Fim', '99999999', v_tstrCipherOpened1); |
998 | - CipherClose(p_path_cacic + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
853 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
999 | 854 | End; |
1000 | 855 | End; |
1001 | 856 | END; |
... | ... | @@ -1021,62 +876,44 @@ begin |
1021 | 876 | end; |
1022 | 877 | end; |
1023 | 878 | |
1024 | -const | |
1025 | - CACIC_APP_NAME = 'col_moni'; | |
1026 | - | |
1027 | -var tstrTripa1 : TStrings; | |
1028 | - intAux : integer; | |
1029 | - | |
1030 | 879 | begin |
1031 | 880 | g_oCacic := TCACIC.Create(); |
1032 | 881 | |
1033 | 882 | if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then |
1034 | 883 | if (ParamCount>0) then |
1035 | - Begin | |
1036 | - For intAux := 1 to ParamCount do | |
1037 | - Begin | |
1038 | - if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then | |
1039 | - v_CipherKey := Trim(Copy(ParamStr(intAux),14,Length((ParamStr(intAux))))); | |
1040 | - End; | |
1041 | - | |
1042 | - if (trim(v_CipherKey)<>'') then | |
1043 | - Begin | |
884 | + Begin | |
885 | + //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini | |
886 | + tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\'); | |
887 | + v_path_cacic := ''; | |
888 | + For intAux := 0 to tstrTripa1.Count -2 do | |
889 | + begin | |
890 | + v_path_cacic := v_path_cacic + tstrTripa1[intAux] + '\'; | |
891 | + end; | |
892 | + | |
893 | + g_oCacic.setCacicPath(v_path_cacic); | |
894 | + v_Debugs := false; | |
895 | + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then | |
896 | + Begin | |
897 | + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
898 | + Begin | |
899 | + v_Debugs := true; | |
900 | + log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
901 | + End; | |
902 | + End; | |
1044 | 903 | |
1045 | - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini | |
1046 | - tstrTripa1 := explode(ExtractFilePath(ParamStr(0)),'\'); | |
1047 | - p_path_cacic := ''; | |
1048 | - For intAux := 0 to tstrTripa1.Count -2 do | |
1049 | - begin | |
1050 | - p_path_cacic := p_path_cacic + tstrTripa1[intAux] + '\'; | |
1051 | - end; | |
904 | + v_tstrCipherOpened := TStrings.Create; | |
905 | + v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName); | |
1052 | 906 | |
1053 | - v_Debugs := false; | |
1054 | - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then | |
1055 | - Begin | |
1056 | - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
1057 | - Begin | |
1058 | - v_Debugs := true; | |
1059 | - log_diario('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
1060 | - End; | |
1061 | - End; | |
907 | + v_tstrCipherOpened1 := TStrings.Create; | |
908 | + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_moni.dat'); | |
1062 | 909 | |
1063 | - // A chave AES foi obtida no parâmetro p_CipherKey. Recomenda-se que cada empresa altere a sua chave. | |
1064 | - v_IV := 'abcdefghijklmnop'; | |
1065 | - v_DatFileName := p_path_cacic + 'cacic2.dat'; | |
1066 | - v_tstrCipherOpened := TStrings.Create; | |
1067 | - v_tstrCipherOpened := CipherOpen(v_DatFileName); | |
1068 | - | |
1069 | - v_tstrCipherOpened1 := TStrings.Create; | |
1070 | - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'temp\col_moni.dat'); | |
1071 | - | |
1072 | - Try | |
1073 | - Executa_Col_moni; | |
1074 | - Except | |
1075 | - SetValorDatMemoria('Col_Moni.nada', 'nada', v_tstrCipherOpened1); | |
1076 | - CipherClose(p_path_cacic + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
1077 | - End; | |
1078 | - End; | |
1079 | - End; | |
910 | + Try | |
911 | + Executa_Col_moni; | |
912 | + Except | |
913 | + SetValorDatMemoria('Col_Moni.nada', 'nada', v_tstrCipherOpened1); | |
914 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_moni.dat', v_tstrCipherOpened1); | |
915 | + End; | |
916 | + End; | |
1080 | 917 | |
1081 | 918 | g_oCacic.Free(); |
1082 | 919 | ... | ... |
col_moni/col_moni.res
No preview for this file type
col_patr/col_patr.dpr
... | ... | @@ -32,12 +32,12 @@ const |
32 | 32 | |
33 | 33 | var |
34 | 34 | hwind:HWND; |
35 | - oCacic : TCACIC; | |
35 | + g_oCacic : TCACIC; | |
36 | 36 | |
37 | 37 | begin |
38 | - oCacic := TCACIC.Create(); | |
38 | + g_oCacic := TCACIC.Create(); | |
39 | 39 | |
40 | - if( oCacic.isAppRunning( CACIC_APP_NAME ) ) | |
40 | + if( g_oCacic.isAppRunning( CACIC_APP_NAME ) ) | |
41 | 41 | then begin |
42 | 42 | hwind := 0; |
43 | 43 | repeat // The string 'My app' must match your App Title (below) |
... | ... | @@ -55,6 +55,6 @@ begin |
55 | 55 | Application.Run; |
56 | 56 | end; |
57 | 57 | |
58 | - oCacic.Free(); | |
58 | + g_oCacic.Free(); | |
59 | 59 | |
60 | 60 | end. | ... | ... |
col_patr/col_patr.res
No preview for this file type
col_patr/main_col_patr.pas
... | ... | @@ -19,46 +19,40 @@ unit main_col_patr; |
19 | 19 | |
20 | 20 | interface |
21 | 21 | |
22 | -uses IniFiles, | |
23 | - Windows, | |
24 | - Sysutils, // Deve ser colocado após o Windows acima, nunca antes | |
25 | - Registry, | |
26 | - LibXmlParser, | |
27 | - XML, | |
28 | - StdCtrls, | |
29 | - Controls, | |
30 | - Classes, | |
31 | - Forms, | |
32 | - PJVersionInfo, | |
33 | - DIALOGS, | |
34 | - DCPcrypt2, | |
35 | - DCPrijndael, | |
36 | - DCPbase64, | |
37 | - ExtCtrls, | |
38 | - Math, | |
39 | - CACIC_Library; | |
40 | - | |
41 | -var p_path_cacic : String; | |
42 | - v_Dados_Patrimonio : TStrings; | |
43 | - v_CipherKey, | |
44 | - v_IV, | |
45 | - v_strCipherClosed, | |
46 | - v_strCipherOpened, | |
47 | - v_configs, | |
48 | - v_option : String; | |
49 | - v_Debugs, | |
50 | - l_cs_cipher : boolean; | |
51 | - | |
52 | -var v_tstrCipherOpened, | |
53 | - v_tstrCipherOpened1 : TStrings; | |
22 | +uses | |
23 | + IniFiles, | |
24 | + Windows, | |
25 | + Sysutils, // Deve ser colocado após o Windows acima, nunca antes | |
26 | + Registry, | |
27 | + LibXmlParser, | |
28 | + XML, | |
29 | + StdCtrls, | |
30 | + Controls, | |
31 | + Classes, | |
32 | + Forms, | |
33 | + PJVersionInfo, | |
34 | + DIALOGS, | |
35 | + ExtCtrls, | |
36 | + Math, | |
37 | + CACIC_Library; | |
54 | 38 | |
55 | 39 | var |
56 | - g_oCacic : TCACIC; | |
40 | + v_Dados_Patrimonio, | |
41 | + v_tstrCipherOpened, | |
42 | + v_tstrCipherOpened1 : TStrings; | |
57 | 43 | |
58 | -// Some constants that are dependant on the cipher being used | |
59 | -// Assuming MCRYPT_RIJNDAEL_128 (i.e., 128bit blocksize, 256bit keysize) | |
60 | -const KeySize = 32; // 32 bytes = 256 bits | |
61 | - BlockSize = 16; // 16 bytes = 128 bits | |
44 | +var | |
45 | + v_strCipherClosed, | |
46 | + v_strCipherOpened, | |
47 | + v_configs, | |
48 | + v_option : String; | |
49 | + | |
50 | +var | |
51 | + v_Debugs, | |
52 | + l_cs_cipher : boolean; | |
53 | + | |
54 | +var | |
55 | + g_oCacic : TCACIC; | |
62 | 56 | |
63 | 57 | type |
64 | 58 | TFormPatrimonio = class(TForm) |
... | ... | @@ -94,15 +88,9 @@ type |
94 | 88 | function GetValorChaveRegEdit(Chave: String): Variant; |
95 | 89 | function GetRootKey(strRootKey: String): HKEY; |
96 | 90 | Function RemoveCaracteresEspeciais(Texto, p_Fill : String; p_start, p_end:integer) : String; |
97 | - function HomeDrive : string; | |
98 | - Function Implode(p_Array : TStrings ; p_Separador : String) : String; | |
99 | 91 | Function CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; |
100 | - Function Explode(Texto, Separador : String) : TStrings; | |
101 | 92 | Function CipherOpen(p_DatFileName : string) : TStrings; |
102 | 93 | Function GetValorDatMemoria(p_Chave : String; p_tstrCipherOpened : TStrings) : String; |
103 | - function PadWithZeros(const str : string; size : integer) : string; | |
104 | - function EnCrypt(p_Data : String) : String; | |
105 | - function DeCrypt(p_Data : String) : String; | |
106 | 94 | procedure FormCreate(Sender: TObject); |
107 | 95 | procedure MontaCombos; |
108 | 96 | procedure MontaInterface; |
... | ... | @@ -175,21 +163,6 @@ var VetorUON1 : TVetorUON1; |
175 | 163 | // Esse array é usado apenas para saber a uon2, após a filtragem pelo uon1 |
176 | 164 | VetorUON2Filtrado : array of String; |
177 | 165 | |
178 | -// Pad a string with zeros so that it is a multiple of size | |
179 | -function TFormPatrimonio.PadWithZeros(const str : string; size : integer) : string; | |
180 | -var | |
181 | - origsize, i : integer; | |
182 | -begin | |
183 | - Result := str; | |
184 | - origsize := Length(Result); | |
185 | - if ((origsize mod size) <> 0) or (origsize = 0) then | |
186 | - begin | |
187 | - SetLength(Result,((origsize div size)+1)*size); | |
188 | - for i := origsize+1 to Length(Result) do | |
189 | - Result[i] := #0; | |
190 | - end; | |
191 | -end; | |
192 | - | |
193 | 166 | function TFormPatrimonio.GetFolderDate(Folder: string): TDateTime; |
194 | 167 | var |
195 | 168 | Rec: TSearchRec; |
... | ... | @@ -211,115 +184,6 @@ begin |
211 | 184 | end; |
212 | 185 | end; |
213 | 186 | |
214 | -// Encrypt a string and return the Base64 encoded result | |
215 | -function TFormPatrimonio.EnCrypt(p_Data : String) : String; | |
216 | -var | |
217 | - l_Cipher : TDCP_rijndael; | |
218 | - l_Data, l_Key, l_IV : string; | |
219 | -begin | |
220 | - Try | |
221 | - if l_cs_cipher then | |
222 | - Begin | |
223 | - | |
224 | - // Pad Key, IV and Data with zeros as appropriate | |
225 | - l_Key := PadWithZeros(v_CipherKey,KeySize); | |
226 | - l_IV := PadWithZeros(v_IV,BlockSize); | |
227 | - l_Data := PadWithZeros(p_Data,BlockSize); | |
228 | - | |
229 | - // Create the cipher and initialise according to the key length | |
230 | - l_Cipher := TDCP_rijndael.Create(nil); | |
231 | - if Length(v_CipherKey) <= 16 then | |
232 | - l_Cipher.Init(l_Key[1],128,@l_IV[1]) | |
233 | - else if Length(v_CipherKey) <= 24 then | |
234 | - l_Cipher.Init(l_Key[1],192,@l_IV[1]) | |
235 | - else | |
236 | - l_Cipher.Init(l_Key[1],256,@l_IV[1]); | |
237 | - | |
238 | - // Encrypt the data | |
239 | - l_Cipher.EncryptCBC(l_Data[1],l_Data[1],Length(l_Data)); | |
240 | - | |
241 | - // Free the cipher and clear sensitive information | |
242 | - l_Cipher.Free; | |
243 | - FillChar(l_Key[1],Length(l_Key),0); | |
244 | - | |
245 | - // Return the Base64 encoded result | |
246 | - Result := Base64EncodeStr(l_Data); | |
247 | - End | |
248 | - else | |
249 | - Begin | |
250 | - log_DEBUG('Criptografia(DESATIVADA) de "'+p_Data+'"'); | |
251 | - Result := p_Data; | |
252 | - End; | |
253 | - Except | |
254 | - log_diario('Erro no Processo de Criptografia'); | |
255 | - End; | |
256 | -end; | |
257 | - | |
258 | -function TFormPatrimonio.DeCrypt(p_Data : String) : String; | |
259 | -var | |
260 | - l_Cipher : TDCP_rijndael; | |
261 | - l_Data, l_Key, l_IV : string; | |
262 | -begin | |
263 | - Try | |
264 | - if l_cs_cipher then | |
265 | - Begin | |
266 | - // Pad Key and IV with zeros as appropriate | |
267 | - l_Key := PadWithZeros(v_CipherKey,KeySize); | |
268 | - l_IV := PadWithZeros(v_IV,BlockSize); | |
269 | - | |
270 | - // Decode the Base64 encoded string | |
271 | - l_Data := Base64DecodeStr(p_Data); | |
272 | - | |
273 | - // Create the cipher and initialise according to the key length | |
274 | - l_Cipher := TDCP_rijndael.Create(nil); | |
275 | - if Length(v_CipherKey) <= 16 then | |
276 | - l_Cipher.Init(l_Key[1],128,@l_IV[1]) | |
277 | - else if Length(v_CipherKey) <= 24 then | |
278 | - l_Cipher.Init(l_Key[1],192,@l_IV[1]) | |
279 | - else | |
280 | - l_Cipher.Init(l_Key[1],256,@l_IV[1]); | |
281 | - | |
282 | - // Decrypt the data | |
283 | - l_Cipher.DecryptCBC(l_Data[1],l_Data[1],Length(l_Data)); | |
284 | - | |
285 | - // Free the cipher and clear sensitive information | |
286 | - l_Cipher.Free; | |
287 | - FillChar(l_Key[1],Length(l_Key),0); | |
288 | - log_DEBUG('DeCriptografia(ATIVADA) de "'+p_Data+'" => "'+l_Data+'"'); | |
289 | - // Return the result | |
290 | - Result := trim(l_Data); | |
291 | - End | |
292 | - else | |
293 | - Begin | |
294 | - log_DEBUG('DeCriptografia(DESATIVADA) de "'+p_Data+'"'); | |
295 | - Result := p_Data; | |
296 | - End; | |
297 | - Except | |
298 | - log_diario('Erro no Processo de Decriptografia'); | |
299 | - End; | |
300 | -end; | |
301 | - | |
302 | -function TFormPatrimonio.HomeDrive : string; | |
303 | -var | |
304 | -WinDir : array [0..144] of char; | |
305 | -begin | |
306 | -GetWindowsDirectory (WinDir, 144); | |
307 | -Result := StrPas (WinDir); | |
308 | -end; | |
309 | - | |
310 | -Function TFormPatrimonio.Implode(p_Array : TStrings ; p_Separador : String) : String; | |
311 | -var intAux : integer; | |
312 | - strAux : string; | |
313 | -Begin | |
314 | - strAux := ''; | |
315 | - For intAux := 0 To p_Array.Count -1 do | |
316 | - Begin | |
317 | - if (strAux<>'') then strAux := strAux + p_Separador; | |
318 | - strAux := strAux + p_Array[intAux]; | |
319 | - End; | |
320 | - Implode := strAux; | |
321 | -end; | |
322 | - | |
323 | 187 | Function TFormPatrimonio.CipherClose(p_DatFileName : string; p_tstrCipherOpened : TStrings) : String; |
324 | 188 | var v_strCipherOpenImploded : string; |
325 | 189 | v_DatFile : TextFile; |
... | ... | @@ -333,11 +197,11 @@ begin |
333 | 197 | Rewrite (v_DatFile); |
334 | 198 | Append(v_DatFile); |
335 | 199 | |
336 | - v_strCipherOpenImploded := FormPatrimonio.Implode(p_tstrCipherOpened,'=CacicIsFree='); | |
200 | + v_strCipherOpenImploded := g_oCacic.implode(p_tstrCipherOpened,g_oCacic.getSeparatorKey); | |
337 | 201 | v_cs_cipher := l_cs_cipher; |
338 | 202 | l_cs_cipher := true; |
339 | 203 | log_DEBUG('Rotina de Fechamento do cacic2.dat ATIVANDO criptografia.'); |
340 | - v_strCipherClosed := EnCrypt(v_strCipherOpenImploded); | |
204 | + v_strCipherClosed := g_oCacic.enCrypt(v_strCipherOpenImploded); | |
341 | 205 | l_cs_cipher := v_cs_cipher; |
342 | 206 | log_DEBUG('Rotina de Fechamento do cacic2.dat RESTAURANDO estado da criptografia.'); |
343 | 207 | |
... | ... | @@ -348,37 +212,6 @@ begin |
348 | 212 | end; |
349 | 213 | end; |
350 | 214 | |
351 | -Function TFormPatrimonio.Explode(Texto, Separador : String) : TStrings; | |
352 | -var | |
353 | - strItem : String; | |
354 | - ListaAuxUTILS : TStrings; | |
355 | - NumCaracteres, | |
356 | - TamanhoSeparador, | |
357 | - I : Integer; | |
358 | -Begin | |
359 | - ListaAuxUTILS := TStringList.Create; | |
360 | - strItem := ''; | |
361 | - NumCaracteres := Length(Texto); | |
362 | - TamanhoSeparador := Length(Separador); | |
363 | - I := 1; | |
364 | - While I <= NumCaracteres Do | |
365 | - Begin | |
366 | - If (Copy(Texto,I,TamanhoSeparador) = Separador) or (I = NumCaracteres) Then | |
367 | - Begin | |
368 | - if (I = NumCaracteres) then strItem := strItem + Texto[I]; | |
369 | - ListaAuxUTILS.Add(trim(strItem)); | |
370 | - strItem := ''; | |
371 | - I := I + (TamanhoSeparador-1); | |
372 | - end | |
373 | - Else | |
374 | - strItem := strItem + Texto[I]; | |
375 | - | |
376 | - I := I + 1; | |
377 | - End; | |
378 | - Explode := ListaAuxUTILS; | |
379 | -end; | |
380 | - | |
381 | - | |
382 | 215 | Function TFormPatrimonio.CipherOpen(p_DatFileName : string) : TStrings; |
383 | 216 | var v_DatFile : TextFile; |
384 | 217 | v_strCipherOpened, |
... | ... | @@ -405,14 +238,14 @@ begin |
405 | 238 | v_cs_cipher := l_cs_cipher; |
406 | 239 | l_cs_cipher := true; |
407 | 240 | log_DEBUG('Rotina de Abertura do cacic2.dat ATIVANDO criptografia.'); |
408 | - v_strCipherOpened:= DeCrypt(v_strCipherClosed); | |
241 | + v_strCipherOpened:= g_oCacic.deCrypt(v_strCipherClosed); | |
409 | 242 | l_cs_cipher := v_cs_cipher; |
410 | 243 | log_DEBUG('Rotina de Abertura do cacic2.dat RESTAURANDO estado da criptografia.'); |
411 | 244 | end; |
412 | 245 | if (trim(v_strCipherOpened)<>'') then |
413 | - Result := explode(v_strCipherOpened,'=CacicIsFree=') | |
246 | + Result := g_oCacic.explode(v_strCipherOpened,g_oCacic.getSeparatorKey) | |
414 | 247 | else |
415 | - Result := explode('Configs.ID_SO=CacicIsFree='+ g_oCacic.getWindowsStrId() +'=CacicIsFree=Configs.Endereco_WS=CacicIsFree=/cacic2/ws/','=CacicIsFree='); | |
248 | + 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); | |
416 | 249 | |
417 | 250 | if Result.Count mod 2 = 0 then |
418 | 251 | Result.Add(''); |
... | ... | @@ -453,7 +286,7 @@ var RegEditSet: TRegistry; |
453 | 286 | ListaAuxSet : TStrings; |
454 | 287 | I : Integer; |
455 | 288 | begin |
456 | - ListaAuxSet := Explode(Chave, '); | |
289 | + ListaAuxSet := g_oCacic.explode(Chave, '); | |
457 | 290 | strRootKey := ListaAuxSet[0]; |
458 | 291 | For I := 1 To ListaAuxSet.Count - 2 Do strKey := strKey + ListaAuxSet[I] + '\'; |
459 | 292 | strValue := ListaAuxSet[ListaAuxSet.Count - 1]; |
... | ... | @@ -530,8 +363,8 @@ var |
530 | 363 | strDataArqLocal, strDataAtual : string; |
531 | 364 | begin |
532 | 365 | try |
533 | - FileSetAttr (p_path_cacic + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 | |
534 | - AssignFile(HistoricoLog,p_path_cacic + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} | |
366 | + FileSetAttr (g_oCacic.getCacicPath + 'cacic2.log',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 | |
367 | + AssignFile(HistoricoLog,g_oCacic.getCacicPath + 'cacic2.log'); {Associa o arquivo a uma variável do tipo TextFile} | |
535 | 368 | {$IOChecks off} |
536 | 369 | Reset(HistoricoLog); {Abre o arquivo texto} |
537 | 370 | {$IOChecks on} |
... | ... | @@ -541,7 +374,7 @@ begin |
541 | 374 | Append(HistoricoLog); |
542 | 375 | Writeln(HistoricoLog,FormatDateTime('dd/mm hh:nn:ss : ', Now) + '======================> Iniciando o Log do CACIC <======================='); |
543 | 376 | end; |
544 | - DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(p_path_cacic + 'cacic2.log'))); | |
377 | + DateTimeToString(strDataArqLocal, 'yyyymmdd', FileDateToDateTime(Fileage(g_oCacic.getCacicPath + 'cacic2.log'))); | |
545 | 378 | DateTimeToString(strDataAtual , 'yyyymmdd', Date); |
546 | 379 | if (strDataAtual <> strDataArqLocal) then // Se o arquivo INI não é da data atual... |
547 | 380 | begin |
... | ... | @@ -581,20 +414,20 @@ end; |
581 | 414 | |
582 | 415 | procedure TFormPatrimonio.RecuperaValoresAnteriores; |
583 | 416 | begin |
584 | - Etiqueta1.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1', v_configs)); | |
585 | - Etiqueta1a.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1a', v_configs)); | |
417 | + Etiqueta1.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1', v_configs)); | |
418 | + Etiqueta1a.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1a', v_configs)); | |
586 | 419 | |
587 | 420 | var_id_unid_organizacional_nivel1 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1',v_tstrCipherOpened); |
588 | - if (var_id_unid_organizacional_nivel1='') then var_id_unid_organizacional_nivel1 := DeCrypt(XML.XML_RetornaValor('ID_UON1', v_configs)); | |
421 | + if (var_id_unid_organizacional_nivel1='') then var_id_unid_organizacional_nivel1 := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON1', v_configs)); | |
589 | 422 | |
590 | 423 | var_id_unid_organizacional_nivel1a := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel1a',v_tstrCipherOpened); |
591 | - if (var_id_unid_organizacional_nivel1a='') then var_id_unid_organizacional_nivel1a := DeCrypt(XML.XML_RetornaValor('ID_UON1a', v_configs)); | |
424 | + if (var_id_unid_organizacional_nivel1a='') then var_id_unid_organizacional_nivel1a := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON1a', v_configs)); | |
592 | 425 | |
593 | 426 | var_id_unid_organizacional_nivel2 := GetValorDatMemoria('Patrimonio.id_unid_organizacional_nivel2',v_tstrCipherOpened); |
594 | - if (var_id_unid_organizacional_nivel2='') then var_id_unid_organizacional_nivel2 := DeCrypt(XML.XML_RetornaValor('ID_UON2', v_configs)); | |
427 | + if (var_id_unid_organizacional_nivel2='') then var_id_unid_organizacional_nivel2 := g_oCacic.deCrypt(XML.XML_RetornaValor('ID_UON2', v_configs)); | |
595 | 428 | |
596 | 429 | var_te_localizacao_complementar := GetValorDatMemoria('Patrimonio.te_localizacao_complementar',v_tstrCipherOpened); |
597 | - if (var_te_localizacao_complementar='') then var_te_localizacao_complementar := DeCrypt(XML.XML_RetornaValor('TE_LOC_COMPL', v_configs)); | |
430 | + if (var_te_localizacao_complementar='') then var_te_localizacao_complementar := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_LOC_COMPL', v_configs)); | |
598 | 431 | |
599 | 432 | // Tentarei buscar informação gravada no Registry |
600 | 433 | var_te_info_patrimonio1 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio1'); |
... | ... | @@ -602,13 +435,13 @@ begin |
602 | 435 | Begin |
603 | 436 | var_te_info_patrimonio1 := GetValorDatMemoria('Patrimonio.te_info_patrimonio1',v_tstrCipherOpened); |
604 | 437 | End; |
605 | - if (var_te_info_patrimonio1='') then var_te_info_patrimonio1 := DeCrypt(XML.XML_RetornaValor('TE_INFO1', v_configs)); | |
438 | + if (var_te_info_patrimonio1='') then var_te_info_patrimonio1 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO1', v_configs)); | |
606 | 439 | |
607 | 440 | var_te_info_patrimonio2 := GetValorDatMemoria('Patrimonio.te_info_patrimonio2',v_tstrCipherOpened); |
608 | - if (var_te_info_patrimonio2='') then var_te_info_patrimonio2 := DeCrypt(XML.XML_RetornaValor('TE_INFO2', v_configs)); | |
441 | + if (var_te_info_patrimonio2='') then var_te_info_patrimonio2 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO2', v_configs)); | |
609 | 442 | |
610 | 443 | var_te_info_patrimonio3 := GetValorDatMemoria('Patrimonio.te_info_patrimonio3',v_tstrCipherOpened); |
611 | - if (var_te_info_patrimonio3='') then var_te_info_patrimonio3 := DeCrypt(XML.XML_RetornaValor('TE_INFO3', v_configs)); | |
444 | + if (var_te_info_patrimonio3='') then var_te_info_patrimonio3 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO3', v_configs)); | |
612 | 445 | |
613 | 446 | // Tentarei buscar informação gravada no Registry |
614 | 447 | var_te_info_patrimonio4 := GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio4'); |
... | ... | @@ -616,13 +449,13 @@ begin |
616 | 449 | Begin |
617 | 450 | var_te_info_patrimonio4 := GetValorDatMemoria('Patrimonio.te_info_patrimonio4',v_tstrCipherOpened); |
618 | 451 | End; |
619 | - if (var_te_info_patrimonio4='') then var_te_info_patrimonio4 := DeCrypt(XML.XML_RetornaValor('TE_INFO4', v_configs)); | |
452 | + if (var_te_info_patrimonio4='') then var_te_info_patrimonio4 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO4', v_configs)); | |
620 | 453 | |
621 | 454 | var_te_info_patrimonio5 := GetValorDatMemoria('Patrimonio.te_info_patrimonio5',v_tstrCipherOpened); |
622 | - if (var_te_info_patrimonio5='') then var_te_info_patrimonio5 := DeCrypt(XML.XML_RetornaValor('TE_INFO5', v_configs)); | |
455 | + if (var_te_info_patrimonio5='') then var_te_info_patrimonio5 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO5', v_configs)); | |
623 | 456 | |
624 | 457 | var_te_info_patrimonio6 := GetValorDatMemoria('Patrimonio.te_info_patrimonio6',v_tstrCipherOpened); |
625 | - if (var_te_info_patrimonio6='') then var_te_info_patrimonio6 := DeCrypt(XML.XML_RetornaValor('TE_INFO6', v_configs)); | |
458 | + if (var_te_info_patrimonio6='') then var_te_info_patrimonio6 := g_oCacic.deCrypt(XML.XML_RetornaValor('TE_INFO6', v_configs)); | |
626 | 459 | |
627 | 460 | Try |
628 | 461 | id_unid_organizacional_nivel1.ItemIndex := id_unid_organizacional_nivel1.Items.IndexOf(RetornaValorVetorUON1(var_id_unid_organizacional_nivel1)); |
... | ... | @@ -684,7 +517,7 @@ begin |
684 | 517 | strTagName := '' |
685 | 518 | else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1')Then |
686 | 519 | Begin |
687 | - strAux1 := DeCrypt(Parser.CurContent); | |
520 | + strAux1 := g_oCacic.deCrypt(Parser.CurContent); | |
688 | 521 | if (strItemName = 'ID1') then |
689 | 522 | Begin |
690 | 523 | VetorUON1[i].id1 := strAux1; |
... | ... | @@ -716,7 +549,7 @@ begin |
716 | 549 | strTagName := '' |
717 | 550 | else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT1A')Then |
718 | 551 | Begin |
719 | - strAux1 := DeCrypt(Parser.CurContent); | |
552 | + strAux1 := g_oCacic.deCrypt(Parser.CurContent); | |
720 | 553 | if (strItemName = 'ID1') then |
721 | 554 | Begin |
722 | 555 | VetorUON1a[i].id1 := strAux1; |
... | ... | @@ -762,7 +595,7 @@ begin |
762 | 595 | strTagName := '' |
763 | 596 | else if (Parser.CurPartType in [ptContent, ptCData]) and (strTagName='IT2')Then |
764 | 597 | Begin |
765 | - strAux1 := DeCrypt(Parser.CurContent); | |
598 | + strAux1 := g_oCacic.deCrypt(Parser.CurContent); | |
766 | 599 | if (strItemName = 'ID1A') then |
767 | 600 | Begin |
768 | 601 | VetorUON2[i].id1a := strAux1; |
... | ... | @@ -874,7 +707,7 @@ var strIdUON1, |
874 | 707 | tstrAux : TStrings; |
875 | 708 | begin |
876 | 709 | tstrAux := TStrings.Create; |
877 | - tstrAux := explode(VetorUON2Filtrado[id_unid_organizacional_nivel2.ItemIndex],'#'); | |
710 | + tstrAux := g_oCacic.explode(VetorUON2Filtrado[id_unid_organizacional_nivel2.ItemIndex],'#'); | |
878 | 711 | Try |
879 | 712 | strIdUON1 := VetorUON1[id_unid_organizacional_nivel1.ItemIndex].id1; |
880 | 713 | strIdUON1a := VetorUON1aFiltrado[id_unid_organizacional_nivel1a.ItemIndex]; |
... | ... | @@ -909,12 +742,12 @@ begin |
909 | 742 | SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\SOFTWARE\Dataprev\Patrimonio\te_info_patrimonio4', te_info_patrimonio4.Text); |
910 | 743 | SetValorDatMemoria('Col_Patr.te_info_patrimonio5' , te_info_patrimonio5.Text, v_tstrCipherOpened1); |
911 | 744 | SetValorDatMemoria('Col_Patr.te_info_patrimonio6' , te_info_patrimonio6.Text, v_tstrCipherOpened1); |
912 | - CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
745 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
913 | 746 | end |
914 | 747 | else |
915 | 748 | Begin |
916 | 749 | SetValorDatMemoria('Col_Patr.nada', 'nada', v_tstrCipherOpened1); |
917 | - CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
750 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
918 | 751 | End; |
919 | 752 | Application.Terminate; |
920 | 753 | end; |
... | ... | @@ -924,21 +757,21 @@ Begin |
924 | 757 | // Se houve alteração na configuração da interface, atualizo os dados no registro e depois monto a interface. |
925 | 758 | // Caso, contrário, pego direto do registro. |
926 | 759 | |
927 | - Etiqueta1.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1', v_configs)); | |
928 | - id_unid_organizacional_nivel1.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta1', v_configs)); | |
760 | + Etiqueta1.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1', v_configs)); | |
761 | + id_unid_organizacional_nivel1.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta1', v_configs)); | |
929 | 762 | |
930 | - Etiqueta1a.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta1a', v_configs)); | |
931 | - id_unid_organizacional_nivel1a.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta1a', v_configs)); | |
763 | + Etiqueta1a.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta1a', v_configs)); | |
764 | + id_unid_organizacional_nivel1a.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta1a', v_configs)); | |
932 | 765 | |
933 | - Etiqueta2.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta2', v_configs)); | |
934 | - id_unid_organizacional_nivel2.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta2', v_configs)); | |
766 | + Etiqueta2.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta2', v_configs)); | |
767 | + id_unid_organizacional_nivel2.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta2', v_configs)); | |
935 | 768 | |
936 | - Etiqueta3.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta3', v_configs)); | |
769 | + Etiqueta3.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta3', v_configs)); | |
937 | 770 | |
938 | - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta4', v_configs)) = 'S') then | |
771 | + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta4', v_configs)) = 'S') then | |
939 | 772 | begin |
940 | - Etiqueta4.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta4', v_configs)); | |
941 | - te_info_patrimonio1.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta4', v_configs)); | |
773 | + Etiqueta4.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta4', v_configs)); | |
774 | + te_info_patrimonio1.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta4', v_configs)); | |
942 | 775 | te_info_patrimonio1.visible := True; |
943 | 776 | end |
944 | 777 | else begin |
... | ... | @@ -947,10 +780,10 @@ Begin |
947 | 780 | |
948 | 781 | end; |
949 | 782 | |
950 | - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta5', v_configs)) = 'S') then | |
783 | + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta5', v_configs)) = 'S') then | |
951 | 784 | begin |
952 | - Etiqueta5.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta5', v_configs)); | |
953 | - te_info_patrimonio2.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta5', v_configs)); | |
785 | + Etiqueta5.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta5', v_configs)); | |
786 | + te_info_patrimonio2.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta5', v_configs)); | |
954 | 787 | te_info_patrimonio2.visible := True; |
955 | 788 | end |
956 | 789 | else begin |
... | ... | @@ -958,10 +791,10 @@ Begin |
958 | 791 | te_info_patrimonio2.visible := False; |
959 | 792 | end; |
960 | 793 | |
961 | - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta6', v_configs)) = 'S') then | |
794 | + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta6', v_configs)) = 'S') then | |
962 | 795 | begin |
963 | - Etiqueta6.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta6', v_configs)); | |
964 | - te_info_patrimonio3.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta6', v_configs)); | |
796 | + Etiqueta6.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta6', v_configs)); | |
797 | + te_info_patrimonio3.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta6', v_configs)); | |
965 | 798 | te_info_patrimonio3.visible := True; |
966 | 799 | end |
967 | 800 | else begin |
... | ... | @@ -969,10 +802,10 @@ Begin |
969 | 802 | te_info_patrimonio3.visible := False; |
970 | 803 | end; |
971 | 804 | |
972 | - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta7', v_configs)) = 'S') then | |
805 | + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta7', v_configs)) = 'S') then | |
973 | 806 | begin |
974 | - Etiqueta7.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta7', v_configs)); | |
975 | - te_info_patrimonio4.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta7', v_configs)); | |
807 | + Etiqueta7.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta7', v_configs)); | |
808 | + te_info_patrimonio4.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta7', v_configs)); | |
976 | 809 | te_info_patrimonio4.visible := True; |
977 | 810 | end else |
978 | 811 | begin |
... | ... | @@ -980,10 +813,10 @@ Begin |
980 | 813 | te_info_patrimonio4.visible := False; |
981 | 814 | end; |
982 | 815 | |
983 | - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta8', v_configs)) = 'S') then | |
816 | + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta8', v_configs)) = 'S') then | |
984 | 817 | begin |
985 | - Etiqueta8.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta8', v_configs)); | |
986 | - te_info_patrimonio5.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta8', v_configs)); | |
818 | + Etiqueta8.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta8', v_configs)); | |
819 | + te_info_patrimonio5.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta8', v_configs)); | |
987 | 820 | te_info_patrimonio5.visible := True; |
988 | 821 | end else |
989 | 822 | begin |
... | ... | @@ -991,10 +824,10 @@ Begin |
991 | 824 | te_info_patrimonio5.visible := False; |
992 | 825 | end; |
993 | 826 | |
994 | - if (DeCrypt(XML.XML_RetornaValor('in_exibir_etiqueta9', v_configs)) = 'S') then | |
827 | + if (g_oCacic.deCrypt(XML.XML_RetornaValor('in_exibir_etiqueta9', v_configs)) = 'S') then | |
995 | 828 | begin |
996 | - Etiqueta9.Caption := DeCrypt(XML.XML_RetornaValor('te_etiqueta9', v_configs)); | |
997 | - te_info_patrimonio6.Hint := DeCrypt(XML.XML_RetornaValor('te_help_etiqueta9', v_configs)); | |
829 | + Etiqueta9.Caption := g_oCacic.deCrypt(XML.XML_RetornaValor('te_etiqueta9', v_configs)); | |
830 | + te_info_patrimonio6.Hint := g_oCacic.deCrypt(XML.XML_RetornaValor('te_help_etiqueta9', v_configs)); | |
998 | 831 | te_info_patrimonio6.visible := True; |
999 | 832 | end |
1000 | 833 | else begin |
... | ... | @@ -1006,7 +839,7 @@ end; |
1006 | 839 | procedure TFormPatrimonio.FormClose(Sender: TObject; var Action: TCloseAction); |
1007 | 840 | begin |
1008 | 841 | SetValorDatMemoria('Col_Patr.nada', 'nada', v_tstrCipherOpened1); |
1009 | - CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
842 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
1010 | 843 | Application.Terminate; |
1011 | 844 | end; |
1012 | 845 | // Função adaptada de http://www.latiumsoftware.com/en/delphi/00004.php |
... | ... | @@ -1020,7 +853,7 @@ var RegEditGet: TRegistry; |
1020 | 853 | begin |
1021 | 854 | try |
1022 | 855 | Result := ''; |
1023 | - ListaAuxGet := Explode(Chave, '); | |
856 | + ListaAuxGet := g_oCacic.explode(Chave, '); | |
1024 | 857 | |
1025 | 858 | strRootKey := ListaAuxGet[0]; |
1026 | 859 | For I := 1 To ListaAuxGet.Count - 2 Do strKey := strKey + ListaAuxGet[I] + '\'; |
... | ... | @@ -1069,104 +902,94 @@ Begin |
1069 | 902 | end; |
1070 | 903 | |
1071 | 904 | procedure TFormPatrimonio.FormCreate(Sender: TObject); |
1072 | -var boolColeta : boolean; | |
1073 | - tstrTripa1 : TStrings; | |
1074 | - i,intAux : integer; | |
1075 | - v_Aux : String; | |
905 | +var boolColeta : boolean; | |
906 | + tstrTripa1 : TStrings; | |
907 | + i,intAux : integer; | |
908 | + v_Aux, | |
909 | + v_path_cacic : String; | |
1076 | 910 | Begin |
1077 | 911 | g_oCacic := TCACIC.Create(); |
1078 | 912 | |
1079 | 913 | if (ParamCount>0) then |
1080 | 914 | Begin |
1081 | 915 | FormPatrimonio.lbVersao.Caption := 'Versão: ' + GetVersionInfo(ParamStr(0)); |
916 | + | |
917 | + v_option := 'system'; | |
1082 | 918 | For intAux := 1 to ParamCount do |
1083 | 919 | Begin |
1084 | - if LowerCase(Copy(ParamStr(intAux),1,13)) = '/p_cipherkey=' then | |
1085 | - v_CipherKey := Trim(Copy(ParamStr(intAux),14,Length((ParamStr(intAux))))); | |
920 | + if LowerCase(Copy(ParamStr(intAux),1,10)) = '/p_option=' then | |
921 | + v_option := Trim(Copy(ParamStr(intAux),11,Length((ParamStr(intAux))))); | |
1086 | 922 | End; |
1087 | 923 | |
1088 | - if (trim(v_CipherKey)<>'') then | |
924 | + tstrTripa1 := g_oCacic.explode(ExtractFilePath(Application.Exename),'\'); //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic | |
925 | + v_path_cacic := ''; | |
926 | + For i := 0 to tstrTripa1.Count -2 do | |
927 | + v_path_cacic := v_path_cacic + tstrTripa1[i] + '\'; | |
928 | + | |
929 | + g_oCacic.setCacicPath(v_path_cacic); | |
930 | + v_Debugs := false; | |
931 | + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then | |
932 | + Begin | |
933 | + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
934 | + Begin | |
935 | + v_Debugs := true; | |
936 | + log_DEBUG('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
937 | + End; | |
938 | + End; | |
939 | + | |
940 | + v_tstrCipherOpened := TStrings.Create; | |
941 | + v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + 'cacic2.dat'); | |
942 | + | |
943 | + v_tstrCipherOpened1 := TStrings.Create; | |
944 | + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_patr.dat'); | |
945 | + | |
946 | + // Os valores possíveis serão 0-DESLIGADO 1-LIGADO 2-ESPERA PARA LIGAR (Será transformado em "1") 3-Ainda se comunicará com o Gerente WEB | |
947 | + l_cs_cipher := false; | |
948 | + v_Aux := GetValorDatMemoria('Configs.CS_CIPHER', v_tstrCipherOpened); | |
949 | + if (v_Aux='1')then | |
950 | + Begin | |
951 | + l_cs_cipher := true; | |
952 | + End; | |
953 | + | |
954 | + Try | |
955 | + boolColeta := false; | |
956 | + if (GetValorDatMemoria('Patrimonio.in_alteracao_fisica',v_tstrCipherOpened)= 'S') then | |
1089 | 957 | Begin |
1090 | - v_option := 'system'; | |
1091 | - For intAux := 1 to ParamCount do | |
1092 | - Begin | |
1093 | - if LowerCase(Copy(ParamStr(intAux),1,10)) = '/p_option=' then | |
1094 | - v_option := Trim(Copy(ParamStr(intAux),11,Length((ParamStr(intAux))))); | |
1095 | - End; | |
958 | + // Solicita o cadastramento de informações de patrimõnio caso seja detectado remanejamento para uma nova rede. | |
959 | + MessageDlg('Atenção: foi identificada uma alteração na localização física deste computador. Por favor, confirme as informações que serão apresentadas na tela que será exibida a seguir.', mtInformation, [mbOk], 0); | |
960 | + boolColeta := true; | |
961 | + End | |
962 | + Else if (GetValorDatMemoria('Patrimonio.in_renovacao_informacoes',v_tstrCipherOpened)= 'S') and (v_option='system') then | |
963 | + Begin | |
964 | + // Solicita o cadastramento de informações de patrimõnio caso tenha completado o prazo configurado para renovação de informações. | |
965 | + MessageDlg('Atenção: é necessário o preenchimento/atualização das informações de Patrimônio e Localização Física deste computador. Por favor, confirme as informações que serão apresentadas na tela que será exibida a seguir.', mtInformation, [mbOk], 0); | |
966 | + boolColeta := true; | |
967 | + end | |
968 | + Else if (GetValorDatMemoria('Patrimonio.dt_ultima_renovacao_patrim',v_tstrCipherOpened)= '') then | |
969 | + Begin | |
970 | + // Solicita o cadastramento de informações de patrimõnio caso ainda não tenha sido cadastrado. | |
971 | + boolColeta := true; | |
972 | + end; | |
1096 | 973 | |
1097 | - tstrTripa1 := explode(ExtractFilePath(Application.Exename),'\'); //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic | |
1098 | - p_path_cacic := ''; | |
1099 | - For i := 0 to tstrTripa1.Count -2 do | |
1100 | - begin | |
1101 | - p_path_cacic := p_path_cacic + tstrTripa1[i] + '\'; | |
1102 | - end; | |
974 | + if boolColeta then | |
975 | + Begin | |
976 | + SetValorDatMemoria('Col_Patr.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1); | |
977 | + log_diario('Coletando informações de Patrimônio e Localização Física.'); | |
978 | + v_configs := GetValorDatMemoria('Patrimonio.Configs',v_tstrCipherOpened); | |
979 | + log_DEBUG('Configurações obtidas: '+v_configs); | |
980 | + | |
981 | + MontaInterface; | |
982 | + MontaCombos; | |
983 | + RecuperaValoresAnteriores; | |
1103 | 984 | |
1104 | - v_Debugs := false; | |
1105 | - if DirectoryExists(p_path_cacic + 'Temp\Debugs') then | |
1106 | - Begin | |
1107 | - if (FormatDateTime('ddmmyyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
1108 | - Begin | |
1109 | - v_Debugs := true; | |
1110 | - log_DEBUG('Pasta "' + p_path_cacic + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(p_path_cacic + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
1111 | - End; | |
1112 | - End; | |
1113 | - | |
1114 | - // A chave AES foi obtida no parâmetro p_CipherKey. Recomenda-se que cada empresa altere a sua chave. | |
1115 | - v_IV := 'abcdefghijklmnop'; | |
1116 | - v_tstrCipherOpened := TStrings.Create; | |
1117 | - v_tstrCipherOpened := CipherOpen(p_path_cacic + 'cacic2.dat'); | |
1118 | - | |
1119 | - v_tstrCipherOpened1 := TStrings.Create; | |
1120 | - v_tstrCipherOpened1 := CipherOpen(p_path_cacic + 'temp\col_patr.dat'); | |
1121 | - | |
1122 | - // Os valores possíveis serão 0-DESLIGADO 1-LIGADO 2-ESPERA PARA LIGAR (Será transformado em "1") 3-Ainda se comunicará com o Gerente WEB | |
1123 | - l_cs_cipher := false; | |
1124 | - v_Aux := GetValorDatMemoria('Configs.CS_CIPHER', v_tstrCipherOpened); | |
1125 | - if (v_Aux='1')then | |
1126 | - Begin | |
1127 | - l_cs_cipher := true; | |
1128 | - End; | |
1129 | - | |
1130 | - Try | |
1131 | - boolColeta := false; | |
1132 | - if (GetValorDatMemoria('Patrimonio.in_alteracao_fisica',v_tstrCipherOpened)= 'S') then | |
1133 | - Begin | |
1134 | - // Solicita o cadastramento de informações de patrimõnio caso seja detectado remanejamento para uma nova rede. | |
1135 | - MessageDlg('Atenção: foi identificada uma alteração na localização física deste computador. Por favor, confirme as informações que serão apresentadas na tela que será exibida a seguir.', mtInformation, [mbOk], 0); | |
1136 | - boolColeta := true; | |
1137 | - End | |
1138 | - Else if (GetValorDatMemoria('Patrimonio.in_renovacao_informacoes',v_tstrCipherOpened)= 'S') and (v_option='system') then | |
1139 | - Begin | |
1140 | - // Solicita o cadastramento de informações de patrimõnio caso tenha completado o prazo configurado para renovação de informações. | |
1141 | - MessageDlg('Atenção: é necessário o preenchimento/atualização das informações de Patrimônio e Localização Física deste computador. Por favor, confirme as informações que serão apresentadas na tela que será exibida a seguir.', mtInformation, [mbOk], 0); | |
1142 | - boolColeta := true; | |
1143 | - end | |
1144 | - Else if (GetValorDatMemoria('Patrimonio.dt_ultima_renovacao_patrim',v_tstrCipherOpened)= '') then | |
1145 | - Begin | |
1146 | - // Solicita o cadastramento de informações de patrimõnio caso ainda não tenha sido cadastrado. | |
1147 | - boolColeta := true; | |
1148 | - end; | |
1149 | - | |
1150 | - if boolColeta then | |
1151 | - Begin | |
1152 | - SetValorDatMemoria('Col_Patr.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1); | |
1153 | - log_diario('Coletando informações de Patrimônio e Localização Física.'); | |
1154 | - v_configs := GetValorDatMemoria('Patrimonio.Configs',v_tstrCipherOpened); | |
1155 | - log_DEBUG('Configurações obtidas: '+v_configs); | |
1156 | - | |
1157 | - MontaInterface; | |
1158 | - MontaCombos; | |
1159 | - RecuperaValoresAnteriores; | |
1160 | - | |
1161 | - End; | |
1162 | - Except | |
1163 | - SetValorDatMemoria('Col_Patr.nada','nada', v_tstrCipherOpened1); | |
1164 | - SetValorDatMemoria('Col_Patr.Fim', '99999999', v_tstrCipherOpened1); | |
1165 | - CipherClose(p_path_cacic + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
1166 | - g_oCacic.Free(); | |
1167 | - Application.Terminate; | |
1168 | 985 | End; |
1169 | - End; | |
986 | + Except | |
987 | + SetValorDatMemoria('Col_Patr.nada','nada', v_tstrCipherOpened1); | |
988 | + SetValorDatMemoria('Col_Patr.Fim', '99999999', v_tstrCipherOpened1); | |
989 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_patr.dat', v_tstrCipherOpened1); | |
990 | + g_oCacic.Free(); | |
991 | + Application.Terminate; | |
992 | + End; | |
1170 | 993 | End; |
1171 | 994 | end; |
1172 | 995 | ... | ... |
col_soft/col_soft.res
No preview for this file type
col_undi/col_undi.res
No preview for this file type
ger_cols/ger_cols.res
No preview for this file type
ini_cols/ini_cols.res
No preview for this file type
mapa/mapacacic.res
No preview for this file type