diff --git a/Pilot_KD_Parino/Common/Conv.cs b/Pilot_KD_Parino/Common/Conv.cs
new file mode 100644
index 0000000..3176f1d
--- /dev/null
+++ b/Pilot_KD_Parino/Common/Conv.cs
@@ -0,0 +1,599 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Pilot_KD_Parino.Common
+{
+ public static class Conv
+ {
+ #region ToByte(转换为byte)
+
+ ///
+ /// 转换为8位可空整型
+ ///
+ /// 输入值
+ ///
+ public static byte ToByte(object input)
+ {
+ return ToByte(input, default(byte));
+ }
+
+ ///
+ /// 转换为8位可空整型
+ ///
+ /// 输入值
+ /// 默认值
+ ///
+ public static byte ToByte(object input, byte defaultValue)
+ {
+ return ToByteOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为8位可空整型
+ ///
+ /// 输入值
+ ///
+ public static byte? ToByteOrNull(object input)
+ {
+ byte result;
+ var success = byte.TryParse(input.SafeString(), out result);
+ if (success)
+ {
+ return result;
+ }
+ return null;
+ }
+
+ #endregion
+
+ #region ToChar(转换为char)
+
+ ///
+ /// 转换为字符
+ ///
+ /// 输入值
+ ///
+ public static char ToChar(object input)
+ {
+ return ToChar(input, default(char));
+ }
+
+ ///
+ /// 转换为字符
+ ///
+ /// 输入值
+ /// 默认值
+ ///
+ public static char ToChar(object input, char defaultValue)
+ {
+ return ToCharOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为可空字符
+ ///
+ /// 输入值
+ ///
+ public static char? ToCharOrNull(object input)
+ {
+ char result;
+ var success = char.TryParse(input.SafeString(), out result);
+ if (success)
+ {
+ return result;
+ }
+ return null;
+ }
+
+ #endregion
+
+ #region ToShort(转换为short)
+
+ ///
+ /// 转换为16位整型
+ ///
+ /// 输入值
+ ///
+ public static short ToShort(object input)
+ {
+ return ToShort(input, default(short));
+ }
+
+ ///
+ /// 转换为16位整型
+ ///
+ /// 输入值
+ /// 默认值
+ ///
+ public static short ToShort(object input, short defaultValue)
+ {
+ return ToShortOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为16位可空整型
+ ///
+ /// 输入值
+ ///
+ public static short? ToShortOrNull(object input)
+ {
+ short result;
+ var success = short.TryParse(input.SafeString(), out result);
+ if (success)
+ {
+ return result;
+ }
+ return null;
+ }
+
+ #endregion
+
+ #region ToInt(转换为int)
+ ///
+ /// 转换为32位整型
+ ///
+ /// 输入值
+ ///
+ public static int ToInt(object input)
+ {
+ return ToInt(input, default(int));
+ }
+
+ ///
+ /// 转换为32位整型
+ ///
+ /// 输入值
+ /// 默认值
+ ///
+ public static int ToInt(object input, int defaultValue)
+ {
+ return ToIntOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为32位可空整型
+ ///
+ /// 输入值
+ ///
+ public static int? ToIntOrNull(object input)
+ {
+ int result;
+ var success = int.TryParse(input.SafeString(), out result);
+ if (success)
+ {
+ return result;
+ }
+ try
+ {
+ var temp = ToDoubleOrNull(input, 0);
+ if (temp == null)
+ {
+ return null;
+ }
+ return System.Convert.ToInt32(temp);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ #endregion
+
+ #region ToLong(转换为long)
+ ///
+ /// 转换为64位整型
+ ///
+ /// 输入值
+ ///
+ public static long ToLong(object input)
+ {
+ return ToLong(input, default(long));
+ }
+
+ ///
+ /// 转换为64位整型
+ ///
+ /// 输入值
+ /// 默认值
+ ///
+ public static long ToLong(object input, long defaultValue)
+ {
+ return ToLongOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为64位可空整型
+ ///
+ /// 输入值
+ ///
+ public static long? ToLongOrNull(object input)
+ {
+ long result;
+ var success = long.TryParse(input.SafeString(), out result);
+ if (success)
+ {
+ return result;
+ }
+ try
+ {
+ var temp = ToDecimalOrNull(input, 0);
+ if (temp == null)
+ {
+ return null;
+ }
+ return System.Convert.ToInt64(temp);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+ #endregion
+
+ #region ToFloat(转换为float)
+ ///
+ /// 转换为32位浮点型,并按指定小数位舍入
+ ///
+ /// 输入值
+ /// 小数位数
+ ///
+ public static float ToFloat(object input, int? digits = null)
+ {
+ return ToFloat(input, default(float), digits);
+ }
+
+ ///
+ /// 转换为32位浮点型,并按指定小数位舍入
+ ///
+ /// 输入值
+ /// 默认值
+ /// 小数位数
+ ///
+ public static float ToFloat(object input, float defaultValue, int? digits = null)
+ {
+ return ToFloatOrNull(input, digits) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为32位可空浮点型,并按指定小数位舍入
+ ///
+ /// 输入值
+ /// 小数位数
+ ///
+ public static float? ToFloatOrNull(object input, int? digits = null)
+ {
+ float result;
+ var success = float.TryParse(input.SafeString(), out result);
+ if (!success)
+ {
+ return null;
+ }
+ if (digits == null)
+ {
+ return result;
+ }
+ return (float)Math.Round(result, digits.Value);
+ }
+ #endregion
+
+ #region ToDouble(转换为double)
+ ///
+ /// 转换为64位浮点型,并按指定小数位舍入,温馨提示:4舍6入5成双
+ ///
+ /// 输入值
+ /// 小数位数
+ ///
+ public static double ToDouble(object input, int? digits = null)
+ {
+ return ToDouble(input, default(double), digits);
+ }
+
+ ///
+ /// 转换为64位浮点型,并按指定小数位舍入,温馨提示:4舍6入5成双
+ ///
+ /// 输入值
+ /// 默认值
+ /// 小数位数
+ ///
+ public static double ToDouble(object input, double defaultValue, int? digits = null)
+ {
+ return ToDoubleOrNull(input, digits) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为64位可空浮点型,并按指定小数位舍入,温馨提示:4舍6入5成双
+ ///
+ /// 输入值
+ /// 小数位数
+ ///
+ public static double? ToDoubleOrNull(object input, int? digits = null)
+ {
+ double result;
+ var success = double.TryParse(input.SafeString(), out result);
+ if (!success)
+ {
+ return null;
+ }
+ return digits == null ? result : Math.Round(result, digits.Value);
+ }
+ #endregion
+
+ #region ToDecimal(转换为decimal)
+ ///
+ /// 转换为128位浮点型,并按指定小数位舍入,温馨提示:4舍6入5成双
+ ///
+ /// 输入值
+ /// 小数位数
+ ///
+ public static decimal ToDecimal(object input, int? digits = null)
+ {
+ return ToDecimal(input, default(decimal), digits);
+ }
+
+ ///
+ /// 转换为128位浮点型,并按指定小数位舍入,温馨提示:4舍6入5成双
+ ///
+ /// 输入值
+ /// 默认值
+ /// 小数位数
+ ///
+ public static decimal ToDecimal(object input, decimal defaultValue, int? digits = null)
+ {
+ return ToDecimalOrNull(input, digits) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为128位可空浮点型,并按指定小数位舍入,温馨提示:4舍6入5成双
+ ///
+ /// 输入值
+ /// 小数位数
+ ///
+ public static decimal? ToDecimalOrNull(object input, int? digits = null)
+ {
+ decimal result;
+ var success = decimal.TryParse(input.SafeString(), out result);
+ if (!success)
+ {
+ return null;
+ }
+ if (digits == null)
+ {
+ return result;
+ }
+ return Math.Round(result, digits.Value);
+ }
+ #endregion
+
+ #region ToBool(转换为bool)
+ ///
+ /// 转换为布尔值
+ ///
+ /// 输入值
+ ///
+ public static bool ToBool(object input)
+ {
+ return ToBool(input, default(bool));
+ }
+
+ ///
+ /// 转换为布尔值
+ ///
+ /// 输入值
+ /// 默认值
+ ///
+ public static bool ToBool(object input, bool defaultValue)
+ {
+ return ToBoolOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为可空布尔值
+ ///
+ /// 输入值
+ ///
+ public static bool? ToBoolOrNull(object input)
+ {
+ bool? value = GetBool(input);
+ if (value != null)
+ {
+ return value.Value;
+ }
+ bool result;
+ return bool.TryParse(input.SafeString(), out result) ? (bool?)result : null;
+ }
+
+ ///
+ /// 获取布尔值
+ ///
+ /// 输入值
+ ///
+ private static bool? GetBool(object input)
+ {
+ switch (input.SafeString().ToLower())
+ {
+ case "0":
+ case "否":
+ case "不":
+ case "no":
+ case "fail":
+ return false;
+ case "1":
+ case "是":
+ case "ok":
+ case "yes":
+ return true;
+ default:
+ return null;
+ }
+ }
+ #endregion
+
+ #region ToDate(转换为DateTime)
+ ///
+ /// 转换为日期
+ ///
+ /// 输入值
+ ///
+ public static DateTime ToDate(object input)
+ {
+ return ToDateOrNull(input) ?? DateTime.MinValue;
+ }
+
+ ///
+ /// 转换为可空日期
+ ///
+ /// 输入值
+ ///
+ public static DateTime? ToDateOrNull(object input)
+ {
+ DateTime result;
+ return DateTime.TryParse(input.SafeString(), out result) ? (DateTime?)result : null;
+ }
+ #endregion
+
+ #region ToGuid(转换为Guid)
+ ///
+ /// 转换为Guid
+ ///
+ /// 输入值
+ ///
+ public static Guid ToGuid(object input)
+ {
+ return ToGuidOrNull(input) ?? Guid.Empty;
+ }
+
+ ///
+ /// 转换为可空Guid
+ ///
+ /// 输入值
+ ///
+ public static Guid? ToGuidOrNull(object input)
+ {
+ Guid result;
+ return Guid.TryParse(input.SafeString(), out result) ? (Guid?)result : null;
+ }
+
+ ///
+ /// 转换为Guid集合
+ ///
+ /// 输入值,以逗号分隔的Guid集合字符串,范例:83B0233C-A24F-49FD-8083-1337209EBC9A,EAB523C6-2FE7-47BE-89D5-C6D440C3033A
+ ///
+ public static List ToGuidList(string input)
+ {
+ return ToList(input);
+ }
+ #endregion
+
+ #region ToList(泛型集合转换)
+ ///
+ /// 泛型集合转换
+ ///
+ /// 目标元素类型
+ /// 输入值,以逗号分隔的元素集合字符串,范例:83B0233C-A24F-49FD-8083-1337209EBC9A,EAB523C6-2FE7-47BE-89D5-C6D440C3033A
+ ///
+ public static List ToList(string input)
+ {
+ var result = new List();
+ if (string.IsNullOrWhiteSpace(input))
+ {
+ return result;
+ }
+ var array = input.Split(',');
+ result.AddRange(from each in array where !string.IsNullOrWhiteSpace(each) select To(each));
+ return result;
+ }
+ #endregion
+
+ #region ToEnum(转换为枚举)
+
+ ///
+ /// 转换为枚举
+ ///
+ /// 枚举类型
+ /// 输入值
+ ///
+ public static T ToEnum(object input) where T : struct
+ {
+ return ToEnum(input, default(T));
+ }
+
+ ///
+ /// 转换为枚举
+ ///
+ /// 枚举类型
+ /// 输入值
+ /// 默认值
+ ///
+ public static T ToEnum(object input, T defaultValue) where T : struct
+ {
+ return ToEnumOrNull(input) ?? defaultValue;
+ }
+
+ ///
+ /// 转换为可空枚举
+ ///
+ /// 枚举类型
+ /// 输入值
+ ///
+ public static T? ToEnumOrNull(object input) where T : struct
+ {
+ T result;
+ var success = System.Enum.TryParse(input.SafeString(), true, out result);
+ if (success)
+ {
+ return result;
+ }
+ return null;
+ }
+
+ #endregion
+
+ #region To(通用泛型转换)
+ ///
+ /// 通用泛型转换
+ ///
+ /// 目标类型
+ /// 输入值
+ ///
+ public static T To(object input)
+ {
+ if (input == null)
+ {
+ return default(T);
+ }
+ if (input is string && string.IsNullOrWhiteSpace(input.ToString()))
+ {
+ return default(T);
+ }
+ Type type = Reflection.GetType();
+ try
+ {
+ if (type.Name.ToLower() == "string")
+ {
+ return (T)(object)input.ToString();
+ }
+ if (type.Name.ToLower() == "guid")
+ {
+ return (T)(object)new Guid(input.ToString());
+ }
+ if (type.IsEnum)
+ {
+ return EnumHelper.Parse(input);
+ }
+ if (input is IConvertible)
+ {
+ return (T)System.Convert.ChangeType(input, type);
+ }
+ return (T)input;
+ }
+ catch
+ {
+ return default(T);
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Pilot_KD_Parino/Common/EnumHelper.cs b/Pilot_KD_Parino/Common/EnumHelper.cs
new file mode 100644
index 0000000..c5bd43f
--- /dev/null
+++ b/Pilot_KD_Parino/Common/EnumHelper.cs
@@ -0,0 +1,288 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Pilot_KD_Parino.Common
+{
+ public class EnumHelper
+ {
+ #region Parse(获取实例)
+ ///
+ /// 获取实例
+ ///
+ /// 枚举类型
+ /// 成员名或值,范例:Enum1枚举有成员A=0,则传入"A"或"0"获取 Enum1.A
+ ///
+ public static TEnum Parse(object member)
+ {
+ string value = member.SafeString();
+ if (string.IsNullOrEmpty(value))
+ {
+ if (typeof(TEnum).IsGenericType)
+ {
+ return default(TEnum);
+ }
+ throw new ArgumentNullException(nameof(member));
+ }
+ return (TEnum)System.Enum.Parse(Reflection.GetType(), value, true);
+ }
+ #endregion
+
+ #region GetName(获取成员名)
+ ///
+ /// 获取成员名
+ ///
+ /// 枚举类型
+ /// 成员名、值、实例均可,范例:Enum1枚举有成员A=0,则传入Enum1.A或0,获取成员名"A"
+ ///
+ public static string GetName(object member)
+ {
+ return GetName(Reflection.GetType(), member);
+ }
+
+ ///
+ /// 获取成员名
+ ///
+ /// 枚举类型
+ /// 成员名、值、实例均可,范例:Enum1枚举有成员A=0,则传入Enum1.A或0,获取成员名"A"
+ ///
+ public static string GetName(Type type, object member)
+ {
+ if (type == null)
+ {
+ return string.Empty;
+ }
+ if (member == null)
+ {
+ return string.Empty;
+ }
+ if (member is string)
+ {
+ return member.ToString();
+ }
+ if (type.GetTypeInfo().IsEnum == false)
+ {
+ return string.Empty;
+ }
+ return System.Enum.GetName(type, member);
+ }
+ #endregion
+
+ #region GetNames(获取枚举所有成员名称)
+ ///
+ /// 获取枚举所有成员名称
+ ///
+ /// 枚举类型
+ ///
+ public static string[] GetNames()
+ {
+ return GetNames(typeof(TEnum));
+ }
+
+ ///
+ /// 获取枚举所有成员名称
+ ///
+ /// 枚举类型
+ ///
+ public static string[] GetNames(Type type)
+ {
+ return System.Enum.GetNames(type);
+ }
+ #endregion
+
+ #region GetValue(获取成员值)
+ ///
+ /// 获取成员值
+ ///
+ /// 枚举类型
+ /// 成员名、值、实例均可,范例:Enum1枚举有成员A=0,可传入"A"、0、Enum1.A,获取值0
+ ///
+ public static int GetValue(object member)
+ {
+ return GetValue(Reflection.GetType(), member);
+ }
+ ///
+ /// 获取成员值
+ ///
+ /// 枚举类型
+ /// 成员名、值、实例均可,范例:Enum1枚举有成员A=0,可传入"A"、0、Enum1.A,获取值0
+ ///
+ public static int GetValue(Type type, object member)
+ {
+ string value = member.SafeString();
+ if (string.IsNullOrEmpty(value))
+ {
+ throw new ArgumentNullException(nameof(member));
+ }
+ return (int)System.Enum.Parse(type, member.ToString(), true);
+ }
+ #endregion
+
+ #region GetDescription(获取描述)
+ ///
+ /// 获取描述,使用 特性设置描述
+ ///
+ /// 枚举 typeparam >
+ /// < param name="member">成员名、值、实例均可,范例:Enum1枚举有成员A=0,可传入"A"、0、Enum1.A,获取值0
+ ///
+ public static string GetDescription(object member)
+ {
+ return Reflection.GetDescription(GetName(member));
+ }
+
+ /////
+ ///// 获取描述,使用特性设置描述
+ /////
+ ///// 枚举类型
+ ///// 成员名、值、实例均可,范例:Enum1枚举有成员A=0,可传入"A"、0、Enum1.A,获取值0
+ /////
+ //public static string GetDescription(Type type, object member)
+ //{
+ // return Reflection.GetDescription(type, GetName(type, member));
+ //}
+
+ ///
+ /// 取得描述
+ ///
+ ///
+ ///
+ public static string GetDescription(Enum value)
+ {
+ Type type = value.GetType();
+ FieldInfo item = type.GetField(value.ToString(), BindingFlags.Public | BindingFlags.Static);
+ if (item == null) return null;
+ var attribute = Attribute.GetCustomAttribute(item, typeof(DescriptionAttribute)) as DescriptionAttribute;
+ if (attribute != null && !string.IsNullOrEmpty(attribute.Description)) return attribute.Description;
+ return null;
+ }
+ #endregion
+
+
+ #region GetItems(获取描述项集合)
+ ///
+ /// 获取描述项集合,文本设置为Description,值为Value
+ ///
+ /// 枚举类型
+ ///
+ public static List- GetItems()
+ {
+ return GetItems(Reflection.GetType());
+ }
+
+ ///
+ /// 获取描述项集合,文本设置为Description,值为Value
+ ///
+ /// 枚举类型
+ ///
+ public static List
- GetItems(Type type)
+ {
+ TypeInfo enumType = type.GetTypeInfo();
+ if (enumType.IsEnum == false)
+ {
+ throw new InvalidOperationException($"类型 {type} 不是枚举");
+ }
+ var result = new List
- ();
+ foreach (var field in enumType.GetFields())
+ {
+ AddItem(type, result, field);
+ }
+ return result.OrderBy(t => t.SortId).ToList();
+ }
+
+ ///
+ /// 验证是否枚举类型
+ ///
+ /// 类型
+ private static void ValidateEnum(Type enumType)
+ {
+ if (enumType.IsEnum == false)
+ {
+ throw new InvalidOperationException(string.Format("类型 {0} 不是枚举", enumType));
+ }
+ }
+
+ ///
+ /// 添加描述项
+ ///
+ /// 枚举类型
+ /// 集合
+ /// 字段
+ private static void AddItem(Type type, ICollection
- result, FieldInfo field)
+ {
+ if (!field.FieldType.GetTypeInfo().IsEnum)
+ {
+ return;
+ }
+ var value = GetValue(type, field.Name);
+ var description = Reflection.GetDescription(field);
+ result.Add(new Item(description, value, value));
+ }
+ #endregion
+
+ #region GetEnumItemByDescription(获取指定描述信息的枚举项)
+ ///
+ /// 获取指定描述信息的枚举项
+ ///
+ /// 枚举类型
+ /// 枚举项描述信息
+ ///
+ public static TEnum GetEnumItemByDescription(string desc)
+ {
+ if (string.IsNullOrEmpty(desc))
+ {
+ throw new ArgumentNullException(nameof(desc));
+ }
+ Type type = typeof(TEnum);
+ FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static);
+ FieldInfo fieldInfo =
+ fieldInfos.FirstOrDefault(p => p.GetCustomAttribute(false).Description == desc);
+ if (fieldInfo == null)
+ {
+ throw new ArgumentNullException($"在枚举({type.FullName})中,未发现描述为“{desc}”的枚举项。");
+ }
+ return (TEnum)System.Enum.Parse(type, fieldInfo.Name);
+ }
+ #endregion
+
+ #region GetDictionary(获取枚举字典)
+ ///
+ /// 获取枚举字典
+ ///
+ /// 枚举类型
+ ///
+ public static Dictionary GetDictionary()
+ {
+ Type enumType = Reflection.GetType().GetTypeInfo();
+ ValidateEnum(enumType);
+
+ Dictionary dic = new Dictionary();
+ foreach (var field in enumType.GetFields())
+ {
+ AddItem(dic, field);
+ }
+ return dic;
+ }
+
+ ///
+ /// 添加描述项
+ ///
+ /// 枚举类型
+ /// 集合
+ /// 字典
+ private static void AddItem(Dictionary result, FieldInfo field)
+ {
+ if (!field.FieldType.GetTypeInfo().IsEnum)
+ {
+ return;
+ }
+ var value = GetValue(field.Name);
+ var description = Reflection.GetDescription(field);
+ result.Add(value, description);
+ }
+ #endregion
+ }
+}
diff --git a/Pilot_KD_Parino/Common/Item.cs b/Pilot_KD_Parino/Common/Item.cs
new file mode 100644
index 0000000..cf677ae
--- /dev/null
+++ b/Pilot_KD_Parino/Common/Item.cs
@@ -0,0 +1,69 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Pilot_KD_Parino.Common
+{
+ public class Item : IComparable
-
+ {
+ ///
+ /// 文本
+ ///
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public string Text { get; set; }
+
+ ///
+ /// 值
+ ///
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public object Value { get; set; }
+
+ ///
+ /// 排序号
+ ///
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public int? SortId { get; set; }
+
+ ///
+ /// 组
+ ///
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public string Group { get; }
+
+ ///
+ /// 禁用
+ ///
+ [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
+ public bool? Disabled { get; }
+
+ ///
+ /// 初始化一个类型的实例
+ ///
+ /// 文本
+ /// 值
+ /// 排序号
+ /// 组
+ /// 禁用
+ public Item(string text, object value, int? sortId = null, string group = null, bool? disabled = null)
+ {
+ Text = text;
+ Value = value;
+ SortId = sortId;
+ Group = group;
+ Disabled = disabled;
+ }
+
+ ///
+ /// 比较
+ ///
+ /// 其他列表项
+ ///
+ public int CompareTo(Item other)
+ {
+ return string.Compare(Text, other.Text, StringComparison.CurrentCulture);
+ }
+ }
+}
diff --git a/Pilot_KD_Parino/Common/JsonHelper.cs b/Pilot_KD_Parino/Common/JsonHelper.cs
new file mode 100644
index 0000000..d00307e
--- /dev/null
+++ b/Pilot_KD_Parino/Common/JsonHelper.cs
@@ -0,0 +1,93 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Pilot_KD_Parino.Common
+{
+ public class JsonHelper
+ {
+ ///
+ /// Json序列化器
+ ///
+ static readonly JsonSerializer JsonSerializer = new JsonSerializer();
+
+ #region ToObject(将Json字符串转换为对象)
+ ///
+ /// 将Json字符串转换为对象
+ ///
+ /// Json字符串
+ public static T ToObject(string json)
+ {
+ if (string.IsNullOrWhiteSpace(json))
+ return default(T);
+ return JsonConvert.DeserializeObject(json);
+ }
+ #endregion
+
+ #region ToObject(字节数组转成对象)
+ ///
+ /// 反序列化对象
+ ///
+ /// 值
+ ///
+ public static object ToObject(byte[] value)
+ {
+
+ using (var ms = new MemoryStream(value, writable: false))
+ {
+ using (var tr = new StreamReader(ms))
+ {
+ using (var jr = new JsonTextReader(tr))
+ {
+ jr.Read();
+ if (jr.TokenType == JsonToken.StartArray)
+ {
+ // 读取类型
+ var typeName = jr.ReadAsString();
+ var type = Type.GetType(typeName, throwOnError: true);// 获取类型
+ // 读取对象
+ jr.Read();
+
+ if (type.Name == "String") { return jr.Value; }
+
+ return JsonSerializer.Deserialize(jr, type);
+ }
+ else if (jr.TokenType == JsonToken.StartObject)
+ {
+
+ return null;
+ }
+ else
+ {
+ throw new InvalidDataException("JsonTranscoder 仅支持 [\"TypeName\", object]");
+ }
+ }
+ }
+ }
+ }
+ #endregion
+
+ #region ToJson(将对象转换为Json字符串)
+ ///
+ /// 将对象转换为Json字符串
+ ///
+ /// 目标对象
+ /// 是否将双引号转成单引号
+ public static string ToJson(object target, bool isConvertToSingleQuotes = false)
+ {
+ if (target == null)
+ return "{}";
+ var result = JsonConvert.SerializeObject(target);
+ if (isConvertToSingleQuotes)
+ result = result.Replace("\"", "'");
+ return result;
+ }
+ #endregion
+
+
+ }
+}
diff --git a/Pilot_KD_Parino/Common/Reflection.cs b/Pilot_KD_Parino/Common/Reflection.cs
new file mode 100644
index 0000000..3434a4f
--- /dev/null
+++ b/Pilot_KD_Parino/Common/Reflection.cs
@@ -0,0 +1,555 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.ComponentModel.DataAnnotations;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+
+namespace Pilot_KD_Parino.Common
+{
+ public static class Reflection
+ {
+ #region GetDescription(获取类型描述)
+ ///
+ /// 获取类型描述,使用设置描述
+ ///
+ /// 类型
+ ///
+ public static string GetDescription()
+ {
+ return GetDescription(GetType());
+ }
+
+ ///
+ /// 获取类型成员描述,使用设置描述
+ ///
+ /// 类型
+ /// 成员名称
+ ///
+ public static string GetDescription(string memberName)
+ {
+ return GetDescription(GetType(), memberName);
+ }
+
+ ///
+ /// 获取类型成员描述,使用设置描述
+ ///
+ /// 类型
+ /// 成员名称
+ ///
+ public static string GetDescription(Type type, string memberName)
+ {
+ if (type == null)
+ {
+ return string.Empty;
+ }
+ return string.IsNullOrEmpty(memberName)
+ ? string.Empty
+ : GetDescription(type.GetTypeInfo().GetMember(memberName).FirstOrDefault());
+ }
+
+ ///
+ /// 获取类型成员描述,使用设置描述
+ ///
+ /// 成员
+ ///
+ public static string GetDescription(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return string.Empty;
+ }
+ var attribute = member.GetCustomAttribute(typeof(DescriptionAttribute)) as DescriptionAttribute;
+ return attribute == null ? member.Name : attribute.Description;
+ }
+ #endregion
+
+ #region GetDisplayName(获取类型显示名称)
+ ///
+ /// 获取类型显示名称,使用设置显示名称
+ ///
+ /// 类型
+ ///
+ public static string GetDisplayName()
+ {
+ return GetDisplayName(GetType());
+ }
+
+ ///
+ /// 获取类型显示名称,使用设置显示名称
+ ///
+ /// 类型
+ ///
+ private static string GetDisplayName(Type type)
+ {
+ if (type == null)
+ {
+ return string.Empty;
+ }
+ var attribute = type.GetCustomAttribute(typeof(DisplayNameAttribute)) as DisplayNameAttribute;
+ return attribute != null ? attribute.DisplayName : string.Empty;
+ }
+
+ ///
+ /// 获取类型成员显示名称,,使用或设置显示名称
+ ///
+ /// 成员
+ ///
+ private static string GetDisplayName(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return string.Empty;
+ }
+ var displayNameAttribute = member.GetCustomAttribute(typeof(DisplayNameAttribute)) as DisplayNameAttribute;
+ if (displayNameAttribute != null)
+ {
+ return displayNameAttribute.DisplayName;
+ }
+ var displayAttribute = member.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute;
+ if (displayAttribute == null)
+ {
+ return string.Empty;
+ }
+ return displayAttribute.Description;
+ }
+
+ #endregion
+
+ #region GetDisplayNameOrDescription(获取显示名称或类型描述)
+ ///
+ /// 获取类型显示名称或描述,使用设置描述,使用设置显示名称
+ ///
+ /// 类型
+ ///
+ public static string GetDisplayNameOrDescription()
+ {
+ var type = GetType();
+ var result = GetDisplayName(type);
+ if (string.IsNullOrEmpty(result))
+ {
+ result = GetDescription(type);
+ }
+ return result;
+ }
+
+ ///
+ /// 获取类型显示名称或成员描述,使用设置描述,使用或设置显示名称
+ ///
+ /// 成员
+ ///
+ public static string GetDisplayNameOrDescription(MemberInfo member)
+ {
+ var result = GetDisplayName(member);
+ if (!string.IsNullOrEmpty(result))
+ {
+ return result;
+ }
+ return GetDescription(member);
+ }
+ #endregion
+
+ #region GetTypesByInterface(获取实现了接口的所有具体类型)
+ ///
+ /// 获取实现了接口的所有具体类型
+ ///
+ /// 接口类型
+ /// 在该程序集中查找
+ ///
+ public static List GetTypesByInterface(Assembly assembly)
+ {
+ var typeInterface = typeof(TInterface);
+ return
+ assembly.GetTypes()
+ .Where(
+ t =>
+ typeInterface.GetTypeInfo().IsAssignableFrom(t) && t != typeInterface &&
+ t.GetTypeInfo().IsAbstract == false)
+ .Select(t => CreateInstance(t))
+ .ToList();
+ }
+ #endregion
+
+ #region CreateInstance(动态创建实例)
+ ///
+ /// 动态创建实例
+ ///
+ /// 目标类型
+ /// 类型
+ /// 传递给构造函数的参数
+ ///
+ public static T CreateInstance(Type type, params object[] parameters)
+ {
+ return Conv.To(Activator.CreateInstance(type, parameters));
+ }
+
+ ///
+ /// 动态创建实例
+ ///
+ /// 目标类型
+ /// 类名,包括命名空间,如果类型不处于当前执行程序集中,需要包含程序集名,范例:Test.Core.Test2,Test.Core
+ /// 传递给构造函数的参数
+ ///
+ public static T CreateInstance(string className, params object[] parameters)
+ {
+ Type type = Type.GetType(className) ?? Assembly.GetCallingAssembly().GetType(className);
+ return CreateInstance(type, parameters);
+ }
+ #endregion
+
+ #region GetAssembly(获取程序集)
+ ///
+ /// 获取程序集
+ ///
+ /// 程序集名称
+ ///
+ public static Assembly GetAssembly(string assemblyName)
+ {
+ return Assembly.Load(new AssemblyName(assemblyName));
+ }
+ #endregion
+
+ #region GetAssemblies(从目录获取所有程序集)
+ ///
+ /// 从目录获取所有程序集
+ ///
+ /// 目录绝对路径
+ ///
+ public static List GetAssemblies(string directoryPath)
+ {
+ return
+ Directory.GetFiles(directoryPath, "*.*", SearchOption.AllDirectories)
+ .ToList()
+ .Where(t => t.EndsWith(".exe") || t.EndsWith(".dll"))
+ .Select(path => Assembly.Load(new AssemblyName(path)))
+ .ToList();
+ }
+ #endregion
+
+ #region GetAttribute(获取特性信息)
+
+ ///
+ /// 获取特性信息
+ ///
+ /// 泛型特性
+ /// 元数据
+ ///
+ public static TAttribute GetAttribute(MemberInfo memberInfo) where TAttribute : Attribute
+ {
+ return (TAttribute)memberInfo.GetCustomAttributes(typeof(TAttribute), false).FirstOrDefault();
+ }
+
+ #endregion
+
+ #region GetAttributes(获取特性信息数据)
+
+ ///
+ /// 获取特性信息数组
+ ///
+ /// 泛型特性
+ /// 元数据
+ ///
+ public static TAttribute[] GetAttributes(MemberInfo memberInfo) where TAttribute : Attribute
+ {
+ return Array.ConvertAll(memberInfo.GetCustomAttributes(typeof(TAttribute), false), x => (TAttribute)x);
+ }
+
+ #endregion
+
+ #region IsBool(是否布尔类型)
+ ///
+ /// 是否布尔类型
+ ///
+ /// 成员
+ ///
+ public static bool IsBool(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return false;
+ }
+ switch (member.MemberType)
+ {
+ case MemberTypes.TypeInfo:
+ return member.ToString() == "System.Boolean";
+ case MemberTypes.Property:
+ return IsBool((PropertyInfo)member);
+ }
+ return false;
+ }
+
+ ///
+ /// 是否布尔类型
+ ///
+ /// 属性
+ ///
+ public static bool IsBool(PropertyInfo property)
+ {
+ return property.PropertyType == typeof(bool) || property.PropertyType == typeof(bool?);
+ }
+ #endregion
+
+ #region IsEnum(是否枚举类型)
+ ///
+ /// 是否枚举类型
+ ///
+ /// 成员
+ ///
+ public static bool IsEnum(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return false;
+ }
+ switch (member.MemberType)
+ {
+ case MemberTypes.TypeInfo:
+ return ((TypeInfo)member).IsEnum;
+ case MemberTypes.Property:
+ return IsEnum((PropertyInfo)member);
+ }
+ return false;
+ }
+
+ ///
+ /// 是否枚举类型
+ ///
+ /// 属性
+ ///
+ public static bool IsEnum(PropertyInfo property)
+ {
+ if (property.PropertyType.GetTypeInfo().IsEnum)
+ {
+ return true;
+ }
+ var value = Nullable.GetUnderlyingType(property.PropertyType);
+ if (value == null)
+ {
+ return false;
+ }
+ return value.GetTypeInfo().IsEnum;
+ }
+ #endregion
+
+ #region IsDate(是否日期类型)
+ ///
+ /// 是否日期类型
+ ///
+ /// 成员
+ ///
+ public static bool IsDate(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return false;
+ }
+ switch (member.MemberType)
+ {
+ case MemberTypes.TypeInfo:
+ return member.ToString() == "System.DateTime";
+ case MemberTypes.Property:
+ return IsDate((PropertyInfo)member);
+ }
+ return false;
+ }
+
+ ///
+ /// 是否日期类型
+ ///
+ /// 属性
+ ///
+ public static bool IsDate(PropertyInfo property)
+ {
+ if (property.PropertyType == typeof(DateTime))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(DateTime?))
+ {
+ return true;
+ }
+ return false;
+ }
+ #endregion
+
+ #region IsInt(是否整型)
+ ///
+ /// 是否整型
+ ///
+ /// 成员
+ ///
+ public static bool IsInt(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return false;
+ }
+ switch (member.MemberType)
+ {
+ case MemberTypes.TypeInfo:
+ return member.ToString() == "System.Int32" || member.ToString() == "System.Int16" ||
+ member.ToString() == "System.Int64";
+ case MemberTypes.Property:
+ return IsInt((PropertyInfo)member);
+ }
+ return false;
+ }
+
+ ///
+ /// 是否整型
+ ///
+ /// 成员
+ ///
+ public static bool IsInt(PropertyInfo property)
+ {
+ if (property.PropertyType == typeof(int))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(int?))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(short))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(short?))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(long))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(long?))
+ {
+ return true;
+ }
+ return false;
+ }
+ #endregion
+
+ #region IsNumber(是否数值类型)
+ ///
+ /// 是否数值类型
+ ///
+ /// 成员
+ ///
+ public static bool IsNumber(MemberInfo member)
+ {
+ if (member == null)
+ {
+ return false;
+ }
+
+ if (IsInt(member))
+ {
+ return true;
+ }
+ switch (member.MemberType)
+ {
+ case MemberTypes.TypeInfo:
+ return member.ToString() == "System.Double" || member.ToString() == "System.Decimal" ||
+ member.ToString() == "System.Single";
+ case MemberTypes.Property:
+ return IsNumber((PropertyInfo)member);
+ }
+ return false;
+ }
+
+ ///
+ /// 是否数值类型
+ ///
+ /// 属性
+ ///
+ public static bool IsNumber(PropertyInfo property)
+ {
+ if (property.PropertyType == typeof(double))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(double?))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(decimal))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(decimal?))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(float))
+ {
+ return true;
+ }
+ if (property.PropertyType == typeof(float?))
+ {
+ return true;
+ }
+ return false;
+ }
+ #endregion
+
+ #region IsGenericCollection(是否泛型集合)
+ ///
+ /// 是否泛型集合
+ ///
+ /// 类型
+ ///
+ public static bool IsGenericCollection(Type type)
+ {
+ if (!type.IsGenericType)
+ {
+ return false;
+ }
+ var typeDefinition = type.GetGenericTypeDefinition();
+ return typeDefinition == typeof(IEnumerable<>)
+ || typeDefinition == typeof(IReadOnlyCollection<>)
+ || typeDefinition == typeof(IReadOnlyList<>)
+ || typeDefinition == typeof(ICollection<>)
+ || typeDefinition == typeof(IList<>)
+ || typeDefinition == typeof(List<>);
+ }
+ #endregion
+
+ #region GetTypeName(获取类型名称)
+
+ ///
+ /// 减去全名正则
+ ///
+ static readonly Regex SubtractFullNameRegex = new Regex(@", Version=\d+.\d+.\d+.\d+, Culture=\w+, PublicKeyToken=\w+", RegexOptions.Compiled);
+
+ ///
+ /// 获取类型名称
+ ///
+ /// 类型
+ ///
+ public static string GetTypeName(Type type)
+ {
+ return SubtractFullNameRegex.Replace(type.AssemblyQualifiedName, "");
+ }
+
+ #endregion
+
+ #region GetType(获取类型)
+ ///
+ /// 获取类型
+ ///
+ /// 类型
+ ///
+ public static Type GetType()
+ {
+ var type = typeof(T);
+ return Nullable.GetUnderlyingType(type) ?? type;
+ }
+ #endregion
+
+ }
+}
diff --git a/Pilot_KD_Parino/Pilot_KD_Parino.csproj b/Pilot_KD_Parino/Pilot_KD_Parino.csproj
index d62c0bb..722ccf9 100644
--- a/Pilot_KD_Parino/Pilot_KD_Parino.csproj
+++ b/Pilot_KD_Parino/Pilot_KD_Parino.csproj
@@ -267,8 +267,9 @@
..\..\派诺(1)\派诺\git\6、程序\GZ_KD_Parino\bin\Debug\log4net.dll
-
- ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll
+
+ False
+ ..\packages\Newtonsoft.Json.dll
..\..\派诺(1)\派诺\git\6、程序\GZ_KD_Parino\bin\Debug\NPOI.dll
@@ -287,6 +288,7 @@
..\..\派诺(1)\派诺\git\6、程序\GZ_KD_Parino\bin\Debug\Oracle.DataAccess.dll
+
False
@@ -314,6 +316,7 @@
+
diff --git a/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs b/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs
index bda6cce..52324c9 100644
--- a/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs
+++ b/Pilot_KD_Parino/QPHY_AutoWrire/Bill5.cs
@@ -460,6 +460,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
var oneToOneTemp = (from q in SaleBILLLIS2Sal
join u in ReceiveBILLLIST on new { q.FClient, q.FDAMOUNT } equals new { u.FClient, u.FDAMOUNT }
select new { q.FClient, q.FBIllNO, q.FCONTRACTNUMBER, u.FDAMOUNT, UFbillNo = u.FBIllNO }).ToList();
+ //var dasdsas = oneToOneTemp.Where(h => h.FBIllNO == "PL-XSDD20250400471").FirstOrDefault();
var saleList1 = oneToOneTemp.Select(t => t.FBIllNO).Distinct().ToList();
var ReceiveList1 = oneToOneTemp.Select(t => t.UFbillNo).Distinct().ToList();
if (saleList1.Count > ReceiveList1.Count)
@@ -704,7 +705,7 @@ namespace Pilot_KD_Parino.QPHY_AutoWrire
//绑定收款单数据
- foreach (var item in ReceiveBILLLIST)
+ foreach (var item in ReceiveBILLLIST2)
{
if (!string.IsNullOrWhiteSpace(item.FCONTRACTNUMBER))
{
diff --git a/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs b/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs
index 72445de..b14cbc5 100644
--- a/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs
+++ b/Pilot_KD_Parino/SQL/SqlManage_yuyubo.cs
@@ -130,7 +130,7 @@ namespace Pilot_KD_Parino.SQL
FROM T_AR_RECEIVEBILL A
WHERE A.FDOCUMENTSTATUS = 'C'
AND A.FISINIT != '1'
-
+
AND A.FRECAMOUNT != A.F_AMOUNT
AND A.FRECAMOUNT >= A.F_AMOUNT {where}
order by FCONTACTUNIT,A.FID desc ", FORGID);
diff --git a/Pilot_KD_Parino/Sal_Order/PushSaleOutBillPlugIn.cs b/Pilot_KD_Parino/Sal_Order/PushSaleOutBillPlugIn.cs
index c2daa14..067cf6b 100644
--- a/Pilot_KD_Parino/Sal_Order/PushSaleOutBillPlugIn.cs
+++ b/Pilot_KD_Parino/Sal_Order/PushSaleOutBillPlugIn.cs
@@ -16,6 +16,8 @@ using Kingdee.BOS.Orm;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
+using Newtonsoft.Json.Linq;
+using Pilot_KD_Parino.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -45,16 +47,29 @@ namespace Pilot_KD_Parino.Sal_Order
var FEntity = this.View.Model.DataObject;
var fid = FEntity.GetPrimaryKeyValue();
- var json = JsonUtil.Serialize(FEntity);
- Logger.Error("FEntity",json,new Exception());
+ //var json = JsonUtil.Serialize(FEntity);
+ //var row = JsonHelper.ToObject(json);
+ //Logger.Error("FEntity",json,new Exception());
var id = FEntity["id"];
var FSALEORGID = FEntity["SaleOrgId"];
- this.View.ShowMessage("就是这个按钮"+ id);
+ sBillNo = FEntity["BillNo"].ToString();//发货通知单号
+ var detailList = (FEntity["SAL_DELIVERYNOTICEENTRY"]);
+ //sId = row.Id;//发货通知单ID
+ //sEntryId = row.SAL_DELIVERYNOTICEENTRY Convert.ToInt64(row.EntryPrimaryKeyValue);//发货通知单ID
+ //string sSql = "select FID from T_SAL_DELIVERYNOTICEENTRY where FID= " + sId + " and FENTRYID= " + sEntryId + " and abs(FBaseUnitQty) > abs(FBASEJOINOUTQTY) ";
+ //sSql = String.Format(@"/*dialect*/" + sSql);
+ //var dt = DBServiceHelper.ExecuteDynamicObject(this.Context, sSql);
+ if (detailList!=null)
+ {
+ string getSourceSql = "select FID from T_SAL_DELIVERYNOTICE where FBILLNO='" + sBillNo + "'";
+ IOperationResult result = Invoke("SAL_DELIVERYNOTICE", "PUR_ReceiveBill", getSourceSql, "7cd93c259999489c97798063f2f7bd70");
+ }
- return;
- //ListSelectedRowCollection rows = this.ListView.SelectedRowsInfo;
+ //this.View.ShowMessage("就是这个按钮"+ id);
+
+ //ListSelectedRowCollection rows =new ListSelectedRowCollection();
//List pkIds = new List();
//List