Utils/JavaAppUtils.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。


using AppManager.Config;
using AppManager.Pojo;
using System;
using System.IO;
using System.Text;

namespace AppManager.Utils {
    /// <summary>
    /// java进程工具,创建bat脚本
    /// </summary>
    internal static class JavaAppUtils {
        public static string Profiles { get; set; }
        public static string JdkPath { get; set; }
        public static string LogPath { get; set; }
        public static string ClosedType { get; set; }
        public static string HeartBeat { get; set; }

        /**
        * 创建杀进程的脚本文件
        * 
        * */
        public static string CreateStartBat(AppSections.AppSection appSection, string logFileName, string errorLogFileName) {
            var result = bool.TrueString;
            //if (null == Profiles || string.Empty.Equals(Profiles)) {
            //    return "运行环境未配置或未保存!";
            //}
            //if ((null == JdkPath || string.Empty.Equals(JdkPath)) && string.IsNullOrEmpty(appSection.Jdk)) {
            //    return "JDK未配置或未保存!";
            //}
            if (string.IsNullOrEmpty(appSection.Jdk)) {
                if (!string.IsNullOrEmpty(JdkPath) && !Directory.Exists(JdkPath)) {
                    return $"JDK路径{JdkPath}不存在,请重新配置!";
                }
            } else {
                if (!string.IsNullOrEmpty(appSection.Jdk) && !Directory.Exists(appSection.Jdk)) {
                    return $"项目:[{appSection.Title}]的JDK路径:[{appSection.Jdk}]不存在,请重新配置!";
                }
            }

            var script = new StringBuilder();
            script.Append("@echo off").Append(Environment.NewLine);
            script.Append("chcp 65001").Append(Environment.NewLine);
            script.Append("title ").Append("\"").Append(appSection.Title).Append("\"").Append(Environment.NewLine);
            if (!string.IsNullOrEmpty(appSection.Ext)) {
                script.Append(StringUtils.TxtDecode(appSection.Ext)).Append(Environment.NewLine);
            }
            // jdk路径
            var usedJdkPath = string.IsNullOrEmpty(appSection.Jdk) ? JdkPath : appSection.Jdk;
            var jdkPathIsExist = Directory.Exists(usedJdkPath);
            if (jdkPathIsExist) {
                script.Append("\"").Append(usedJdkPath).Append("\\bin\\java.exe\"");
            } else {
                script.Append("java");
            }
            // 启动参数
            if (!string.IsNullOrEmpty(appSection.Param)) {
                script.Append(" ").Append(StringUtils.TxtDecode(appSection.Param));
            }
            // jar包路径
后面还有 72 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。