|
|
@ -2,6 +2,7 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Reflection;
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
using Furion.JsonSerialization;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
@ -138,12 +139,18 @@ public static class JsonUtil
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prop.SetValue(model, ToDBC(sourceVal.ToString().ToUpper()));
|
|
|
|
prop.SetValue(model, ToDBC(sourceVal.ToString().ToUpper()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 全角改为半角
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="input"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
public static string ToDBC(string input)
|
|
|
|
public static string ToDBC(string input)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char[] c = input.ToCharArray();
|
|
|
|
char[] c = input.ToCharArray();
|
|
|
@ -160,32 +167,10 @@ public static class JsonUtil
|
|
|
|
return new string(c);
|
|
|
|
return new string(c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 处理所有时间字段,将Datetime.Min设置为null
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
|
|
|
public static void MinDateToNull(object model)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var props = model.GetType().GetProperties();
|
|
|
|
|
|
|
|
foreach (PropertyInfo prop in props)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (prop.PropertyType == typeof(DateTime?))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DateTime? sourceVal = (DateTime?)prop.GetValue(model);
|
|
|
|
|
|
|
|
if (sourceVal != null && sourceVal.HasValue && sourceVal.Value == DateTime.MinValue)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
prop.SetValue(model, null);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 去空格
|
|
|
|
/// 长TAB键的识别替换空格
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public static void TrimFields(object model)
|
|
|
|
public static bool TrimFields(object model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var props = model.GetType().GetProperties();
|
|
|
|
var props = model.GetType().GetProperties();
|
|
|
|
foreach (PropertyInfo prop in props)
|
|
|
|
foreach (PropertyInfo prop in props)
|
|
|
@ -196,9 +181,36 @@ public static class JsonUtil
|
|
|
|
object sourceVal = prop.GetValue(model);
|
|
|
|
object sourceVal = prop.GetValue(model);
|
|
|
|
if (sourceVal != null)
|
|
|
|
if (sourceVal != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
prop.SetValue(model, ToDBC(sourceVal.ToString().Trim()));
|
|
|
|
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace(" ", " "));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace(" "," "));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace(",", ","));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("。", "."));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("?", "?"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("!", "!"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("《", "<<"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("》", ">>"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("》", ">>"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace(";", ";"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("‘", "'"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("’", "'"));
|
|
|
|
|
|
|
|
prop.SetValue(model, sourceVal.ToString().Replace("、", ","));
|
|
|
|
|
|
|
|
if (Regex.IsMatch(sourceVal.ToString(), @"[\u4e00-\u9fa5]")&&!(propName.ToUpper()=="YARD"|| propName.ToUpper() == "CARRIER" || propName.ToUpper() == "YARDREMARK" || propName.ToUpper() == "SOREMARK"
|
|
|
|
|
|
|
|
|| propName.ToUpper() == "SIREMARK" || propName.ToUpper() == "OP" || propName.ToUpper() == "DOC" || propName.ToUpper() == "SALE" || propName.ToUpper() == "CUSTSERVICE"
|
|
|
|
|
|
|
|
|| propName.ToUpper() == "CUSTOMERNAME" || propName.ToUpper() == "SIREMARK" || propName.ToUpper() == "SHIPAGENCY"
|
|
|
|
|
|
|
|
)) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|