|
|
|
@ -64,9 +64,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFile>
|
|
|
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// 清空指定目录下的所有旧文件和子目录,但保留目录本身
|
|
|
|
|
|
|
|
bool clearDirectoryContents(const QString& dirPath)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(dirPath.trimmed().isEmpty()) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QDir dir(dirPath);
|
|
|
|
|
|
|
|
if(dir.isRoot()) {
|
|
|
|
|
|
|
|
qDebug() << QString("Refuse to clear root directory: %1").arg(dirPath);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!dir.exists()) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfoList entries = dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries | QDir::Hidden | QDir::System);
|
|
|
|
|
|
|
|
for(int i = 0; i < entries.size(); ++i) {
|
|
|
|
|
|
|
|
const QFileInfo& entry = entries.at(i);
|
|
|
|
|
|
|
|
bool bRemoved = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(entry.isDir() && !entry.isSymLink()) {
|
|
|
|
|
|
|
|
bRemoved = clearDirectoryContents(entry.absoluteFilePath()) && dir.rmdir(entry.fileName());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
bRemoved = QFile::remove(entry.absoluteFilePath());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!bRemoved) {
|
|
|
|
|
|
|
|
qDebug() << QString("Failed to remove old result item: %1").arg(entry.absoluteFilePath());
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 多条PVT曲线都可能带压力横坐标,只保存第一次读到的有效横坐标
|
|
|
|
// 多条PVT曲线都可能带压力横坐标,只保存第一次读到的有效横坐标
|
|
|
|
void setPebiPressureIfEmpty(nmDataPvtParaForPebi* pPvtPara, const QVector<double>& vecX)
|
|
|
|
void setPebiPressureIfEmpty(nmDataPvtParaForPebi* pPvtPara, const QVector<double>& vecX)
|
|
|
|
@ -3306,6 +3344,14 @@ bool nmDataAnalyzeManager::saveNmResult(QString sRstCode, iSubWndFitting* pSubWn
|
|
|
|
if(pContextProvider == nullptr || !pContextProvider->getSaveResultDir(pSubWndF, sRstCode, sDir)) {
|
|
|
|
if(pContextProvider == nullptr || !pContextProvider->getSaveResultDir(pSubWndF, sRstCode, sDir)) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// sDir为当前成果窗口目录
|
|
|
|
|
|
|
|
// 保存前先清空成果ID目录下的旧内容,避免旧RstWnd目录或残留文件继续被加载
|
|
|
|
|
|
|
|
QString sResultRootPath = QFileInfo(sDir).dir().absolutePath();
|
|
|
|
|
|
|
|
if(!clearDirectoryContents(sResultRootPath)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QString sResultPath = sDir + "/Results";
|
|
|
|
QString sResultPath = sDir + "/Results";
|
|
|
|
this->ensureDirectoryExists(sResultPath);
|
|
|
|
this->ensureDirectoryExists(sResultPath);
|
|
|
|
// 将数据写入Json文件
|
|
|
|
// 将数据写入Json文件
|
|
|
|
|