Commit 0e2451b7dd32f78492dd64de6f21d5c8265115d6
1 parent
cf0bd127
Exists in
master
-Acrescentado debugador do cacicservice, pois devido ao script de instalação pel…
…o netlogon, o serviço estava sendo instalado sem ser com o tipo idetarivo. -Acrescentado loop de espera para pegar o nome de usuário logado, pois às vezes o mapa executava antes de realizar o login completo na máquina.
Showing
17 changed files
with
274 additions
and
102 deletions
Show diff stats
CACIC_Library.pas
... | ... | @@ -60,6 +60,7 @@ uses Windows, |
60 | 60 | Tlhelp32, |
61 | 61 | ComObj, |
62 | 62 | ShellAPI, |
63 | + WinSvc, | |
63 | 64 | Variants; |
64 | 65 | |
65 | 66 | type |
... | ... | @@ -124,7 +125,7 @@ type |
124 | 125 | {*------------------------------------------------------------------------------ |
125 | 126 | Classe geral da biblioteca |
126 | 127 | -------------------------------------------------------------------------------} |
127 | - TCACIC = class(TCACIC_Windows) | |
128 | + TCACIC = class(TCACIC_Windows) | |
128 | 129 | constructor Create(); |
129 | 130 | destructor Destroy; override; |
130 | 131 | private |
... | ... | @@ -140,7 +141,7 @@ type |
140 | 141 | Windows : TCACIC_Windows; /// objeto de informacoes de windows |
141 | 142 | function checkIfFileDateIsToday(pStrFileName : String) : Boolean; |
142 | 143 | function countOccurences(const strSubText, strText: string) : Integer; |
143 | - function createOneProcess(pStrCmd: string; pBoolWait: boolean; pWordShowWindow : word = SW_HIDE) : Boolean; | |
144 | + function createOneProcess(pStrCmd: string; pBoolWait: boolean; pWordShowWindow : word = SW_HIDE; waitMilliseconds : cardinal = INFINITE) : Boolean; | |
144 | 145 | function capitalize (CONST s: STRING) : String; |
145 | 146 | function checkModule(pStrModuleFileName, pStrModuleHashCode : String) : String; |
146 | 147 | function deCrypt(pStrCipheredText : String; pBoolShowInLog : boolean = true; pBoolForceDecrypt : boolean = false) : String; |
... | ... | @@ -199,6 +200,10 @@ type |
199 | 200 | procedure writeDailyLog(pStrLogMessage : String; pStrFileNameSuffix : String = ''); |
200 | 201 | procedure writeDebugLog(pStrDebugMessage : String); override; |
201 | 202 | procedure writeExceptionLog(pStrExceptionMessage, pStrExceptionClassName : String; pStrAddedMessage : String = ''); override; |
203 | + | |
204 | + function serviceGetType(sMachine, sService: PChar): DWORD; | |
205 | + function serviceStart(sMachine,sService : string ) : boolean; | |
206 | + function ServiceGetStatus(sMachine, sService: PChar): DWORD; | |
202 | 207 | end; |
203 | 208 | |
204 | 209 | // Declaração de constantes para a biblioteca |
... | ... | @@ -1091,6 +1096,47 @@ begin |
1091 | 1096 | end; |
1092 | 1097 | end; |
1093 | 1098 | |
1099 | +function TCACIC.serviceStart(sMachine,sService : string ) : boolean; | |
1100 | +var | |
1101 | + schm,schs : SC_Handle; | |
1102 | + ss : TServiceStatus; | |
1103 | + psTemp : PChar; | |
1104 | + dwChkP : DWord; | |
1105 | +begin | |
1106 | + ss.dwCurrentState := 0; | |
1107 | + schm := OpenSCManager(PChar(sMachine),Nil,SC_MANAGER_CONNECT); | |
1108 | + if(schm > 0)then | |
1109 | + begin | |
1110 | + schs := OpenService(schm,PChar(sService),SERVICE_START or SERVICE_QUERY_STATUS); | |
1111 | + if(schs > 0)then | |
1112 | + begin | |
1113 | + psTemp := Nil; | |
1114 | + if(StartService(schs,0,psTemp))then | |
1115 | + begin | |
1116 | + if(QueryServiceStatus(schs,ss))then | |
1117 | + begin | |
1118 | + while(SERVICE_RUNNING <> ss.dwCurrentState)do | |
1119 | + begin | |
1120 | + dwChkP := ss.dwCheckPoint; | |
1121 | + Sleep(ss.dwWaitHint); | |
1122 | + if(not QueryServiceStatus(schs,ss))then | |
1123 | + begin | |
1124 | + break; | |
1125 | + end; | |
1126 | + if(ss.dwCheckPoint < dwChkP)then | |
1127 | + begin | |
1128 | + break; | |
1129 | + end; | |
1130 | + end; | |
1131 | + end; | |
1132 | + end; | |
1133 | + CloseServiceHandle(schs); | |
1134 | + end; | |
1135 | + CloseServiceHandle(schm); | |
1136 | + end; | |
1137 | + Result := SERVICE_RUNNING = ss.dwCurrentState; | |
1138 | +end; | |
1139 | + | |
1094 | 1140 | procedure TCACIC.writeDebugLog(pStrDebugMessage : String); |
1095 | 1141 | Begin |
1096 | 1142 | if isInDebugMode(copy(pStrDebugMessage,1,pos(':',pStrDebugMessage)-1)) then |
... | ... | @@ -1224,7 +1270,7 @@ end; |
1224 | 1270 | @param p_wait TRUE se deve aguardar término da excução, FALSE caso contrário |
1225 | 1271 | @param p_showWindow Constante que define o tipo de exibição da janela do aplicativo |
1226 | 1272 | -------------------------------------------------------------------------------} |
1227 | -function TCACIC.createOneProcess(pStrCmd: string; pBoolWait: boolean; pWordShowWindow : word = SW_HIDE): boolean; | |
1273 | +function TCACIC.createOneProcess(pStrCmd: string; pBoolWait: boolean; pWordShowWindow : word = SW_HIDE; waitMilliseconds : cardinal = INFINITE): boolean; | |
1228 | 1274 | var |
1229 | 1275 | SUInfo: TStartupInfo; |
1230 | 1276 | ProcInfo: TProcessInformation; |
... | ... | @@ -1244,8 +1290,7 @@ begin |
1244 | 1290 | nil, |
1245 | 1291 | nil, |
1246 | 1292 | false, |
1247 | - CREATE_NEW_CONSOLE or | |
1248 | - BELOW_NORMAL_PRIORITY_CLASS, | |
1293 | + NORMAL_PRIORITY_CLASS, | |
1249 | 1294 | nil, |
1250 | 1295 | nil, |
1251 | 1296 | SUInfo, |
... | ... | @@ -1253,7 +1298,7 @@ begin |
1253 | 1298 | if (Result) then |
1254 | 1299 | begin |
1255 | 1300 | if(pBoolWait) then begin |
1256 | - WaitForSingleObject(ProcInfo.hProcess, INFINITE); | |
1301 | + WaitForSingleObject(ProcInfo.hProcess, waitMilliseconds); | |
1257 | 1302 | CloseHandle(ProcInfo.hProcess); |
1258 | 1303 | CloseHandle(ProcInfo.hThread); |
1259 | 1304 | end; |
... | ... | @@ -1950,5 +1995,102 @@ begin |
1950 | 1995 | end; |
1951 | 1996 | end; |
1952 | 1997 | end; |
1998 | + | |
1999 | +function TCACIC.ServiceGetType(sMachine, sService: PChar): DWORD; | |
2000 | + {*******************************************} | |
2001 | + {*** Parameters: ***} | |
2002 | + {*** sService: specifies the name of the service to open | |
2003 | + {*** sMachine: specifies the name of the target computer | |
2004 | + {*** ***} | |
2005 | + {*** Return Values: ***} | |
2006 | + | |
2007 | +var | |
2008 | + SCManHandle, SvcHandle: SC_Handle; | |
2009 | + SS: TServiceStatus; | |
2010 | + dwStat: DWORD; | |
2011 | +begin | |
2012 | + dwStat := 0; | |
2013 | + // Open service manager handle. | |
2014 | + writeDebugLog('ServiceGetStatus: Executando OpenSCManager.SC_MANAGER_CONNECT'); | |
2015 | + SCManHandle := OpenSCManager(sMachine, nil, SC_MANAGER_CONNECT); | |
2016 | + if (SCManHandle > 0) then | |
2017 | + begin | |
2018 | + writeDebugLog('ServiceGetStatus: Executando OpenService.SERVICE_QUERY_STATUS'); | |
2019 | + SvcHandle := OpenService(SCManHandle, sService, SERVICE_ALL_ACCESS); | |
2020 | + // if Service installed | |
2021 | + if (SvcHandle > 0) then | |
2022 | + begin | |
2023 | + writeDebugLog('ServiceGetStatus: O serviço "'+ sService +'" já está instalado.'); | |
2024 | + // SS structure holds the service status (TServiceStatus); | |
2025 | + if (QueryServiceStatus(SvcHandle, SS)) then | |
2026 | + dwStat := ss.dwServiceType; | |
2027 | + if dwStat <> 272 then | |
2028 | + begin | |
2029 | + ChangeServiceConfig(SvcHandle, | |
2030 | + 272, //iterative | |
2031 | + SERVICE_NO_CHANGE, | |
2032 | + SERVICE_NO_CHANGE, | |
2033 | + nil, | |
2034 | + nil, | |
2035 | + nil, | |
2036 | + nil, | |
2037 | + nil, | |
2038 | + nil, | |
2039 | + nil); | |
2040 | + end; | |
2041 | + | |
2042 | + if (QueryServiceStatus(SvcHandle, SS)) then | |
2043 | + dwStat := ss.dwServiceType; | |
2044 | + CloseServiceHandle(SvcHandle); | |
2045 | + end; | |
2046 | + CloseServiceHandle(SCManHandle); | |
2047 | + end; | |
2048 | + Result := dwStat; | |
2049 | +end; | |
2050 | + | |
2051 | +function TCACIC.ServiceGetStatus(sMachine, sService: PChar): DWORD; | |
2052 | + {*******************************************} | |
2053 | + {*** Parameters: ***} | |
2054 | + {*** sService: specifies the name of the service to open | |
2055 | + {*** sMachine: specifies the name of the target computer | |
2056 | + {*** ***} | |
2057 | + {*** Return Values: ***} | |
2058 | + {*** -1 = Error opening service ***} | |
2059 | + {*** 1 = SERVICE_STOPPED ***} | |
2060 | + {*** 2 = SERVICE_START_PENDING ***} | |
2061 | + {*** 3 = SERVICE_STOP_PENDING ***} | |
2062 | + {*** 4 = SERVICE_RUNNING ***} | |
2063 | + {*** 5 = SERVICE_CONTINUE_PENDING ***} | |
2064 | + {*** 6 = SERVICE_PAUSE_PENDING ***} | |
2065 | + {*** 7 = SERVICE_PAUSED ***} | |
2066 | + {******************************************} | |
2067 | +var | |
2068 | + SCManHandle, SvcHandle: SC_Handle; | |
2069 | + SS: TServiceStatus; | |
2070 | + dwStat: DWORD; | |
2071 | +begin | |
2072 | + dwStat := 0; | |
2073 | + // Open service manager handle. | |
2074 | + writeDebugLog('ServiceGetStatus: Executando OpenSCManager.SC_MANAGER_CONNECT'); | |
2075 | + SCManHandle := OpenSCManager(sMachine, nil, SC_MANAGER_CONNECT); | |
2076 | + if (SCManHandle > 0) then | |
2077 | + begin | |
2078 | + writeDebugLog('ServiceGetStatus: Executando OpenService.SERVICE_QUERY_STATUS'); | |
2079 | + SvcHandle := OpenService(SCManHandle, sService, SERVICE_QUERY_STATUS); | |
2080 | + // if Service installed | |
2081 | + if (SvcHandle > 0) then | |
2082 | + begin | |
2083 | + writeDebugLog('ServiceGetStatus: O serviço "'+ sService +'" já está instalado.'); | |
2084 | + // SS structure holds the service status (TServiceStatus); | |
2085 | + if (QueryServiceStatus(SvcHandle, SS)) then | |
2086 | + dwStat := ss.dwCurrentState; | |
2087 | + | |
2088 | + CloseServiceHandle(SvcHandle); | |
2089 | + end; | |
2090 | + CloseServiceHandle(SCManHandle); | |
2091 | + end; | |
2092 | + Result := dwStat; | |
2093 | +end; | |
2094 | + | |
1953 | 2095 | end. |
1954 | 2096 | ... | ... |
Grupo_CACIC.groupproj
... | ... | @@ -19,15 +19,6 @@ |
19 | 19 | <Target Name="chksis:Make"> |
20 | 20 | <MSBuild Projects="chksis\chksis.dproj" Targets="Make" /> |
21 | 21 | </Target> |
22 | - <Target Name="cacicservice"> | |
23 | - <MSBuild Projects="cacicservice\cacicservice.dproj" Targets="" /> | |
24 | - </Target> | |
25 | - <Target Name="cacicservice:Clean"> | |
26 | - <MSBuild Projects="cacicservice\cacicservice.dproj" Targets="Clean" /> | |
27 | - </Target> | |
28 | - <Target Name="cacicservice:Make"> | |
29 | - <MSBuild Projects="cacicservice\cacicservice.dproj" Targets="Make" /> | |
30 | - </Target> | |
31 | 22 | <Target Name="cacic280"> |
32 | 23 | <MSBuild Projects="cacic280.dproj" Targets="" /> |
33 | 24 | </Target> |
... | ... | @@ -37,6 +28,15 @@ |
37 | 28 | <Target Name="cacic280:Make"> |
38 | 29 | <MSBuild Projects="cacic280.dproj" Targets="Make" /> |
39 | 30 | </Target> |
31 | + <Target Name="cacicservice"> | |
32 | + <MSBuild Projects="cacicservice\cacicservice.dproj" Targets="" /> | |
33 | + </Target> | |
34 | + <Target Name="cacicservice:Clean"> | |
35 | + <MSBuild Projects="cacicservice\cacicservice.dproj" Targets="Clean" /> | |
36 | + </Target> | |
37 | + <Target Name="cacicservice:Make"> | |
38 | + <MSBuild Projects="cacicservice\cacicservice.dproj" Targets="Make" /> | |
39 | + </Target> | |
40 | 40 | <Target Name="gercols"> |
41 | 41 | <MSBuild Projects="gercols\gercols.dproj" Targets="" /> |
42 | 42 | </Target> |
... | ... | @@ -83,12 +83,12 @@ |
83 | 83 | <MSBuild Projects="C:\Documents and Settings\adriano\Meus documentos\RAD Studio\Projects\TesteSoftware.dproj" Targets="Make" /> |
84 | 84 | </Target> |
85 | 85 | <Target Name="Build"> |
86 | - <CallTarget Targets="chksis;cacicservice;cacic280;gercols;installcacic;mapacacic;CacicVersionsAndHashes;TesteSoftware" /> | |
86 | + <CallTarget Targets="chksis;cacic280;cacicservice;gercols;installcacic;mapacacic;CacicVersionsAndHashes;TesteSoftware" /> | |
87 | 87 | </Target> |
88 | 88 | <Target Name="Clean"> |
89 | - <CallTarget Targets="chksis:Clean;cacicservice:Clean;cacic280:Clean;gercols:Clean;installcacic:Clean;mapacacic:Clean;CacicVersionsAndHashes:Clean;TesteSoftware:Clean" /> | |
89 | + <CallTarget Targets="chksis:Clean;cacic280:Clean;cacicservice:Clean;gercols:Clean;installcacic:Clean;mapacacic:Clean;CacicVersionsAndHashes:Clean;TesteSoftware:Clean" /> | |
90 | 90 | </Target> |
91 | 91 | <Target Name="Make"> |
92 | - <CallTarget Targets="chksis:Make;cacicservice:Make;cacic280:Make;gercols:Make;installcacic:Make;mapacacic:Make;CacicVersionsAndHashes:Make;TesteSoftware:Make" /> | |
92 | + <CallTarget Targets="chksis:Make;cacic280:Make;cacicservice:Make;gercols:Make;installcacic:Make;mapacacic:Make;CacicVersionsAndHashes:Make;TesteSoftware:Make" /> | |
93 | 93 | </Target> |
94 | 94 | </Project> |
95 | 95 | \ No newline at end of file | ... | ... |
MapaTesteProj/MapaCACIC.dproj
... | ... | @@ -24,7 +24,7 @@ |
24 | 24 | <Borland.Personality>Delphi.Personality</Borland.Personality> |
25 | 25 | <Borland.ProjectType /> |
26 | 26 | <BorlandProject> |
27 | -<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">7</VersionInfo><VersionInfo Name="Debug">True</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.7</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Licença: GNU/LGPL</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">mapacacic.dpr</Source></Source></Delphi.Personality><ModelSupport>False</ModelSupport></BorlandProject></BorlandProject> | |
27 | +<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">8</VersionInfo><VersionInfo Name="Debug">True</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.8</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Licença: GNU/LGPL</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">mapacacic.dpr</Source></Source></Delphi.Personality><ModelSupport>False</ModelSupport></BorlandProject></BorlandProject> | |
28 | 28 | </ProjectExtensions> |
29 | 29 | <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" /> |
30 | 30 | <ItemGroup> | ... | ... |
MapaTesteProj/MapaCACIC.res
No preview for this file type
MapaTesteProj/MapaTeste.dcu
No preview for this file type
MapaTesteProj/MapaTeste.pas
... | ... | @@ -166,8 +166,10 @@ Begin |
166 | 166 | Visible := false; |
167 | 167 | |
168 | 168 | reset(textFileAguarde); |
169 | - objCACIC.deleteFileOrFolder(objCacic.getLocalFolderName + | |
170 | - '\temp\aguarde_MAPACACIC.txt'); | |
169 | + if FileExists(objCACIC.getLocalFolderName + '\temp\aguarde_MAPACACIC.txt') then | |
170 | + objCACIC.deleteFileOrFolder(objCacic.getLocalFolderName + | |
171 | + '\temp\aguarde_MAPACACIC.txt'); | |
172 | + | |
171 | 173 | Application.ProcessMessages; |
172 | 174 | |
173 | 175 | Sair; |
... | ... | @@ -315,7 +317,7 @@ Begin |
315 | 317 | End |
316 | 318 | else |
317 | 319 | begin |
318 | - MessageDlg(#13#13+'Não foi possível realizar a conexão!',mtError, [mbOK], 0); | |
320 | + objCACIC.writeDailyLog('Não foi possível realizar a conexão!'); | |
319 | 321 | end; |
320 | 322 | btCombosUpdate.Enabled := true; |
321 | 323 | End; |
... | ... | @@ -428,7 +430,9 @@ end; |
428 | 430 | procedure TfrmMapaCacic.MontaInterface; |
429 | 431 | var strConfigsPatrimonioInterface, |
430 | 432 | strNomeLDAP : String; |
433 | + count : integer; | |
431 | 434 | Begin |
435 | + count := 0; | |
432 | 436 | btCombosUpdate.Enabled := false; |
433 | 437 | |
434 | 438 | strConfigsPatrimonioInterface := objCacic.deCrypt(objCacic.getValueFromFile |
... | ... | @@ -449,9 +453,15 @@ Begin |
449 | 453 | //-----------------------------USUARIO LOGADO----------------------------------- |
450 | 454 | |
451 | 455 | // edTeInfoUserLogado.Text := getUserLogon; |
452 | - strTeInfoPatrimonio2:=objCACIC.getValueFromTags('UserName',fetchWMIvalues('Win32_ComputerSystem',objCACIC.getLocalFolderName,'UserName')); | |
453 | - strTeInfoPatrimonio2:=copy(strTeInfoPatrimonio2, pos('\', strTeInfoPatrimonio2)+1, length(strTeInfoPatrimonio2)); | |
454 | - edTeInfoPatrimonio2.Text:=strTeInfoPatrimonio2; | |
456 | + while(strTeInfoPatrimonio2 = '') and (count < 600) do | |
457 | + begin | |
458 | + strTeInfoPatrimonio2:=objCACIC.getValueFromTags('UserName',fetchWMIvalues('Win32_ComputerSystem',objCACIC.getLocalFolderName,'UserName')); | |
459 | + strTeInfoPatrimonio2:=copy(strTeInfoPatrimonio2, pos('\', strTeInfoPatrimonio2)+1, length(strTeInfoPatrimonio2)); | |
460 | + edTeInfoPatrimonio2.Text:=strTeInfoPatrimonio2; | |
461 | + sleep(1000); | |
462 | + count := count + 1; | |
463 | + end; | |
464 | + | |
455 | 465 | if edTeInfoPatrimonio2.Text <> '' then |
456 | 466 | begin |
457 | 467 | lbEtiqueta2.Visible := true; |
... | ... | @@ -684,10 +694,10 @@ begin |
684 | 694 | else |
685 | 695 | Begin |
686 | 696 | frmMapaCacic.boolAcessoOK := false; |
687 | - MessageDLG(#13#10+'Atenção! É necessário reinstalar o CACIC nesta estação.' + #13#10 + #13#10 + | |
688 | - 'A escctrutura encontra-se corrompida.' + #13#10,mtError,[mbOK],0); | |
689 | - Application.ProcessMessages; | |
690 | - frmMapaCacic.Finalizar; | |
697 | + Application.messagebox(Pchar('Atenção! É necessário reinstalar o CACIC nesta estação.' + | |
698 | + #13#10 + #13#10 + 'A estrutura encontra-se corrompida.'), | |
699 | + 'Erro!',MB_ICONERROR + mb_ok); | |
700 | + Finalizar; | |
691 | 701 | End; |
692 | 702 | end |
693 | 703 | else | ... | ... |
MapaTesteProj/Source/synsock.pas
cacic280.dproj
... | ... | @@ -40,7 +40,7 @@ |
40 | 40 | <Borland.Personality>Delphi.Personality</Borland.Personality> |
41 | 41 | <Borland.ProjectType>VCLApplication</Borland.ProjectType> |
42 | 42 | <BorlandProject> |
43 | -<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">9</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev.Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo Agente Principal</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.9</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright">Baseado na licença GNU/LGPL</VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName">Cacic - Configurador Automático e Coletor de Informações Computacionais</VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">cacic280.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> | |
43 | +<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">11</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev.Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo Agente Principal</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.11</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright">Baseado na licença GNU/LGPL</VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName">Cacic - Configurador Automático e Coletor de Informações Computacionais</VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">cacic280.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> | |
44 | 44 | </ProjectExtensions> |
45 | 45 | <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" /> |
46 | 46 | <ItemGroup> | ... | ... |
cacic280.res
No preview for this file type
cacicservice/CACICserviceMain.pas
... | ... | @@ -97,7 +97,7 @@ begin |
97 | 97 | //TOKEN_ADJUST_SESSIONID := 256; |
98 | 98 | |
99 | 99 | // Log the client on to the local computer. |
100 | - | |
100 | + ServiceType := stWin32; | |
101 | 101 | dwSessionId := WTSGetActiveConsoleSessionId(); |
102 | 102 | hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); |
103 | 103 | if (hSnap = INVALID_HANDLE_VALUE) then |
... | ... | @@ -433,15 +433,6 @@ Begin |
433 | 433 | else |
434 | 434 | g_oCacic.writeDebugLog('ExecutaCACIC: Cookie Bloqueado pelo Agente Principal ENCONTRADO - CACIC em Execução!'); |
435 | 435 | |
436 | - // Execução do MAPA. | |
437 | - if ((g_oCacic.getValueFromFile('Configs', 'modulo_patr', | |
438 | - g_oCacic.getLocalFolderName + 'GerCols.inf') = 'S') and | |
439 | - (g_oCacic.getValueFromFile('Configs', 'col_patr_exe', | |
440 | - g_oCacic.getLocalFolderName + 'GerCols.inf') <> 's')) then | |
441 | - begin | |
442 | - g_oCacic.createOneProcess(g_oCacic.getLocalFolderName + 'Modules\mapacacic.exe',false,SW_NORMAL); | |
443 | - end; | |
444 | - | |
445 | 436 | g_oCacic.writeDebugLog('ExecutaCACIC: Verificando existência de nova versão deste serviço para atualização.'); |
446 | 437 | // Verifico a existência de nova versão do serviço e finalizo em caso positivo... |
447 | 438 | if (FileExists(g_oCacic.getLocalFolderName + 'Temp\cacicservice.exe')) and | ... | ... |
cacicservice/cacicservice.dproj
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <Borland.Personality>Delphi.Personality</Borland.Personality> |
38 | 38 | <Borland.ProjectType>VCLApplication</Borland.ProjectType> |
39 | 39 | <BorlandProject> |
40 | -<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Language><Language Name="RootDir">E:\NTService\</Language></Language><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">6</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo para Sustentação do Agente Principal</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.6</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Licença: GNU/LGPL</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">cacicservice.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> | |
40 | +<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><Language><Language Name="RootDir">E:\NTService\</Language></Language><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">7</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo para Sustentação do Agente Principal</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.7</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Licença: GNU/LGPL</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">cacicservice.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> | |
41 | 41 | </ProjectExtensions> |
42 | 42 | <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" /> |
43 | 43 | <ItemGroup> | ... | ... |
cacicservice/cacicservice.res
No preview for this file type
gercols/gercols.dpr
... | ... | @@ -247,7 +247,7 @@ Begin |
247 | 247 | |
248 | 248 | if (objCacic.getValueFromTags('WebManagerAddress', strRetorno,'<>') <> '') then |
249 | 249 | Begin |
250 | - strForcaColeta = objCacic.getValueFromTags('ForcaColeta', strRetorno, '<>'); | |
250 | + strForcaColeta := objCacic.getValueFromTags('ForcaColeta', strRetorno, '<>'); | |
251 | 251 | // if strForcaColeta <> 'S' then |
252 | 252 | // objCacic.setValueToFile('Configs','col_patr_exe', |
253 | 253 | // 'n', |
... | ... | @@ -850,6 +850,7 @@ Begin |
850 | 850 | else if FindCmdLineSwitch ('getTest', True) then |
851 | 851 | begin |
852 | 852 | getTest(); |
853 | + Finalizar(false); | |
853 | 854 | end; |
854 | 855 | |
855 | 856 | // Chamada efetuada pelo Agente Principal quando da existência de temp\<AgentePrincipal>.exe para AutoUpdate |
... | ... | @@ -925,7 +926,7 @@ Begin |
925 | 926 | intTotalExecutedCollects := 0; |
926 | 927 | intTotalSendedCollects := 0; |
927 | 928 | |
928 | - //getConfigs(true); | |
929 | + getConfigs(true); | |
929 | 930 | |
930 | 931 | // Abaixo eu testo se existe um endereço configurado para não disparar os procedimentos de coleta em vão. |
931 | 932 | if (objCacic.getWebManagerAddress <> '') then | ... | ... |
installcacic/installcacic.dproj
... | ... | @@ -32,7 +32,7 @@ |
32 | 32 | <Borland.Personality>Delphi.Personality</Borland.Personality> |
33 | 33 | <Borland.ProjectType>VCLApplication</Borland.ProjectType> |
34 | 34 | <BorlandProject> |
35 | -<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">6</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.6</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Licença: GNU/LGPL</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">installcacic.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> | |
35 | +<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">True</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">2</VersionInfo><VersionInfo Name="MinorVer">8</VersionInfo><VersionInfo Name="Release">1</VersionInfo><VersionInfo Name="Build">8</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">1046</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName">Dataprev - Emp. de TI da Prev Social - URES/SESS</VersionInfoKeys><VersionInfoKeys Name="FileDescription">Sistema CACIC - Módulo para Verificação e Instalação de Estrutura Básica do Sistema CACIC</VersionInfoKeys><VersionInfoKeys Name="FileVersion">2.8.1.8</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">3.0</VersionInfoKeys><VersionInfoKeys Name="Comments">Licença: GNU/LGPL</VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">installcacic.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject> | |
36 | 36 | </ProjectExtensions> |
37 | 37 | <Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" /> |
38 | 38 | <ItemGroup> | ... | ... |
installcacic/installcacic.res
No preview for this file type
installcacic/uInstallCACIC.pas
... | ... | @@ -111,7 +111,6 @@ type |
111 | 111 | function boolCanRunCACIC : boolean; |
112 | 112 | function findWindowByTitle(pStrWindowTitle: string) : Hwnd; |
113 | 113 | function listFileDir(pStrPath: string) : string; |
114 | - function serviceGetStatus(sMachine, sService: PChar) : DWORD; | |
115 | 114 | function serviceStart(pStrServiceName : string ) : boolean; |
116 | 115 | function serviceRunning(pCharMachineName, pCharServiceName: PChar) : boolean; |
117 | 116 | function serviceStopped(pCharMachineName, pCharServiceName: PChar) : boolean; |
... | ... | @@ -135,6 +134,8 @@ implementation |
135 | 134 | {$R *.dfm} |
136 | 135 | |
137 | 136 | procedure TfrmInstallCACIC.FormCreate(Sender: TObject); |
137 | +var | |
138 | +wordServiceStatus, serviceType : DWord; | |
138 | 139 | begin |
139 | 140 | Try |
140 | 141 | boolShowForm := true; |
... | ... | @@ -200,49 +201,6 @@ begin |
200 | 201 | End; |
201 | 202 | end; |
202 | 203 | |
203 | -function TfrmInstallCACIC.ServiceGetStatus(sMachine, sService: PChar): DWORD; | |
204 | - {*******************************************} | |
205 | - {*** Parameters: ***} | |
206 | - {*** sService: specifies the name of the service to open | |
207 | - {*** sMachine: specifies the name of the target computer | |
208 | - {*** ***} | |
209 | - {*** Return Values: ***} | |
210 | - {*** -1 = Error opening service ***} | |
211 | - {*** 1 = SERVICE_STOPPED ***} | |
212 | - {*** 2 = SERVICE_START_PENDING ***} | |
213 | - {*** 3 = SERVICE_STOP_PENDING ***} | |
214 | - {*** 4 = SERVICE_RUNNING ***} | |
215 | - {*** 5 = SERVICE_CONTINUE_PENDING ***} | |
216 | - {*** 6 = SERVICE_PAUSE_PENDING ***} | |
217 | - {*** 7 = SERVICE_PAUSED ***} | |
218 | - {******************************************} | |
219 | -var | |
220 | - SCManHandle, SvcHandle: SC_Handle; | |
221 | - SS: TServiceStatus; | |
222 | - dwStat: DWORD; | |
223 | -begin | |
224 | - dwStat := 0; | |
225 | - // Open service manager handle. | |
226 | - objCacic.writeDebugLog('ServiceGetStatus: Executando OpenSCManager.SC_MANAGER_CONNECT'); | |
227 | - SCManHandle := OpenSCManager(sMachine, nil, SC_MANAGER_CONNECT); | |
228 | - if (SCManHandle > 0) then | |
229 | - begin | |
230 | - objCacic.writeDebugLog('ServiceGetStatus: Executando OpenService.SERVICE_QUERY_STATUS'); | |
231 | - SvcHandle := OpenService(SCManHandle, sService, SERVICE_QUERY_STATUS); | |
232 | - // if Service installed | |
233 | - if (SvcHandle > 0) then | |
234 | - begin | |
235 | - objCacic.writeDebugLog('ServiceGetStatus: O serviço "'+ sService +'" já está instalado.'); | |
236 | - // SS structure holds the service status (TServiceStatus); | |
237 | - if (QueryServiceStatus(SvcHandle, SS)) then | |
238 | - dwStat := ss.dwCurrentState; | |
239 | - CloseServiceHandle(SvcHandle); | |
240 | - end; | |
241 | - CloseServiceHandle(SCManHandle); | |
242 | - end; | |
243 | - Result := dwStat; | |
244 | -end; | |
245 | - | |
246 | 204 | // start service |
247 | 205 | // |
248 | 206 | // return TRUE if successful |
... | ... | @@ -393,7 +351,7 @@ Begin |
393 | 351 | End; |
394 | 352 | |
395 | 353 | procedure TfrmInstallCACIC.installCACIC; |
396 | -var wordServiceStatus : DWORD; | |
354 | +var wordServiceStatus, serviceType : cardinal; | |
397 | 355 | tstrRequest_ConfigIC : TStringList; |
398 | 356 | strAuxInstallCACIC : String; |
399 | 357 | begin |
... | ... | @@ -717,7 +675,11 @@ begin |
717 | 675 | objCacic, |
718 | 676 | strChkSisInfFileName); |
719 | 677 | |
720 | - objCacic.setValueToFile('Installation','chkSIS.exe', objCacic.checkModule(objCacic.getWinDir + 'chksis.exe', objCACIC.deCrypt( objCacic.getValueFromTags('CHKSIS.EXE_HASH', strCommResponse,'<>'),false,true)), strChkSisInfFileName); | |
678 | + objCacic.setValueToFile('Installation','chkSIS.exe', | |
679 | + objCacic.checkModule(objCacic.getWinDir + 'chksis.exe', | |
680 | + objCACIC.deCrypt( objCacic.getValueFromTags | |
681 | + ('CHKSIS.EXE_HASH', strCommResponse,'<>'), | |
682 | + false,true)), strChkSisInfFileName); | |
721 | 683 | |
722 | 684 | // Caso o Cacic tenha sido baixado executo-o com parâmetro de configuração de servidor |
723 | 685 | if (objCacic.getValueFromFile('Installation','CacicService.exe' , strChkSisInfFileName) = 'Ok!') and |
... | ... | @@ -739,8 +701,7 @@ begin |
739 | 701 | ComunicaInsucesso('1'); // O indicador "1" sinalizará que não foi devido a privilégio na estação |
740 | 702 | End; |
741 | 703 | |
742 | - if boolCanRunCACIC and | |
743 | - (objCacic.getValueFromFile('Installation','ChkSIS.exe', strChkSisInfFileName) = 'Ok!') then | |
704 | + if (objCacic.getValueFromFile('Installation','ChkSIS.exe', strChkSisInfFileName) = 'Ok!') then | |
744 | 705 | Begin |
745 | 706 | // Se não for plataforma NT executo o agente principal |
746 | 707 | if not (objCacic.isWindowsNTPlataform()) then |
... | ... | @@ -761,8 +722,18 @@ begin |
761 | 722 | {*** 6 = SERVICE_PAUSE_PENDING ***} |
762 | 723 | {*** 7 = SERVICE_PAUSED ***} |
763 | 724 | |
725 | + informaProgresso('Verificando CACICservice.'); | |
764 | 726 | // Verifico se o serviço está instalado/rodando,etc. |
765 | - wordServiceStatus := ServiceGetStatus(nil,'CacicSustainService'); | |
727 | + wordServiceStatus := objCacic.ServiceGetStatus(nil,'CacicSustainService'); | |
728 | + | |
729 | + //Verifico o serviço para correção de bug | |
730 | + if wordServiceStatus <> 0 then | |
731 | + begin | |
732 | + //verifica o status, se não estiver correto altera | |
733 | + serviceType := objCacic.serviceGetType('', 'CacicSustainService'); | |
734 | + end; | |
735 | + | |
736 | + | |
766 | 737 | if (wordServiceStatus = 0) then |
767 | 738 | Begin |
768 | 739 | // Instalo e Habilito o serviço |
... | ... | @@ -788,8 +759,10 @@ begin |
788 | 759 | MessageDLG(#13#10+'ATENÇÃO!'+#13#10+#13#10+'Se o ícone do CACIC não for exibido na bandeja do sistema, é recomendável a reinicialização da máquina.',mtInformation,[mbOK],0); |
789 | 760 | informaProgresso('Executando o Agente Principal do CACIC.'); |
790 | 761 | End; |
791 | - | |
792 | - objCacic.createOneProcess(objCacic.getLocalFolderName + objCACIC.getMainProgramName, false); | |
762 | + | |
763 | + if boolCanRunCACIC then | |
764 | + objCacic.createOneProcess(objCacic.getLocalFolderName + objCACIC.getMainProgramName, false); | |
765 | + | |
793 | 766 | End |
794 | 767 | else |
795 | 768 | if FileExists(objCacic.getLocalFolderName + 'aguarde_CACIC.txt') then |
... | ... | @@ -823,12 +796,12 @@ end; |
823 | 796 | |
824 | 797 | function TfrmInstallCACIC.serviceRunning(pCharMachineName, pCharServiceName: PChar): Boolean; |
825 | 798 | begin |
826 | - Result := SERVICE_RUNNING = ServiceGetStatus(pCharMachineName, pCharServiceName); | |
799 | + Result := SERVICE_RUNNING = objCacic.ServiceGetStatus(pCharMachineName, pCharServiceName); | |
827 | 800 | end; |
828 | 801 | |
829 | 802 | function TfrmInstallCACIC.serviceStopped(pCharMachineName, pCharServiceName: PChar): Boolean; |
830 | 803 | begin |
831 | - Result := SERVICE_STOPPED = ServiceGetStatus(pCharMachineName, pCharServiceName); | |
804 | + Result := SERVICE_STOPPED = objCacic.ServiceGetStatus(pCharMachineName, pCharServiceName); | |
832 | 805 | end; |
833 | 806 | |
834 | 807 | function TfrmInstallCACIC.findWindowByTitle(pStrWindowTitle: string): Hwnd; | ... | ... |
main.pas
... | ... | @@ -73,6 +73,7 @@ var strConfigsPatrimonio, |
73 | 73 | g_intStatus, |
74 | 74 | g_intStatusAnterior, |
75 | 75 | g_intIconIndex : integer; |
76 | + bl_primeira_execucao : bool = false; | |
76 | 77 | objCACIC: TCACIC; |
77 | 78 | |
78 | 79 | type |
... | ... | @@ -961,8 +962,12 @@ Begin |
961 | 962 | Result := not (FileExists(objCACIC.getLocalFolderName + 'aguarde_CACIC.txt')); |
962 | 963 | End; |
963 | 964 | |
965 | + | |
966 | + | |
964 | 967 | procedure TFormularioGeral.FormCreate(Sender: TObject); |
965 | 968 | var textFileAguarde : TextFile; |
969 | + serviceType, wordServiceStatus : Cardinal; | |
970 | + service_start : bool; | |
966 | 971 | begin |
967 | 972 | objCACIC := TCACIC.Create; |
968 | 973 | objCACIC.setLocalFolderName(ExtractFilePath(ParamStr(0))); |
... | ... | @@ -972,6 +977,8 @@ begin |
972 | 977 | strGerColsInfFileName := objCACIC.getLocalFolderName + 'gercols.inf'; |
973 | 978 | strChkSisInfFileName := objCACIC.getWinDir + 'chksis.inf'; |
974 | 979 | |
980 | + bl_primeira_execucao := true; | |
981 | + | |
975 | 982 | // A verificação dupla é uma solução de contorno para o caso de o boolCipher ter sido setado após criptografia/deCriptografia do dado gravado |
976 | 983 | if (objCACIC.deCrypt( objCACIC.getValueFromFile('Hash-Codes',objCACIC.getMainProgramName,strChkSisInfFileName),false,true) = objCACIC.getFileHash(ParamStr(0))) then |
977 | 984 | Begin |
... | ... | @@ -988,6 +995,44 @@ begin |
988 | 995 | strWin32_NetworkAdapterConfiguration := fetchWMIvalues('Win32_NetworkAdapterConfiguration', objCACIC.getLocalFolderName); |
989 | 996 | strWin32_ComputerSystem := fetchWMIvalues('Win32_ComputerSystem', objCACIC.getLocalFolderName); |
990 | 997 | |
998 | + //Correção do bug do script net logon da pgfn; | |
999 | + //O script estava instalando o cacic sem interação com desktop, | |
1000 | + //bugando o mapa e o trayicon. | |
1001 | + | |
1002 | + {*** 1 = SERVICE_STOPPED ***} | |
1003 | + {*** 2 = SERVICE_START_PENDING ***} | |
1004 | + {*** 3 = SERVICE_STOP_PENDING ***} | |
1005 | + {*** 4 = SERVICE_RUNNING ***} | |
1006 | + {*** 5 = SERVICE_CONTINUE_PENDING ***} | |
1007 | + {*** 6 = SERVICE_PAUSE_PENDING ***} | |
1008 | + {*** 7 = SERVICE_PAUSED ***} | |
1009 | + | |
1010 | + // Verifico se o serviço está instalado/rodando,etc. | |
1011 | + wordServiceStatus := objCacic.ServiceGetStatus(nil,'CacicSustainService'); | |
1012 | + | |
1013 | + //Verifico o serviço para correção de bug | |
1014 | + // Verifico se o serviço está instalado/rodando,etc. | |
1015 | + | |
1016 | + if wordServiceStatus <> 0 then | |
1017 | + begin | |
1018 | + //verifica o status, se não estiver correto altera | |
1019 | + serviceType := objCacic.serviceGetType('', 'CacicSustainService'); | |
1020 | + end; | |
1021 | + | |
1022 | + if (wordServiceStatus = 0) then | |
1023 | + Begin | |
1024 | + // Instalo e Habilito o serviço | |
1025 | + objCacic.createOneProcess(objCacic.getWinDir + 'cacicservice.exe /install /silent',true); | |
1026 | + End | |
1027 | + else if (wordServiceStatus < 4) then | |
1028 | + Begin | |
1029 | + objCacic.createOneProcess(objCacic.getWinDir + 'cacicservice.exe -start', true); | |
1030 | + End | |
1031 | + else if (wordServiceStatus > 4) then | |
1032 | + Begin | |
1033 | + objCacic.createOneProcess(objCacic.getWinDir + 'cacicservice.exe -continue', true); | |
1034 | + End; | |
1035 | + | |
991 | 1036 | TrayIcon1 := TTrayIcon.Create(self); |
992 | 1037 | TrayIcon1.Hint := pnVersao.Caption; |
993 | 1038 | if not (objCACIC.getValueFromTags('IPAddress',strWin32_NetworkAdapterConfiguration) = '') then |
... | ... | @@ -1257,7 +1302,7 @@ begin |
1257 | 1302 | if ((p_acao = 'getTest') or (p_acao = 'getConfigs')) then //se for getTest, esperar a aplicação finalizar. |
1258 | 1303 | objCACIC.createOneProcess(objCACIC.getLocalFolderName + 'Modules\gercols.exe /'+p_acao+' /WebServicesFolderName='+objCACIC.getWebServicesFolderName +' /LocalFolderName='+objCACIC.getLocalFolderName + ' /WebManagerAddress=' + objCACIC.getWebManagerAddress + ' /MainProgramName=' + objCACIC.getMainProgramName + ' /MainProgramHash=' + objCACIC.getMainProgramHash,true,SW_HIDE) |
1259 | 1304 | else |
1260 | - objCACIC.createOneProcess(objCACIC.getLocalFolderName + 'Modules\gercols.exe /'+p_acao+' /WebServicesFolderName='+objCACIC.getWebServicesFolderName +' /LocalFolderName='+objCACIC.getLocalFolderName + ' /WebManagerAddress=' + objCACIC.getWebManagerAddress + ' /MainProgramName=' + objCACIC.getMainProgramName + ' /MainProgramHash=' + objCACIC.getMainProgramHash,false,SW_HIDE); | |
1305 | + objCACIC.createOneProcess(objCACIC.getLocalFolderName + 'Modules\gercols.exe /'+p_acao+' /WebServicesFolderName='+objCACIC.getWebServicesFolderName +' /LocalFolderName='+objCACIC.getLocalFolderName + ' /WebManagerAddress=' + objCACIC.getWebManagerAddress + ' /MainProgramName=' + objCACIC.getMainProgramName + ' /MainProgramHash=' + objCACIC.getMainProgramHash,true,SW_HIDE); | |
1261 | 1306 | g_intStatus := 1; |
1262 | 1307 | objCacic.setBoolCipher(not objCacic.isInDebugMode); |
1263 | 1308 | End |
... | ... | @@ -1290,7 +1335,7 @@ begin |
1290 | 1335 | objCacic.writeDailyLog('Invoca_MapaCacic: Criando processo mapa.'); |
1291 | 1336 | objCACIC.writeDebugLog('Invoca_MapaCacic: Criando Processo Mapa => "'+objCACIC.getLocalFolderName + 'Modules\MapaCACIC.exe'); |
1292 | 1337 | sleep(10000); //Pausa para dar tempo de realizar o login na máquina, senão o usuário fica em branco. |
1293 | - if (objCACIC.createOneProcess(objCACIC.getLocalFolderName + 'Modules\mapacacic.exe',false,SW_NORMAL)) then | |
1338 | + if (objCACIC.createOneProcess(objCACIC.getLocalFolderName + 'Modules\mapacacic.exe',false,SW_SHOW)) then | |
1294 | 1339 | objCacic.writeDailyLog('Invoca_MapaCacic: Processo criado.') |
1295 | 1340 | else |
1296 | 1341 | objCacic.writeDailyLog('Invoca_MapaCacic: Falha ao criar processo.'); |
... | ... | @@ -1327,11 +1372,13 @@ end; |
1327 | 1372 | procedure TFormularioGeral.ExecutaCACIC(Sender: TObject); |
1328 | 1373 | var v_mensagem, |
1329 | 1374 | v_tipo_mensagem, |
1375 | + primeira_execucao, | |
1330 | 1376 | v_TE_FILA_FTP : string; |
1331 | 1377 | v_MsgDlgType : TMsgDlgType; |
1332 | 1378 | intTentativas : integer; |
1333 | 1379 | begin |
1334 | 1380 | try |
1381 | + primeira_execucao := FormatDateTime('yyyymmdd', Now); | |
1335 | 1382 | |
1336 | 1383 | if FindCmdLineSwitch('execute', True) or |
1337 | 1384 | FindCmdLineSwitch('atualizacao', True) or |
... | ... | @@ -1374,9 +1421,14 @@ begin |
1374 | 1421 | //////////////////////////////////////////////////////////////////////////////// |
1375 | 1422 | // CRIADO PARA TESTAR A CHAMADA DO MAPA CACIC // |
1376 | 1423 | //////////////////////////////////////////////////////////////////////////////// |
1377 | - if (trim(objCACIC.getValueFromFile('Configs','col_patr_exe', strGerColsInfFileName))<>'s') | |
1424 | + if not FindCmdLineSwitch('atualizacao', True) and | |
1425 | + (trim(objCACIC.getValueFromFile('Configs','col_patr_exe', strGerColsInfFileName))<>'s') | |
1378 | 1426 | and not (FileExists(objCacic.getLocalFolderName + 'Temp\aguarde_MAPACACIC.txt')) |
1379 | - and (objCACIC.getValueFromFile('Configs', 'modulo_patr', strGerColsInfFileName) = 'S') then begin | |
1427 | + and (objCACIC.getValueFromFile('Configs', 'modulo_patr', strGerColsInfFileName) = 'S') | |
1428 | + and ((objCACIC.getValueFromFile('Configs','primeira_execucao', | |
1429 | + objCacic.getLocalFolderName + 'cacic280.inf') <> | |
1430 | + primeira_execucao) and bl_primeira_execucao) then | |
1431 | + begin | |
1380 | 1432 | objCACIC.writeDebugLog('ExecutaCACIC: Executa chamada ao Mapa Cacic...'); |
1381 | 1433 | Invoca_MapaCacic; |
1382 | 1434 | end; |
... | ... | @@ -1481,6 +1533,9 @@ begin |
1481 | 1533 | objCACIC.writeExceptionLog(E.Message,E.ClassName,'PROBLEMAS AO TENTAR ATIVAR COLETAS.'); |
1482 | 1534 | end; |
1483 | 1535 | objCACIC.writeDebugLog('ExecutaCACIC: ' + DupeString('=',100)); |
1536 | + objCacic.setValueToFile('Configs','primeira_execucao', primeira_execucao, | |
1537 | + objCacic.getLocalFolderName + 'cacic280.inf'); | |
1538 | + bl_primeira_execucao := false; | |
1484 | 1539 | end; |
1485 | 1540 | |
1486 | 1541 | procedure TFormularioGeral.ExecutarMapa1DrawItem(Sender: TObject; | ... | ... |