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, ...@@ -668,4 +668,95 @@ int Rpc_GetCalculationState(int server_index,
return res; 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); ...@@ -121,4 +121,13 @@ int Rpc_GetLastError(int server_index, const char* &result, int timeout);
const char* &message, const char* &message,
int timeout); 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 #endif // RDKQTCPCLIENTLIB_H
...@@ -827,23 +827,25 @@ DeploymentState UProjectResultsUploadingThread::GetUploadState() ...@@ -827,23 +827,25 @@ DeploymentState UProjectResultsUploadingThread::GetUploadState()
void UProjectResultsUploadingThread::run() void UProjectResultsUploadingThread::run()
{ {
uploadState = DS_CopyResults;
if(!CopyResultsToDestinationDir()) if(!CopyResultsToDestinationDir())
{ {
uploadState = DS_Error; uploadState = DS_Error;
return; return;
} }
uploadState = DS_PackResults;
if(!ZipResults()) if(!ZipResults())
{ {
uploadState = DS_Error; uploadState = DS_Error;
return; return;
} }
uploadState = DS_UploadResults;
if(!UploadResultsViaFtp()) if(!UploadResultsViaFtp())
{ {
uploadState = DS_Error; uploadState = DS_Error;
return; return;
} }
uploadState = DS_UploadFinished;
} }
bool UProjectResultsUploadingThread::CopyResultsToDestinationDir() bool UProjectResultsUploadingThread::CopyResultsToDestinationDir()
...@@ -2070,6 +2072,12 @@ bool UProjectDeployerQt::UploadCalculationResults() ...@@ -2070,6 +2072,12 @@ bool UProjectDeployerQt::UploadCalculationResults()
QDir results_dir(results_dir_path); QDir results_dir(results_dir_path);
QString results_path=""; QString results_path="";
if(deploymentState>=DS_DeployFinished)
{
lastError = "Upload finished already";
return false;
}
if(results_dir.exists()) if(results_dir.exists())
{ {
QStringList rd_contents = results_dir.entryList(QDir::Filter::NoDotAndDotDot); QStringList rd_contents = results_dir.entryList(QDir::Filter::NoDotAndDotDot);
...@@ -2115,23 +2123,61 @@ bool UProjectDeployerQt::UploadCalculationResults() ...@@ -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 else
{ {
lastError = "Upload skipped";
deploymentState = DS_UploadFinished; deploymentState = DS_UploadFinished;
} }
} }
else else
{ {
lastError = "Upload skipped";
deploymentState = DS_UploadFinished; deploymentState = DS_UploadFinished;
} }
return true;
} }
/// , /// ,
/// , .. /// , ..
bool UProjectDeployerQt::CloseSolver() 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 }//namespace RDK
...@@ -390,6 +390,8 @@ virtual bool UploadCalculationResults(); ...@@ -390,6 +390,8 @@ virtual bool UploadCalculationResults();
/// , /// ,
/// , .. /// , ..
virtual bool CloseSolver(); virtual bool CloseSolver();
///
virtual int GetUploadState();
public: // public: //
......
...@@ -109,6 +109,8 @@ virtual bool UploadCalculationResults() {return false;}; ...@@ -109,6 +109,8 @@ virtual bool UploadCalculationResults() {return false;};
/// , /// ,
/// , .. /// , ..
virtual bool CloseSolver() {return false;}; virtual bool CloseSolver() {return false;};
///
virtual int GetUploadState(){return -1;};
// -------------------------- // --------------------------
......
...@@ -182,6 +182,26 @@ bool URpcDecoderCommon::IsCmdSupported(const UEPtr<URpcCommand> &command) const ...@@ -182,6 +182,26 @@ bool URpcDecoderCommon::IsCmdSupported(const UEPtr<URpcCommand> &command) const
} }
else else
if(cmd == "GetCalculationState") if(cmd == "GetCalculationState")
{
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; return true;
} }
...@@ -518,6 +538,46 @@ const char* URpcDecoderCommon::RemoteCall(const char *request, int &return_value ...@@ -518,6 +538,46 @@ const char* URpcDecoderCommon::RemoteCall(const char *request, int &return_value
response = res_ss.str(); response = res_ss.str();
return_value=0; 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(); 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