/// <summary> /// 数据结构行刷新 /// </summary> /// <param name="objName"></param> /// <param name="objCode"></param> /// <param name="dt">原有数据</param> /// <returns></returns> public static bool Flesh(string objName, string objCode, MDataTable dt, out string msg) { bool result = false; msg = LangConst.NoNewColumn; MDataTable newDt = dt.GetSchema(false); //移除表结构缓存 string tableKey = CacheManage.GetKey(CacheKeyType.Schema, objName); string codeKey = CacheManage.GetKey(CacheKeyType.Schema, objCode); CacheManage.LocalInstance.Remove(tableKey); CacheManage.LocalInstance.Remove(codeKey); if (!string.IsNullOrEmpty(AppConfig.DB.SchemaMapPath)) { IOHelper.Delete(AppConfig.RunPath + AppConfig.DB.SchemaMapPath + tableKey + ".ts"); IOHelper.Delete(AppConfig.RunPath + AppConfig.DB.SchemaMapPath + codeKey + ".ts"); } FillTable(objName, objCode, newDt);//重新获取。 MDataTable addTable = dt.GetSchema(false); // bool needUpdate = false; foreach (MDataRow row in newDt.Rows) { MDataRow mr = dt.FindRow(string.Format("Field='{0}'", row.Get <string>("Field"))); if (mr == null)//找不到,则添加行 { row.Set(Config_Grid.OrderNum, 255); row.Set(Config_Grid.Hidden, true); row.Set(Config_Grid.GridID, Guid.NewGuid()); addTable.Rows.Add(row); } } if (addTable.Rows.Count > 0) { result = addTable.AcceptChanges(AcceptOp.InsertWithID); if (!result) { msg = Convert.ToString((Exception)addTable.DynamicData); } } return(result); }