|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
|
using System.Data; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.Text; |
|
|
|
|
using System.Windows.Input; |
|
|
|
|
using HandyControl.Controls; |
|
|
|
|
@ -43,6 +44,8 @@ public class AlgorithmConfigVM : BaseViewModel |
|
|
|
|
public void InitAlgorithmData(object param) |
|
|
|
|
{ |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (param == null) |
|
|
|
|
{ |
|
|
|
|
AlgorithmConfigJson = "{}"; |
|
|
|
|
string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER"; |
|
|
|
|
@ -60,6 +63,52 @@ public class AlgorithmConfigVM : BaseViewModel |
|
|
|
|
AlgorithmConfigJson = JToken.Parse(sb.ToString()).ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
string[] types = param.ToString().Split(" "); |
|
|
|
|
string filename = string.Empty; |
|
|
|
|
if (types.Last().Equals("S4")) |
|
|
|
|
{ |
|
|
|
|
filename = "p8p8s4.config"; |
|
|
|
|
}else if (types.Last().Equals("S3")) |
|
|
|
|
{ |
|
|
|
|
filename = "p8p8s3.config"; |
|
|
|
|
}else if (types.Last().Equals("S2")) |
|
|
|
|
{ |
|
|
|
|
filename = "p8p8s2.config"; |
|
|
|
|
}else if (types.Last().Equals("S1")) |
|
|
|
|
{ |
|
|
|
|
filename = "p8p8s1.config"; |
|
|
|
|
}else |
|
|
|
|
{ |
|
|
|
|
filename = "p8p8.config"; |
|
|
|
|
} |
|
|
|
|
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SparkCore", "config",filename); |
|
|
|
|
if (!File.Exists(filePath)) |
|
|
|
|
{ |
|
|
|
|
AlgorithmConfigJson = "{}"; |
|
|
|
|
string sql = @"SELECT JSON as json FROM ALGORITHM_CONFIG ORDER BY JSON_ORDER"; |
|
|
|
|
DataTable dataTable = DataBaseHelper.ExecuteQuery(sql); |
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
if (dataTable != null) |
|
|
|
|
{ |
|
|
|
|
foreach (DataRow row in dataTable.Rows) |
|
|
|
|
{ |
|
|
|
|
sb.Append(row["json"].ToString()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (sb.Length > 0) |
|
|
|
|
{ |
|
|
|
|
AlgorithmConfigJson = JToken.Parse(sb.ToString()).ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
string content = File.ReadAllText(filePath); |
|
|
|
|
AlgorithmConfigJson = JToken.Parse(content).ToString(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
new MessageBox().Show($"{MultilingualHelper.getString("ApplicationError")}{ex.Message}"); |
|
|
|
|
|