diff --git a/product/src/tools/setup/appendProductInfo/mainwindow.cpp b/product/src/tools/setup/appendProductInfo/mainwindow.cpp index 52ad92c6..44ab9932 100644 --- a/product/src/tools/setup/appendProductInfo/mainwindow.cpp +++ b/product/src/tools/setup/appendProductInfo/mainwindow.cpp @@ -7,7 +7,7 @@ #include #include -const char* magicString = "KBDCT"; +const char* magicString = "EMS60"; const int productInfoLength = 8; const int productBit = productInfoLength - 1 -1 ; const int isExclusiveBit = productInfoLength - 1 ; @@ -96,7 +96,7 @@ bool MainWindow::appendProductInfo(const QString & fileName) bool MainWindow::fillProductInfoFlag(char *productFlag, int length) { - //拷贝kbdct + //拷贝EMS60 memcpy(productFlag,magicString,6); if(ui->comboBox_productName->currentText() == "PSCADA") diff --git a/product/src/tools/setup/build_system_scripts/centos7_debug/checkDiskSpace.sh b/product/src/tools/setup/build_system_scripts/centos7_debug/checkDiskSpace.sh index b24e1048..153bc015 100644 --- a/product/src/tools/setup/build_system_scripts/centos7_debug/checkDiskSpace.sh +++ b/product/src/tools/setup/build_system_scripts/centos7_debug/checkDiskSpace.sh @@ -2,7 +2,7 @@ CURRENT=$(df / | grep / | awk '{ print $5}' | sed 's/%//g') THRESHOLD=90 if [ "$CURRENT" -gt "$THRESHOLD" ] ; then -mail -s 'Linux构建服务器磁盘空间剩余空间小于10%' -r 'Linux构建服务器 ' ganyuhang@kbdct.com zhouzhenglong@kbdct.com<< EOF +mail -s 'Linux构建服务器磁盘空间剩余空间小于10%' -r 'Linux构建服务器 ' user2@test.com user3@test.com<< EOF 服务器地址[192.168.79.70]磁盘剩余空间(root分区). 已使用: $CURRENT%,请及时清理/ptsa/iscs路径下过期文件 EOF fi diff --git a/product/src/tools/setup/build_system_scripts/windows10_debug/lowDiskSpaceAlert.ps1 b/product/src/tools/setup/build_system_scripts/windows10_debug/lowDiskSpaceAlert.ps1 index 6fe558db..068312d6 100644 --- a/product/src/tools/setup/build_system_scripts/windows10_debug/lowDiskSpaceAlert.ps1 +++ b/product/src/tools/setup/build_system_scripts/windows10_debug/lowDiskSpaceAlert.ps1 @@ -5,14 +5,14 @@ $drives = @("D"); $minSize = 20GB; # SMTP configuration: username, password & so on -$email_username = "no_reply_phabricator@kbdct.com"; -$email_password = "kbdct@101"; +$email_username = "user1@test.com"; +$email_password = "user1@101"; $email_smtp_host = "smtp.qiye.163.com"; $email_smtp_port = 25; $email_smtp_SSL = 0; -$email_from_address = "no_reply_phabricator@kbdct.com"; -$email_to_addressArray = @("ganyuhang@kbdct.com", "zhouzhenglong@kbdct.com"); -#$email_to_addressArray = @("ganyuhang@kbdct.com"); +$email_from_address = "user1@test.com"; +$email_to_addressArray = @("user2@test.com", "user3@test.com"); +#$email_to_addressArray = @("user2@test.com"); if ($drives -eq $null -Or $drives -lt 1) { diff --git a/product/src/tools/setup/mkenv/mkenv.pro b/product/src/tools/setup/mkenv/mkenv.pro index 4379d620..02aec3ff 100644 --- a/product/src/tools/setup/mkenv/mkenv.pro +++ b/product/src/tools/setup/mkenv/mkenv.pro @@ -1,13 +1,16 @@ include(../setup_common.pri) TEMPLATE = aux -SETUP_UNZIP_DIR = $$system_path($$SETUP_SRC_DIR/iscs6000_unzip) +SETUP_UNZIP_DIR = $$system_path($$SETUP_SRC_DIR/ems60_unzip) +SETUP_PDB_UNZIP_DIR = $$system_path($$SETUP_SRC_DIR/../ems60_pdb_unzip) win32:script_ex = bat linux:script_ex = sh SCRIPT_FILE = copy_src.$$script_ex win32: COPY_SRC_DIR += "if exist $$SETUP_UNZIP_DIR $$RMDIR $$SETUP_UNZIP_DIR " +win32: COPY_SRC_DIR += "if exist $$SETUP_PDB_UNZIP_DIR $$RMDIR $$SETUP_PDB_UNZIP_DIR " +win32: COPY_SRC_DIR += "$$QMAKE_MKDIR $$SETUP_PDB_UNZIP_DIR" linux: COPY_SRC_DIR += "if [ -d $$SETUP_UNZIP_DIR ]; then $$RMDIR $$SETUP_UNZIP_DIR; fi " @@ -15,16 +18,22 @@ COPY_SRC_DIR += \ "$$QMAKE_MKDIR $$SETUP_UNZIP_DIR" linux: COPY_SRC_DIR += "$$QMAKE_MKDIR $$SETUP_UNZIP_DIR/platform" linux: COPY_SRC_DIR += "$$QMAKE_MKDIR $$SETUP_UNZIP_DIR/product" +linux: COPY_SRC_DIR += "$$QMAKE_MKDIR $$SETUP_UNZIP_DIR/products" win32: COPY_SRC_DIR += "chcp 65001 " COPY_SRC_DIR += \ + "$$copyToDestDir($$ISCS6000_HOME/resource/,$$SETUP_UNZIP_DIR/resource) " \ "$$copyToDestDir($$ISCS6000_HOME/product/common/,$$SETUP_UNZIP_DIR/product/common) " \ "$$copyToDestDir($$ISCS6000_HOME/platform/common/,$$SETUP_UNZIP_DIR/platform/common) " \ "$$copyToDestDir($$ISCS6000_HOME/product/$$PLATFORM_DIR_NAME/,$$SETUP_UNZIP_DIR/product/$$PLATFORM_DIR_NAME) " \ "$$copyToDestDir($$ISCS6000_HOME/platform/$$PLATFORM_DIR_NAME/,$$SETUP_UNZIP_DIR/platform/$$PLATFORM_DIR_NAME) " \ - "$$copyToDestDir($$ISCS6000_HOME/products/,$$SETUP_UNZIP_DIR/products) " \ + "$$copyToDestDir($$ISCS6000_HOME/products/EMS/,$$SETUP_UNZIP_DIR/products/EMS) " \ "$$copyToDestDir($$ISCS6000_SUPPORT_DIR/,$$SETUP_UNZIP_DIR/support) " \ - "$$copyToDestDir($$ISCS6000_HOME/web/$$ISCS6000_OS/,$$SETUP_UNZIP_DIR/web) " \ + "$$copyToDestDir($$ISCS6000_HOME/setup_web/$$ISCS6000_OS/,$$SETUP_UNZIP_DIR/web) " "$$copyToDestDir($$ISCS6000_DOC_DIR/,$$SETUP_UNZIP_DIR/doc)" + +win32: COPY_SRC_DIR += \ + "$$copyPDBToDestDir($$ISCS6000_HOME/platform/$$PLATFORM_DIR_NAME,$$SETUP_PDB_UNZIP_DIR/platform/$$PLATFORM_DIR_NAME) " \ + "$$copyPDBToDestDir($$ISCS6000_HOME/product/$$PLATFORM_DIR_NAME,$$SETUP_PDB_UNZIP_DIR/product/$$PLATFORM_DIR_NAME) " win32: COPY_SRC_DIR += "IF %ERRORLEVEL% LEQ 1 exit /b 0 " write_file($$OUT_PWD/$$SCRIPT_FILE,COPY_SRC_DIR) linux { diff --git a/product/src/tools/setup/qrcGen/main.cpp b/product/src/tools/setup/qrcGen/main.cpp index 5174701b..a72421a2 100644 --- a/product/src/tools/setup/qrcGen/main.cpp +++ b/product/src/tools/setup/qrcGen/main.cpp @@ -1,11 +1,10 @@ -#include +#include #include #include #include #include #include - -#define EMPTY_DIR_FILENAME ".kbdct_installer" +#include "setup/CommonDef.h" bool createEmptyDirMsk(const QString &src_path) { @@ -24,7 +23,7 @@ bool createEmptyDirMsk(const QString &src_path) // 为空 if(QDir(it.filePath()).isEmpty()) { - QFile file(it.filePath() + QDir::separator() + EMPTY_DIR_FILENAME ); + QFile file(it.filePath() + QDir::separator() + g_pszEmptyDirFileName ); file.open(QIODevice::WriteOnly); // Or QIODevice::ReadWrite } } diff --git a/product/src/tools/setup/setup.pro b/product/src/tools/setup/setup.pro index a95a842c..2f1b0483 100644 --- a/product/src/tools/setup/setup.pro +++ b/product/src/tools/setup/setup.pro @@ -9,7 +9,8 @@ SUBDIRS += \ qrcGen \ setupConfigSet \ readVersion \ - mkenv + mkenv \ + setup_installer ISCS6000_PATCH=$$(ISCS6000_PATCH) diff --git a/product/src/tools/setup/setupConfigSet/main.cpp b/product/src/tools/setup/setupConfigSet/main.cpp index 0377cdca..52cd7f50 100644 --- a/product/src/tools/setup/setupConfigSet/main.cpp +++ b/product/src/tools/setup/setupConfigSet/main.cpp @@ -77,8 +77,7 @@ bool parseCommandline(QCoreApplication& app) // qDebug() << parser.value(jobid); qDebug() << parser.value(configPath); - //setConfig(parser.value(configPath),parser.value(revision)); - + setConfig(parser.value(configPath),parser.value(revision)); return true; } diff --git a/product/src/tools/setup/setup_common.pri b/product/src/tools/setup/setup_common.pri index 17c199eb..9af4978d 100644 --- a/product/src/tools/setup/setup_common.pri +++ b/product/src/tools/setup/setup_common.pri @@ -7,14 +7,16 @@ ISCS6000_DOC_DIR = $$(ISCS6000_DOC_DIR) ISCS6000_SUPPORT_DIR = $$(ISCS6000_SUPPORT_DIR) win32:QMAKE_STATIC_BIN = $$(QMAKE_STATIC_BIN) win32:JOM_BIN = $$(JOM_BIN) +CUSTOM_SVN_VERSION = "20240510" #注释掉此变量则会使用SVN版本号 ################################################ #=========================================================================================================================== -isEmpty(SETUP_DEBUG_RELEASE):SETUP_DEBUG_RELEASE = debug # 默认debug -isEmpty(ISCS6000_DOC_DIR):ISCS6000_DOC_DIR = $$clean_path($$SRC_ROOT_PATH/../../../ISCS6000文档/08用户文档) #文档目录,默认按照SVN路径来构建,可以手动指定目录 -isEmpty(ISCS6000_SUPPORT_DIR):ISCS6000_SUPPORT_DIR = $$clean_path($$SRC_ROOT_PATH/../../support) #support目录,默认SVN路径下,可以手动指定目录 -win32:isEmpty(QMAKE_STATIC_BIN):QMAKE_STATIC_BIN = $$clean_path(D:/qtstatic/bin/qmake.exe) #static qmake路径 -win32:isEmpty(JOM_BIN):JOM_BIN = $$clean_path(C:/Qt/Qt5.9.2/Tools/QtCreator/bin/jom.exe) +isEmpty(SETUP_DEBUG_RELEASE):SETUP_DEBUG_RELEASE = release # 默认debug +#isEmpty(ISCS6000_DOC_DIR):ISCS6000_DOC_DIR = $$clean_path($$SRC_ROOT_PATH/../../../ISCS6000文档/08用户文档) #文档目录,默认按照SVN路径来构建,可以手动指定目录 +isEmpty(ISCS6000_DOC_DIR):ISCS6000_DOC_DIR = $$clean_path($$SRC_ROOT_PATH/../../setup_doc) #文档目录,默认按照SVN路径来构建,可以手动指定目录 +isEmpty(ISCS6000_SUPPORT_DIR):ISCS6000_SUPPORT_DIR = $$clean_path($$SRC_ROOT_PATH/../../setup_support) #support目录,默认SVN路径下,可以手动指定目录 +win32:isEmpty(QMAKE_STATIC_BIN):QMAKE_STATIC_BIN = $$clean_path(G:/dev_tools/qt592static/bin/qmake.exe) #static qmake路径 +win32:isEmpty(JOM_BIN):JOM_BIN = $$clean_path(D:/dev_tool/Qt592/Tools/QtCreator/bin/jom.exe) #============================================================================================================================ ################################################################ @@ -41,11 +43,15 @@ win32:{ CONFIG(debug): error("please use release build configuration") #判定当前的编译配置为release版本 } DISTSUBNAME = _$${SETUP_DEBUG_RELEASE}_setup -SVNN = $$system("svn info --no-newline --show-item last-changed-revision ../../") -#SVNN = $$replace(SVNN,"M","") -#SVNN = $$replace(SVNN,"S","") -#SVNN = $$replace(SVNN,"P","") -#SVNN = $$section(SVNN, :, 0, 0) +SVNN = $$system("svnversion -n ..") +SVNN = $$replace(SVNN,"M","") +SVNN = $$replace(SVNN,"S","") +SVNN = $$replace(SVNN,"P","") +SVNN = $$section(SVNN, :, 0, 0) + +!isEmpty(CUSTOM_SVN_VERSION):SVNN = $$CUSTOM_SVN_VERSION +message("VERSION:" $$SVNN) + isEmpty(SVNN): error("svn revision number is empty!") isEmpty(SRC_ROOT_PATH):error("SRC_ROOT_PATH not found") isEmpty(ISCS6000_OS):error("ISCS6000_OS not found") @@ -57,6 +63,7 @@ SETUP_PATCH_DIR = $$system_path($$SETUP_DEST_DIR/patch) win32:{ RMDIR = $$QMAKE_DEL_DIR /s /q COPYFLAG = /E /NP /NS /NC /NFL /NDL /UNICODE /MT /XD .svn /XF *.exp *.lib *.pdb *.ilk + PDB_COPYFLAG = /NP /NS /NC /NFL /NDL /UNICODE /MT *.pdb COPYFILE = robocopy } @@ -82,5 +89,12 @@ defineReplace(copyToDestDir) { linux: return( $$COPYFILE $$COPYFLAG $$1 $$2 ) } +defineReplace(copyPDBToDestDir) { + src = $$1 + dst = $$2 + + win32: return( $$COPYFILE $$system_path($$1) $$system_path($$2) $$PDB_COPYFLAG ) +} + ISCS6000_HOME = $$clean_path($$SRC_ROOT_PATH/../../) diff --git a/product/src/tools/setup/setup_installer/CInstallWorker.cpp b/product/src/tools/setup/setup_installer/CInstallWorker.cpp index c0a72630..bd847fcb 100644 --- a/product/src/tools/setup/setup_installer/CInstallWorker.cpp +++ b/product/src/tools/setup/setup_installer/CInstallWorker.cpp @@ -3,9 +3,7 @@ #include #include #include - - -#define EMPTY_DIR_FILENAME ".kbdct_installer" +#include "setup/CommonDef.h" CInstallWorker::CInstallWorker(QObject *parent) : QObject(parent) { @@ -40,7 +38,7 @@ bool CInstallWorker::cpyDir(const QString &srcPath, const QString &dstPath, bool QString dstFilePath; foreach (QString fileName, origDir.entryList(QDir::Files)) { - if(fileName.compare(EMPTY_DIR_FILENAME) == 0) // 空目录占位符文件不复制 + if(fileName.compare(g_pszEmptyDirFileName) == 0) // 空目录占位符文件不复制 continue; srcFilePath = srcPath + QDir::separator() + fileName; @@ -65,8 +63,7 @@ bool CInstallWorker::cpyDir(const QString &srcPath, const QString &dstPath, bool #endif if(!result) { - emit error( tr("拷贝") + "[" + dstFilePath + "]" - + tr("失败") ); + emit error( tr("拷贝") + "[" + dstFilePath + "]" + tr("失败")); } } @@ -127,15 +124,16 @@ void CInstallWorker::doCopy(const QString &mainProgramPath,const QString &produc emit error(tr("创建新目录过程错误")); } - QString srcDir(":iscs6000_unzip"); + QString srcDir = QString(":%1").arg(g_pszSetupUnzipDir); QString dstDir(mainProgramPath); QStringList srcDirs; srcDirs << QStringLiteral("product") << QStringLiteral("platform") - << "support"; + << QStringLiteral("resource") + << QStringLiteral("support"); if(isWeb) { - srcDirs << "web"; + srcDirs << QStringLiteral("web"); } if(!cpyDir(srcDir,srcDirs,dstDir,true)) diff --git a/product/src/tools/setup/setup_installer/SetupFunc.h b/product/src/tools/setup/setup_installer/SetupFunc.h index 3aa5fb03..eb62ef2e 100644 --- a/product/src/tools/setup/setup_installer/SetupFunc.h +++ b/product/src/tools/setup/setup_installer/SetupFunc.h @@ -56,5 +56,5 @@ bool setSysctl(); #endif -} //< iot_sys +} //< namespace iot_sys diff --git a/product/src/tools/setup/setup_installer/SetupFuncLinux.cpp b/product/src/tools/setup/setup_installer/SetupFuncLinux.cpp index 172559f6..5ad7d683 100644 --- a/product/src/tools/setup/setup_installer/SetupFuncLinux.cpp +++ b/product/src/tools/setup/setup_installer/SetupFuncLinux.cpp @@ -15,6 +15,7 @@ #include "setupCommon.h" #include #include +#include "setup/CommonDef.h" namespace iot_sys { @@ -38,13 +39,6 @@ QString getDesktopPath() } } -static const char *pszSystemdCfgFile = "/usr/lib/systemd/system/iscs6000_launcher.service"; - -//< 前面需加上用户HOME目录路径 -static const char *pszXdgCfgDir = "/.config/autostart/"; -static const char *pszXdgCfgFile = "iscs6000_hmi_explorer.desktop"; -static const char *pszDesktopEntryDirName = "iscs6000"; -static const char *pszAppDir = "/usr/share/applications"; const QString desktopDir = getDesktopPath(); @@ -52,7 +46,7 @@ const QString desktopDir = getDesktopPath(); bool regSysService(QString &strErr,QString path) { //< 判断服务是否已注册,普通用户权限可执行 - if (0 == QProcess::execute("systemctl is-enabled iscs6000_launcher.service")) + if (0 == QProcess::execute(QString("systemctl is-enabled %1.service").arg(g_pszLauncherServiceName) ) ) { strErr = QObject::tr("已设置服务自启动,若需重新设置,请先取消!"); return false; @@ -83,13 +77,13 @@ bool regSysService(QString &strErr,QString path) //< 生成或修改systemd服务配置文件 { - QSettings objIniSetting(pszSystemdCfgFile, QSettings::IniFormat); + QSettings objIniSetting(g_pszLauncherServiceFile, QSettings::IniFormat); objIniSetting.setIniCodec( QTextCodec::codecForLocale() ); if (!objIniSetting.isWritable()) { strErr = QObject::tr("服务配置文件不可写,请确认是否具有权限!") - + "\n" + pszSystemdCfgFile; + + "\n" + g_pszLauncherServiceFile; return false; } @@ -98,7 +92,7 @@ bool regSysService(QString &strErr,QString path) objIniSetting.clear(); objIniSetting.beginGroup("Unit"); - objIniSetting.setValue("Description", "iscs6000_launcher"); + objIniSetting.setValue("Description", g_pszLauncherServiceName); objIniSetting.setValue("After", "network.target"); objIniSetting.endGroup(); @@ -123,7 +117,7 @@ bool regSysService(QString &strErr,QString path) if (QSettings::NoError != objIniSetting.status()) { strErr = QObject::tr("写入服务配置文件失败!") - + "\n" + pszSystemdCfgFile; + + "\n" + g_pszLauncherServiceFile; return false; } } @@ -136,7 +130,7 @@ bool regSysService(QString &strErr,QString path) } //< 设置服务开机自启动 - if (0 != QProcess::execute("systemctl enable iscs6000_launcher.service")) + if (0 != QProcess::execute(QString("systemctl enable %1.service").arg(g_pszLauncherServiceName) )) { strErr = QObject::tr("设置服务开机自启动失败!"); return false; @@ -163,9 +157,9 @@ bool setHmiAutoStart(QString &strErr,QString path) { strCfgFileDir = QString("/home/%1").arg(sudo_user); } - strCfgFileDir += pszXdgCfgDir; + strCfgFileDir += g_pszXdgAutoStartCfgDir; - const QString strCfgFileFullPath = strCfgFileDir + pszXdgCfgFile; + const QString strCfgFileFullPath = strCfgFileDir + g_pszHMIXdgDesktopCfgFile; if (QFile::exists(strCfgFileFullPath)) { @@ -224,7 +218,7 @@ bool setHmiAutoStart(QString &strErr,QString path) { QTextStream objStreamOut(&objFile); objStreamOut << "[Desktop Entry]" << endl; - objStreamOut << "Name=iscs6000_hmi_explorer" << endl; + objStreamOut << "Name=" << g_pszHMIXdgDesktopName << endl; objStreamOut << "Exec=" << strExec << endl; objStreamOut << "Type=Application" << endl; objStreamOut << "X-GNOME-AutoRestart=false" << endl; @@ -247,12 +241,20 @@ public: QString comment; QString exec; QString icon; - CDesktopEntry(const QString destopName_,const QString name_, const QString comment_, const QString exec_, const QString icon_=""): + + // 用于窗体识别,解决某些桌面组件无法识别窗体而导致的问题 + // 比如dash-to-dock上收藏的图标与运行的图标分离(正常应该是一个图标) + // 参见:https://github.com/micheleg/dash-to-dock/issues/215 + QString startupWMClass; + + CDesktopEntry(const QString destopName_,const QString name_, const QString comment_, const QString exec_, + const QString icon_="", const QString startupWMClass_=""): desktopName(destopName_), name(name_), comment(comment_), exec(exec_), - icon(icon_) + icon(icon_), + startupWMClass(startupWMClass_) { } @@ -277,10 +279,12 @@ bool createDesktopEntry(const QString &entrypath, const CDesktopEntry &entry, QS QTextStream objStreamOut(&objFile); objStreamOut << "[Desktop Entry]" << endl; objStreamOut << "Name=" << entry.name << endl; - objStreamOut << "Exec=sh -c \"export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Qt5.9.9/5.9.9/gcc_64/lib;" << entry.exec << "\"" <开始菜单 return true; @@ -300,7 +297,7 @@ bool regMysqlService(QString &path,QString &strErr) else { //< 判断服务是否已存在 - SC_HANDLE hService = ::OpenService(hSCM, pszServiceName, SERVICE_QUERY_CONFIG); + SC_HANDLE hService = ::OpenService(hSCM, g_pTCharLauncherServiceName, SERVICE_QUERY_CONFIG); if (NULL == hService) { //< 创建服务 @@ -313,7 +310,7 @@ bool regMysqlService(QString &path,QString &strErr) //< 2、多用户登录时会启动多个实例,而实际上由于端口占用等原因,是起不来的; //< 3、本程序停止服务时存在困难,见下面unregSysService()中的注释。 hService = ::CreateService( - hSCM, pszServiceName, pszServiceName, + hSCM, g_pTCharLauncherServiceName, g_pTCharLauncherServiceName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, strExec.toStdWString().c_str(), NULL, NULL, NULL, NULL, NULL); @@ -349,7 +346,7 @@ bool regMysqlService(QString &path,QString &strErr) bool regUninstallReg(const QString &iconPath,const QString &version,const QString &uninstallerPath,QString &strErr) { - QSettings objRegSetting(pszUninstallRegPath, QSettings::NativeFormat); + QSettings objRegSetting(g_pszRegUninstallRegPath, QSettings::NativeFormat); if(!objRegSetting.isWritable()) { @@ -358,15 +355,15 @@ bool regUninstallReg(const QString &iconPath,const QString &version,const QStrin } objRegSetting.setValue("DisplayIcon",iconPath); // 需要自定义 - objRegSetting.setValue("DisplayName","PowerSCADA3000W"); + objRegSetting.setValue("DisplayName","DiCS-EMS60"); objRegSetting.setValue("DisplayVersion",version); // 需要拼接 - objRegSetting.setValue("Publisher","SHENZHEN KANGBIDA CONTROL TECHNOLOGY CO.LTD"); + objRegSetting.setValue("Publisher","BYD CO.LTD"); objRegSetting.setValue("UninstallString",uninstallerPath); //需要拼接 return true; } -} //< iot_sys +} //< namespace iot_sys diff --git a/product/src/tools/setup/setup_installer/SetupWidget.cpp b/product/src/tools/setup/setup_installer/SetupWidget.cpp index cf6a57c9..8ca73ea5 100644 --- a/product/src/tools/setup/setup_installer/SetupWidget.cpp +++ b/product/src/tools/setup/setup_installer/SetupWidget.cpp @@ -59,15 +59,15 @@ bool SetupWidget::isOpenGauss() bool SetupWidget::isKingBase() { - if( isKylin()) + if (ui->comboBox_dbtype->currentText() == "KingBase") { - if (ui->comboBox_dbtype->currentText() == "KingBase") - return true; + return true; } + return false; } -const char* magicString = "KBDCT"; +const char* magicString = "EMS60"; const int productInfoLength = 8; const int productBit = productInfoLength - 1 -1 ; const int isExclusiveBit = productInfoLength - 1 ; @@ -175,10 +175,6 @@ bool SetupWidget::SaveSetupXml(const QString &fileName) { return false; } - if(isKylin()) - { - m_nProductId = m_nProductId + 100 ; - } QDomNode module=root.firstChild(); QDomElement element=module.toElement(); if(!element.isNull()) @@ -283,7 +279,7 @@ bool SetupWidget::CopyFileToPath(QString sourcePath, QString dstPath, bool overr bool SetupWidget::getPreSetConfig() { - QFile file(":/iscs6000_unzip/product/common/sysconfig/setup_config.xml"); + QFile file(QString(":/%1/product/common/sysconfig/setup_config.xml").arg(g_pszSetupUnzipDir)); if(!file.open(QFile::ReadOnly)) { file.close(); @@ -560,9 +556,9 @@ void SetupWidget::on_NextButton1_clicked() #endif #ifdef OS_LINUX -if((isMainProgram&&isDatabase&&isWeb)==false) +if((isMainProgram||isDatabase||isWeb)==false) { - MessageDlg dlg(this,false,tr("当前版本必须选择全部组件")); + MessageDlg dlg(this,false,tr("安装组件不能为空")); dlg.exec(); return; } @@ -751,23 +747,7 @@ void SetupWidget::initConnect() void SetupWidget::initUi() { ui->stackedWidget->setCurrentIndex(0); - - if( !isKylin()) { - ui->label_35->setHidden(true); - ui->comboBox_dbtype->setHidden(true); - } - else - { - ui->comboBox_dbtype->setCurrentText("MySQL"); - } -#ifdef OS_LINUX - if( isMySQL()) - ui->LineEdit_port->setText("3306"); - if( isOpenGauss() ) - ui->LineEdit_port->setText("5432"); - if( isKingBase() ) - ui->LineEdit_port->setText("54321"); -#endif + initDatabaseParam(); #ifdef OS_WINDOWS this->setWindowFlag(Qt::FramelessWindowHint); @@ -788,6 +768,9 @@ void SetupWidget::initUi() msgColor = QColor(1, 194, 231); errColor = QColor(255, 255, 255); + + ui->DecompressButton2->hide(); //默认禁用掉解压2按钮 + m_bOnlyDecompress = false; } void SetupWidget::on_PushButton_1_clicked() @@ -829,6 +812,11 @@ void SetupWidget::on_checkBox_3_stateChanged(int arg1) void SetupWidget::startInstall() { + if(m_bOnlyDecompress) + { + slotInstallHelperFinishedHandler(0,QProcess::NormalExit); + return; + } QString config_path = SYS_CONFIG_PATH; QDir dir(config_path); @@ -907,28 +895,27 @@ bool SetupWidget::fillHelperArgs(QStringList &arguments) arguments << "en"; } - //--port 3306 --username root --password kbdct --dbname iscs6000 + //--port 3306 --username root --password emspasswd --dbname ems arguments << "--ip" << ui->LineEdit_ip->text(); arguments << "--port" << ui->LineEdit_port->text(); arguments << "--dbname" << ui->LineEdit_dbname->text(); + arguments << "--username" << ui->LineEdit_db_user_name->text(); //TODO 数据库脚本修改支持修改用户名和密码 if( isMySQL()){ - arguments << "--username" << "root"; arguments << "--dbtype" << DB_MYSQL; } if(isOpenGauss()) { - arguments << "--username" << "iscs"; arguments << "--dbtype" << DB_OPENGAUSS; - } if( isKingBase()){ - arguments << "--username" << "system"; arguments << "--dbtype" << DB_KINGBASE; - } - arguments << "--password" << PASSWORD_DEFINE; + /* 为以后搜索方便,保留此注释 + * arguments << "--password" << EMS_DEFAULT_PASSWD; + */ + arguments << "--password" << ui->LineEdit_db_user_password->text(); return true; } @@ -939,7 +926,7 @@ void SetupWidget::initLangUi() tr("软件版本") + " ["+software_version+"]\n" + tr("版权所有") - + "\nShenZhen,Chinese\nKBD Control TechnoLogy Co.Ltd."; + + "\nShenZhen,Chinese\nBYD Co.Ltd."; ui->label_version->setText(str); ui->ComboBox_components->clear(); @@ -983,6 +970,27 @@ void SetupWidget::showInstallFailUi() ui->label_ico->setStyleSheet("border-image:url(:/res/安装_失败.png);"); } +void SetupWidget::initDatabaseParam() +{ + ui->LineEdit_dbname->setText(EMS_DEFAULT_DATABASE); + ui->LineEdit_db_user_password->setText(EMS_DEFAULT_PASSWD); + if( isMySQL()) + { + ui->LineEdit_db_user_name->setText("root"); + ui->LineEdit_port->setText("3306"); + } + if( isOpenGauss() ) + { + ui->LineEdit_db_user_name->setText("ems60"); + ui->LineEdit_port->setText("5432"); + } + if( isKingBase() ) + { + ui->LineEdit_db_user_name->setText("system"); + ui->LineEdit_port->setText("54321"); + } +} + void SetupWidget::loadComBoboxItems() { loadProductItems(); @@ -1061,7 +1069,7 @@ void SetupWidget::loadProductItems() ui->comboBox_product->clear(); //< "product" - QDir dir(":/iscs6000_unzip/products"); + QDir dir(QString(":/%1/products").arg(g_pszSetupUnzipDir)); if(dir.exists()) { QFileInfoList list=dir.entryInfoList(); @@ -1075,7 +1083,7 @@ void SetupWidget::loadProductItems() } } - ui->comboBox_product->setCurrentText(getProductChineseName("PSCADA")); + ui->comboBox_product->setCurrentText(getProductChineseName("EMS")); ProductInfo info; if(!getIscs6000ProductInfo(QCoreApplication::applicationFilePath(),info)) @@ -1113,46 +1121,46 @@ bool SetupWidget::setProductInstallPath(QString &sProductName) if(sProductName == "PSCADA") { #ifdef OS_WINDOWS - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "PowerSCADA3000W" ; - DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "PowerSCADA3000W" + QDir::separator() + "database" ; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_PSCADA ; + DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_PSCADA + QDir::separator() + "database" ; #else - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "PowerSCADA3000L"; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_PSCADA; #endif } else if(sProductName == "ISCS") { #ifdef OS_WINDOWS - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "ISCS6000" ; - DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "ISCS6000" + QDir::separator() + "database" ; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_ISCS ; + DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_ISCS + QDir::separator() + "database" ; #else - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "ISCS6000"; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_ISCS; #endif } else if(sProductName == "PSMS") { #ifdef OS_WINDOWS - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "PSMS3000"; - DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "PSMS3000" + QDir::separator() + "database" ; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_PSMS; + DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_PSMS + QDir::separator() + "database" ; #else - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "PSMS3000"; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_PSMS; #endif } else if(sProductName == "EMS") { #ifdef OS_WINDOWS - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "WiseEnergy"; - DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "WiseEnergy" + QDir::separator() + "database" ; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_EMS; + DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_EMS + QDir::separator() + "database" ; #else - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "WiseEnergy"; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_EMS; #endif } else { #ifdef OS_WINDOWS - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "ISCS6000_HOME"; - DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "ISCS6000_HOME" + QDir::separator() + "database" ; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_EMS; + DatabasePath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_EMS + QDir::separator() + "database" ; #else - MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + "ISCS6000_HOME"; + MainProgramPath = QStringLiteral(INSTALL_FREFIX) + QDir::separator() + g_pszInstallDir_EMS; #endif } return true; @@ -1160,7 +1168,7 @@ bool SetupWidget::setProductInstallPath(QString &sProductName) void SetupWidget::loadProjectItems() { //< "product" - QDir dir(":/iscs6000_unzip/products/" + ui->comboBox_product->currentData().toString()); + QDir dir(QString(":/%1/products/").arg(g_pszSetupUnzipDir) + ui->comboBox_product->currentData().toString()); ui->comboBox_project->clear(); if(dir.exists()) { @@ -1188,9 +1196,9 @@ void SetupWidget::loadProjectItems() void SetupWidget::regDbConfig() { - + /* 为以后搜索方便,保留此注释 EMS_DEFAULT_DATABASE QSettings settings; - settings.setValue("login/psw","kbdct@0755"); + settings.setValue("login/psw",EMS_DEFAULT_PASSWD); if( isMySQL() ) { @@ -1214,7 +1222,30 @@ void SetupWidget::regDbConfig() } settings.setValue("login/ip","127.0.0.1"); - settings.setValue("login/dbname","iscs6000"); + settings.setValue("login/dbname",EMS_DEFAULT_DATABASE); + */ + + QSettings settings; + settings.setValue("login/psw",ui->LineEdit_db_user_password->text()); + settings.setValue("login/user",ui->LineEdit_db_user_name->text()); + settings.setValue("login/port",ui->LineEdit_port->text().toInt()); + + if( isMySQL() ) + { + settings.setValue("login/dbtype",0); + } + if( isOpenGauss() ) + { + settings.setValue("login/dbtype",1); + } + + if( isKingBase() ) + { + settings.setValue("login/dbtype",3); + } + + settings.setValue("login/ip",ui->LineEdit_ip->text()); + settings.setValue("login/dbname",ui->LineEdit_dbname->text()); } void SetupWidget::addMsg(const QString &msg) @@ -1247,6 +1278,12 @@ void SetupWidget::on_btn_install_continue_clicked() void SetupWidget::on_FinishButton_clicked() { + if(m_bOnlyDecompress) + { + qApp->quit(); + return; + } + QString strErr; QString destPath = MainProgramPath; #ifdef OS_WINDOWS @@ -1307,6 +1344,41 @@ void SetupWidget::on_FinishButton_clicked() qApp->quit(); } +void SetupWidget::on_DecompressButton_clicked() +{ + ui->stackedWidget->setCurrentIndex(2); + ui->BackButton2->hide(); //禁用上一步 + ui->NextButton2->hide(); //禁用下一步 + ui->DecompressButton2->show(); //启用解压按钮 + ui->checkBox51->hide(); //最后完成界面的显示值 + ui->checkBox52->hide(); //最后完成界面的显示值 + ui->checkBox53->hide(); //最后完成界面的显示值 + isMainProgram = true; + isDatabase = true; + isWeb = true; + m_bOnlyDecompress = true; +} + +void SetupWidget::on_DecompressButton2_clicked() +{ + MainProgramPath = ui->LineEdit1->text(); + QDir installDir(MainProgramPath); + if(installDir.exists()) + { + MessageDlg dlg(this,false,tr("主程序路径不能为空")); + dlg.exec(); + return; + } + + ui->stackedWidget->setCurrentIndex(4); + + ui->btn_install_continue->setDisabled(true); + + //< 发送开始拷贝信号 + emit startCopy(MainProgramPath,ui->comboBox_product->currentData().toString(),ui->comboBox_project->currentText(),isWeb); + addMsg(tr("正在拷贝文件...")); +} + void SetupWidget::slotInstallHelperHandler() { while(m_installHelperProcess.canReadLine()) @@ -1427,11 +1499,5 @@ QLocale::Language SetupWidget::getCurrentLan() void SetupWidget::on_comboBox_dbtype_currentTextChanged(const QString &/*arg1*/) { - if(!isKylin()) - return; - - if( isMySQL()) - ui->LineEdit_port->setText("3306"); - if( isKingBase() ) - ui->LineEdit_port->setText("54321"); + initDatabaseParam(); } diff --git a/product/src/tools/setup/setup_installer/SetupWidget.h b/product/src/tools/setup/setup_installer/SetupWidget.h index d0c89d48..c4c4b599 100644 --- a/product/src/tools/setup/setup_installer/SetupWidget.h +++ b/product/src/tools/setup/setup_installer/SetupWidget.h @@ -11,11 +11,11 @@ #include #include -#define PRODUCT_ID_PLAT 40 -#define PRODUCT_ID_ISCS 41 -#define PRODUCT_ID_PSCADA 42 -#define PRODUCT_ID_EMS 43 -#define PRODUCT_ID_PSMS 44 +#define PRODUCT_ID_PLAT 10 +#define PRODUCT_ID_EMS 60 +#define PRODUCT_ID_PSCADA 20 +#define PRODUCT_ID_PSMS 30 +#define PRODUCT_ID_ISCS 40 class ProductInfo { @@ -69,6 +69,8 @@ private slots: void on_NextButton3_clicked(); // 开始安装的前一步 void on_btn_install_continue_clicked(); //安装完成后的继续按钮 void on_FinishButton_clicked();//结束按钮 + void on_DecompressButton_clicked(); //仅解压 + void on_DecompressButton2_clicked(); //解压 void on_UninstallButton_clicked(); // 卸载按钮 void startInstall(); // 开始安装 @@ -92,6 +94,7 @@ private slots: void initLangUi(); // 初始化ui同时在语言切换时加载 void initInstallWorker(); //初始化安装线程,主要负责拷贝文件 void showInstallFailUi(); // 展示安装失败的界面 + void initDatabaseParam(); //填充数据库界面中默认参数 void loadComBoboxItems(); @@ -175,7 +178,7 @@ private: QFile *m_logFile; // 日志文件 QTextStream *m_logStream; // 日志流 - + bool m_bOnlyDecompress; //是否仅解压,默认否 }; #endif // SETUPWIDGET_H diff --git a/product/src/tools/setup/setup_installer/SetupWidget.ui b/product/src/tools/setup/setup_installer/SetupWidget.ui index b0ac33d8..d8ee5b5a 100644 --- a/product/src/tools/setup/setup_installer/SetupWidget.ui +++ b/product/src/tools/setup/setup_installer/SetupWidget.ui @@ -199,6 +199,13 @@ 0 + + + + 仅解压 + + + @@ -621,6 +628,13 @@ p, li { white-space: pre-wrap; } + + + + 解压 + + + @@ -737,7 +751,7 @@ p, li { white-space: pre-wrap; } 127.0.0.1 - true + false @@ -754,10 +768,10 @@ p, li { white-space: pre-wrap; } - iscs6000 + ems60 - true + false @@ -777,7 +791,38 @@ p, li { white-space: pre-wrap; } 3306 - true + false + + + + + + + 数据库用户名 + + + + + + + system + + + + + + + ems@byd23 + + + QLineEdit::Normal + + + + + + + 数据库密码 @@ -1163,7 +1208,4 @@ p, li { white-space: pre-wrap; } - - - diff --git a/product/src/tools/setup/setup_installer/SingleProcInstance.cpp b/product/src/tools/setup/setup_installer/SingleProcInstance.cpp index 2f30d534..7461d924 100644 --- a/product/src/tools/setup/setup_installer/SingleProcInstance.cpp +++ b/product/src/tools/setup/setup_installer/SingleProcInstance.cpp @@ -111,7 +111,7 @@ bool iot_public::CSingleProcInstance::hasInstanceRunning(const string& strUnique { std::transform(strName.begin(), strName.end(), strName.begin(), ::tolower); } - strName = "__kbdct_" + strName; + strName = "__iot_" + strName; if (!g_objGlobalMutex_.create(strName.c_str())) { //_assert(false); @@ -143,7 +143,7 @@ bool iot_public::CSingleProcInstance::hasInstanceRunning(const string& strUnique { std::transform(strName.begin(), strName.end(), strName.begin(), ::tolower); } - strName = TMPDIR"/__kbdct_" + strName; + strName = TMPDIR"/__iot_" + strName; int fdLockFile; struct flock fl; /* 打开锁文件 */ diff --git a/product/src/tools/setup/setup_installer/res/setup_style.qss b/product/src/tools/setup/setup_installer/res/setup_style.qss index f8f052f9..4d0da310 100644 --- a/product/src/tools/setup/setup_installer/res/setup_style.qss +++ b/product/src/tools/setup/setup_installer/res/setup_style.qss @@ -1,4 +1,4 @@ -/*第一页*/ +/*第一页*/ #Widget1, #WidgetInstall1, #WidgetInstall2, @@ -21,6 +21,8 @@ color: rgba(255,255,255,1); font: 10pt "黑体"; } +#DecompressButton, +#DecompressButton2, #CancelButton, #InstallButton, #UninstallButton, @@ -223,7 +225,9 @@ QRadioButton #label_32, #label_33, #label_34, -#label_35 +#label_35, +#label_db_user_name, +#label_db_user_password { color: rgba(0,222,255,1); font-family:"黑体"; diff --git a/product/src/tools/setup/setup_installer/res/背景.png b/product/src/tools/setup/setup_installer/res/背景.png index b36f800a..f03137d0 100644 Binary files a/product/src/tools/setup/setup_installer/res/背景.png and b/product/src/tools/setup/setup_installer/res/背景.png differ diff --git a/product/src/tools/setup/setup_installer/setupCommon.h b/product/src/tools/setup/setup_installer/setupCommon.h index 33a71717..072475fd 100644 --- a/product/src/tools/setup/setup_installer/setupCommon.h +++ b/product/src/tools/setup/setup_installer/setupCommon.h @@ -1,6 +1,6 @@ #pragma once -#define INSTALLER_UNIQUE_NAME "iscs6000_installer" +#include "setup/CommonDef.h" const static int pos_min_x=10; const static int pos_max_x=560; @@ -10,23 +10,6 @@ const static int pos_max_y=400; const static char* g_platform_dir_name = PLATFORM_DIR; const static char* g_iscs6000_os = ISCS6000_OS; -#ifdef OS_WINDOWS - #define SYS_CONFIG_PATH "C:/Program Files/PowerSCADA3000" - #define UNINSTALL_EXEC_NAME "uninstall.exe" - #define INSTALL_HELPER_EXEC_NAME "setup_install_helper.exe" - #define INSTALL_FREFIX "D:" - -#endif - -#ifdef OS_LINUX - #define SYS_CONFIG_PATH "/etc/powerscada3000" - #define UNINSTALL_EXEC_NAME "uninstall" - #define INSTALL_HELPER_EXEC_NAME "setup_install_helper" - #define INSTALL_FREFIX "/opt" -#endif - -#define PASSWORD_DEFINE "kbdct@0755" - #define DB_MYSQL "mysql" #define DB_OPENGAUSS "opengauss" #define DB_KINGBASE "kingbase" diff --git a/product/src/tools/setup/setup_installer/setup_installer.pro b/product/src/tools/setup/setup_installer/setup_installer.pro index 28897756..571601b0 100644 --- a/product/src/tools/setup/setup_installer/setup_installer.pro +++ b/product/src/tools/setup/setup_installer/setup_installer.pro @@ -10,7 +10,7 @@ TEMPLATE = app include(../setup_common.pri) DEST_CONFIG = $$SETUP_DEBUG_RELEASE -TARGET = iscs6000_installer +TARGET = DiCS-EMS60-installer QMAKE_PROJECT_DEPTH = 0 ISCS6000_REC_SRC = $$system_path($$SETUP_SRC_DIR/$$SETUP_SRC_QRC_NAME) !isEmpty(ISCS6000_REC_SRC):exists($$ISCS6000_REC_SRC): RESOURCES *= $$ISCS6000_REC_SRC diff --git a/product/src/tools/setup/setup_patch/patchwoker.cpp b/product/src/tools/setup/setup_patch/patchwoker.cpp index 938836f5..912441a1 100644 --- a/product/src/tools/setup/setup_patch/patchwoker.cpp +++ b/product/src/tools/setup/setup_patch/patchwoker.cpp @@ -4,7 +4,7 @@ #include #include -#define EMPTY_DIR_FILENAME ".kbdct_installer" +#define EMPTY_DIR_FILENAME ".ems_installer" CPatchWoker::CPatchWoker(QObject *parent) : QObject(parent) { diff --git a/product/src/tools/setup/setup_uninstall/CUninstallWorker.cpp b/product/src/tools/setup/setup_uninstall/CUninstallWorker.cpp index d3b08ade..dfd3b577 100644 --- a/product/src/tools/setup/setup_uninstall/CUninstallWorker.cpp +++ b/product/src/tools/setup/setup_uninstall/CUninstallWorker.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "setup/CommonDef.h" #ifdef OS_WINDOWS #include "windows.h" @@ -9,33 +10,24 @@ #pragma comment(lib,"user32.lib") #endif -#ifdef OS_WINDOWS -#define SYS_CONFIG_PATH "C:/Program Files/PowerSCADA3000" -#endif - -#ifdef OS_LINUX -#define SYS_CONFIG_PATH "/etc/powerscada3000" -#endif - - -static const char *pszAUninstallRegPath = "HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"; - - CUninstallWorker::CUninstallWorker(QObject *parent) : QObject(parent) { } -void CUninstallWorker::doWork(const QString &manProgramPath, const QString &dbPath, bool isHisdataDel, bool isBackupDel) +void CUninstallWorker::doWork(const QString &manProgramPath, const QString &dbPath, + const QString &dbName,const QString &dbUserName,const QString &dbUserPassword, + bool isHisdataDel, bool isBackupDel) { closeService(manProgramPath,dbPath); - delFiles(manProgramPath, dbPath,isHisdataDel, isBackupDel); + delFiles(manProgramPath, dbPath,dbName,dbUserName,dbUserPassword,isHisdataDel, isBackupDel); removeConfig(); emit resultReady(); } void CUninstallWorker::closeService(const QString &manProgramPath,const QString &dbPath) { + Q_UNUSED(manProgramPath); status(tr("正在关闭服务...")); //TODO 后期变更为程序获取执行结果 #ifdef OS_WINDOWS @@ -53,10 +45,11 @@ void CUninstallWorker::closeService(const QString &manProgramPath,const QString system_hidden("taskkill /F /IM mysqld.exe"); - system_hidden("sc stop Redis"); - system_hidden("sc delete Redis"); + //< 暂时不使用Redis和nginx +// system_hidden("sc stop Redis"); +// system_hidden("sc delete Redis"); - system_hidden("taskkill /F /IM nginx.exe"); +// system_hidden("taskkill /F /IM nginx.exe"); #endif //TODO linux下暂时不停止任何应用 @@ -74,14 +67,20 @@ void CUninstallWorker::closeService(const QString &manProgramPath,const QString } -void CUninstallWorker::delFiles(const QString &manProgramPath, const QString &dbPath, bool isHisdataDel, bool isBackupDel) +void CUninstallWorker::delFiles(const QString &manProgramPath, const QString &dbPath, + const QString &dbName,const QString &dbUserName,const QString &dbUserPassword, + bool isHisdataDel, bool isBackupDel) { + Q_UNUSED(dbName); + Q_UNUSED(dbUserName); + Q_UNUSED(dbUserPassword); + //< 获取路径 QDir mainDir(manProgramPath); //< 删除主程序其他路径程序 QStringList dirNeedDel; - dirNeedDel << "data" << "doc" << "support" << "products" << "web" << "coreDump" << "miniDump" <<"log" << "doc" << "platform"; + dirNeedDel << "resource" << "data" << "doc" << "support" << "products" << "web" << "coreDump" << "miniDump" <<"log" << "doc" << "platform"; //< 删除工程备份数据 if(isBackupDel) @@ -95,7 +94,8 @@ void CUninstallWorker::delFiles(const QString &manProgramPath, const QString &db dirNeedDel << "hisdata"; // Linux 删除历史数据 #ifdef OS_LINUX - system("influx -execute 'drop database iscs6000'"); + QString cmd = QString("influx -username %1 -password %2 -execute 'drop database %3'").arg(dbUserName).arg(dbUserPassword).arg(dbName); + system(cmd.toStdString().c_str()); #endif } @@ -118,8 +118,9 @@ void CUninstallWorker::delFiles(const QString &manProgramPath, const QString &db } } +#ifdef OS_WINDOWS // 从程序列表删除ISCS6000 - QSettings objRegSetting(pszAUninstallRegPath, QSettings::NativeFormat); + QSettings objRegSetting(g_pszAUninstallRegPath, QSettings::NativeFormat); if(!objRegSetting.isWritable()) { error(tr("无法写入注册表")); @@ -127,9 +128,9 @@ void CUninstallWorker::delFiles(const QString &manProgramPath, const QString &db } else { - objRegSetting.remove("ISCS6000"); + objRegSetting.remove(g_pszRegItem); } - +#endif //TODO 删除product if(!emptyDir(mainDir.absoluteFilePath("product"))) diff --git a/product/src/tools/setup/setup_uninstall/CUninstallWorker.h b/product/src/tools/setup/setup_uninstall/CUninstallWorker.h index 233dd254..e23f6454 100644 --- a/product/src/tools/setup/setup_uninstall/CUninstallWorker.h +++ b/product/src/tools/setup/setup_uninstall/CUninstallWorker.h @@ -10,7 +10,9 @@ public: explicit CUninstallWorker(QObject *parent = nullptr); public slots: - void doWork(const QString & manProgramPath, const QString &dbPath,bool isHisdataDel, bool isBackupDel); + void doWork(const QString & manProgramPath, const QString &dbPath, + const QString &dbName,const QString &dbUserName,const QString &dbUserPassword, + bool isHisdataDel, bool isBackupDel); signals: void resultReady(); @@ -19,7 +21,9 @@ signals: private: void closeService(const QString &manProgramPath, const QString &dbPath); - void delFiles(const QString & manProgramPath, const QString &dbPath,bool isHisdataDel, bool isBackupDel); + void delFiles(const QString & manProgramPath, const QString &dbPath, + const QString &dbName,const QString &dbUserName,const QString &dbUserPassword, + bool isHisdataDel, bool isBackupDel); void removeConfig(); bool emptyDir(const QString &path); diff --git a/product/src/tools/setup/setup_uninstall/SetupFunc.h b/product/src/tools/setup/setup_uninstall/SetupFunc.h index ad8b17ee..d5d4fdfa 100644 --- a/product/src/tools/setup/setup_uninstall/SetupFunc.h +++ b/product/src/tools/setup/setup_uninstall/SetupFunc.h @@ -44,5 +44,5 @@ bool removeShortcut(QString &strErr); //< 删除文件夹 bool DelDir(QString &path); -} //< iot_sys +} //< namespace iot_sys diff --git a/product/src/tools/setup/setup_uninstall/SetupFuncLinux.cpp b/product/src/tools/setup/setup_uninstall/SetupFuncLinux.cpp index 275c7f97..92e0683d 100644 --- a/product/src/tools/setup/setup_uninstall/SetupFuncLinux.cpp +++ b/product/src/tools/setup/setup_uninstall/SetupFuncLinux.cpp @@ -11,8 +11,8 @@ #ifdef OS_LINUX #include - #include "SetupFunc.h" +#include "setup/CommonDef.h" namespace iot_sys { @@ -37,23 +37,14 @@ QString getDesktopPath() } } -static const char *pszSystemdCfgFile = "/usr/lib/systemd/system/iscs6000_launcher.service"; - -//< 前面需加上用户HOME目录路径 -static const char *pszXdgCfgDir = "/.config/autostart/"; -static const char *pszXdgCfgFile = "iscs6000_hmi_explorer.desktop"; - -static const char *pszDesktopEntryDirName = "iscs6000"; -static const char *pszAppDir = "/usr/share/applications"; const QString desktopDir = getDesktopPath(); - //< 注销系统服务 bool unregSysService(QString &strErr) { //< 该路径普通用户可访问 - if (!QFile::exists(pszSystemdCfgFile)) + if (!QFile::exists(g_pszLauncherServiceFile)) { //< 重新加载一次,确保systemd配置与文件一致,需需管理员权限 //QProcess::execute("systemctl daemon-reload"); @@ -63,16 +54,16 @@ bool unregSysService(QString &strErr) } //< 停止服务 - QProcess::execute("systemctl stop iscs6000_launcher.service"); + QProcess::execute(QString("systemctl stop %1.service").arg(g_pszLauncherServiceName) ); //< 取消服务开机自启动 - QProcess::execute("systemctl disable iscs6000_launcher.service"); + QProcess::execute(QString("systemctl disable %1.service").arg(g_pszLauncherServiceName) ); //< 删除服务配置文件 - if (!QFile::remove(pszSystemdCfgFile)) + if (!QFile::remove(g_pszLauncherServiceFile)) { strErr = QObject::tr("删除服务配置文件失败,请确认是否具有权限!") - + "\n" + pszSystemdCfgFile; + + "\n" + g_pszLauncherServiceFile; return false; } @@ -102,9 +93,9 @@ bool unsetHmiAutoStart(QString &strErr) { strCfgFileDir = QString("/home/%1").arg(sudo_user); } - strCfgFileDir += pszXdgCfgDir; + strCfgFileDir += g_pszXdgAutoStartCfgDir; - const QString strCfgFileFullPath = strCfgFileDir + pszXdgCfgFile; + const QString strCfgFileFullPath = strCfgFileDir + g_pszHMIXdgDesktopCfgFile; if (QFile::exists(strCfgFileFullPath)) { @@ -131,8 +122,8 @@ bool removeShortcut(QString &strErr) { //< todo Q_UNUSED(strErr); - QDir appDir(pszAppDir); - QString appDestPath = appDir.absoluteFilePath(pszDesktopEntryDirName); + QDir appDir(g_pszAppDir); + QString appDestPath = appDir.absoluteFilePath(g_pszDesktopEntryDirName); if(QDir(appDestPath).exists()) { QDir(appDestPath).removeRecursively(); @@ -151,10 +142,11 @@ bool removeShortcut(QString &strErr) bool unregHisDataSrvService(QString &strErr) { - return system("systemctl disable iscs6000_db_his_data_srv.service"); + QString strUnRegShell = QString("systemctl disable %1.service").arg(g_pszDBHisDataServiceName); + return system(strUnRegShell.toStdString().c_str()); } -} //< iot_sys +} //< namespace iot_sys #endif //< #ifdef OS_LINUX diff --git a/product/src/tools/setup/setup_uninstall/SetupFuncWindows.cpp b/product/src/tools/setup/setup_uninstall/SetupFuncWindows.cpp index 32f2f779..5e119b2f 100644 --- a/product/src/tools/setup/setup_uninstall/SetupFuncWindows.cpp +++ b/product/src/tools/setup/setup_uninstall/SetupFuncWindows.cpp @@ -16,15 +16,11 @@ #include #include "SetupFunc.h" +#include "setup/CommonDef.h" namespace iot_sys { -static const TCHAR *pszServiceName = _T("iscs6000_launcher"); - -static const char *pszAutoRunRegPath = "HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"; - - //< 注销系统服务 bool unregSysService(QString &strErr) { @@ -38,8 +34,8 @@ bool unregSysService(QString &strErr) } else { - SC_HANDLE hService = ::OpenService(hSCM, pszServiceName, SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE); - //SC_HANDLE hService = ::OpenService(hSCM, _T("iscs6000_launcher_17b5ab7"), SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE); + SC_HANDLE hService = ::OpenService(hSCM, g_pTCharLauncherServiceName, SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE); + //SC_HANDLE hService = ::OpenService(hSCM, _T("xxxx_launcher_17b5ab7"), SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE); if (NULL == hService) { @@ -54,9 +50,9 @@ bool unregSysService(QString &strErr) { //< todo 当使用SERVICE_USER_XXX_PROCESS类型的服务注册时,停止服务存在困难 //< 此情况下服务的真实名称是注册名加上用户会话的ID,而ID是变化的,且微软没有开发获取的方法 - //< 比如真实的服务名是“iscs6000_launcher_17b5ab7”且正在运行,如果查询“iscs6000_launcher”的状态,是停止的 - //< 也无法通过停止“iscs6000_launcher”服务来停止“iscs6000_launcher_17b5ab7” - //< 删除“iscs6000_launcher”服务后,“iscs6000_launcher_17b5ab7”还可见,必须注销重新登录才会消失 + //< 比如真实的服务名是“xxxx_launcher_17b5ab7”且正在运行,如果查询“xxxx_launcher”的状态,是停止的 + //< 也无法通过停止“xxxx_launcher”服务来停止“xxxx_launcher_17b5ab7” + //< 删除“xxxx_launcher”服务后,“xxxx_launcher_17b5ab7”还可见,必须注销重新登录才会消失 if(SERVICE_STOPPED != objStatus.dwCurrentState && TRUE == ControlService(hService, SERVICE_CONTROL_STOP, &objStatus)) @@ -113,9 +109,9 @@ bool unregSysService(QString &strErr) //< 取消HMI自启动 bool unsetHmiAutoStart(QString &strErr) { - QSettings objRegSetting(pszAutoRunRegPath, QSettings::NativeFormat); + QSettings objRegSetting(g_pszAutoRunRegPath, QSettings::NativeFormat); - if (objRegSetting.contains("iscs6000_hmi_explorer")) + if (objRegSetting.contains(g_pszAutoRunHMI)) { if (!objRegSetting.isWritable()) { @@ -123,7 +119,7 @@ bool unsetHmiAutoStart(QString &strErr) return false; } - objRegSetting.remove("iscs6000_hmi_explorer"); + objRegSetting.remove(g_pszAutoRunHMI); if (QSettings::NoError != objRegSetting.status()) { @@ -171,8 +167,8 @@ bool unsetSysStartupAutoStart(QString &strErr,QString path) bool unsetSysStartupAutoStartByVbs(QString &strErr) { Q_UNUSED(strErr) - QDir dir("C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp"); - if(dir.remove("sys_startup.vbs")) + QDir dir(g_pszAutoStartSysStartupPath); + if(dir.remove(g_pszSysStartupVBS)) { return true; } @@ -194,7 +190,7 @@ bool removeShortcut(QString &strErr) //>桌面快捷方式 //<开始菜单快捷方式 - QString startMenuPath=QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)+"/PowerSCADA3000W"; + QString startMenuPath=QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)+"/EMS60"; QDir startMenuPathDir(startMenuPath); if(startMenuPathDir.removeRecursively()) return true; @@ -237,7 +233,6 @@ bool DelDir(QString &path) bool unregHisDataSrvService(QString &strErr) { - const TCHAR *pszServiceName = _T("db_his_data_srv"); bool bRet = false; //< 打开服务控制管理器 @@ -248,7 +243,7 @@ bool unregHisDataSrvService(QString &strErr) } else { - SC_HANDLE hService = ::OpenService(hSCM, pszServiceName, SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE); + SC_HANDLE hService = ::OpenService(hSCM, g_pTCharDBHisDataServiceName, SERVICE_QUERY_STATUS | SERVICE_STOP | DELETE); if (NULL == hService) { @@ -264,9 +259,9 @@ bool unregHisDataSrvService(QString &strErr) { //< todo 当使用SERVICE_USER_XXX_PROCESS类型的服务注册时,停止服务存在困难 //< 此情况下服务的真实名称是注册名加上用户会话的ID,而ID是变化的,且微软没有开发获取的方法 - //< 比如真实的服务名是“iscs6000_launcher_17b5ab7”且正在运行,如果查询“iscs6000_launcher”的状态,是停止的 - //< 也无法通过停止“iscs6000_launcher”服务来停止“iscs6000_launcher_17b5ab7” - //< 删除“iscs6000_launcher”服务后,“iscs6000_launcher_17b5ab7”还可见,必须注销重新登录才会消失 + //< 比如真实的服务名是“xxxx_launcher_17b5ab7”且正在运行,如果查询“xxxx_launcher”的状态,是停止的 + //< 也无法通过停止“xxxx_launcher”服务来停止“xxxx_launcher_17b5ab7” + //< 删除“xxxx_launcher”服务后,“xxxx_launcher_17b5ab7”还可见,必须注销重新登录才会消失 if(SERVICE_STOPPED != objStatus.dwCurrentState && TRUE == ControlService(hService, SERVICE_CONTROL_STOP, &objStatus)) @@ -322,6 +317,6 @@ bool unregHisDataSrvService(QString &strErr) } -} //< iot_sys +} //< namespace iot_sys #endif //< #ifdef OS_WINDOWS diff --git a/product/src/tools/setup/setup_uninstall/SetupWidget.cpp b/product/src/tools/setup/setup_uninstall/SetupWidget.cpp index e6ab23d2..c81fc307 100644 --- a/product/src/tools/setup/setup_uninstall/SetupWidget.cpp +++ b/product/src/tools/setup/setup_uninstall/SetupWidget.cpp @@ -15,7 +15,7 @@ #include #include "SetupFunc.h" #include "CUninstallWorker.h" - +#include "setup/CommonDef.h" #ifdef OS_WINDOWS #include "windows.h" @@ -45,13 +45,6 @@ const static int pos_max_x=560; const static int pos_min_y=10; const static int pos_max_y=400; -#ifdef OS_WINDOWS -#define SYS_CONFIG_PATH "C:/Program Files/PowerSCADA3000" -#endif - -#ifdef OS_LINUX -#define SYS_CONFIG_PATH "/etc/powerscada3000" -#endif using namespace iot_sys; @@ -75,7 +68,7 @@ SetupWidget::SetupWidget(QWidget *parent) : #endif #ifdef OS_LINUX ui->gridLayout_4->setContentsMargins(0,0,0,0); - ui->label->setVisible(false); +// ui->label->setVisible(false); #endif m_SetupRunPath = qApp->applicationDirPath(); @@ -84,6 +77,8 @@ SetupWidget::SetupWidget(QWidget *parent) : ReadSetupXml( m_SetupRunPath + "/product/common/sysconfig/setup_config.xml"); + initDBInfoLayout(); + ui->stackedWidget->setCurrentIndex(0); initUninstallWorker(); @@ -98,6 +93,25 @@ SetupWidget::~SetupWidget() } +void SetupWidget::setDBInfoValid(bool bHidden) +{ + ui->label_dbName->setHidden(bHidden); + ui->label_dbPassword->setHidden(bHidden); + + ui->lineEdit_dbName->setHidden(bHidden); + ui->lineEdit_dbPassword->setHidden(bHidden); +} + +void SetupWidget::initDBInfoLayout() +{ + ui->lineEdit_dbName->setText(EMS_DEFAULT_DATABASE); + ui->lineEdit_dbPassword->setText(EMS_DEFAULT_PASSWD); + + setDBInfoValid(true); + + connect(ui->checkBox_hisdata,SIGNAL(stateChanged(int)),this,SLOT(onHisDataCheckStateChanged(int))); +} + bool SetupWidget::ReadSetupXml(const QString &fileName) { QFile file(fileName); @@ -293,6 +307,18 @@ void SetupWidget::paintEvent(QPaintEvent *event) } } +void SetupWidget::onHisDataCheckStateChanged(int checkState) +{ + if(checkState == Qt::Checked) + { + setDBInfoValid(false); + } + else + { + setDBInfoValid(true); + } +} + void SetupWidget::addMsg(const QString &msg) { @@ -318,16 +344,23 @@ void SetupWidget::on_UnNextButton1_clicked() #ifdef OS_WINDOWS - system_hidden("net stop db_his_data_srv"); - system_hidden("sc delete db_his_data_srv"); + QString strCmdShell = QString("net stop %1").arg(g_pszDBHisDataServiceName); + system_hidden(strCmdShell.toStdString().c_str()); + + strCmdShell = QString("sc delete %1").arg(g_pszDBHisDataServiceName); + system_hidden(strCmdShell.toStdString().c_str()); system_hidden("net stop net_keepalived"); system_hidden("sc delete net_keepalived"); system_hidden( net_keepalived_stop.toStdString().c_str() ); #endif #ifdef OS_LINUX - system("systemctl stop iscs6000_db_his_data_srv"); - system("systemctl disable iscs6000_db_his_data_srv"); + QString strShell = QString("systemctl stop %1").arg(g_pszDBHisDataServiceName); + system(strShell.toStdString().c_str()); + + QString("systemctl disable %1").arg(g_pszDBHisDataServiceName); + system(strShell.toStdString().c_str()); + system("systemctl stop net_keepalived"); system("systemctl disable net_keepalived"); system( net_keepalived_stop.toStdString().c_str() ); @@ -343,7 +376,9 @@ void SetupWidget::on_UnNextButton1_clicked() return ; } - emit startWork(MainProgramPath,DatabasePath,ui->checkBox_hisdata->isChecked(),ui->checkBox_backup->isChecked()); + emit startWork(MainProgramPath,DatabasePath, + ui->lineEdit_dbName->text(),ui->lineEdit_dbName->text(),ui->lineEdit_dbPassword->text(), + ui->checkBox_hisdata->isChecked(),ui->checkBox_backup->isChecked()); ui->stackedWidget->setCurrentIndex(1); // 开始卸载 ui->btn_uninstall_continue->setVisible(false); @@ -475,7 +510,7 @@ void SetupWidget::getAllProcName(const QString &path, QStringList &procList) procList.append(list.at(index).fileName()); } #else - if(list.at(index).fileName().endsWith(".exe") && list.at(index).fileName() != "uninstall.exe" &&list.at(index).fileName().size()>4) + if(list.at(index).fileName().endsWith(".exe") && list.at(index).fileName() != UNINSTALL_EXEC_NAME &&list.at(index).fileName().size()>4) { procList.append(list.at(index).fileName()); } @@ -566,6 +601,7 @@ QString SetupWidget::canUninstall() } return runName; } + #else QString SetupWidget::canUninstall() diff --git a/product/src/tools/setup/setup_uninstall/SetupWidget.h b/product/src/tools/setup/setup_uninstall/SetupWidget.h index ad5e84c5..b9d677c9 100644 --- a/product/src/tools/setup/setup_uninstall/SetupWidget.h +++ b/product/src/tools/setup/setup_uninstall/SetupWidget.h @@ -24,7 +24,9 @@ public: ~SetupWidget(); signals: - void startWork(const QString & manProgramPath, const QString &dbPath,bool isHisdataDel, bool isBackupDel); + void startWork(const QString & manProgramPath,const QString &dbPath, + const QString &dbName,const QString &dbUserName,const QString &dbUserPassword, + bool isHisdataDel, bool isBackupDel); protected: bool ReadSetupXml(const QString &fileName); @@ -37,7 +39,7 @@ protected: private slots: - + void onHisDataCheckStateChanged(int checkState); void addMsg(const QString &msg); // 添加消息 @@ -67,6 +69,9 @@ private: QString canUninstall(); + void initDBInfoLayout(); + void setDBInfoValid(bool bHidden); + private: Ui::SetupWidget *ui; diff --git a/product/src/tools/setup/setup_uninstall/SetupWidget.ui b/product/src/tools/setup/setup_uninstall/SetupWidget.ui index f929134b..41fdc814 100644 --- a/product/src/tools/setup/setup_uninstall/SetupWidget.ui +++ b/product/src/tools/setup/setup_uninstall/SetupWidget.ui @@ -44,7 +44,7 @@ 1 - 2 + 0 @@ -101,19 +101,37 @@ - 清理历史数据 + 清理历史数据(勾选会删除数据库) - - - color:rgb(255, 255, 255) - - - (勾选清理历史数据会删除数据库) - - + + + + + 时数据库名 + + + + + + + + + + 时数据库密码 + + + + + + + QLineEdit::Normal + + + +