| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public Entity.RunAnalyConfigure GetByObjectTypeAndObjectID(string ObjectType, long ObjectID) |
| | | { |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | return db.Queryable<Entity.RunAnalyConfigure>() |
| | | .Where(x => x.ObjectType == ObjectType && x.ObjectID == ObjectID) |
| | | .First(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public long InsertOrUpdate(Entity.RunAnalyConfigurePure pure) |
| | | { |
| | | if (pure == null) |
| | | { |
| | | return default; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var entity = db.Queryable<Entity.RunAnalyConfigure>() |
| | | .Where(x => x.ObjectType == pure.ObjectType && x.ObjectID == pure.ObjectID) |
| | | .First(); |
| | | if (entity == null) |
| | | { |
| | | entity = new Entity.RunAnalyConfigure(pure); |
| | | } |
| | | else |
| | | { |
| | | entity.Reset(pure); |
| | | } |
| | | |
| | | if (entity.ID < 1) |
| | | { |
| | | entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId(); |
| | | if (entity.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var bol = db.Updateable(entity).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | return entity.ID; |
| | | } |
| | | catch |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置 |
| | | /// </summary> |
| | | public bool Set(List<Entity.RunAnalyConfigure> entityList) |
| | | public bool Set(List<Entity.RunAnalyConfigurePure> pureList) |
| | | { |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var ids = new List<long>(); |
| | | if (entityList != null && entityList.Count > 0) |
| | | if (pureList != null && pureList.Count > 0) |
| | | { |
| | | foreach (var entity in entityList) |
| | | foreach (var pure in pureList) |
| | | { |
| | | var entity = db.Queryable<Entity.RunAnalyConfigure>() |
| | | .Where(x => x.ObjectType == pure.ObjectType && x.ObjectID == pure.ObjectID) |
| | | .First(); |
| | | if (entity == null) |
| | | { |
| | | entity = new Entity.RunAnalyConfigure(pure); |
| | | } |
| | | else |
| | | { |
| | | entity.Reset(pure); |
| | | } |
| | | |
| | | if (entity.ID < 1) |
| | | { |
| | | entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId(); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | ids.Add(entity.ID); |
| | | } |
| | | } |
| | | |
| | | db.Deleteable<Entity.RunAnalyConfigure>().Where(x => !ids.Contains(x.ID)).ExecuteCommandHasChange(); |
| | | db.CommitTran(); |
| | | return true; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 通过 ObjectType 和 ObjectID 删除 |
| | | /// </summary> |
| | | public bool DeleteByObjectTypeAndObjectID(string ObjectType, long ObjectID) |
| | | { |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | return db.Deleteable<Entity.RunAnalyConfigure>() |
| | | .Where(x => x.ObjectType == ObjectType && x.ObjectID == ObjectID) |
| | | .ExecuteCommandHasChange(); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |