public DataTable GetWorkOrderRevertByOrderID(string OrderID, string OrderByStr) { DataTable dt = new DataTable(); int totalCount = 0; Entities.QueryWorkOrderReceiver query = new QueryWorkOrderReceiver(); query.OrderID = OrderID; dt = Dal.WorkOrderReceiver.Instance.GetWorkOrderReceiver(query, OrderByStr, 1, 99999, out totalCount); #region 处理LogDesc字段 if (dt != null) { #region 反射,添加字段 PropertyInfo[] myfList = typeof(LogDesc).GetProperties(); for (int i = 0; i < myfList.Length; i++) { dt.Columns.Add(myfList[i].Name); } #endregion foreach (DataRow dr in dt.Rows) { try { LogDesc checkInfo = (LogDesc)Newtonsoft.Json.JsonConvert.DeserializeObject(dr["LogDesc"].ToString(), typeof(LogDesc)); if (checkInfo != null) { for (int i = 0; i < myfList.Length; i++) { dr[myfList[i].Name] = myfList[i].GetValue(checkInfo, null); } } } catch (Exception ex) { } } } #endregion return(dt); }
private Entities.WorkOrderRevert GetWorkOrderRevertByLogDesc(string LogDesc) { Entities.WorkOrderRevert model = new Entities.WorkOrderRevert(); PropertyInfo[] myfList = typeof(LogDesc).GetProperties(); LogDesc checkInfo = (LogDesc)Newtonsoft.Json.JsonConvert.DeserializeObject(LogDesc, typeof(LogDesc)); if (checkInfo != null) { for (int i = 0; i < myfList.Length; i++) { PropertyInfo p = typeof(Entities.WorkOrderRevert).GetProperty(myfList[i].Name); if (p != null) { object val = myfList[i].GetValue(checkInfo, null); p.SetValue(model, val, null); } } } return(model); }