这是一个用来监控本地文件夹变化的服务
w1146869587
2021-11-08 116970f499b5003852a9655a215456dfc2747b87
mbwatch.txt
5个文件已添加
3个文件已修改
139 ■■■■■ 已修改文件
bak/mbwatch.txt 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbfileutil.cpp 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbfileutil.h 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbwatch.pro 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbwatchapp.cpp 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbwatchapp.h 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbwatchmain.cpp 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
mbwatch/mbwatchmain.h 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
bak/mbwatch.txt
New file
@@ -0,0 +1,7 @@
CREATE TABLE TN_WATCH_USER (
    CN_S_LOGIN              VARCHAR( 128 )        NOT NULL,
    CN_S_SERVER_ID        VARCHAR( 128 )        NOT NULL,
    CN_S_BACKUP_DIR     VARCHAR( 512 )        NOT NULL,
    CN_S_SERVER_PATH   VARCHAR( 512 )        NOT NULL,
    primary key(CN_S_LOGIN,CN_S_SERVER_ID)
);
mbwatch/mbfileutil.cpp
New file
@@ -0,0 +1,23 @@
#include "mbfileutil.h"
#include <QFileInfo>
#include <QDateTime>
CMBFileUtil::CMBFileUtil()
{
}
CMBFileUtil::~CMBFileUtil()
{
}
QString CMBFileUtil::lastModifiedTime(QString fileName)
{
    QFileInfo fileInfo(fileName);
    QDateTime lastModifiedTime;
    lastModifiedTime = fileInfo.lastModified();
    QString strLastTime =  lastModifiedTime.toString("yyyy.MM.dd hh:mm:ss");
    return strLastTime;
}
mbwatch/mbfileutil.h
New file
@@ -0,0 +1,20 @@
#ifndef MBFILEUTIL_H
#define MBFILEUTIL_H
#include <QObject>
/**************************************************
*
*   文件工具(获取文件最后修改时间,so on)
*
***************************************************/
class CMBFileUtil
{
public:
    CMBFileUtil();
    ~CMBFileUtil();
public:
    static QString lastModifiedTime(QString fileName);
};
#endif // MBFILEUTIL_H
mbwatch/mbwatch.pro
@@ -13,7 +13,9 @@
SOURCES += \
        main.cpp \
        mbwatchapp.cpp
        mbfileutil.cpp \
        mbwatchapp.cpp \
        mbwatchmain.cpp
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
@@ -25,5 +27,7 @@
include(qtservice/qtservice.pri)
HEADERS += \
    mbwatchapp.h
    mbfileutil.h \
    mbwatchapp.h \
    mbwatchmain.h
mbwatch/mbwatchapp.cpp
@@ -1,5 +1,6 @@
#include "mbwatchapp.h"
#include "mbfileutil.h"
#include <QDebug>
CMBWatchApp::CMBWatchApp(int argc, char **argv)
: QtService<QCoreApplication>(argc, argv, "mbWatchDaemon")
@@ -14,22 +15,26 @@
}
// 开始
void CMBWatchApp::start()
{
    m_watchMain.start();
}
// 停止
void CMBWatchApp::stop()
{
    m_watchMain.stop();
}
// 暂停
void CMBWatchApp::pause()
{
    m_watchMain.pause();
}
// 恢复
void CMBWatchApp::resume()
{
    m_watchMain.resume();
}
mbwatch/mbwatchapp.h
@@ -2,6 +2,7 @@
#define MBWATCHAPP_H
#include <QCoreApplication>
#include "qtservice.h"
#include "mbwatchmain.h"
class CMBWatchApp : public QtService<QCoreApplication>
{
@@ -13,6 +14,8 @@
    virtual void stop();
    virtual void pause();
    virtual void resume();
private:
    CMBWatchMain  m_watchMain;
};
#endif // MBWATCHAPP_H
mbwatch/mbwatchmain.cpp
New file
@@ -0,0 +1,45 @@
#include "mbwatchmain.h"
// mb_watch_user.db
// TN_WATCH_USER
// CN_S_LOGIN       联合主键
// CN_S_SERVER_ID   联合主键
// CN_S_BACKUP_DIR
// CN_S_SERVER_PATH
// mb_watch_log_xxxx.db( xxx---> serverid login )
// CN_S_ID          唯一值,由 CN_S_FILE_NAME ---> md5化成
// CN_S_FILE_NAME
// CN_T_LAST_MODFIY
// mb_watch.db
// TN_ND_BACKUPDIR_FILE
CMBWatchMain::CMBWatchMain()
{
}
CMBWatchMain::~CMBWatchMain()
{
}
void CMBWatchMain::start()
{
}
void CMBWatchMain::stop()
{
}
void CMBWatchMain::pause()
{
}
void CMBWatchMain::resume()
{
}
mbwatch/mbwatchmain.h
New file
@@ -0,0 +1,18 @@
#ifndef MBWATCHMAIN_H
#define MBWATCHMAIN_H
#include <QObject>
class CMBWatchMain : public QObject
{
    Q_OBJECT
public:
    CMBWatchMain();
    ~CMBWatchMain();
public:
    void start();
    void stop();
    void pause();
    void resume();
};
#endif // MBWATCHMAIN_H