diff --git a/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java b/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java index 069a132..1e571aa 100644 --- a/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java +++ b/src/main/java/com/insigma/service/impl/WindowsTomcatMysql.java @@ -76,10 +76,11 @@ public class WindowsTomcatMysql implements Computer, Database, Middleware { log.info("备份压缩备份文件..."); ZipUtil.zip7Z( - AppCfg.HZB + File.separatorChar + "format", + AppCfg.HZB + File.separatorChar + format, AppCfg.HZB + File.separatorChar + format + ".gz"); - log.info("启动 数据库 服务..."); + log.info("删除文件夹,然后启动 数据库 服务..."); + FileUtil.delAllFile(AppCfg.HZB + File.separatorChar + format); if (canNotRun(ws, WinServiceTool.WindowsService::startService)) { return false; } diff --git a/src/main/java/com/insigma/ui/Test.java b/src/main/java/com/insigma/ui/Test.java index 1941c51..d41c360 100644 --- a/src/main/java/com/insigma/ui/Test.java +++ b/src/main/java/com/insigma/ui/Test.java @@ -30,15 +30,15 @@ public class Test { return; } addButton(textPanel, new JButton("√ 执行shell命令"), e -> computer.runShell("SERVICES.MSC", true)); - addButton(textPanel, new JButton("备份"), e -> computer.runBak(AppCfg.HZB)); - // addButton(textPanel, new JButton("还原"), e -> computer.runRestore("")); + addButton(textPanel, new JButton("√ 备份"), e -> computer.runBak(AppCfg.HZB)); + addButton(textPanel, new JButton("还原"), e -> computer.runRestore("D:\\hzb2021\\20220430.gz")); addButton(textPanel, new JButton("√ 重建索引"), e -> database.rebuildIndex(IndexObj.getData())); addButton(textPanel, new JButton("√ 清楚垃圾数据"), e -> database.cleanDbCache(TabColObj.getSQL(), TabColObj.getData())); - addButton(textPanel, new JButton("设置数据库大小"), e -> database.setDbSize(64)); - addButton(textPanel, new JButton("注册数据库服务"), e -> database.registrationDbService()); + addButton(textPanel, new JButton("√ 设置数据库大小"), e -> database.setDbSize(128)); + addButton(textPanel, new JButton("√ 注册数据库服务"), e -> database.registrationDbService()); addButton(textPanel, new JButton("√ 清楚应用缓存"), e -> middleware.cleanMwCache()); - addButton(textPanel, new JButton("设置中间件大小"), e -> middleware.setMwSize(128,256,512,512)); - addButton(textPanel, new JButton("注册中间件服务"), e -> middleware.registrationMwService()); + addButton(textPanel, new JButton("√ 设置中间件大小"), e -> middleware.setMwSize(128,256,1024,1024)); + addButton(textPanel, new JButton("√ 注册中间件服务"), e -> middleware.registrationMwService()); addButton(textPanel, new JButton("√ 启动数据库服务"), e -> database.startDbService()); addButton(textPanel, new JButton("√ 停止数据库服务"), e -> database.stopDbService()); addButton(textPanel, new JButton("√ 启动中间件服务"), e -> middleware.startMwService()); diff --git a/src/main/java/com/insigma/utils/WinCommandUtil.java b/src/main/java/com/insigma/utils/WinCommandUtil.java index 0b36db2..632d857 100644 --- a/src/main/java/com/insigma/utils/WinCommandUtil.java +++ b/src/main/java/com/insigma/utils/WinCommandUtil.java @@ -91,9 +91,10 @@ public class WinCommandUtil implements Runnable { String objectName, String displayName, String imagePath) { + boolean bool = false; log.info("操作:{},{},{},{}", path, serviceName, objectName, displayName); if (registryKeyExists(path)) { - return true; + bool = false; } try { Advapi32Util.registrySetIntValue(WinReg.HKEY_LOCAL_MACHINE, path, "Type", 16); @@ -109,13 +110,13 @@ public class WinCommandUtil implements Runnable { } path += "\\Parameters"; if (registryKeyExists(path)) { - return true; + bool = false; } } catch (Exception e) { log.error("操作发生异常:{}", e.getMessage()); - return false; + bool = true; } - return true; + return bool; } /* 注册服务部分 【2】修改注册表 Java */ public static boolean registerJava(String hzbPath, @@ -215,16 +216,19 @@ public class WinCommandUtil implements Runnable { private static boolean registryKeyExists(String path) { // 判断KeyPath是否存在 + boolean bool = false; boolean isOkay = Advapi32Util.registryKeyExists(WinReg.HKEY_LOCAL_MACHINE, path); + log.debug("查询 {} 对象:{}", path, isOkay); if (!isOkay) { try { - Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, path); + boolean b = Advapi32Util.registryCreateKey(WinReg.HKEY_LOCAL_MACHINE, path); + log.debug("新增 {} 对象:{}", path, b); } catch (Exception e) { log.error("操作发生异常:{}", e.getMessage()); - return true; + bool = true; } } - return false; + return bool; } /***