| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加载配置文件(优先级:配置文件 > 默认配置) |
| | | /// </summary> |
| | | /// <remarks> |
| | | /// 从应用程序目录下的 StackerCraneJob/stackercrane-command-config.json 读取配置。 |
| | | /// 如果文件不存在或解析失败,使用默认配置。 |
| | | /// </remarks> |
| | | /// <returns>堆垛机命令配置</returns> |
| | | private static StackerCraneCommandConfig LoadConfig() |
| | | { |
| | | try |
| | | { |
| | | // 构造配置文件路径 |
| | | string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "StackerCraneJob", "stackercrane-command-config.json"); |
| | | if (File.Exists(configPath)) |
| | | { |
| | | // 读取并解析 JSON 配置 |
| | | string json = File.ReadAllText(configPath); |
| | | return System.Text.Json.JsonSerializer.Deserialize<StackerCraneCommandConfig>(json) ?? new StackerCraneCommandConfig(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 配置加载失败,使用默认配置 |
| | | Console.WriteLine($"配置加载失败: {ex.Message},使用默认配置"); |
| | | } |
| | | |
| | | return new StackerCraneCommandConfig(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Quartz Job 的执行入口 |
| | | /// </summary> |
| | | /// <remarks> |