mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Передача больших файлов xml с задачами кусками
This commit is contained in:
@@ -276,6 +276,86 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
case TYPE_XMLANSWER_QUERY_TASKS_AMM_FOR_TRAINEE:
|
||||
case TYPE_XMLANSWER_QUERY_TASKS_FIM_FOR_TRAINEE:
|
||||
{
|
||||
//ПОЛУЧЕНИЕ РАЗМЕРА ФАЙЛА
|
||||
forever
|
||||
{
|
||||
stream.startTransaction();
|
||||
stream >> fileSize;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: fileSize - FAIL commitTransaction");
|
||||
|
||||
if (!socket->waitForReadyRead(TCP_READ_TIMEOUT)) {
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: ERROR! readyRead timeout - fileSize!!!");
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
emit sigSendDebugLog("CLIENT: filesize: " + QString::number(fileSize));
|
||||
|
||||
socket->waitForReadyRead(100);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//ПОЛУЧЕНИЕ САМОГО ФАЙЛА
|
||||
emit sigSendDebugLog(Tools::getTime() + "AfterRead size and path BytesAvailable: " + socket->bytesAvailable());
|
||||
|
||||
QByteArray array;
|
||||
|
||||
forever
|
||||
{
|
||||
stream.startTransaction();
|
||||
stream >> tmpBlock;
|
||||
|
||||
if(!stream.commitTransaction()){
|
||||
|
||||
if(socket->state() == QAbstractSocket::UnconnectedState){
|
||||
emit sigSocketDisabled();
|
||||
return;
|
||||
}
|
||||
if(socket->waitForReadyRead(TCP_READ_TIMEOUT)){
|
||||
continue;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
array.append(tmpBlock);
|
||||
|
||||
emit sigSendDebugLog(Tools::getTime() + "CLIENT: toFile :" + array.size());
|
||||
|
||||
sizeReceiveData += array.size();
|
||||
countSend++;
|
||||
|
||||
tmpBlock.clear();
|
||||
|
||||
if(sizeReceiveData == fileSize){
|
||||
emit sigSendDebugLog(Tools::getTime() + "FINAL Count send: " + QString::number(countSend));
|
||||
emit sigSendDebugLog(Tools::getTime() + "FINAL Size received: " + QString::number(sizeReceiveData));
|
||||
emit sigSendDebugLog(Tools::getTime() + "FINAL File size" + QString::number(fileSize));
|
||||
emit sigUpdateBytesAvailable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
emit sigSendDebugLog(Tools::getTime() + "File loaded");
|
||||
|
||||
//ОЧИСТКА ПОСЛЕ ПЕРЕДАЧИ
|
||||
fileSize = 0;
|
||||
tmpBlock.clear();
|
||||
sizeReceiveData = 0;
|
||||
countSend = 0;
|
||||
|
||||
xmlParserQueryToDB(packetType, array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
QByteArray array;
|
||||
stream.startTransaction();
|
||||
stream >> array;
|
||||
@@ -286,6 +366,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
|
||||
xmlParserQueryToDB(packetType, array);
|
||||
|
||||
packetType = PacketType::TYPE_NONE;
|
||||
*/
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
||||
@@ -41,13 +41,13 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeList ty
|
||||
connect(this, &AMMtasksWidget::signal_prepareListItemsForTrainee, taskTreePreparation, &TaskTreePreparation::slot_prepareListItemsForTrainee);
|
||||
connect(taskTreePreparation, &TaskTreePreparation::signal_listItemsReady, this, &AMMtasksWidget::slot_listItemsReady);
|
||||
|
||||
threadAnimation = new QThread();
|
||||
//threadAnimation = new QThread();
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
waitAnimationWidget->moveToThread(threadAnimation);
|
||||
threadAnimation->start();
|
||||
//waitAnimationWidget->moveToThread(threadAnimation);
|
||||
//threadAnimation->start();
|
||||
|
||||
ui->btnDelete->setObjectName("btnDelete");
|
||||
ui->btnDelete->setEnabled(false);
|
||||
@@ -84,13 +84,13 @@ AMMtasksWidget::~AMMtasksWidget()
|
||||
waitAnimationWidget->hideWithStop();
|
||||
taskTreePreparation->stopParser();
|
||||
|
||||
threadAnimation->quit();
|
||||
threadAnimation->wait();
|
||||
//threadAnimation->quit();
|
||||
//threadAnimation->wait();
|
||||
|
||||
threadPreparation->quit();
|
||||
threadPreparation->wait();
|
||||
|
||||
delete threadAnimation;
|
||||
//delete threadAnimation;
|
||||
delete threadPreparation;
|
||||
|
||||
delete taskTreePreparation;
|
||||
@@ -374,5 +374,6 @@ void AMMtasksWidget::on_btnCheck_clicked()
|
||||
|
||||
void AMMtasksWidget::on_btnAssignTask_clicked()
|
||||
{
|
||||
assignTaskAMMtoTrainee();
|
||||
if(QMessageBox::question(this, tr("New task"), tr("Assign this task?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
assignTaskAMMtoTrainee();
|
||||
}
|
||||
|
||||
@@ -33,13 +33,13 @@ FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeList ty
|
||||
|
||||
preparationTreeWidget();
|
||||
|
||||
threadAnimation = new QThread();
|
||||
//threadAnimation = new QThread();
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
waitAnimationWidget->moveToThread(threadAnimation);
|
||||
threadAnimation->start();
|
||||
//waitAnimationWidget->moveToThread(threadAnimation);
|
||||
//threadAnimation->start();
|
||||
|
||||
ui->btnDelete->setObjectName("btnDelete");
|
||||
ui->btnDelete->setEnabled(false);
|
||||
@@ -80,10 +80,10 @@ FIMtasksWidget::~FIMtasksWidget()
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
|
||||
threadAnimation->quit();
|
||||
threadAnimation->wait();
|
||||
//threadAnimation->quit();
|
||||
//threadAnimation->wait();
|
||||
|
||||
delete threadAnimation;
|
||||
//delete threadAnimation;
|
||||
|
||||
delete waitAnimationWidget;
|
||||
delete treeWidget;
|
||||
@@ -565,5 +565,6 @@ void FIMtasksWidget::on_btnCheck_clicked()
|
||||
|
||||
void FIMtasksWidget::on_btnAssignTask_clicked()
|
||||
{
|
||||
assignTaskFIMtoTrainee();
|
||||
if(QMessageBox::question(this, tr("New task"), tr("Assign this task?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
|
||||
assignTaskFIMtoTrainee();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user