对比新文件 |
| | |
| | | 锘縰sing Yw.DAL.SQLite; |
| | | |
| | | namespace HStation.DAL.SQLite |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public partial class XhsProject : BaseDAL_Paras_Flags_TagName_TreeSorter<Entity.XhsProject>, IXhsProject |
| | | { |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | public override ConnectionConfig ConnectionConfig |
| | | { |
| | | get { return Xhs.ConfigHelper.SQLiteConnectionConfig; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 鎻掑叆鎷撳睍 |
| | | /// </summary> |
| | | public long InsertEx(Entity.XhsProject entityProject, List<Entity.XhsProjectSite> entityProjectSiteList) |
| | | { |
| | | if (entityProject == null) |
| | | { |
| | | return default; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | if (entityProject.ID < 1) |
| | | { |
| | | entityProject.ID = db.Insertable(entityProject).ExecuteReturnSnowflakeId(); |
| | | if (entityProject.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var bol = db.Insertable(entityProject).ExecuteCommand() > 0; |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | |
| | | if (entityProjectSiteList != null && entityProjectSiteList.Count > 0) |
| | | { |
| | | foreach (var entityProjectSite in entityProjectSiteList) |
| | | { |
| | | entityProjectSite.ProjectID = entityProject.ID; |
| | | if (entityProjectSite.ID < 1) |
| | | { |
| | | entityProjectSite.ID = db.Insertable(entityProjectSite).ExecuteReturnSnowflakeId(); |
| | | if (entityProjectSite.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | var bol = db.Insertable(entityProjectSite).ExecuteCommand() >= 0; |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return default; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return entityProject.ID; |
| | | } |
| | | catch |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 缂栬緫鎷撳睍 |
| | | /// </summary> |
| | | public bool UpdateEx(Entity.XhsProject entityProject, List<Entity.XhsProjectSite> entityProjectSiteList) |
| | | { |
| | | if (entityProject == null) |
| | | { |
| | | return false; |
| | | } |
| | | if (entityProject.ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var bol = db.Updateable(entityProject).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | if (entityProjectSiteList != null && entityProjectSiteList.Count > 0) |
| | | { |
| | | foreach (var entityProjectSite in entityProjectSiteList) |
| | | { |
| | | entityProjectSite.ProjectID = entityProject.ID; |
| | | if (entityProjectSite.ID < 1) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | bol = db.Updateable(entityProjectSite).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | db.CommitTran(); |
| | | return true; |
| | | } |
| | | catch |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 閫氳繃 ID 鍒犻櫎 锛堟嫇灞曪級 |
| | | /// </summary> |
| | | public bool DeleteExByID(long ID) |
| | | { |
| | | if (ID < 1) |
| | | { |
| | | return false; |
| | | } |
| | | using (var db = new SqlSugarClient(ConnectionConfig)) |
| | | { |
| | | try |
| | | { |
| | | db.BeginTran(); |
| | | var bol = db.Deleteable<Entity.XhsProject>().Where(x => x.ID == ID).ExecuteCommandHasChange(); |
| | | if (!bol) |
| | | { |
| | | db.RollbackTran(); |
| | | return false; |
| | | } |
| | | db.Deleteable<Entity.XhsProjectSite>().Where(x => x.ProjectID == ID).ExecuteCommandHasChange(); |
| | | db.CommitTran(); |
| | | return true; |
| | | } |
| | | catch |
| | | { |
| | | db.RollbackTran(); |
| | | throw; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |