fix: extension

master
Tongg 9 months ago
parent b732c2db7c
commit f96cd17ef0
  1. 27
      Model/Extension/CommonExtension.cs
  2. 2
      ViewModel/Configuration/AlgorithmConfigVM.cs

@ -5,6 +5,11 @@ namespace SparkClient.Model.Extension;
public static class CommonExtension public static class CommonExtension
{ {
/// <summary>
/// 安全的ToString
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ToSafeString(this object obj) public static string ToSafeString(this object obj)
{ {
if (null == obj) if (null == obj)
@ -16,12 +21,22 @@ public static class CommonExtension
return obj.ToString(); return obj.ToString();
} }
} }
/// <summary>
/// 简单的判断字符串是否为Null或空白
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsNullOrEmpty(this string str) public static bool IsNullOrEmpty(this string str)
{ {
return String.IsNullOrEmpty(str); return String.IsNullOrEmpty(str);
} }
public static string toMD5Code(this object obj) /// <summary>
/// 生成对象签名(Null对象为时间戳)
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string GenerateSign(this object obj)
{ {
if (null == obj) if (null == obj)
{ {
@ -34,6 +49,11 @@ public static class CommonExtension
} }
} }
/// <summary>
/// 字符串按类型转为JToken
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static JToken ConvertJTokenValue(this string value) public static JToken ConvertJTokenValue(this string value)
{ {
// 处理布尔类型(不区分大小写) // 处理布尔类型(不区分大小写)
@ -63,4 +83,9 @@ public static class CommonExtension
// 默认处理为字符串 // 默认处理为字符串
return new JValue(value); return new JValue(value);
} }
// public static string ConvertNumberToString(this ob value)
// {
// return "";
// }
} }

@ -91,7 +91,7 @@ public class AlgorithmConfigVM : BaseViewModel
if (row.Mode == null || row.Spec == null) if (row.Mode == null || row.Spec == null)
continue; continue;
insertSql.Add($"INSERT INTO AGILE_ALGORITHM_CONFIG (GUID, Mode, Spec, Shape, JsonKey, Value)" + insertSql.Add($"INSERT INTO AGILE_ALGORITHM_CONFIG (GUID, Mode, Spec, Shape, JsonKey, Value)" +
$@"VALUES ('{row.toMD5Code()}',{row.Mode.Value},'{row.Spec.Value}','{row.Shape}','{row.JsonKey}','{row.Value}');"); $@"VALUES ('{row.GenerateSign()}',{row.Mode.Value},'{row.Spec.Value}','{row.Shape}','{row.JsonKey}','{row.Value}');");
finalSaveData.Add(row); finalSaveData.Add(row);
} }

Loading…
Cancel
Save