Commit 290433ff authored by Aivan_2008's avatar Aivan_2008
Browse files

Added functional project finalization/results uploading state

--HG--
branch : DeploymentQt
parent bdf40dbb4835
......@@ -668,4 +668,95 @@ int Rpc_GetCalculationState(int server_index,
return res;
}
int Rpc_FinishCalculation(int server_index, bool& result, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("FinishCalculation", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|");
if(spl.size()>=2)
{
result = spl[0].trimmed().toInt();
last_error = spl[1].toUtf8().constData();
}
}
return res;
}
int Rpc_UploadCalculationResults(int server_index, bool& result, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("UploadCalculationResults", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|");
if(spl.size()>=2)
{
result = spl[0].trimmed().toInt();
if(!result)
last_error = spl[1].toUtf8().constData();
}
}
return res;
}
int Rpc_GetUploadState(int server_index, int& upload_state, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("GetUploadState", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|");
if(spl.size()>=2)
{
upload_state = spl[0].trimmed().toInt();
last_error = spl[1].toUtf8().constData();
}
}
if(res)
return res;
}
int Rpc_CloseSolver(int server_index, bool& result, const char* &last_error, int timeout)
{
RDK::USerStorageXML request,response;
int res = ProcessSimpleCommand("CloseSolver", server_index, -1, timeout, request, response);
std::string res_string;
res_string=response.ReadString("Data", "").c_str();
if(res_string!="")
{
QString qs = res_string.c_str();
QStringList spl = qs.split("|");
if(spl.size()>=2)
{
result = spl[0].trimmed().toInt();
if(!result)
last_error = spl[1].toUtf8().constData();
}
}
return res;
}
......@@ -121,4 +121,13 @@ int Rpc_GetLastError(int server_index, const char* &result, int timeout);
const char* &message,
int timeout);
int Rpc_FinishCalculation(int server_index, bool& result, const char* &last_error, int timeout);
int Rpc_UploadCalculationResults(int server_index, bool& result, const char* &last_error, int timeout);
int Rpc_GetUploadState(int server_index, int& upload_state, const char* &last_error, int timeout);
int Rpc_CloseSolver(int server_index, bool& result, const char* &last_error, int timeout);
#endif // RDKQTCPCLIENTLIB_H
......@@ -827,23 +827,25 @@ DeploymentState UProjectResultsUploadingThread::GetUploadState()
void UProjectResultsUploadingThread::run()
{
uploadState = DS_CopyResults;
if(!CopyResultsToDestinationDir())
{
uploadState = DS_Error;
return;
}
uploadState = DS_PackResults;
if(!ZipResults())
{
uploadState = DS_Error;
return;
}
uploadState = DS_UploadResults;
if(!UploadResultsViaFtp())
{
uploadState = DS_Error;
return;
}
uploadState = DS_UploadFinished;
}
bool UProjectResultsUploadingThread::CopyResultsToDestinationDir()
......@@ -2070,6 +2072,12 @@ bool UProjectDeployerQt::UploadCalculationResults()
QDir results_dir(results_dir_path);
QString results_path="";
if(deploymentState>=DS_DeployFinished)
{
lastError = "Upload finished already";
return false;
}
if(results_dir.exists())
{
QStringList rd_contents = results_dir.entryList(QDir::Filter::NoDotAndDotDot);
......@@ -2115,23 +2123,61 @@ bool UProjectDeployerQt::UploadCalculationResults()
//
// (?)
//
if(projectResultsUploadingThread!=NULL)
{
delete projectResultsUploadingThread;
}
projectResultsUploadingThread = new UProjectResultsUploadingThread();
projectResultsUploadingThread->SetDatabasePath(db_path);
projectResultsUploadingThread->SetRemoteFtpPath(QString(ftp_remote_path.c_str()));
projectResultsUploadingThread->SetStorageResultsDirPath(results_dir_path);
projectResultsUploadingThread->SetStorageResultsDirPath(relative_results_destination_dir_path);
projectResultsUploadingThread->start();
lastError = "Upload started";
}
else
{
lastError = "Upload skipped";
deploymentState = DS_UploadFinished;
}
}
else
{
lastError = "Upload skipped";
deploymentState = DS_UploadFinished;
}
return true;
}
/// ,
/// , ..
bool UProjectDeployerQt::CloseSolver()
{
return true;
}
///
int UProjectDeployerQt::GetUploadState()
{
if(projectResultsUploadingThread!=NULL)
{
if(projectResultsUploadingThread->isRunning())
{
int upl_state = projectResultsUploadingThread->GetUploadState();
this->lastError = std::string("Upload thread LE: ")+projectResultsUploadingThread->GetLastError().toUtf8().constData();
return upl_state;
}
else if(projectResultsUploadingThread->isFinished())
{
return DS_UploadFinished;
}
}
else
{
//
//
return deploymentState;
}
}
}//namespace RDK
......@@ -390,6 +390,8 @@ virtual bool UploadCalculationResults();
/// ,
/// , ..
virtual bool CloseSolver();
///
virtual int GetUploadState();
public: //
......
......@@ -109,6 +109,8 @@ virtual bool UploadCalculationResults() {return false;};
/// ,
/// , ..
virtual bool CloseSolver() {return false;};
///
virtual int GetUploadState(){return -1;};
// --------------------------
......
......@@ -186,6 +186,26 @@ bool URpcDecoderCommon::IsCmdSupported(const UEPtr<URpcCommand> &command) const
return true;
}
else
if(cmd == "FinishCalculation")
{
return true;
}
else
if(cmd == "UploadCalculationResults")
{
return true;
}
else
if(cmd == "GetUploadState")
{
return true;
}
else
if(cmd == "CloseSolver")
{
return true;
}
else
if(cmd == "StopVideoSource")
return true;
......@@ -518,6 +538,46 @@ const char* URpcDecoderCommon::RemoteCall(const char *request, int &return_value
response = res_ss.str();
return_value=0;
}
else
if(cmd=="FinishCalculation")
{
bool rs = GetApplication()->GetProjectDeployer()->FinishCalculation();
std::string le = GetApplication()->GetProjectDeployer()->GetLastError();
std::stringstream ss;
ss<<rs<<"|"<<le;
response = ss.str();
return_value=0;
}
else
if(cmd=="UploadCalculationResults")
{
bool rs = GetApplication()->GetProjectDeployer()->UploadCalculationResults();
std::string le = GetApplication()->GetProjectDeployer()->GetLastError();
std::stringstream ss;
ss<<rs<<"|"<<le;
response = ss.str();
return_value=0;
}
else
if(cmd=="GetUploadState")
{
int us = GetApplication()->GetProjectDeployer()->GetUploadState();
std::string le = GetApplication()->GetProjectDeployer()->GetLastError();
std::stringstream ss;
ss<<us<<"|"<<le;
response = ss.str();
return_value=0;
}
else
if(cmd=="CloseSolver")
{
bool rs = GetApplication()->GetProjectDeployer()->CloseSolver();
std::string le = GetApplication()->GetProjectDeployer()->GetLastError();
std::stringstream ss;
ss<<rs<<"|"<<le;
response = ss.str();
return_value=0;
}
}
result.SelectRoot();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment