|
|
|
@ -7,6 +7,7 @@ using Newtonsoft.Json; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
using SparkClient.Model.Entity.ApiEntity; |
|
|
|
|
using SparkClient.Model.Helper; |
|
|
|
|
using System.Configuration; |
|
|
|
|
|
|
|
|
|
namespace SparkClient.Model.Services |
|
|
|
|
{ |
|
|
|
@ -39,8 +40,8 @@ namespace SparkClient.Model.Services |
|
|
|
|
string algo_config = lightLevelValue.ToString() ?? throw new InvalidOperationException(); |
|
|
|
|
|
|
|
|
|
//图片根目录 |
|
|
|
|
string image_file_base_path = "D:\\diamond_images"; |
|
|
|
|
|
|
|
|
|
string? image_file_base_path = ConfigurationManager.AppSettings["ImageFileBasePath"]; |
|
|
|
|
|
|
|
|
|
// 将所有变量拼接成一个 JSON 对象 |
|
|
|
|
JObject jsonData = new JObject( |
|
|
|
|
new JProperty("shape", shape), |
|
|
|
@ -86,9 +87,10 @@ namespace SparkClient.Model.Services |
|
|
|
|
|
|
|
|
|
// 算法调用失败时,保存图片到历史记录文件夹 |
|
|
|
|
if (result.status == "P002") |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
// 从配置文件中读取 imageHistoryPath |
|
|
|
|
// 定义历史记录文件夹路径 |
|
|
|
|
string imageHistoryPath = "D:\\ImageHistory"; |
|
|
|
|
string? imageHistoryPath = ConfigurationManager.AppSettings["ImageHistoryPath"]; |
|
|
|
|
// 生成时间戳,格式为 yyyyMMddHHmmss |
|
|
|
|
string timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"); |
|
|
|
|
// 组合新的文件夹路径 |
|
|
|
@ -143,7 +145,6 @@ namespace SparkClient.Model.Services |
|
|
|
|
catch (JsonException ex) |
|
|
|
|
{ |
|
|
|
|
// 记录日志或处理异常 |
|
|
|
|
Console.WriteLine($"Error parsing image_files JSON: {ex.Message}"); |
|
|
|
|
Logger.Error($"Error parsing image_files JSON: {ex.Message}"); |
|
|
|
|
Logger.Error($"Stack Trace: {ex.StackTrace}"); |
|
|
|
|
} |
|
|
|
@ -155,15 +156,11 @@ namespace SparkClient.Model.Services |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
// 记录日志或处理异常 |
|
|
|
|
Console.WriteLine($"Error in CallParseJsonAndReturnActions: {ex.Message}"); |
|
|
|
|
Console.WriteLine($"Stack Trace: {ex.StackTrace}"); |
|
|
|
|
Logger.Error($"Error in CallParseJsonAndReturnActions: {ex.Message}"); |
|
|
|
|
Logger.Error($"Stack Trace: {ex.StackTrace}"); |
|
|
|
|
// 如果有 InnerException,打印出来 |
|
|
|
|
if (ex.InnerException != null) |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine($"Inner Exception: {ex.InnerException.Message}"); |
|
|
|
|
Console.WriteLine($"Inner Stack Trace: {ex.InnerException.StackTrace}"); |
|
|
|
|
Logger.Error($"Inner Exception: {ex.InnerException.Message}"); |
|
|
|
|
Logger.Error($"Inner Stack Trace: {ex.InnerException.StackTrace}"); |
|
|
|
|
} |
|
|
|
|