/// <summary> /// 操作 /// </summary> /// <param name="item"></param> /// <returns></returns> public IActionResult OnPostBusinessDetailsForm(Data_Business_Details item) { var info = new WriteReturn(); using (var db = new DataContext(AppEtl.Db)) { var table = IFast.Query <Data_Business>(a => a.Id == item.Id).ToItem <Data_Business>(db); var source = IFast.Query <Data_Source>(a => a.Id == item.DataSourceId).ToItem <Data_Source>(db); var key = string.Format(AppEtl.CacheKey.Column, source.Host, item.TableName); var colunm = RedisInfo.Get <List <CacheColumn> >(key, AppEtl.CacheDb).Find(a => a.Name == item.ColumnName); db.BeginTrans(); if (IFast.Query <Data_Business_Details>(a => a.FieldId == item.FieldId).ToCount(db) == 0) { item.FieldId = Guid.NewGuid().ToStr(); info = IFast.Add(item); if (info.IsSuccess) { info = DataSchema.AddColumn(db, table, item, colunm, source); if (info.IsSuccess) { DataSchema.UpdateColumnComment(db, table, item, colunm, source); } } } else { info = IFast.Update <Data_Business_Details>(item, a => a.FieldId == item.FieldId); if (info.IsSuccess) { info.IsSuccess = DataSchema.UpdateColumn(db, table, item, colunm, source); if (info.IsSuccess) { DataSchema.UpdateColumnComment(db, table, item, colunm, source); } } } if (info.IsSuccess) { db.SubmitTrans(); return(new JsonResult(new { success = true, msg = "操作成功" })); } else { db.RollbackTrans(); return(new JsonResult(new { success = false, msg = "操作失败" })); } } }