Commit 215812043974ebf84e85dfc60f7cb44814db4e94
1 parent
f6154e32
Exists in
master
concerto de bugs
Showing
5 changed files
with
43 additions
and
38 deletions
Show diff stats
cacic-daemon/cacicD/cacicd.cpp
@@ -38,14 +38,14 @@ void cacicD::start() { | @@ -38,14 +38,14 @@ void cacicD::start() { | ||
38 | QJsonObject agenteConfigJson = result["agentcomputer"].toObject(); | 38 | QJsonObject agenteConfigJson = result["agentcomputer"].toObject(); |
39 | QJsonObject configuracoes = agenteConfigJson["configuracoes"].toObject(); | 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 | Ocacictimer->iniciarTimer(); | 43 | Ocacictimer->iniciarTimer(); |
44 | }else{ | 44 | }else{ |
45 | //Iniciar com um timer default (4 horas), pra não ficar freezado pra sempre. | 45 | //Iniciar com um timer default (4 horas), pra não ficar freezado pra sempre. |
46 | QLogger::QLog_Error("Cacic Daemon", QString("Problemas com o arquivo getConfig.json")); | 46 | QLogger::QLog_Error("Cacic Daemon", QString("Problemas com o arquivo getConfig.json")); |
47 | QLogger::QLog_Info("Cacic Daemon", QString("Inicializando periodicidade de execução do serviço com tempo padrão.")); | 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 | Ocacictimer->iniciarTimer(); | 49 | Ocacictimer->iniciarTimer(); |
50 | } | 50 | } |
51 | }catch (...){ | 51 | }catch (...){ |
cacic-daemon/cacicD/cacictimer.cpp
@@ -29,6 +29,12 @@ void CacicTimer::iniciarTimer() | @@ -29,6 +29,12 @@ void CacicTimer::iniciarTimer() | ||
29 | void CacicTimer::mslot(){ | 29 | void CacicTimer::mslot(){ |
30 | try{ | 30 | try{ |
31 | verificarPeriodicidadeJson(); | 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 | }catch (...){ | 38 | }catch (...){ |
33 | QLogger::QLog_Info("Cacic Daemon (Timer)", QString("Não foi possivel verificar a periodicidade no getConfig.json")); | 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,21 +44,20 @@ void CacicTimer::mslot(){ | ||
38 | QLogger::QLog_Info("Cacic Daemon (Timer)", QString("getTeste() success.")); | 44 | QLogger::QLog_Info("Cacic Daemon (Timer)", QString("getTeste() success.")); |
39 | if(getConfig()){ | 45 | if(getConfig()){ |
40 | QLogger::QLog_Info("Cacic Daemon (Timer)", QString("getConfig() success.")); | 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 | }else{ | 61 | }else{ |
57 | qDebug() << "getConfig() failed. - " + QDateTime::currentDateTime().toLocalTime().toString(); | 62 | qDebug() << "getConfig() failed. - " + QDateTime::currentDateTime().toLocalTime().toString(); |
58 | QLogger::QLog_Error("Cacic Daemon (Timer)", "Falha na obtenção do arquivo de configuração."); | 63 | QLogger::QLog_Error("Cacic Daemon (Timer)", "Falha na obtenção do arquivo de configuração."); |
@@ -74,10 +79,13 @@ bool CacicTimer::getTest(){ | @@ -74,10 +79,13 @@ bool CacicTimer::getTest(){ | ||
74 | bool ok; | 79 | bool ok; |
75 | QJsonObject as; | 80 | QJsonObject as; |
76 | as["computador"] = OCacic_Computer.toJsonObject(); | 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 | try{ | 89 | try{ |
82 | ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, | 90 | ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, |
83 | this->applicationDirPath + "/getTest.json"); | 91 | this->applicationDirPath + "/getTest.json"); |
@@ -97,10 +105,13 @@ bool CacicTimer::getConfig(){ | @@ -97,10 +105,13 @@ bool CacicTimer::getConfig(){ | ||
97 | bool ok; | 105 | bool ok; |
98 | QJsonObject as; | 106 | QJsonObject as; |
99 | as["computador"] = OCacic_Computer.toJsonObject(); | 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 | try{ | 115 | try{ |
105 | ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, | 116 | ccacic->setJsonToFile(jsonresult.contains("reply") ? jsonresult["reply"].toObject() : jsonresult, |
106 | this->applicationDirPath + "/getConfigNew.json"); | 117 | this->applicationDirPath + "/getConfigNew.json"); |
@@ -182,7 +193,6 @@ void CacicTimer::iniciarModulo(QString modulo) | @@ -182,7 +193,6 @@ void CacicTimer::iniciarModulo(QString modulo) | ||
182 | if((proc.atEnd()) && (proc.exitStatus() == QProcess::NormalExit)){ | 193 | if((proc.atEnd()) && (proc.exitStatus() == QProcess::NormalExit)){ |
183 | registraFimColeta("SUCESSO"); | 194 | registraFimColeta("SUCESSO"); |
184 | }else{ | 195 | }else{ |
185 | - proc.waitForFinished(120000); | ||
186 | if((!proc.atEnd()) || (proc.exitStatus() == QProcess::CrashExit)){ | 196 | if((!proc.atEnd()) || (proc.exitStatus() == QProcess::CrashExit)){ |
187 | registraFimColeta("ERRO"); | 197 | registraFimColeta("ERRO"); |
188 | proc.kill(); | 198 | proc.kill(); |
@@ -221,7 +231,8 @@ void CacicTimer::iniciarInstancias(){ | @@ -221,7 +231,8 @@ void CacicTimer::iniciarInstancias(){ | ||
221 | timer = new QTimer(this); | 231 | timer = new QTimer(this); |
222 | cMutex = new QMutex(QMutex::Recursive); | 232 | cMutex = new QMutex(QMutex::Recursive); |
223 | OCacicComm = new CacicComm(); | 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 | OCacicComm->setUsuario("cacic"); | 236 | OCacicComm->setUsuario("cacic"); |
226 | OCacicComm->setPassword("cacic123"); | 237 | OCacicComm->setPassword("cacic123"); |
227 | } | 238 | } |
@@ -230,11 +241,10 @@ void CacicTimer::verificarPeriodicidadeJson() | @@ -230,11 +241,10 @@ void CacicTimer::verificarPeriodicidadeJson() | ||
230 | { | 241 | { |
231 | QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json"); | 242 | QJsonObject result = ccacic->getJsonFromFile(this->applicationDirPath + "/getConfig.json"); |
232 | if(!result.contains("error") && !result.isEmpty()){ | 243 | if(!result.contains("error") && !result.isEmpty()){ |
233 | - | ||
234 | QJsonObject agenteConfigJson = result["agentcomputer"].toObject(); | 244 | QJsonObject agenteConfigJson = result["agentcomputer"].toObject(); |
235 | QJsonObject configuracoes = agenteConfigJson["configuracoes"].toObject(); | 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 | reiniciarTimer(); | 248 | reiniciarTimer(); |
239 | } | 249 | } |
240 | }else{ | 250 | }else{ |
gercols/gercols.pro
src/cacic_comm.cpp
@@ -44,7 +44,8 @@ QJsonObject CacicComm::comm(QString route, bool *ok, const QJsonObject &json, bo | @@ -44,7 +44,8 @@ QJsonObject CacicComm::comm(QString route, bool *ok, const QJsonObject &json, bo | ||
44 | } | 44 | } |
45 | req.setSslConfiguration(QSslConfiguration::defaultConfiguration()); | 45 | req.setSslConfiguration(QSslConfiguration::defaultConfiguration()); |
46 | } else | 46 | } else |
47 | - url = "http://" + urlGerente + route; | 47 | + url = "http://" + this->urlGerente + route; |
48 | + | ||
48 | req.setUrl(url); | 49 | req.setUrl(url); |
49 | req.setHeader(QNetworkRequest::LocationHeader, "Cacic Agente"); | 50 | req.setHeader(QNetworkRequest::LocationHeader, "Cacic Agente"); |
50 | if (json.empty()){ | 51 | if (json.empty()){ |
src/ccacic.h
@@ -17,10 +17,6 @@ | @@ -17,10 +17,6 @@ | ||
17 | #include "../src/crypto++/include/aes.h" | 17 | #include "../src/crypto++/include/aes.h" |
18 | #include "../src/crypto++/include/base64.h" | 18 | #include "../src/crypto++/include/base64.h" |
19 | #include "../src/crypto++/include/modes.h" | 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 | class CCacic | 21 | class CCacic |
26 | { | 22 | { |