| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 插入拓展 |
| | | /// </summary> |
| | | public long InsertEx(Entity.BimfaceFile entity, List<Entity.BimfaceFileLabel> entityLabelList) |
| | | { |
| | | if (entity == null) |
| | | { |
| | | return default; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (entity.ID > 0) |
| | | { |
| | | var bol = db.Insertable(entity).ExecuteCommand() > 0; |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | entity.ID = db.Insertable(entity).ExecuteReturnSnowflakeId(); |
| | | } |
| | | if (entity.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | if (entityLabelList != null && entityLabelList.Count > 0) |
| | | { |
| | | entityLabelList.ForEach(x => |
| | | { |
| | | x.BimfaceFileID = entity.ID; |
| | | if (x.ID < 1) |
| | | { |
| | | x.ID = SnowFlakeSingle.instance.NextId(); |
| | | } |
| | | }); |
| | | var bol = db.Insertable(entityLabelList).ExecuteCommand() > 0; |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return entity.ID; |
| | | } |
| | | catch |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新 FileStatus |
| | | /// </summary> |
| | | public bool UpdateFileStatus(long ID, int FileStatus) |