Commit 215812043974ebf84e85dfc60f7cb44814db4e94

Authored by Eli de Faria Junior
1 parent f6154e32
Exists in master

concerto de bugs

cacic-daemon/cacicD/cacicd.cpp
... ... @@ -38,14 +38,14 @@ void cacicD::start() {
38 38 QJsonObject agenteConfigJson = result["agentcomputer"].toObject();
39 39 QJsonObject configuracoes = agenteConfigJson["configuracoes"].toObject();
40 40  
41   - //o valor nu_intervalo_exec vem em horas. Se não me engano, o valor que o timer aceita é em segundos,por isso 3600
42   - Ocacictimer->setPeriodicidadeExecucao(configuracoes["nu_intervalo_exec"].toInt() * 3600);
  41 + //o valor nu_intervalo_exec vem em minutos. O valor que o timer aceita é em milisegundos,por isso 60000
  42 + Ocacictimer->setPeriodicidadeExecucao(configuracoes["nu_intervalo_exec"].toString().toInt() * 60000);
43 43 Ocacictimer->iniciarTimer();
44 44 }else{
45 45 //Iniciar com um timer default (4 horas), pra não ficar freezado pra sempre.
46 46 QLogger::QLog_Error("Cacic Daemon", QString("Problemas com o arquivo getConfig.json"));
47 47 QLogger::QLog_Info("Cacic Daemon", QString("Inicializando periodicidade de execução do serviço com tempo padrão."));
48   -
  48 + Ocacictimer->setPeriodicidadeExecucao(14400000); // 14400000 = 4horas (valor padrão)
49 49 Ocacictimer->iniciarTimer();
50 50 }
51 51 }catch (...){
... ...
cacic-daemon/cacicD/cacictimer.cpp
... ... @@ -29,6 +29,12 @@ void CacicTimer::iniciarTimer()
29 29 void CacicTimer::mslot(){
30 30 try{
31 31 verificarPeriodicidadeJson();
  32 + bool ok;
  33 + QJsonObject resposta = OCacicComm->login(&ok);
  34 + if(resposta.isEmpty() || resposta.contains("error")){
  35 + //de vez enquando a conexão da erro, é bom tentar 2 vezes pra garantir.
  36 + resposta = OCacicComm->login(&ok);
  37 + }
32 38 }catch (...){
33 39 QLogger::QLog_Info("Cacic Daemon (Timer)", QString("Não foi possivel verificar a periodicidade no getConfig.json"));
34 40 }
... ... @@ -38,21 +44,20 @@ void CacicTimer::mslot(){
38 44 QLogger::QLog_Info("Cacic Daemon (Timer)", QString("getTeste() success."));
39 45 if(getConfig()){
40 46 QLogger::QLog_Info("Cacic Daemon (Timer)", QString("getConfig() success."));
41   - QStringList nomesModulos = verificarModulos();
42   -
43   - if ( !nomesModulos.empty() ) {
44   - foreach( QString nome, nomesModulos ) {
45   - definirDirModulo(getApplicationDirPath(), nome);
46   - iniciarModulo(getDirProgram());
47   -
48   - if(nome == "cacic-gercols"){
49   - //Envio do json gerado na coleta
50   - bool ok;
51   - QJsonObject jsonColeta = ccacic->getJsonFromFile("coleta.json");
52   - OCacicComm->comm("/ws/neo/coleta", &ok, jsonColeta );
53   - }
54   - }
55   - }
  47 + //QStringList nomesModulos = verificarModulos();
  48 + //if ( !nomesModulos.empty() ) {
  49 + // foreach( QString nome, nomesModulos ) {
  50 + definirDirModulo(getApplicationDirPath(), "gercols");
  51 + iniciarModulo(getDirProgram());
  52 +
  53 + // if(nome == "gercols"){
  54 + // // Envio do json gerado na coleta
  55 + // bool ok;
  56 + // QJsonObject jsonColeta = ccacic->getJsonFromFile("coleta.json");
  57 + // OCacicComm->comm("/ws/neo/coleta", &ok, jsonColeta );
  58 + // }
  59 + // }
  60 + //}
56 61 }else{
57 62 qDebug() << "getConfig() failed. - " + QDateTime::currentDateTime().toLocalTime().toString();
58 63 QLogger::QLog_Error("Cacic Daemon (Timer)", "Falha na obtenção do arquivo de configuração.");
... ... @@ -74,10 +79,13 @@ bool CacicTimer::getTest(){
74 79 bool ok;
75 80 QJsonObject as;
76 81 as["computador"] = OCacic_Computer.toJsonObject();
77   - QJsonObject jsonresult = OCacicComm->comm("/ws/neo/test", &ok, as);
78   - // if(jsonresult.contains("error")){
79   - // return false;
80   - // }
  82 + QJsonObject jsonresult = OCacicComm->comm("/ws/neo/getTest", &ok, as, false);
  83 + if(!ok){
  84 + jsonresult = OCacicComm->comm("/ws/neo/getTest", &ok, as, false); // mais uma vez pra garantir.
  85 + }
  86 + if(jsonresult.contains("error")){
  87 + return false;
  88 + }
81 89 try{
82 90 ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult,
83 91 this->applicationDirPath + "/getTest.json");
... ... @@ -97,10 +105,13 @@ bool CacicTimer::getConfig(){
97 105 bool ok;
98 106 QJsonObject as;
99 107 as["computador"] = OCacic_Computer.toJsonObject();
100   - QJsonObject jsonresult = OCacicComm->comm("/ws/neo/config", &ok, as);
101   - // if(jsonresult.contains("error")){
102   - // return false;
103   - // }
  108 + QJsonObject jsonresult = OCacicComm->comm("/ws/neo/config", &ok, as, false);
  109 + if(!ok){
  110 + jsonresult = OCacicComm->comm("/ws/neo/config", &ok, as, false); // mais uma vez pra garantir.
  111 + }
  112 + if(jsonresult.contains("error")){
  113 + return false;
  114 + }
104 115 try{
105 116 ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult,
106 117 this->applicationDirPath + "/getConfigNew.json");
... ... @@ -182,7 +193,6 @@ void CacicTimer::iniciarModulo(QString modulo)
182 193 if((proc.atEnd()) && (proc.exitStatus() == QProcess::NormalExit)){
183 194 registraFimColeta("SUCESSO");
184 195 }else{
185   - proc.waitForFinished(120000);
186 196 if((!proc.atEnd()) || (proc.exitStatus() == QProcess::CrashExit)){
187 197 registraFimColeta("ERRO");
188 198 proc.kill();
... ... @@ -221,7 +231,8 @@ void CacicTimer::iniciarInstancias(){
221 231 timer = new QTimer(this);
222 232 cMutex = new QMutex(QMutex::Recursive);
223 233 OCacicComm = new CacicComm();
224   - OCacicComm->setUrlSsl("https://10.1.0.137/cacic/web/app_dev.php");
  234 + OCacicComm->setUrlSsl("https://teste.cacic.cc");
  235 + OCacicComm->setUrlGerente("teste.cacic.cc");
225 236 OCacicComm->setUsuario("cacic");
226 237 OCacicComm->setPassword("cacic123");
227 238 }
... ... @@ -230,11 +241,10 @@ void CacicTimer::verificarPeriodicidadeJson()
230 241 {
231 242 QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json");
232 243 if(!result.contains("error") && !result.isEmpty()){
233   -
234 244 QJsonObject agenteConfigJson = result["agentcomputer"].toObject();
235 245 QJsonObject configuracoes = agenteConfigJson["configuracoes"].toObject();
236   - if(getPeriodicidadeExecucao() != configuracoes["nu_intervalo_exec"].toInt()){
237   - setPeriodicidadeExecucao(configuracoes["nu_intervalo_exec"].toInt() * 3600);
  246 + if(getPeriodicidadeExecucao() != configuracoes["nu_intervalo_exec"].toString().toInt()){
  247 + setPeriodicidadeExecucao(configuracoes["nu_intervalo_exec"].toString().toInt() * 60000);
238 248 reiniciarTimer();
239 249 }
240 250 }else{
... ...
gercols/gercols.pro
... ... @@ -57,5 +57,3 @@ INCLUDEPATH += ../src \
57 57 ../src/crypto++/include/
58 58  
59 59 DEFINES += STATIC
60   - message("Static build.")
61   -}
... ...
src/cacic_comm.cpp
... ... @@ -44,7 +44,8 @@ QJsonObject CacicComm::comm(QString route, bool *ok, const QJsonObject &amp;json, bo
44 44 }
45 45 req.setSslConfiguration(QSslConfiguration::defaultConfiguration());
46 46 } else
47   - url = "http://" + urlGerente + route;
  47 + url = "http://" + this->urlGerente + route;
  48 +
48 49 req.setUrl(url);
49 50 req.setHeader(QNetworkRequest::LocationHeader, "Cacic Agente");
50 51 if (json.empty()){
... ...
src/ccacic.h
... ... @@ -17,10 +17,6 @@
17 17 #include "../src/crypto++/include/aes.h"
18 18 #include "../src/crypto++/include/base64.h"
19 19 #include "../src/crypto++/include/modes.h"
20   -//#include <filters.h>
21   -//#include <hex.h>
22   -//#include <sha.h>
23   -//#include <md5.h>
24 20  
25 21 class CCacic
26 22 {
... ...