对比新文件 |
| | |
| | | 锘縰sing Yw.DAL.PostgreSql; |
| | | |
| | | namespace HStation.DAL.PostgreSql |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class PumpMain : BaseDAL_Paras_Flags_TagName_Sorter<Entity.PumpMain>, IPumpMain |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public override ConnectionConfig ConnectionConfig |
| | | { |
| | | get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } |
| | | } |
| | | |
| | | //鍒犻櫎鎷撳睍 |
| | | public bool DeleteEx(long ID) |
| | | { |
| | | if (ID <= 0) |
| | | { |
| | | return default; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var main = db.Queryable<Entity.PumpMain>().ToList().Find(x => x.ID == ID); |
| | | var result = db.Deleteable(main).ExecuteCommand() > 0; |
| | | if (!result) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | else |
| | | { |
| | | var map = db.Queryable<Entity.PumpGroupAndMainMap>().ToList().Find(x => x.PumpMainID == ID); |
| | | if (map != null) |
| | | { |
| | | var mapresult = db.Deleteable(map).ExecuteCommand() > 0; |
| | | if (!mapresult) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return true; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //鎻掑叆鎷撳睍 |
| | | public long InsertsEx(Entity.PumpMain pumpMain, Entity.PumpGroupAndMainMap pumpGroupAndMainMap) |
| | | { |
| | | if (pumpMain == null) |
| | | { |
| | | return default; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var result = db.Insertable(pumpMain).ExecuteReturnSnowflakeId(); |
| | | if (result < 0) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | else |
| | | { |
| | | if (pumpGroupAndMainMap != null) |
| | | { |
| | | pumpGroupAndMainMap.PumpMainID = result; |
| | | var mapresult = db.Insertable(pumpGroupAndMainMap).ExecuteReturnSnowflakeId(); |
| | | if (mapresult < 0) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |