|
@@ -330,6 +330,21 @@ void ResourceWatcherFSM::TriggerProccessUpload()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+void ResourceWatcherFSM::TriggerFileListUpload()
|
|
|
+{
|
|
|
+ CSmartPointer<IConfigInfo> spCtSettingConfig;
|
|
|
+ GetEntityBase()->GetFunction()->OpenConfig(Config_CenterSetting, spCtSettingConfig);
|
|
|
+ //集中配置读取需要上送的路径
|
|
|
+ CSimpleStringA fileListPath("");
|
|
|
+ spCtSettingConfig->ReadConfigValue(m_pEntity->GetEntityName(), "DirPathToUploadFileList", fileListPath);
|
|
|
+ if (!fileListPath.IsNullOrEmpty())
|
|
|
+ {
|
|
|
+ m_fileListPath = fileListPath.Split('|');
|
|
|
+ UploadDirPathFileListTask* uploadFileListTask = new UploadDirPathFileListTask(this);
|
|
|
+ GetEntityBase()->GetFunction()->PostThreadPoolTask(uploadFileListTask);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
ErrorCodeEnum ResourceWatcherFSM::OnInit()
|
|
|
{
|
|
|
neverMainPage = true; //是否未进入过首页
|
|
@@ -4890,7 +4905,7 @@ void ResourceWatcherFSM::ConfirmWindowEffectHasBeenOpen()
|
|
|
}
|
|
|
#endif // RVC_OS_LINUX
|
|
|
|
|
|
-void ResourceWatcherFSM::GetSystemProccess()
|
|
|
+void ResourceWatcherFSM::UploadSystemProccess()
|
|
|
{
|
|
|
if(processName.empty())
|
|
|
{
|
|
@@ -4933,4 +4948,139 @@ void ResourceWatcherFSM::GetSystemProccess()
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+void ResourceWatcherFSM::UploadDirPathFileList(CSimpleStringA dirFilePath)
|
|
|
+{
|
|
|
+ CSimpleStringA realPath(true);
|
|
|
+ int res = ExpandDir(dirFilePath, realPath);
|
|
|
+ switch (res)
|
|
|
+ {
|
|
|
+ case -1: //映射无效,使用原数据
|
|
|
+ {
|
|
|
+ realPath = dirFilePath;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case -2: //GetPath映射错误,ExpandDir有报错,这里就不报了
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ DWORD attrs = GetFileAttributesA(realPath);
|
|
|
+ if (attrs == INVALID_FILE_ATTRIBUTES)
|
|
|
+ {
|
|
|
+ const DWORD lastError = GetLastError();
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A15")("Acess to path error:[%s], GLE = %u.", realPath.GetData(), lastError);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (!(attrs & FILE_ATTRIBUTE_DIRECTORY))
|
|
|
+ { //非文件夹类型
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA5A15")("Path [%s] is not Directory!", realPath.GetData());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ int len = 0;
|
|
|
+ vector<CSimpleStringA> fileList = GetFileListFromDirectory(realPath);
|
|
|
+ if (!fileList.empty())
|
|
|
+ {
|
|
|
+
|
|
|
+ string tPath = realPath.GetData();
|
|
|
+ string jsonPath;
|
|
|
+ for (char c : tPath) { //替换反斜杠
|
|
|
+ if (c == '\\') {
|
|
|
+ jsonPath += '\\';
|
|
|
+ jsonPath += '\\';
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ jsonPath += c;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ CSimpleStringA curListStr = "";
|
|
|
+ CSimpleStringA endStr = ",";
|
|
|
+ CSimpleStringA totalListStr = CSimpleStringA::Format("{\"path\":\"%s\", \"fileList\":[", jsonPath.c_str());
|
|
|
+
|
|
|
+ if (totalListStr.GetLength() > 1000)
|
|
|
+ {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Dir Path length over 1000!");
|
|
|
+ DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("%s", totalListStr.SubString(0, 1000));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < fileList.size(); i++)
|
|
|
+ {
|
|
|
+ curListStr = CSimpleStringA("\"") + fileList[i] + "\"";
|
|
|
+ len = totalListStr.GetLength() + curListStr.GetLength();
|
|
|
+ if (len > 1000 || i == (fileList.size() - 1))
|
|
|
+ {
|
|
|
+ endStr = "]}";
|
|
|
+ if (i == (fileList.size() - 1)) //最后一个
|
|
|
+ {
|
|
|
+ totalListStr = totalListStr + curListStr + endStr;
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetFileListFromDirectory")(totalListStr.GetData());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else //长度超限
|
|
|
+ {
|
|
|
+ totalListStr[totalListStr.GetLength() - 1] = ']';
|
|
|
+ totalListStr = totalListStr + "}";
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetFileListFromDirectory")(totalListStr.GetData());
|
|
|
+ totalListStr = CSimpleStringA::Format("{\"path\":\"%s\", \"fileList\":[", jsonPath.c_str()) + curListStr + ","; //超过长度则从当前进程开始重新搭建日志
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ endStr = ",";
|
|
|
+ totalListStr = totalListStr + curListStr + endStr;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+vector<CSimpleStringA> ResourceWatcherFSM::GetFileListFromDirectory(CSimpleStringA path)
|
|
|
+{
|
|
|
+ vector<CSimpleStringA> files;
|
|
|
+#ifdef _WIN32
|
|
|
+ WIN32_FIND_DATAA data;
|
|
|
+ HANDLE hFind;
|
|
|
+
|
|
|
+ CSimpleStringA searchPath = path + "\\*";
|
|
|
+ hFind = FindFirstFileA(searchPath.GetData(), &data);
|
|
|
+ if (hFind != INVALID_HANDLE_VALUE) {
|
|
|
+ do {
|
|
|
+ if (strcmp(data.cFileName, ".") == 0 || strcmp(data.cFileName, "..") == 0)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ files.push_back(data.cFileName);
|
|
|
+
|
|
|
+ if ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { //文件夹类型,只传文件夹名
|
|
|
+ CSimpleStringA fullPath = path + "\\" + data.cFileName;
|
|
|
+ UploadDirPathFileList(fullPath); //上送子文件夹下的文件列表
|
|
|
+ }
|
|
|
+ } while (FindNextFileA(hFind, &data) != 0);
|
|
|
+ FindClose(hFind);
|
|
|
+ }
|
|
|
+#else
|
|
|
+ DIR* dir = opendir(path.GetData());
|
|
|
+ if (!dir) return files;
|
|
|
+
|
|
|
+ struct dirent* entry;
|
|
|
+ while ((entry = readdir(dir)) != nullptr) {
|
|
|
+ if (CSimpleStringA(entry->d_name) == "." || CSimpleStringA(entry->d_name) == "..")
|
|
|
+ continue;
|
|
|
+
|
|
|
+ files.push_back(entry->d_name);
|
|
|
+
|
|
|
+ CSimpleStringA fullPath = path + "/" + entry->d_name;
|
|
|
+ DWORD attrs = GetFileAttributesA(fullPath);
|
|
|
+ if (attrs & FILE_ATTRIBUTE_DIRECTORY) { //文件夹类型,只传文件夹名
|
|
|
+ UploadDirPathFileList(fullPath); //上送子文件夹下的文件列表
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closedir(dir);
|
|
|
+#endif
|
|
|
+
|
|
|
+ return files;
|
|
|
}
|