Commit 4d566bb72f239870e95fde861d123bcee85f3672
1 parent
ea871732
Exists in
master
Reuso de codigos da library generica, pequenas correcoes e faxina de codigo.
git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/agente-windows@774 fecfc0c7-e812-0410-ae72-849f08638ee7
Showing
23 changed files
with
272 additions
and
282 deletions
Show diff stats
cacic2.res
No preview for this file type
cacicservice/CACICsvc.res
No preview for this file type
cacicservice/CACICsvcMain.pas
| ... | ... | @@ -44,7 +44,7 @@ type |
| 44 | 44 | |
| 45 | 45 | { Internal Start & Stop methods } |
| 46 | 46 | function GetValorChaveRegIni(p_Secao, p_Chave, p_File : String): String; |
| 47 | - procedure doSaveLog(Msg : String); | |
| 47 | + procedure logDEBUG(Msg : String); | |
| 48 | 48 | Procedure WMEndSession(var Msg : TWMEndSession) ; message WM_ENDSESSION; |
| 49 | 49 | procedure ExecutaCACIC; |
| 50 | 50 | public |
| ... | ... | @@ -62,7 +62,7 @@ implementation |
| 62 | 62 | procedure TCACICservice.WMEndSession(var Msg : TWMEndSession) ; |
| 63 | 63 | begin |
| 64 | 64 | if Msg.EndSession = TRUE then |
| 65 | - doSaveLog('Windows finalizado em ' + FormatDateTime('c', Now)) ; | |
| 65 | + logDEBUG('Windows finalizado em ' + FormatDateTime('c', Now)) ; | |
| 66 | 66 | inherited; |
| 67 | 67 | Application.Free; |
| 68 | 68 | end; |
| ... | ... | @@ -77,7 +77,7 @@ var |
| 77 | 77 | i, j, v_Size_Section, v_Size_Key : integer; |
| 78 | 78 | v_SectionName, v_KeyName : string; |
| 79 | 79 | begin |
| 80 | -//doSaveLog('GetVCRini: Secao: '+p_Secao+' Chave: '+p_Chave+' File: '+p_File); | |
| 80 | + logDEBUG('GetVCRini: Secao: '+p_Secao+' Chave: '+p_Chave+' File: '+p_File); | |
| 81 | 81 | Result := ''; |
| 82 | 82 | v_SectionName := '[' + p_Secao + ']'; |
| 83 | 83 | v_Size_Section := strLen(PChar(v_SectionName)); |
| ... | ... | @@ -106,32 +106,34 @@ var |
| 106 | 106 | end; |
| 107 | 107 | end; |
| 108 | 108 | |
| 109 | -procedure TCACICservice.doSaveLog(Msg : String); | |
| 109 | +procedure TCACICservice.logDEBUG(Msg : String); | |
| 110 | 110 | var fLog: textfile; |
| 111 | 111 | begin |
| 112 | - AssignFile(fLog, g_oCacic.Windows.getWinDir + 'CACICsvc.log'); | |
| 113 | - if FileExists(g_oCacic.Windows.getWinDir + 'CACICsvc.log') then | |
| 114 | - Append(fLog) | |
| 115 | - else | |
| 116 | - Rewrite(fLog); | |
| 117 | - Writeln(fLog,FormatDateTime('dd/mm hh:nn:ss ', Now) + '[CACICsvc] : ' +msg); | |
| 118 | - CloseFile(fLog); | |
| 112 | + // Somente gravarei informações para debug se o arquivo "<HomeDrive>:\CACICsvc.log" existir | |
| 113 | + if FileExists(g_oCacic.Windows.getHomeDrive + 'CACICsvc.log') then | |
| 114 | + Begin | |
| 115 | + AssignFile(fLog, g_oCacic.Windows.getHomeDrive + 'CACICsvc.log'); | |
| 116 | + if FileExists(g_oCacic.Windows.getHomeDrive + 'CACICsvc.log') then | |
| 117 | + Append(fLog) | |
| 118 | + else | |
| 119 | + Rewrite(fLog); | |
| 120 | + Writeln(fLog,FormatDateTime('dd/mm hh:nn:ss ', Now) + '[CACICsvc][DEBUG] : ' +msg); | |
| 121 | + CloseFile(fLog); | |
| 122 | + End; | |
| 119 | 123 | End; |
| 120 | 124 | |
| 121 | 125 | procedure ServiceController(CtrlCode: DWord); stdcall; |
| 122 | 126 | begin |
| 123 | - CACICservice.Controller(CtrlCode); | |
| 127 | + CACICservice.Controller(CtrlCode); | |
| 124 | 128 | end; |
| 125 | 129 | |
| 126 | 130 | function TCACICservice.GetServiceController: TServiceController; |
| 127 | 131 | begin |
| 128 | - Result := ServiceController; | |
| 132 | + Result := ServiceController; | |
| 129 | 133 | end; |
| 130 | 134 | |
| 131 | 135 | procedure TCACICservice.ServiceExecute(Sender: TService); |
| 132 | 136 | begin |
| 133 | - doSaveLog('TCACICservice.ServiceExecute'); | |
| 134 | - | |
| 135 | 137 | { Loop while service is active in SCM } |
| 136 | 138 | While NOT Terminated do |
| 137 | 139 | Begin |
| ... | ... | @@ -144,8 +146,9 @@ end; |
| 144 | 146 | |
| 145 | 147 | procedure TCACICservice.ServiceStart(Sender: TService; var Started: Boolean); |
| 146 | 148 | begin |
| 147 | - g_oCacic := TCACIC.Create; | |
| 148 | 149 | |
| 150 | + g_oCacic := TCACIC.Create; | |
| 151 | + CACICservice.logDEBUG('TCACICservice.ServiceStart'); | |
| 149 | 152 | Started := true; |
| 150 | 153 | |
| 151 | 154 | ExecutaCACIC; |
| ... | ... | @@ -159,8 +162,10 @@ end; |
| 159 | 162 | |
| 160 | 163 | procedure TCACICservice.ExecutaCACIC; |
| 161 | 164 | Begin |
| 162 | - g_oCacic.setCacicPath(g_oCacic.getHomeDrive + GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini') + '\'); | |
| 165 | + CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : setCacicPath => '+GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini')); | |
| 166 | + g_oCacic.setCacicPath(GetValorChaveRegIni('Cacic2', 'cacic_dir', g_oCacic.getWinDir + 'chksis.ini')); | |
| 163 | 167 | |
| 168 | + CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : deleteFile => '+g_oCacic.getCacicPath + 'aguarde_CACIC.txt'); | |
| 164 | 169 | DeleteFile(g_oCacic.getCacicPath + 'aguarde_CACIC.txt'); |
| 165 | 170 | Sleep(3000); |
| 166 | 171 | |
| ... | ... | @@ -169,7 +174,8 @@ Begin |
| 169 | 174 | Begin |
| 170 | 175 | // Executo o CHKsis, verificando a estrutura do sistema |
| 171 | 176 | Try |
| 172 | - WinEXEC(PChar(g_oCacic.getWinDir + 'chksis.exe'),sw_HIDE); | |
| 177 | + CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : winExec => '+g_oCacic.getWinDir + 'chksis.exe'); | |
| 178 | + g_oCacic.createSampleProcess(g_oCacic.getWinDir + 'chksis.exe',false); | |
| 173 | 179 | Except |
| 174 | 180 | End; |
| 175 | 181 | |
| ... | ... | @@ -180,19 +186,21 @@ Begin |
| 180 | 186 | |
| 181 | 187 | // Executo o Agente Principal do CACIC |
| 182 | 188 | Try |
| 183 | - WinEXEC(PChar(g_oCacic.getCacicPath + 'cacic2.exe'),sw_hide); | |
| 189 | + CACICservice.logDEBUG('TCACICservice.ExecutaCACIC : winExec => '+g_oCacic.getCacicPath + 'cacic2.exe'); | |
| 190 | + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe',false); | |
| 184 | 191 | Except |
| 185 | 192 | End; |
| 186 | 193 | End; |
| 187 | 194 | |
| 188 | 195 | procedure TCACICservice.ServiceAfterInstall(Sender: TService); |
| 189 | - | |
| 190 | 196 | begin |
| 191 | 197 | ServiceStart(nil,boolStarted); |
| 198 | + CACICservice.logDEBUG('TCACICservice.ServiceAfterInstall'); | |
| 192 | 199 | end; |
| 193 | 200 | |
| 194 | 201 | procedure TCACICservice.Timer_CHKsisTimer(Sender: TObject); |
| 195 | 202 | begin |
| 203 | + CACICservice.logDEBUG('TCACICservice.Timer_CHKsisTimer'); | |
| 196 | 204 | ExecutaCACIC; |
| 197 | 205 | |
| 198 | 206 | // Verificações diversas |
| ... | ... | @@ -202,6 +210,7 @@ end; |
| 202 | 210 | procedure TCACICservice.ServiceStop(Sender: TService; |
| 203 | 211 | var Stopped: Boolean); |
| 204 | 212 | begin |
| 213 | + CACICservice.logDEBUG('TCACICservice.ServiceStop'); | |
| 205 | 214 | Stopped := true; |
| 206 | 215 | end; |
| 207 | 216 | ... | ... |
chkcacic/FormConfig.dfm
| ... | ... | @@ -154,11 +154,11 @@ object Configs: TConfigs |
| 154 | 154 | Text = 'Cacic' |
| 155 | 155 | end |
| 156 | 156 | object Button_Gravar: TButton |
| 157 | - Left = 74 | |
| 157 | + Left = 48 | |
| 158 | 158 | Top = 325 |
| 159 | - Width = 150 | |
| 159 | + Width = 214 | |
| 160 | 160 | Height = 35 |
| 161 | - Caption = 'Gravar Configura'#231#245'es' | |
| 161 | + Caption = 'Concluir Instala'#231#227'o/Atualiza'#231#227'o' | |
| 162 | 162 | Font.Charset = DEFAULT_CHARSET |
| 163 | 163 | Font.Color = clWindowText |
| 164 | 164 | Font.Height = -13 |
| ... | ... | @@ -169,7 +169,7 @@ object Configs: TConfigs |
| 169 | 169 | OnClick = Button_GravarClick |
| 170 | 170 | end |
| 171 | 171 | object btSair: TButton |
| 172 | - Left = 265 | |
| 172 | + Left = 291 | |
| 173 | 173 | Top = 325 |
| 174 | 174 | Width = 150 |
| 175 | 175 | Height = 35 | ... | ... |
chkcacic/FormConfig.pas
| ... | ... | @@ -20,8 +20,21 @@ unit FormConfig; |
| 20 | 20 | interface |
| 21 | 21 | |
| 22 | 22 | uses |
| 23 | - Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
| 24 | - Dialogs, StdCtrls,main, PJVersionInfo, NTFileSecurity, Buttons, ExtCtrls; | |
| 23 | + Windows, | |
| 24 | + Messages, | |
| 25 | + SysUtils, | |
| 26 | + Variants, | |
| 27 | + Classes, | |
| 28 | + Graphics, | |
| 29 | + Controls, | |
| 30 | + Forms, | |
| 31 | + Dialogs, | |
| 32 | + StdCtrls, | |
| 33 | + main, | |
| 34 | + PJVersionInfo, | |
| 35 | + NTFileSecurity, | |
| 36 | + Buttons, | |
| 37 | + ExtCtrls; | |
| 25 | 38 | |
| 26 | 39 | type |
| 27 | 40 | TConfigs = class(TForm) | ... | ... |
chkcacic/chkcacic.dpr
| ... | ... | @@ -27,18 +27,18 @@ const |
| 27 | 27 | CACIC_APP_NAME = 'chkcacic'; |
| 28 | 28 | |
| 29 | 29 | var |
| 30 | - g_oCacic : TCACIC; | |
| 30 | + oCacic : TCACIC; | |
| 31 | 31 | |
| 32 | 32 | begin |
| 33 | - g_oCacic := TCACIC.Create(); | |
| 33 | + oCacic := TCACIC.Create(); | |
| 34 | 34 | |
| 35 | - if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) | |
| 35 | + if( not oCacic.isAppRunning( CACIC_APP_NAME ) ) | |
| 36 | 36 | then begin |
| 37 | 37 | Application.Initialize; |
| 38 | 38 | Application.CreateForm(TForm1, Form1); |
| 39 | 39 | Application.Run; |
| 40 | 40 | end; |
| 41 | 41 | |
| 42 | - g_oCacic.Free(); | |
| 42 | + oCacic.Free(); | |
| 43 | 43 | |
| 44 | 44 | end. | ... | ... |
chkcacic/chkcacic.res
No preview for this file type
chkcacic/main.pas
| ... | ... | @@ -80,9 +80,9 @@ uses |
| 80 | 80 | IdFTP, |
| 81 | 81 | Tlhelp32, |
| 82 | 82 | ExtCtrls, |
| 83 | + Dialogs, | |
| 83 | 84 | CACIC_Library, |
| 84 | - WinSvc, | |
| 85 | - dialogs; | |
| 85 | + WinSvc; | |
| 86 | 86 | |
| 87 | 87 | var |
| 88 | 88 | v_ip_serv_cacic, |
| ... | ... | @@ -94,9 +94,9 @@ var |
| 94 | 94 | v_versao_remota, |
| 95 | 95 | v_strCipherClosed, |
| 96 | 96 | v_strCipherOpened, |
| 97 | - v_retorno, | |
| 98 | 97 | v_versao_REM, |
| 99 | - v_versao_LOC : String; | |
| 98 | + v_versao_LOC, | |
| 99 | + v_retorno : String; | |
| 100 | 100 | |
| 101 | 101 | var |
| 102 | 102 | v_Debugs : boolean; |
| ... | ... | @@ -392,6 +392,7 @@ var v_DatFile : TextFile; |
| 392 | 392 | v_strCipherOpened, |
| 393 | 393 | v_strCipherClosed : string; |
| 394 | 394 | begin |
| 395 | + LogDebug('Tentando acessar configurações em '+g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 395 | 396 | v_strCipherOpened := ''; |
| 396 | 397 | if FileExists(p_DatFileName) then |
| 397 | 398 | begin |
| ... | ... | @@ -415,10 +416,8 @@ begin |
| 415 | 416 | else |
| 416 | 417 | 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); |
| 417 | 418 | |
| 418 | - | |
| 419 | 419 | if Result.Count mod 2 <> 0 then |
| 420 | 420 | Result.Add(''); |
| 421 | - | |
| 422 | 421 | end; |
| 423 | 422 | |
| 424 | 423 | Procedure SetValorDatMemoria(p_Chave : string; p_Valor : String); |
| ... | ... | @@ -573,11 +572,6 @@ end; |
| 573 | 572 | function SetValorChaveRegIni(p_Secao, p_Chave, p_Valor, p_File : String): String; |
| 574 | 573 | var Reg_Ini : TIniFile; |
| 575 | 574 | begin |
| 576 | -// FileSetAttr (p_File,0); | |
| 577 | - { | |
| 578 | - To remove write protection on a file: | |
| 579 | - Den Schreibschutz einer Datei aufheben: | |
| 580 | - } | |
| 581 | 575 | if (FileGetAttr(p_File) and faReadOnly) > 0 then |
| 582 | 576 | FileSetAttr(p_File, FileGetAttr(p_File) xor faReadOnly); |
| 583 | 577 | |
| ... | ... | @@ -650,12 +644,14 @@ end; |
| 650 | 644 | |
| 651 | 645 | Procedure CriaFormConfigura; |
| 652 | 646 | begin |
| 647 | + LogDebug('Chamando Criação do Formulário de Configurações - 1'); | |
| 653 | 648 | Application.CreateForm(TConfigs, FormConfig.Configs); |
| 654 | 649 | FormConfig.Configs.lbVersao.Caption := 'v: ' + getVersionInfo(ParamStr(0)); |
| 655 | 650 | end; |
| 656 | 651 | |
| 657 | 652 | Procedure MostraFormConfigura; |
| 658 | 653 | begin |
| 654 | + LogDebug('Exibindo formulário de configurações'); | |
| 659 | 655 | FormConfig.Configs.ShowModal; |
| 660 | 656 | end; |
| 661 | 657 | |
| ... | ... | @@ -726,12 +722,12 @@ begin |
| 726 | 722 | LogDebug('FTP: Change to "'+p_PathServer+'"'); |
| 727 | 723 | IdFTP.ChangeDir(p_PathServer); |
| 728 | 724 | Try |
| 729 | - LogDebug('Iniciando FTP de "'+p_Dest + '\' + p_File+'"'); | |
| 730 | - LogDebug('HashCode de "'+p_File+'" Antes do FTP => '+g_oCacic.GetFileHash(p_File)); | |
| 731 | - IdFTP.Get(p_File, p_Dest + '\' + p_File, True, True); | |
| 732 | - LogDebug('HashCode de "'+p_Dest + '\' + p_File +'" Após o FTP => '+g_oCacic.GetFileHash(p_Dest + '\' + p_File)); | |
| 725 | + LogDebug('Iniciando FTP de "'+p_Dest + p_File+'"'); | |
| 726 | + LogDebug('HashCode de "'+p_File+'" Antes do FTP => '+g_oCacic.GetFileHash(p_Dest + p_File)); | |
| 727 | + IdFTP.Get(p_File, p_Dest + p_File, True, True); | |
| 728 | + LogDebug('HashCode de "'+p_Dest + p_File +'" Após o FTP => '+g_oCacic.GetFileHash(p_Dest + p_File)); | |
| 733 | 729 | Finally |
| 734 | - LogDebug('HashCode de "'+p_Dest + '\' + p_File +'" Após o FTP em Finally => '+g_oCacic.GetFileHash(p_Dest + '\' + p_File)); | |
| 730 | + LogDebug('HashCode de "'+p_Dest + p_File +'" Após o FTP em Finally => '+g_oCacic.GetFileHash(p_Dest + p_File)); | |
| 735 | 731 | IdFTP.Disconnect; |
| 736 | 732 | IdFTP.Free; |
| 737 | 733 | result := true; |
| ... | ... | @@ -751,7 +747,7 @@ procedure GravaConfiguracoes; |
| 751 | 747 | var chkcacic_ini : TextFile; |
| 752 | 748 | begin |
| 753 | 749 | try |
| 754 | - g_oCacic.setCacicPath(Configs.Edit_cacic_dir.text+'); | |
| 750 | + LogDebug('g_ocacic => setCacicpath => '+Configs.Edit_cacic_dir.text+'); | |
| 755 | 751 | |
| 756 | 752 | FileSetAttr (ExtractFilePath(Application.Exename) + '\chkcacic.ini',0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED em máquinas 2000 |
| 757 | 753 | AssignFile(chkcacic_ini,ExtractFilePath(Application.Exename) + '\chkcacic.ini'); {Associa o arquivo a uma variável do tipo TextFile} |
| ... | ... | @@ -845,13 +841,15 @@ begin |
| 845 | 841 | |
| 846 | 842 | // Escrita dos parâmetros obrigatórios |
| 847 | 843 | Writeln(chkcacic_ini,'ip_serv_cacic='+v_ip_serv_cacic); |
| 848 | - Writeln(chkcacic_ini,'cacic_dir='+Configs.Edit_cacic_dir.text); | |
| 844 | + Writeln(chkcacic_ini,'cacic_dir='+g_oCacic.getHomeDrive + Configs.Edit_cacic_dir.text+'\'); | |
| 849 | 845 | Writeln(chkcacic_ini,'exibe_informacoes='+v_exibe_informacoes); |
| 850 | 846 | |
| 851 | 847 | // Escrita dos valores opcionais quando existirem |
| 852 | 848 | if (v_te_instala_informacoes_extras <>'') then |
| 853 | 849 | Writeln(chkcacic_ini,'te_instala_informacoes_extras='+ StringReplace(v_te_instala_informacoes_extras,#13#10,'*13*10',[rfReplaceAll])); |
| 854 | 850 | CloseFile(chkcacic_ini); {Fecha o arquivo texto} |
| 851 | + | |
| 852 | + g_oCacic.setCacicPath(g_oCacic.getHomeDrive + Configs.Edit_cacic_dir.text+'\'); | |
| 855 | 853 | except |
| 856 | 854 | end; |
| 857 | 855 | end; |
| ... | ... | @@ -962,7 +960,9 @@ var SearchRec: TSearchRec; |
| 962 | 960 | Result: Integer; |
| 963 | 961 | strFileName : String; |
| 964 | 962 | begin |
| 963 | + | |
| 965 | 964 | strFileName := StringReplace(v_dir + '\' + v_files,'\\','\',[rfReplaceAll]); |
| 965 | + LogDebug('Matando: '+strFileName); | |
| 966 | 966 | Result:=FindFirst(strFileName, faAnyFile, SearchRec); |
| 967 | 967 | |
| 968 | 968 | while result=0 do |
| ... | ... | @@ -1022,52 +1022,56 @@ end; |
| 1022 | 1022 | |
| 1023 | 1023 | procedure verifyAndGet(p_strModuleName, |
| 1024 | 1024 | p_strFileHash, |
| 1025 | - p_strDestinationFolderName, | |
| 1026 | - p_strServUpdates, | |
| 1027 | - p_strPortaServUpdates, | |
| 1028 | - p_strNomeUsuarioLoginServUpdates, | |
| 1029 | - p_strSenhaLoginServUpdates, | |
| 1030 | - p_strPathServUpdates, | |
| 1031 | - p_strExibeInformacoes : String); | |
| 1032 | - var v_strFileHash : String; | |
| 1033 | - Begin | |
| 1025 | + p_strDestinationFolderName : String); | |
| 1026 | +var v_strFileHash, | |
| 1027 | + v_strDestinationFolderName : String; | |
| 1028 | +Begin | |
| 1029 | + v_strDestinationFolderName := p_strDestinationFolderName + '\'; | |
| 1030 | + v_strDestinationFolderName := StringReplace(v_strDestinationFolderName,'\\','\',[rfReplaceAll]); | |
| 1034 | 1031 | |
| 1032 | + LogDebug('Verificando módulo: '+v_strDestinationFolderName +p_strModuleName); | |
| 1035 | 1033 | // Verifico validade do Módulo e mato-o em caso negativo. |
| 1036 | - v_strFileHash := g_oCacic.GetFileHash(p_strDestinationFolderName + '\'+p_strModuleName); | |
| 1034 | + v_strFileHash := g_oCacic.GetFileHash(v_strDestinationFolderName + p_strModuleName); | |
| 1037 | 1035 | |
| 1038 | - LogDebug('verifyAndGet - strFileHash de "'+p_strDestinationFolderName + '\'+p_strModuleName+'": ' + v_strFileHash); | |
| 1036 | + LogDebug('verifyAndGet - HashCode Remot: "'+p_strFileHash+'"'); | |
| 1037 | + LogDebug('verifyAndGet - HashCode Local: "'+v_strFileHash+'"'); | |
| 1039 | 1038 | |
| 1040 | 1039 | If (v_strFileHash <> p_strFileHash) then |
| 1041 | - Matar(p_strDestinationFolderName, p_strModuleName); | |
| 1040 | + Matar(v_strDestinationFolderName, p_strModuleName); | |
| 1042 | 1041 | |
| 1043 | - If not FileExists(p_strDestinationFolderName + '\'+p_strModuleName) Then | |
| 1042 | + If not FileExists(v_strDestinationFolderName + p_strModuleName) Then | |
| 1044 | 1043 | Begin |
| 1045 | 1044 | if (FileExists(ExtractFilePath(Application.Exename) + '\modulos\'+p_strModuleName)) then |
| 1046 | 1045 | Begin |
| 1047 | - LogDiario('Copiando '+p_strModuleName+' de '+ExtractFilePath(Application.Exename)+'modulos\'); | |
| 1048 | - CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\'+p_strModuleName), PChar(p_strDestinationFolderName + '\'+p_strModuleName),false); | |
| 1049 | - FileSetAttr (PChar(p_strDestinationFolderName + '\' + p_strModuleName),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED | |
| 1046 | + LogDebug('Copiando '+p_strModuleName+' de '+ExtractFilePath(Application.Exename)+'modulos\'); | |
| 1047 | + CopyFile(PChar(ExtractFilePath(Application.Exename) + 'modulos\'+p_strModuleName), PChar(v_strDestinationFolderName + p_strModuleName),false); | |
| 1048 | + FileSetAttr (PChar(v_strDestinationFolderName + p_strModuleName),0); // Retira os atributos do arquivo para evitar o erro FILE ACCESS DENIED | |
| 1050 | 1049 | End |
| 1051 | 1050 | else |
| 1052 | 1051 | begin |
| 1052 | + | |
| 1053 | 1053 | Try |
| 1054 | - if not FTP(p_strServUpdates, | |
| 1055 | - p_strPortaServUpdates, | |
| 1056 | - p_strNomeUsuarioLoginServUpdates, | |
| 1057 | - p_strSenhaLoginServUpdates, | |
| 1058 | - p_strPathServUpdates, | |
| 1054 | + if not FTP(XML_RetornaValor('te_serv_updates' , v_retorno), | |
| 1055 | + XML_RetornaValor('nu_porta_serv_updates' , v_retorno), | |
| 1056 | + XML_RetornaValor('nm_usuario_login_serv_updates', v_retorno), | |
| 1057 | + XML_RetornaValor('te_senha_login_serv_updates' , v_retorno), | |
| 1058 | + XML_RetornaValor('te_path_serv_updates' , v_retorno), | |
| 1059 | 1059 | p_strModuleName, |
| 1060 | - p_strDestinationFolderName) then | |
| 1061 | - Configs.Memo_te_instala_informacoes_extras.Lines.add(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+p_strDestinationFolderName + '\'+p_strModuleName+'".'+#13#10+'Verifique o Servidor de Updates.'); | |
| 1060 | + v_strDestinationFolderName) then | |
| 1061 | + Configs.Memo_te_instala_informacoes_extras.Lines.add(#13#10+'ATENÇÃO! Não foi possível efetuar FTP para "'+v_strDestinationFolderName + p_strModuleName+'".'+#13#10+'Verifique o Servidor de Updates.'); | |
| 1062 | 1062 | Except |
| 1063 | - LogDebug('FTP de "'+ p_strDestinationFolderName + '\' + p_strModuleName+'" Interrompido.'); | |
| 1063 | + LogDebug('FTP de "'+ v_strDestinationFolderName + p_strModuleName+'" Interrompido.'); | |
| 1064 | 1064 | End; |
| 1065 | 1065 | |
| 1066 | - if not FileExists(p_strDestinationFolderName + '\' + p_strModuleName) Then | |
| 1066 | + if not FileExists(v_strDestinationFolderName + p_strModuleName) Then | |
| 1067 | 1067 | Begin |
| 1068 | - LogDebug('Problemas Efetuando Download de '+ p_strDestinationFolderName + '\' + p_strModuleName+' (FTP)'); | |
| 1068 | + LogDebug('Problemas Efetuando Download de '+ v_strDestinationFolderName + p_strModuleName+' (FTP)'); | |
| 1069 | 1069 | LogDebug('Conexão:'); |
| 1070 | - LogDebug(p_strServUpdates+', '+p_strPortaServUpdates+', '+p_strNomeUsuarioLoginServUpdates+', '+p_strSenhaLoginServUpdates+', '+p_strPathServUpdates); | |
| 1070 | + LogDebug(XML_RetornaValor('te_serv_updates',v_retorno) +', '+ | |
| 1071 | + XML_RetornaValor('nu_porta_serv_updates' , v_retorno)+', '+ | |
| 1072 | + XML_RetornaValor('nm_usuario_login_serv_updates', v_retorno)+', '+ | |
| 1073 | + XML_RetornaValor('te_senha_login_serv_updates' , v_retorno)+', '+ | |
| 1074 | + XML_RetornaValor('te_path_serv_updates' , v_retorno)); | |
| 1071 | 1075 | End |
| 1072 | 1076 | else |
| 1073 | 1077 | LogDiario('Download Concluído de "'+p_strModuleName+'" (FTP)'); |
| ... | ... | @@ -1114,6 +1118,8 @@ begin |
| 1114 | 1118 | bool_CommandLine := false; |
| 1115 | 1119 | bool_ArquivoINI := FileExists(ExtractFilePath(Application.Exename) + '\chkcacic.ini'); |
| 1116 | 1120 | |
| 1121 | + g_oCacic := TCACIC.Create(); | |
| 1122 | + g_oCacic.setBoolCipher(true); | |
| 1117 | 1123 | Try |
| 1118 | 1124 | |
| 1119 | 1125 | // 2.2.0.17 - Tratamento de opções passadas em linha de comando |
| ... | ... | @@ -1155,7 +1161,6 @@ begin |
| 1155 | 1161 | Begin |
| 1156 | 1162 | If not bool_ArquivoINI then |
| 1157 | 1163 | Begin |
| 1158 | - LogDiario('Abrindo formulário de configurações'); | |
| 1159 | 1164 | CriaFormConfigura; |
| 1160 | 1165 | MostraFormConfigura; |
| 1161 | 1166 | End; |
| ... | ... | @@ -1165,8 +1170,7 @@ begin |
| 1165 | 1170 | v_te_instala_informacoes_extras := StringReplace(GetValorChaveRegIni('Cacic2', 'te_instala_informacoes_extras', ExtractFilePath(Application.Exename) + '\chkcacic.ini'),'*13*10',#13#10,[rfReplaceAll]); |
| 1166 | 1171 | End; |
| 1167 | 1172 | |
| 1168 | - g_oCacic := TCACIC.Create(); | |
| 1169 | - g_oCacic.setCacicPath(g_oCacic.getHomeDrive + v_cacic_dir + '\'); | |
| 1173 | + g_oCacic.setCacicPath(v_cacic_dir); | |
| 1170 | 1174 | |
| 1171 | 1175 | if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then |
| 1172 | 1176 | Begin |
| ... | ... | @@ -1202,7 +1206,7 @@ begin |
| 1202 | 1206 | Configs.ckboxExibeInformacoes.Checked := true; |
| 1203 | 1207 | Configs.ckboxExibeInformacoes.Visible := false; |
| 1204 | 1208 | |
| 1205 | - Configs.Height := 357; | |
| 1209 | + Configs.Height := 350; | |
| 1206 | 1210 | Configs.lbMensagemNaoAplicavel.Visible := false; |
| 1207 | 1211 | |
| 1208 | 1212 | Configs.Memo_te_instala_informacoes_extras.Clear; |
| ... | ... | @@ -1232,7 +1236,7 @@ begin |
| 1232 | 1236 | bool_configura := false; |
| 1233 | 1237 | |
| 1234 | 1238 | //chave AES. Recomenda-se que cada empresa/órgão altere a sua chave. |
| 1235 | - v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + '\' + g_oCacic.getDatFileName); | |
| 1239 | + v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 1236 | 1240 | |
| 1237 | 1241 | if (g_oCacic.isWindowsGEXP()) then // Se >= Maior ou Igual ao WinXP... |
| 1238 | 1242 | Begin |
| ... | ... | @@ -1282,7 +1286,6 @@ begin |
| 1282 | 1286 | |
| 1283 | 1287 | while (v_ip_serv_cacic = '') or (v_cacic_dir = '') or bool_configura do |
| 1284 | 1288 | Begin |
| 1285 | - LogDiario('Abrindo formulário de configurações'); | |
| 1286 | 1289 | bool_configura := false; |
| 1287 | 1290 | CriaFormConfigura; |
| 1288 | 1291 | |
| ... | ... | @@ -1304,6 +1307,7 @@ begin |
| 1304 | 1307 | Application.Terminate; |
| 1305 | 1308 | end; |
| 1306 | 1309 | |
| 1310 | + LogDebug('Verificando pasta "'+g_oCacic.getCacicPath+'"'); | |
| 1307 | 1311 | // Verifico a existência do diretório configurado para o Cacic, normalmente CACIC |
| 1308 | 1312 | if not DirectoryExists(g_oCacic.getCacicPath) then |
| 1309 | 1313 | begin |
| ... | ... | @@ -1311,6 +1315,7 @@ begin |
| 1311 | 1315 | ForceDirectories(g_oCacic.getCacicPath); |
| 1312 | 1316 | end; |
| 1313 | 1317 | |
| 1318 | + LogDebug('Verificando pasta "'+g_oCacic.getCacicPath+'modulos'+'"'); | |
| 1314 | 1319 | // Para eliminar versão 20014 e anteriores que provavelmente não fazem corretamente o AutoUpdate |
| 1315 | 1320 | if not DirectoryExists(g_oCacic.getCacicPath+'modulos') then |
| 1316 | 1321 | begin |
| ... | ... | @@ -1319,11 +1324,12 @@ begin |
| 1319 | 1324 | LogDiario('Criando pasta '+g_oCacic.getCacicPath+'modulos'); |
| 1320 | 1325 | end; |
| 1321 | 1326 | |
| 1327 | + LogDebug('Verificando pasta "'+g_oCacic.getCacicPath+'Temp'+'"'); | |
| 1322 | 1328 | // Crio o SubDiretório TEMP, caso não exista |
| 1323 | - if not DirectoryExists(g_oCacic.getCacicPath+'temp') then | |
| 1329 | + if not DirectoryExists(g_oCacic.getCacicPath+'Temp') then | |
| 1324 | 1330 | begin |
| 1325 | - ForceDirectories(g_oCacic.getCacicPath + 'temp'); | |
| 1326 | - LogDiario('Criando pasta '+g_oCacic.getCacicPath+'temp'); | |
| 1331 | + ForceDirectories(g_oCacic.getCacicPath + 'Temp'); | |
| 1332 | + LogDiario('Criando pasta '+g_oCacic.getCacicPath+'Temp'); | |
| 1327 | 1333 | end; |
| 1328 | 1334 | |
| 1329 | 1335 | |
| ... | ... | @@ -1361,19 +1367,15 @@ begin |
| 1361 | 1367 | idHTTP1.Free; |
| 1362 | 1368 | |
| 1363 | 1369 | v_retorno := Response_Config.DataString; |
| 1364 | - v_te_serv_updates := XML_RetornaValor('te_serv_updates' , v_retorno); | |
| 1365 | - v_nu_porta_serv_updates := XML_RetornaValor('nu_porta_serv_updates' , v_retorno); | |
| 1366 | - v_nm_usuario_login_serv_updates := XML_RetornaValor('nm_usuario_login_serv_updates', v_retorno); | |
| 1367 | - v_te_senha_login_serv_updates := XML_RetornaValor('te_senha_login_serv_updates' , v_retorno); | |
| 1368 | - v_te_path_serv_updates := XML_RetornaValor('te_path_serv_updates' , v_retorno); | |
| 1370 | + LogDebug('Retorno de comunicação com servidor: '+v_retorno); | |
| 1369 | 1371 | |
| 1370 | 1372 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); |
| 1371 | 1373 | LogDebug(':::::::::::::::: VALORES OBTIDOS NO Gerente WEB :::::::::::::::'); |
| 1372 | 1374 | LogDebug(':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'); |
| 1373 | - LogDebug('Servidor de updates......................: '+v_te_serv_updates); | |
| 1374 | - LogDebug('Porta do servidor de updates.............: '+v_nu_porta_serv_updates); | |
| 1375 | - LogDebug('Usuário para login no servidor de updates: '+v_nm_usuario_login_serv_updates); | |
| 1376 | - LogDebug('Pasta no servidor de updates.............: '+v_te_path_serv_updates); | |
| 1375 | + LogDebug('Servidor de updates......................: '+XML_RetornaValor('te_serv_updates' , v_retorno)); | |
| 1376 | + LogDebug('Porta do servidor de updates.............: '+XML_RetornaValor('nu_porta_serv_updates' , v_retorno)); | |
| 1377 | + LogDebug('Usuário para login no servidor de updates: '+XML_RetornaValor('nm_usuario_login_serv_updates', v_retorno)); | |
| 1378 | + LogDebug('Pasta no servidor de updates.............: '+XML_RetornaValor('te_path_serv_updates' , v_retorno)); | |
| 1377 | 1379 | LogDebug(' '); |
| 1378 | 1380 | LogDebug('Versões dos Agentes Principais:'); |
| 1379 | 1381 | LogDebug('------------------------------'); |
| ... | ... | @@ -1403,7 +1405,7 @@ begin |
| 1403 | 1405 | // Atribuição de acesso ao módulo principal e pastas |
| 1404 | 1406 | Form1.FS_SetSecurity(g_oCacic.getCacicPath); |
| 1405 | 1407 | Form1.FS_SetSecurity(g_oCacic.getCacicPath + 'cacic2.exe'); |
| 1406 | - Form1.FS_SetSecurity(g_oCacic.getCacicPath + 'cacic2.dat'); | |
| 1408 | + Form1.FS_SetSecurity(g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 1407 | 1409 | Form1.FS_SetSecurity(g_oCacic.getCacicPath + 'cacic2.log'); |
| 1408 | 1410 | Form1.FS_SetSecurity(g_oCacic.getCacicPath + 'modulos'); |
| 1409 | 1411 | Form1.FS_SetSecurity(g_oCacic.getCacicPath + 'temp'); |
| ... | ... | @@ -1494,14 +1496,8 @@ begin |
| 1494 | 1496 | |
| 1495 | 1497 | // Tento detectar o ChkSis.EXE e copio ou faço FTP caso não exista |
| 1496 | 1498 | verifyAndGet('chksis.exe', |
| 1497 | - XML_RetornaValor('CHKSIS_HASH', v_retorno), | |
| 1498 | - g_oCacic.getWinDir, | |
| 1499 | - v_te_serv_updates, | |
| 1500 | - v_nu_porta_serv_updates, | |
| 1501 | - v_nm_usuario_login_serv_updates, | |
| 1502 | - v_te_senha_login_serv_updates, | |
| 1503 | - v_te_path_serv_updates, | |
| 1504 | - v_exibe_informacoes); | |
| 1499 | + XML_RetornaValor('TE_HASH_CHKSIS', v_retorno), | |
| 1500 | + g_oCacic.getWinDir); | |
| 1505 | 1501 | |
| 1506 | 1502 | // Tento detectar o ChkSis.INI e crio-o caso necessário |
| 1507 | 1503 | If not FileExists(g_oCacic.getWinDir + 'chksis.ini') Then |
| ... | ... | @@ -1517,14 +1513,8 @@ begin |
| 1517 | 1513 | Begin |
| 1518 | 1514 | // Tento detectar o CACICsvc.EXE e copio ou faço FTP caso não exista |
| 1519 | 1515 | verifyAndGet('cacicsvc.exe', |
| 1520 | - XML_RetornaValor('CACICSVC_HASH', v_retorno), | |
| 1521 | - g_oCacic.getWinDir, | |
| 1522 | - v_te_serv_updates, | |
| 1523 | - v_nu_porta_serv_updates, | |
| 1524 | - v_nm_usuario_login_serv_updates, | |
| 1525 | - v_te_senha_login_serv_updates, | |
| 1526 | - v_te_path_serv_updates, | |
| 1527 | - v_exibe_informacoes); | |
| 1516 | + XML_RetornaValor('TE_HASH_CACICSVC', v_retorno), | |
| 1517 | + g_oCacic.getWinDir); | |
| 1528 | 1518 | |
| 1529 | 1519 | // O CACICsvc usará o arquivo de configurações \Windows\chksis.ini |
| 1530 | 1520 | End; |
| ... | ... | @@ -1542,24 +1532,12 @@ begin |
| 1542 | 1532 | |
| 1543 | 1533 | // Tento detectar o Agente Principal e copio ou faço FTP caso não exista |
| 1544 | 1534 | verifyAndGet('cacic2.exe', |
| 1545 | - XML_RetornaValor('CACIC2_HASH', v_retorno), | |
| 1546 | - g_oCacic.getCacicPath, | |
| 1547 | - v_te_serv_updates, | |
| 1548 | - v_nu_porta_serv_updates, | |
| 1549 | - v_nm_usuario_login_serv_updates, | |
| 1550 | - v_te_senha_login_serv_updates, | |
| 1551 | - v_te_path_serv_updates, | |
| 1552 | - v_exibe_informacoes); | |
| 1535 | + XML_RetornaValor('TE_HASH_CACIC2', v_retorno), | |
| 1536 | + g_oCacic.getCacicPath); | |
| 1553 | 1537 | |
| 1554 | 1538 | verifyAndGet('ger_cols.exe', |
| 1555 | - XML_RetornaValor('GER_COLS_HASH', v_retorno), | |
| 1556 | - g_oCacic.getCacicPath + 'modulos', | |
| 1557 | - v_te_serv_updates, | |
| 1558 | - v_nu_porta_serv_updates, | |
| 1559 | - v_nm_usuario_login_serv_updates, | |
| 1560 | - v_te_senha_login_serv_updates, | |
| 1561 | - v_te_path_serv_updates, | |
| 1562 | - v_exibe_informacoes); | |
| 1539 | + XML_RetornaValor('TE_HASH_GER_COLS', v_retorno), | |
| 1540 | + g_oCacic.getCacicPath + 'modulos'); | |
| 1563 | 1541 | |
| 1564 | 1542 | // Caso exista a pasta "modulos", copio todos os executáveis para a pasta Cacic\modulos, exceto cacic2.exe, ger_cols.exe e chksis.exe |
| 1565 | 1543 | if (v_modulos <> '') then |
| ... | ... | @@ -1584,35 +1562,17 @@ begin |
| 1584 | 1562 | |
| 1585 | 1563 | // Tento detectar (de novo) o ChkSis.EXE e copio ou faço FTP caso não exista |
| 1586 | 1564 | verifyAndGet('chksis.exe', |
| 1587 | - XML_RetornaValor('CHKSIS_HASH', v_retorno), | |
| 1588 | - g_oCacic.getWinDir, | |
| 1589 | - v_te_serv_updates, | |
| 1590 | - v_nu_porta_serv_updates, | |
| 1591 | - v_nm_usuario_login_serv_updates, | |
| 1592 | - v_te_senha_login_serv_updates, | |
| 1593 | - v_te_path_serv_updates, | |
| 1594 | - v_exibe_informacoes); | |
| 1565 | + XML_RetornaValor('TE_HASH_CHKSIS', v_retorno), | |
| 1566 | + g_oCacic.getWinDir); | |
| 1595 | 1567 | |
| 1596 | 1568 | // Tento detectar (de novo) o Agente Principal e copio ou faço FTP caso não exista |
| 1597 | 1569 | verifyAndGet('cacic2.exe', |
| 1598 | - XML_RetornaValor('CACIC2_HASH', v_retorno), | |
| 1599 | - g_oCacic.getCacicPath, | |
| 1600 | - v_te_serv_updates, | |
| 1601 | - v_nu_porta_serv_updates, | |
| 1602 | - v_nm_usuario_login_serv_updates, | |
| 1603 | - v_te_senha_login_serv_updates, | |
| 1604 | - v_te_path_serv_updates, | |
| 1605 | - v_exibe_informacoes); | |
| 1570 | + XML_RetornaValor('TE_HASH_CACIC2', v_retorno), | |
| 1571 | + g_oCacic.getCacicPath); | |
| 1606 | 1572 | |
| 1607 | 1573 | verifyAndGet('ger_cols.exe', |
| 1608 | - XML_RetornaValor('GER_COLS_HASH', v_retorno), | |
| 1609 | - g_oCacic.getCacicPath + 'modulos', | |
| 1610 | - v_te_serv_updates, | |
| 1611 | - v_nu_porta_serv_updates, | |
| 1612 | - v_nm_usuario_login_serv_updates, | |
| 1613 | - v_te_senha_login_serv_updates, | |
| 1614 | - v_te_path_serv_updates, | |
| 1615 | - v_exibe_informacoes); | |
| 1574 | + XML_RetornaValor('TE_HASH_GER_COLS', v_retorno), | |
| 1575 | + g_oCacic.getCacicPath + 'modulos'); | |
| 1616 | 1576 | |
| 1617 | 1577 | if (g_oCacic.isWindowsNTPlataform) then |
| 1618 | 1578 | Begin |
| ... | ... | @@ -1659,7 +1619,7 @@ begin |
| 1659 | 1619 | // Igualo as chaves ip_serv_cacic dos arquivos chksis.ini e cacic2.ini! |
| 1660 | 1620 | SetValorDatMemoria('Configs.EnderecoServidor', v_ip_serv_cacic); |
| 1661 | 1621 | LogDebug('Fechando Arquivo de Configurações do Cacic'); |
| 1662 | - CipherClose(g_oCacic.getDatFileName); | |
| 1622 | + CipherClose(g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 1663 | 1623 | |
| 1664 | 1624 | LogDebug('Abrindo Arquivo de Configurações do ChkSis'); |
| 1665 | 1625 | CipherOpen(g_oCacic.getWinDir + 'chksis.dat'); |
| ... | ... | @@ -1709,9 +1669,9 @@ begin |
| 1709 | 1669 | Begin |
| 1710 | 1670 | LogDebug('Executando '+g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic); |
| 1711 | 1671 | if (strDataHoraCACIC2_INI <> strDataHoraCACIC2_FIM) then |
| 1712 | - WinExec(PChar(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE) | |
| 1672 | + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute', false) | |
| 1713 | 1673 | else |
| 1714 | - WinExec(PChar(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE); | |
| 1674 | + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic , false); | |
| 1715 | 1675 | End |
| 1716 | 1676 | else |
| 1717 | 1677 | Begin |
| ... | ... | @@ -1729,14 +1689,14 @@ begin |
| 1729 | 1689 | if (wordServiceStatus = 0) then |
| 1730 | 1690 | Begin |
| 1731 | 1691 | // Instalo e Habilito o serviço |
| 1732 | - LogDiario('Instalando CACICservice...'); | |
| 1733 | - WinExec(PChar(g_oCacic.getWinDir + 'cacicsvc.exe -install'), SW_NORMAL); | |
| 1692 | + LogDiario('Instalando/Iniciando CACICservice...'); | |
| 1693 | + g_oCacic.createSampleProcess(g_oCacic.getWinDir + 'cacicsvc.exe -install',false); | |
| 1734 | 1694 | End |
| 1735 | 1695 | else if ((wordServiceStatus < 4) or |
| 1736 | 1696 | (wordServiceStatus > 4)) then |
| 1737 | 1697 | Begin |
| 1738 | 1698 | LogDiario('Iniciando CACICservice'); |
| 1739 | - WinExec(PChar(g_oCacic.getWinDir + 'cacicsvc.exe -start'), SW_NORMAL); | |
| 1699 | + g_oCacic.createSampleProcess(g_oCacic.getWinDir + 'cacicsvc.exe -start', false); | |
| 1740 | 1700 | End |
| 1741 | 1701 | else |
| 1742 | 1702 | LogDiario('Não instalei o CACICservice. Já está rodando...'); |
| ... | ... | @@ -1757,9 +1717,10 @@ begin |
| 1757 | 1717 | End; |
| 1758 | 1718 | |
| 1759 | 1719 | try |
| 1760 | - g_oCacic.Free(); | |
| 1720 | + g_oCacic.Free; | |
| 1761 | 1721 | except |
| 1762 | 1722 | end; |
| 1723 | + | |
| 1763 | 1724 | Application.Terminate; |
| 1764 | 1725 | end; |
| 1765 | 1726 | ... | ... |
chksis/chksis.dpr
| ... | ... | @@ -640,7 +640,7 @@ begin |
| 640 | 640 | v_cacic_dir := GetValorChaveRegIni('Cacic2', 'cacic_dir' , ExtractFilePath(ParamStr(0)) + 'chksis.ini'); |
| 641 | 641 | v_rem_cacic_v0x := GetValorChaveRegIni('Cacic2', 'rem_cacic_v0x', ExtractFilePath(ParamStr(0)) + 'chksis.ini'); |
| 642 | 642 | |
| 643 | - g_oCacic.setCacicPath(g_oCacic.getHomeDrive + v_cacic_dir +'\'); | |
| 643 | + g_oCacic.setCacicPath(v_cacic_dir); | |
| 644 | 644 | |
| 645 | 645 | v_Debugs := false; |
| 646 | 646 | if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then |
| ... | ... | @@ -804,28 +804,7 @@ begin |
| 804 | 804 | |
| 805 | 805 | // 5 segundos para espera de possível FTP... |
| 806 | 806 | Sleep(5000); |
| 807 | - { | |
| 808 | - Try | |
| 809 | - // Crio a chave/valor chksis para autoexecução do Cacic, caso não exista esta chave/valor | |
| 810 | - log_diario('Setando chave HLM../Run com ' + HomeDrive + '\chksis.exe'); | |
| 811 | - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\CheckSystemRoutine', HomeDrive + '\chksis.exe'); | |
| 812 | - Except | |
| 813 | - End; | |
| 814 | 807 | |
| 815 | - | |
| 816 | - bool_ExistsAutoRun := false; | |
| 817 | - if (GetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2')=Dir + '\cacic2.exe') then | |
| 818 | - bool_ExistsAutoRun := true | |
| 819 | - else | |
| 820 | - Begin | |
| 821 | - Try | |
| 822 | - // Crio a chave/valor cacic2 para autoexecução do Cacic, caso não exista esta chave/valor | |
| 823 | - log_diario('Setando chave HLM../Run com ' + Dir + '\cacic2.exe'); | |
| 824 | - SetValorChaveRegEdit('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\cacic2', Dir + '\cacic2.exe'); | |
| 825 | - Except | |
| 826 | - End; | |
| 827 | - End; | |
| 828 | - } | |
| 829 | 808 | // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor |
| 830 | 809 | if Posso_Rodar_CACIC or not bool_ExistsAutoRun then |
| 831 | 810 | Begin |
| ... | ... | @@ -833,9 +812,9 @@ begin |
| 833 | 812 | |
| 834 | 813 | // Caso tenha havido download de agentes principais, executar coletas imediatamente... |
| 835 | 814 | if (bool_download_CACIC2) then |
| 836 | - WinExec(PChar(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute'), SW_HIDE) | |
| 815 | + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic+ ' /execute', false) | |
| 837 | 816 | else |
| 838 | - WinExec(PChar(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic ), SW_HIDE); | |
| 817 | + g_oCacic.createSampleProcess(g_oCacic.getCacicPath + 'cacic2.exe /ip_serv_cacic=' + v_ip_serv_cacic , false); | |
| 839 | 818 | End; |
| 840 | 819 | end; |
| 841 | 820 | |
| ... | ... | @@ -845,6 +824,8 @@ const |
| 845 | 824 | begin |
| 846 | 825 | g_oCacic := TCACIC.Create(); |
| 847 | 826 | |
| 827 | + g_oCacic.setBoolCipher(true); | |
| 828 | + | |
| 848 | 829 | if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) |
| 849 | 830 | then begin |
| 850 | 831 | if (FindWindowByTitle('chkcacic') = 0) and (FindWindowByTitle('cacic2') = 0) | ... | ... |
chksis/chksis.res
No preview for this file type
col_anvi/col_anvi.dpr
| ... | ... | @@ -28,12 +28,15 @@ uses |
| 28 | 28 | PJVersionInfo, |
| 29 | 29 | CACIC_Library in '..\CACIC_Library.pas'; |
| 30 | 30 | |
| 31 | -var v_strCipherClosed : String; | |
| 31 | +var | |
| 32 | + v_strCipherClosed : String; | |
| 32 | 33 | |
| 33 | -var v_Debugs : boolean; | |
| 34 | +var | |
| 35 | + v_Debugs : boolean; | |
| 34 | 36 | |
| 35 | -var v_tstrCipherOpened, | |
| 36 | - v_tstrCipherOpened1 : TStrings; | |
| 37 | +var | |
| 38 | + v_tstrCipherOpened, | |
| 39 | + v_tstrCipherOpened1 : TStrings; | |
| 37 | 40 | |
| 38 | 41 | var |
| 39 | 42 | g_oCacic : TCACIC; |
| ... | ... | @@ -391,48 +394,57 @@ end; |
| 391 | 394 | |
| 392 | 395 | var tstrTripa1 : TStrings; |
| 393 | 396 | intAux : integer; |
| 394 | - v_path_cacic : String; | |
| 397 | + strAux : String; | |
| 395 | 398 | const |
| 396 | 399 | CACIC_APP_NAME = 'col_anvi'; |
| 397 | 400 | |
| 398 | 401 | begin |
| 399 | 402 | g_oCacic := TCACIC.Create(); |
| 400 | 403 | |
| 404 | + g_oCacic.setBoolCipher(true); | |
| 405 | + | |
| 401 | 406 | if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then |
| 402 | 407 | if (ParamCount>0) then |
| 403 | - Begin | |
| 404 | - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini | |
| 405 | - tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\'); | |
| 406 | - v_path_cacic := ''; | |
| 407 | - For intAux := 0 to tstrTripa1.Count -2 do | |
| 408 | - v_path_cacic := v_path_cacic + tstrTripa1[intAux] + '\'; | |
| 409 | - | |
| 410 | - g_oCacic.setCacicPath(v_path_cacic); | |
| 411 | - | |
| 412 | - v_Debugs := false; | |
| 413 | - if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then | |
| 414 | - Begin | |
| 415 | - if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
| 408 | + Begin | |
| 409 | + strAux := ''; | |
| 410 | + For intAux := 1 to ParamCount do | |
| 411 | + Begin | |
| 412 | + if LowerCase(Copy(ParamStr(intAux),1,11)) = '/cacicpath=' then | |
| 413 | + begin | |
| 414 | + strAux := Trim(Copy(ParamStr(intAux),12,Length((ParamStr(intAux))))); | |
| 415 | + log_DEBUG('Parâmetro /CacicPath recebido com valor="'+strAux+'"'); | |
| 416 | + end; | |
| 417 | + end; | |
| 418 | + | |
| 419 | + if (strAux <> '') then | |
| 416 | 420 | Begin |
| 417 | - v_Debugs := true; | |
| 418 | - log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
| 421 | + g_oCacic.setCacicPath(strAux); | |
| 422 | + | |
| 423 | + v_Debugs := false; | |
| 424 | + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then | |
| 425 | + Begin | |
| 426 | + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
| 427 | + Begin | |
| 428 | + v_Debugs := true; | |
| 429 | + log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
| 430 | + End; | |
| 419 | 431 | End; |
| 420 | - End; | |
| 421 | - | |
| 422 | - v_tstrCipherOpened := TStrings.Create; | |
| 423 | - v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName); | |
| 424 | 432 | |
| 425 | - v_tstrCipherOpened1 := TStrings.Create; | |
| 426 | - v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_anvi.dat'); | |
| 433 | + v_tstrCipherOpened := TStrings.Create; | |
| 434 | + v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 427 | 435 | |
| 428 | - Try | |
| 429 | - Executa_Col_Anvi; | |
| 430 | - Except | |
| 431 | - Begin | |
| 432 | - SetValorDatMemoria('Col_Anvi.nada', 'nada', v_tstrCipherOpened1); | |
| 433 | - CipherClose(g_oCacic.getCacicPath + 'temp\col_anvi.dat', v_tstrCipherOpened1); | |
| 434 | - End; | |
| 435 | - End; | |
| 436 | + v_tstrCipherOpened1 := TStrings.Create; | |
| 437 | + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_anvi.dat'); | |
| 438 | + | |
| 439 | + Try | |
| 440 | + Executa_Col_Anvi; | |
| 441 | + Except | |
| 442 | + Begin | |
| 443 | + SetValorDatMemoria('Col_Anvi.nada', 'nada', v_tstrCipherOpened1); | |
| 444 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_anvi.dat', v_tstrCipherOpened1); | |
| 445 | + End; | |
| 446 | + End; | |
| 447 | + End; | |
| 436 | 448 | End; |
| 437 | 449 | g_oCacic.Free(); |
| 438 | 450 | end. | ... | ... |
col_anvi/col_anvi.res
No preview for this file type
col_comp/col_comp.dpr
| ... | ... | @@ -25,12 +25,15 @@ uses |
| 25 | 25 | Registry, |
| 26 | 26 | CACIC_Library in '..\CACIC_Library.pas'; |
| 27 | 27 | |
| 28 | -var v_strCipherClosed : String; | |
| 28 | +var | |
| 29 | + v_strCipherClosed : String; | |
| 29 | 30 | |
| 30 | -var v_tstrCipherOpened, | |
| 31 | - v_tstrCipherOpened1 : TStrings; | |
| 31 | +var | |
| 32 | + v_tstrCipherOpened, | |
| 33 | + v_tstrCipherOpened1 : TStrings; | |
| 32 | 34 | |
| 33 | -var g_oCacic : TCACIC; | |
| 35 | +var | |
| 36 | + g_oCacic : TCACIC; | |
| 34 | 37 | |
| 35 | 38 | procedure log_diario(strMsg : String); |
| 36 | 39 | var |
| ... | ... | @@ -140,7 +143,6 @@ begin |
| 140 | 143 | Result := ''; |
| 141 | 144 | end; |
| 142 | 145 | |
| 143 | - | |
| 144 | 146 | function GetRootKey(strRootKey: String): HKEY; |
| 145 | 147 | begin |
| 146 | 148 | /// Encontrar uma maneira mais elegante de fazer esses testes. |
| ... | ... | @@ -343,37 +345,46 @@ end; |
| 343 | 345 | |
| 344 | 346 | var tstrTripa1 : TStrings; |
| 345 | 347 | intAux : integer; |
| 346 | - v_path_cacic : String; | |
| 348 | + strAux : String; | |
| 347 | 349 | |
| 348 | 350 | const |
| 349 | 351 | CACIC_APP_NAME = 'col_comp'; |
| 350 | 352 | |
| 351 | 353 | begin |
| 352 | 354 | g_oCacic := TCACIC.Create(); |
| 353 | - if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then | |
| 354 | - if (ParamCount>0) then | |
| 355 | - Begin | |
| 356 | - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini | |
| 357 | - tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\'); | |
| 358 | - v_path_cacic := ''; | |
| 359 | - For intAux := 0 to tstrTripa1.Count -2 do | |
| 360 | - v_path_cacic := v_path_cacic + tstrTripa1[intAux] + '\'; | |
| 361 | 355 | |
| 362 | - g_oCacic.setCacicPath(v_path_cacic); | |
| 356 | + g_oCacic.setBoolCipher(true); | |
| 363 | 357 | |
| 364 | - v_tstrCipherOpened := TStrings.Create; | |
| 365 | - v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName); | |
| 366 | - | |
| 367 | - v_tstrCipherOpened1 := TStrings.Create; | |
| 368 | - v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_comp.dat'); | |
| 369 | - | |
| 370 | - Try | |
| 371 | - Executa_Col_comp; | |
| 372 | - Except | |
| 373 | - SetValorDatMemoria('Col_Comp.nada', 'nada', v_tstrCipherOpened1); | |
| 374 | - CipherClose(g_oCacic.getCacicPath + 'temp\col_comp.dat', v_tstrCipherOpened1); | |
| 375 | - End; | |
| 376 | - Halt(0); | |
| 377 | - End; | |
| 358 | + if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then | |
| 359 | + if (ParamCount>0) then | |
| 360 | + Begin | |
| 361 | + strAux := ''; | |
| 362 | + For intAux := 1 to ParamCount do | |
| 363 | + Begin | |
| 364 | + if LowerCase(Copy(ParamStr(intAux),1,11)) = '/cacicpath=' then | |
| 365 | + begin | |
| 366 | + strAux := Trim(Copy(ParamStr(intAux),12,Length((ParamStr(intAux))))); | |
| 367 | + end; | |
| 368 | + end; | |
| 369 | + | |
| 370 | + if (strAux <> '') then | |
| 371 | + Begin | |
| 372 | + g_oCacic.setCacicPath(strAux); | |
| 373 | + | |
| 374 | + v_tstrCipherOpened := TStrings.Create; | |
| 375 | + v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 376 | + | |
| 377 | + v_tstrCipherOpened1 := TStrings.Create; | |
| 378 | + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_comp.dat'); | |
| 379 | + | |
| 380 | + Try | |
| 381 | + Executa_Col_comp; | |
| 382 | + Except | |
| 383 | + SetValorDatMemoria('Col_Comp.nada', 'nada', v_tstrCipherOpened1); | |
| 384 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_comp.dat', v_tstrCipherOpened1); | |
| 385 | + End; | |
| 386 | + Halt(0); | |
| 387 | + End; | |
| 388 | + End; | |
| 378 | 389 | g_oCacic.Free(); |
| 379 | 390 | end. | ... | ... |
col_comp/col_comp.res
No preview for this file type
col_hard/col_hard.dpr
| ... | ... | @@ -39,7 +39,6 @@ uses |
| 39 | 39 | CACIC_Library in '..\CACIC_Library.pas'; |
| 40 | 40 | |
| 41 | 41 | var |
| 42 | - v_path_cacic, | |
| 43 | 42 | v_mensagem, |
| 44 | 43 | v_strCipherClosed : String; |
| 45 | 44 | v_debugs : boolean; |
| ... | ... | @@ -538,7 +537,7 @@ var v_te_cpu_fabricante, |
| 538 | 537 | v_registry : TRegistry; |
| 539 | 538 | |
| 540 | 539 | begin |
| 541 | - g_oCacic := TCACIC.Create(); | |
| 540 | + | |
| 542 | 541 | Try |
| 543 | 542 | SetValorDatMemoria('Col_Hard.Inicio', FormatDateTime('hh:nn:ss', Now), v_tstrCipherOpened1); |
| 544 | 543 | v_Report := TStringList.Create; |
| ... | ... | @@ -955,47 +954,51 @@ begin |
| 955 | 954 | g_oCacic.Free(); |
| 956 | 955 | end; |
| 957 | 956 | |
| 957 | +var strAux : String; | |
| 958 | 958 | begin |
| 959 | 959 | g_oCacic := TCACIC.Create(); |
| 960 | 960 | |
| 961 | + g_oCacic.setBoolCipher(true); | |
| 962 | + | |
| 961 | 963 | if( not g_oCacic.isAppRunning( CACIC_APP_NAME ) ) then |
| 962 | 964 | if (ParamCount>0) then |
| 963 | - Begin | |
| 964 | - //Pegarei o nível anterior do diretório, que deve ser, por exemplo \Cacic, para leitura do cacic2.ini | |
| 965 | - tstrTripa1 := g_oCacic.explode(ExtractFilePath(ParamStr(0)),'\'); | |
| 966 | - v_path_cacic := ''; | |
| 967 | - intAux :=0; | |
| 968 | - While intAux < tstrTripa1.Count -1 do | |
| 969 | - begin | |
| 970 | - v_path_cacic := v_path_cacic + tstrTripa1[intAux] + '\'; | |
| 971 | - intAux := intAux + 1 | |
| 972 | - end; | |
| 973 | - | |
| 974 | - g_oCacic.setCacicPath(v_path_cacic); | |
| 975 | - | |
| 976 | - v_tstrCipherOpened := TStrings.Create; | |
| 977 | - v_tstrCipherOpened := CipherOpen(g_oCacic.getDatFileName); | |
| 978 | - | |
| 979 | - v_tstrCipherOpened1 := TStrings.Create; | |
| 980 | - v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_hard.dat'); | |
| 981 | - | |
| 982 | - Try | |
| 983 | - v_Debugs := false; | |
| 984 | - if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then | |
| 985 | - Begin | |
| 986 | - if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
| 987 | - Begin | |
| 988 | - v_Debugs := true; | |
| 989 | - log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
| 990 | - End; | |
| 991 | - End; | |
| 992 | - Executa_Col_Hard; | |
| 993 | - Except | |
| 994 | - SetValorDatMemoria('Col_Hard.nada', 'nada', v_tstrCipherOpened1); | |
| 995 | - CipherClose(g_oCacic.getCacicPath + 'temp\col_hard.dat', v_tstrCipherOpened1); | |
| 996 | - End; | |
| 997 | - End; | |
| 965 | + Begin | |
| 966 | + strAux := ''; | |
| 967 | + For intAux := 1 to ParamCount do | |
| 968 | + Begin | |
| 969 | + if LowerCase(Copy(ParamStr(intAux),1,11)) = '/cacicpath=' then | |
| 970 | + begin | |
| 971 | + strAux := Trim(Copy(ParamStr(intAux),12,Length((ParamStr(intAux))))); | |
| 972 | + log_DEBUG('Parâmetro /CacicPath recebido com valor="'+strAux+'"'); | |
| 973 | + end; | |
| 974 | + end; | |
| 998 | 975 | |
| 999 | - g_oCacic.Free(); | |
| 976 | + if (strAux <> '') then | |
| 977 | + Begin | |
| 978 | + g_oCacic.setCacicPath(strAux); | |
| 979 | + | |
| 980 | + v_tstrCipherOpened := TStrings.Create; | |
| 981 | + v_tstrCipherOpened := CipherOpen(g_oCacic.getCacicPath + g_oCacic.getDatFileName); | |
| 982 | + | |
| 983 | + v_tstrCipherOpened1 := TStrings.Create; | |
| 984 | + v_tstrCipherOpened1 := CipherOpen(g_oCacic.getCacicPath + 'temp\col_hard.dat'); | |
| 985 | + | |
| 986 | + Try | |
| 987 | + v_Debugs := false; | |
| 988 | + if DirectoryExists(g_oCacic.getCacicPath + 'Temp\Debugs') then | |
| 989 | + Begin | |
| 990 | + if (FormatDateTime('ddmmyyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs')) = FormatDateTime('ddmmyyyy', date)) then | |
| 991 | + Begin | |
| 992 | + v_Debugs := true; | |
| 993 | + log_diario('Pasta "' + g_oCacic.getCacicPath + 'Temp\Debugs" com data '+FormatDateTime('dd-mm-yyyy', GetFolderDate(g_oCacic.getCacicPath + 'Temp\Debugs'))+' encontrada. DEBUG ativado.'); | |
| 994 | + End; | |
| 995 | + End; | |
| 996 | + Executa_Col_Hard; | |
| 997 | + Except | |
| 998 | + SetValorDatMemoria('Col_Hard.nada', 'nada', v_tstrCipherOpened1); | |
| 999 | + CipherClose(g_oCacic.getCacicPath + 'temp\col_hard.dat', v_tstrCipherOpened1); | |
| 1000 | + End; | |
| 1001 | + End; | |
| 1002 | + End; | |
| 1000 | 1003 | |
| 1001 | 1004 | end. | ... | ... |
col_hard/col_hard.res
No preview for this file type
col_moni/col_moni.res
No preview for this file type
col_patr/col_patr.res
No preview for this file type
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