| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -10,11 +10,9 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				#pragma comment(lib, "Wininet.lib")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				Cigarette* cg;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//extern SyncQueue<_ExportDataInfo>* export_Data_Info_queue;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				extern SyncQueue<_XMLExportDataInfo>* export_XMLData_Info_queue;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				extern ConfPath g_conf_path;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				extern bool flag;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				//extern FtpManager ftpManager;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				ExportDataThread::ExportDataThread(QObject* parent) : QThread(parent)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -68,8 +66,6 @@ void ExportDataThread::start_work()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				void ExportDataThread::stop()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					b_quit = true;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					//_ExportDataInfo data;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					//export_Data_Info_queue->put(data);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					_XMLExportDataInfo data;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					export_XMLData_Info_queue->put(data);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					InternetCloseHandle(hftp);
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -225,8 +221,6 @@ int ExportDataThread::insertXMLNode(const char* xmlPath, _XMLExportDataInfo& dat
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				void ExportDataThread::run()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					while (!b_quit) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						//_ExportDataInfo element;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						//export_Data_Info_queue->take(element);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						_XMLExportDataInfo element;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						export_XMLData_Info_queue->take(element);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -237,38 +231,8 @@ void ExportDataThread::run()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							QString filePath = g_conf_path.config_path + "/" + xmlPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							sprintf(buf, filePath.toLocal8Bit().constData(), element.cameraId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							insertXMLNode(buf, element);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							QString remotePath = "/tmp1/" + xmlPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							QString remotePath = "/tmp/" + xmlPath;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							ConnectServer(filePath, remotePath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							QDateTime now_ts = QDateTime::currentDateTime();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							for (int index = 0; index < element.shotCounts; index++) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								// ÉÏ´«ALL
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								QString all_folder = g_conf_path.save_pics_path + "/ALL/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ now_ts.toString("yyyy-MM-dd") + "/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ QString::number(element.cameraId + 1) + "/" + QString::number(index + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								QString all_folder_remote = "./image/ALL/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ now_ts.toString("yyyy-MM-dd") + "/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ QString::number(element.cameraId + 1) + "/" + QString::number(index + 1) + "/";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								ConnectServer(all_folder, all_folder_remote);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								// ÉÏ´«ng
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								QString ng_folder = g_conf_path.save_pics_path + "/ng/" 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ now_ts.toString("yyyy-MM-dd") + "/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ QString::number(element.cameraId + 1) + "/" + QString::number(index + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								QString ng_folder_remote = "./image/ng/" 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ now_ts.toString("yyyy-MM-dd") + "/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ QString::number(element.cameraId + 1) + "/" + QString::number(index + 1) + "/";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								ConnectServer(ng_folder, ng_folder_remote);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								// ÉÏ´«ng_result
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								QString ng_result_folder = g_conf_path.save_pics_path + "/ng_result/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ now_ts.toString("yyyy-MM-dd") + "/" 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ QString::number(element.cameraId + 1) + "/" + QString::number(index + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								QString ng_result_folder_remote = "./image/ng_result/" 
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ now_ts.toString("yyyy-MM-dd") + "/"
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
									+ QString::number(element.cameraId + 1) + "/" + QString::number(index + 1) + "/";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								ConnectServer(ng_result_folder, ng_result_folder_remote);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -322,21 +286,22 @@ void ExportDataThread::ConnectServer(QString srcPath, QString destPath) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 上传文件源为一个文件
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if (size == 0) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						int pos = filePath.find_last_of('/');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						string destFileName = filePath.substr(pos + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						check_save_dir(remotePath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						int pos = remotePath.find_last_of('/');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						string destFileName = remotePath.substr(pos + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						string tempPath = remotePath.substr(0, pos + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						check_save_dir(tempPath);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						if (!FtpPutFileA(hftp, filePath.c_str(), destFileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							qDebug() << "ftp put file failed because" << dw;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 上传源为一个文件夹
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					else{
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						for (int i = 0; i < size; i++) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							string tempFilePath = files[i].c_str();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							string tempFilePath = (string(files[i]).erase(0, filePath.length() + 1)).c_str();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							// 获取上传路径中的文件名
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							int pos = tempFilePath.find_last_of('/');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							string destFileName = tempFilePath.substr(pos + 1);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							check_save_dir(remotePath + tempFilePath.substr(0,pos+1));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if(!FtpPutFileA(hftp, tempFilePath.c_str(), destFileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							check_save_dir(remotePath + tempFilePath.substr(0, pos + 1));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
							if(!FtpPutFileA(hftp, files[i].c_str(), destFileName.c_str(), FTP_TRANSFER_TYPE_BINARY, 0))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
								qDebug() << "ftp put files failed because " << dw;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -368,3 +333,41 @@ void ExportDataThread::GetFiles(string path, std::vector<string>& files) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						_findclose(hFile);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				BOOL ExportDataThread::FtpUploadPic(uchar *buffer, string remotePath) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DWORD dwBytesReturn = 0;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DWORD UploadDataSize = 0;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					BYTE* pUploadData = NULL;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					DWORD dwRet, bRet = 0;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					string tempFile = "temp.jpg";
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					HINTERNET hFtpFile = NULL;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					hFtpFile = FtpOpenFileA(hftp, remotePath.c_str(), GENERIC_WRITE, FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_RELOAD, NULL);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 打开文件
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					HANDLE hFile = CreateFileA(tempFile.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_ARCHIVE, NULL);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if (INVALID_HANDLE_VALUE == hFile) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						qDebug() << "CreateFile error because " << GetLastError();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						CloseHandle(hFile);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return FALSE;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					/// -> 以下的代码还未改好
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 获取文件大小
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					UploadDataSize = GetFileSize(hFile, NULL);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					pUploadData = new BYTE[UploadDataSize];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 读取文件到缓冲区
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					ReadFile(hFile, pUploadData, UploadDataSize, &dwRet, NULL);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					UploadDataSize = dwRet;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					// 开始上传数据
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					bRet = InternetWriteFile(hFtpFile, buffer, UploadDataSize, &dwBytesReturn);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					if (FALSE == bRet) {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						qDebug() << "InternetWirteFile error because " << GetLastError();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						delete[] buffer;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
						return FALSE;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					delete[] buffer;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					CloseHandle(hFile);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
					return TRUE;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				}
 |