mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 18:35:35 +08:00
Ref T554, writer parses publishing response and support PHP debug flag
This commit is contained in:
committed by
Mat Sutcliffe
parent
db0df3b00e
commit
eca5a36afd
@@ -116,11 +116,16 @@ namespace BlackCore
|
|||||||
multiPart->append(CDatabaseUtils::getJsonTextMultipart(json, compress));
|
multiPart->append(CDatabaseUtils::getJsonTextMultipart(json, compress));
|
||||||
if (sApp->getGlobalSetup().dbDebugFlag())
|
if (sApp->getGlobalSetup().dbDebugFlag())
|
||||||
{
|
{
|
||||||
|
// add debug flag
|
||||||
multiPart->append(CDatabaseUtils::getMultipartWithDebugFlag());
|
multiPart->append(CDatabaseUtils::getMultipartWithDebugFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
QUrl url(m_modelPublishUrl.toQUrl());
|
// QUrl url("https://192.168.0.153/service/publishauto.php");
|
||||||
if (compress) { url.setQuery(CDatabaseUtils::getCompressedQuery()); }
|
QUrl url(m_autoPublishUrl.toQUrl());
|
||||||
|
QUrlQuery query;
|
||||||
|
if (compress) { query = CDatabaseUtils::getCompressedQuery(); }
|
||||||
|
url.setQuery(query);
|
||||||
|
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
CNetworkUtils::ignoreSslVerification(request);
|
CNetworkUtils::ignoreSslVerification(request);
|
||||||
const int logId = m_writeLog.addPendingUrl(url);
|
const int logId = m_writeLog.addPendingUrl(url);
|
||||||
@@ -171,7 +176,9 @@ namespace BlackCore
|
|||||||
bool directWrite;
|
bool directWrite;
|
||||||
const bool sendingSuccessful = CDatastoreUtility::parseSwiftPublishResponse(responseData, modelsPublished, modelsSkipped, msgs, directWrite);
|
const bool sendingSuccessful = CDatastoreUtility::parseSwiftPublishResponse(responseData, modelsPublished, modelsSkipped, msgs, directWrite);
|
||||||
const int c = CDatabaseUtils::fillInMissingAircraftAndLiveryEntities(modelsPublished);
|
const int c = CDatabaseUtils::fillInMissingAircraftAndLiveryEntities(modelsPublished);
|
||||||
|
|
||||||
emit this->publishedModels(modelsPublished, modelsSkipped, msgs, sendingSuccessful, directWrite);
|
emit this->publishedModels(modelsPublished, modelsSkipped, msgs, sendingSuccessful, directWrite);
|
||||||
|
|
||||||
if (!modelsPublished.isEmpty())
|
if (!modelsPublished.isEmpty())
|
||||||
{
|
{
|
||||||
emit this->publishedModelsSimplified(modelsPublished, directWrite);
|
emit this->publishedModelsSimplified(modelsPublished, directWrite);
|
||||||
@@ -200,22 +207,23 @@ namespace BlackCore
|
|||||||
m_pendingAutoPublishReply = nullptr;
|
m_pendingAutoPublishReply = nullptr;
|
||||||
const QUrl url(nwReply->url());
|
const QUrl url(nwReply->url());
|
||||||
const QString urlString(url.toString());
|
const QString urlString(url.toString());
|
||||||
|
const QString responseData(nwReply->readAll().trimmed());
|
||||||
|
const QString error = nwReply->errorString();
|
||||||
|
nwReply->close(); // close asap
|
||||||
|
|
||||||
|
CStatusMessageList msgs;
|
||||||
|
const bool ok = CDatastoreUtility::parseAutoPublishResponse(responseData, msgs);
|
||||||
|
|
||||||
if (nwReply->error() == QNetworkReply::NoError)
|
if (nwReply->error() == QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
const QString responseData(nwReply->readAll().trimmed());
|
// no error
|
||||||
nwReply->close(); // close asap
|
|
||||||
if (responseData.isEmpty())
|
|
||||||
{
|
|
||||||
const CStatusMessageList msgs({CStatusMessage(cats, CStatusMessage::SeverityError, u"No response data from " % urlString)});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QString error = nwReply->errorString();
|
msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, u"HTTP error: " % error));
|
||||||
nwReply->close(); // close asap
|
|
||||||
const CStatusMessageList msgs({CStatusMessage(cats, CStatusMessage::SeverityError, u"HTTP error: " % error)});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit this->autoPublished(ok, urlString, msgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDatabaseWriter::killPendingModelReply()
|
bool CDatabaseWriter::killPendingModelReply()
|
||||||
@@ -251,7 +259,7 @@ namespace BlackCore
|
|||||||
QList<QByteArray> arrays;
|
QList<QByteArray> arrays;
|
||||||
while (pos < arrsize)
|
while (pos < arrsize)
|
||||||
{
|
{
|
||||||
QByteArray arr = data.mid(pos, size);
|
const QByteArray arr = data.mid(pos, size);
|
||||||
arrays << arr;
|
arrays << arr;
|
||||||
pos += arr.size();
|
pos += arr.size();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,9 @@ namespace BlackCore
|
|||||||
//! Published models, simplified version of publishedModels
|
//! Published models, simplified version of publishedModels
|
||||||
void publishedModelsSimplified(const BlackMisc::Simulation::CAircraftModelList &modelsPublished, bool directWrite);
|
void publishedModelsSimplified(const BlackMisc::Simulation::CAircraftModelList &modelsPublished, bool directWrite);
|
||||||
|
|
||||||
|
//! Auto publishing completed
|
||||||
|
void autoPublished(bool success, const QString &url, const BlackMisc::CStatusMessageList &msgs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BlackMisc::Network::CUrlLogList m_writeLog;
|
BlackMisc::Network::CUrlLogList m_writeLog;
|
||||||
BlackMisc::Network::CUrl m_modelPublishUrl; //!< model publishing
|
BlackMisc::Network::CUrl m_modelPublishUrl; //!< model publishing
|
||||||
|
|||||||
Reference in New Issue
Block a user