59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include "downdrunable.h"
|
|
|
|
#if _MSC_VER >= 1600
|
|
#pragma execution_character_set("utf-8")
|
|
#endif
|
|
|
|
DownDrunable::DownDrunable
|
|
(const QString& name, QString url, QString path, QString time, QString key,double pos_x,double pos_y)
|
|
: name(name), path(path), time(time), key(key),pos_x(pos_x),pos_y(pos_y)
|
|
{
|
|
this->setAutoDelete(true);
|
|
cli = new MyClient(url.toStdString(), 80);
|
|
cli->set_timeout_sec(10);
|
|
cli->set_read_timeout(20, 20);
|
|
cli->set_keep_alive_max_count(10);
|
|
}
|
|
|
|
DownDrunable::~DownDrunable()
|
|
{
|
|
emit Log(now() + "\tdowload " + time + "_" + key + ".tif");
|
|
}
|
|
|
|
QString DownDrunable::now()
|
|
{
|
|
QDateTime current_date_time = QDateTime::currentDateTime();
|
|
return current_date_time.toString("yyyy_MM_dd_HH_mm_ss_zzz");
|
|
}
|
|
|
|
void DownDrunable::run()
|
|
{
|
|
QString ClearPath;
|
|
|
|
if((pos_x!= -1.0)||(pos_y!= -1.0))
|
|
{
|
|
QString tmp_pos = "_"+QString::number(int(pos_x))+"_"+QString::number(int(pos_y));
|
|
|
|
ClearPath = path + "/" + time + "_" +key + tmp_pos + ".tif";
|
|
}
|
|
else
|
|
ClearPath = path + "/" + time + "_" +key + ".tif";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
{
|
|
auto res = cli->Mget(name.toStdString().c_str());
|
|
cli->StoreFile(res->body, ClearPath.toStdString());
|
|
}
|
|
catch(MyException error)
|
|
{
|
|
emit Log(now() + "\t" + error.what());
|
|
}
|
|
emit DownloadFinsh(key.toInt());
|
|
emit ToShowIMG( ClearPath,key.toInt());
|
|
}
|