From f5e3a3a6785cd9305c476eadf329c8ae00161add Mon Sep 17 00:00:00 2001
From: w1146869587 <wah1146869587@126.com>
Date: 星期二, 09 十一月 2021 17:24:14 +0800
Subject: [PATCH] watch db

---
 mbwatch/mbtasklog.cpp |   78 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 1 deletions(-)

diff --git a/mbwatch/mbtasklog.cpp b/mbwatch/mbtasklog.cpp
index 02adc5a..007b50b 100644
--- a/mbwatch/mbtasklog.cpp
+++ b/mbwatch/mbtasklog.cpp
@@ -1,18 +1,92 @@
 #include "mbtasklog.h"
 #include <QMutex>
+#include <QDir>
+#include "mbfileutil.h"
+
 
 CMBTaskLog::CMBTaskLog()
 {
-
+    m_pMdWare = NULL;
+    m_pWatchDb = new CMBWatchDb();
 }
 
 CMBTaskLog::~CMBTaskLog()
 {
+    if( m_pWatchDb ){
+        delete m_pWatchDb;
+        m_pWatchDb = NULL;
+    }
 }
 
+void CMBTaskLog::set(QString logDbPath, QString backupDir, QString svrPath)
+{
+    m_logDbPath = logDbPath;
+    m_backupDir = backupDir;
+    m_svrPath = svrPath;
+}
+
+void CMBTaskLog::setMdWare(CMBMdware *pMdWare)
+{
+    m_pMdWare = pMdWare;
+}
+
+// 鏌ユ壘鏂囦欢
+bool CMBTaskLog::findFile(const QString &path,QString &errInfo)
+{
+    int i = 0;
+    bool bIsDir = false;
+
+    QDir dir(path);
+
+    if(!dir.exists())
+    {
+        return false;
+    }
+
+    dir.setFilter(QDir::Dirs | QDir::Files);
+    dir.setSorting(QDir::DirsFirst);//鏂囦欢澶规帓鍦ㄥ墠闈�+    QFileInfoList list = dir.entryInfoList();
+
+    do
+    {
+        QFileInfo fileInfo = list.at(i);
+        if(fileInfo.fileName() == "." | fileInfo.fileName() == "..")
+        {
+            ++i;
+            continue;
+        }
+        bIsDir = fileInfo.isDir();
+        if(bIsDir)
+        {
+            if(!findFile(fileInfo.filePath(),errInfo))
+                return false;
+        }
+        else
+        {
+            QString  fileName    = fileInfo.absoluteFilePath();
+            QString  svrPath     = CMBFileUtil::genSvrPath(m_backupDir,fileName, m_svrPath);
+            QString  lastMdfTime = CMBFileUtil::lastModifiedTime(fileName);
+            m_pWatchDb->insertBackupDirDB(fileName,"",svrPath,lastMdfTime);
+        }
+        ++i;
+    }while(i < list.size());
+
+
+    return true;
+}
 
 void CMBTaskLog::run()
 {
+    QString errInfo;
+    if(!m_pWatchDb->init(m_logDbPath,errInfo)){
+        emit m_pMdWare->sigErrInfo(errInfo);
+        return ;
+    }
+    // 閬嶅巻鏂囦欢澶�澶囦唤鏂囦欢澶�+    if(!findFile(m_backupDir,errInfo)){
+        emit m_pMdWare->sigErrInfo(errInfo);
+        return ;
+    }
 
 }
 
@@ -21,3 +95,5 @@
 
 
 
+
+

--
Gitblit v1.9.1