From c04ea620c30dd8c54ece14b9f788684f0de5a0cc Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期一, 09 九月 2024 09:13:37 +0800 Subject: [PATCH] 增加sqllite库 --- Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpGroup.cs | 79 ++++++ Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPart.cs | 159 +++++++++++++ Service/HStation.Service.Assets.Core/HStation.Service.Assets.Core.csproj | 4 Service/HStation.Service.Organize.Core/04-dal/03-sqlite/UserLoginMap.cs | 18 + WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/03-mgr/XhsProjectMgrPage.cs | 3 Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpSeries.cs | 122 ++++++++++ Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMapGroupAndMain.cs | 18 + Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpTypeSeriesMap.cs | 18 + Service/HStation.Service.Organize.Core/04-dal/03-sqlite/EmployeeMain.cs | 73 ++++++ Service/HStation.Service.Organize.Core/04-dal/03-sqlite/LoginUserMain.cs | 18 + Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMain.cs | 103 ++++++++ Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpType.cs | 18 + Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPropContent.cs | 18 + Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMainAndPartMap.cs | 18 + 14 files changed, 664 insertions(+), 5 deletions(-) diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpGroup.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpGroup.cs new file mode 100644 index 0000000..d72d714 --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpGroup.cs @@ -0,0 +1,79 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpGroup : BaseDAL_Paras_Flags_TagName_Sorter<Entity.PumpGroup>, IPumpGroup + { + /// <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 group = db.Queryable<Entity.PumpGroup>().ToList().Find(x => x.ID == ID); + var groupresult = db.Deleteable(group).ExecuteCommand() > 0; + if (!groupresult) + { + db.RollbackTran(); + return default; + } + else + { + var idlist = db.Queryable<Entity.PumpGroupAndMainMap>() + .Where(x => x.PumpGroupID == group.ID) + .Select(x => x.PumpMainID) // 鍋囪 PumpGroupID 鏄笌 PumpMain 鍏宠仈鐨勫閿� + .ToList(); + var main = db.Queryable<Entity.PumpGroupAndMainMap>() + .Where(x => x.PumpGroupID == group.ID) + .ToList(); + if (main.Count > 0) + { + var Modelresult = db.Deleteable(main).ExecuteCommand() > 0; + if (!Modelresult) + { + db.RollbackTran(); + return default; + } + else + { + var Map = db.Queryable<Entity.PumpMain>().ToList(); + var Mapresult = db.Deleteable<Entity.PumpMain>() + .In(x => x.ID, idlist) + .ExecuteCommand() > 0; + if (!Mapresult) + { + db.RollbackTran(); + return default; + } + } + } + } + db.CommitTran(); + return groupresult; + } + catch (Exception ex) + { + db.RollbackTran(); + throw; + } + } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMain.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMain.cs new file mode 100644 index 0000000..8730938 --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMain.cs @@ -0,0 +1,103 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <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; + } + } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMainAndPartMap.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMainAndPartMap.cs new file mode 100644 index 0000000..2b45796 --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMainAndPartMap.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpMainAndPartMap : BaseDAL<Entity.PumpMainAndPartMap>, IPumpMainAndPartMap + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMapGroupAndMain.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMapGroupAndMain.cs new file mode 100644 index 0000000..16af789 --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpMapGroupAndMain.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpGroupAndMainMap : BaseDAL_Paras_Flags_TagName<Entity.PumpGroupAndMainMap>, IPumpGroupAndMainMap + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPart.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPart.cs new file mode 100644 index 0000000..f95f4a7 --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPart.cs @@ -0,0 +1,159 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpPartMain : BaseDAL_Sorter<Entity.PumpPartMain>, IPumpPartMain + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } + } + + //鎻掑叆鎷撳睍 + public long InsertsEx(Entity.PumpPartMain part, List<Entity.PumpPropContent> pumpPropContents, Entity.PumpMainAndPartMap partmap) + { + if (part == null) + { + return default; + } + using (var db = new SqlSugarClient(ConnectionConfig)) + { + try + { + db.BeginTran(); + var result = db.Insertable(part).ExecuteReturnSnowflakeId(); + if (result < 0) + { + db.RollbackTran(); + return default; + } + else + { + if (partmap != null) + { + partmap.PumpPartID = result; + var mainandpartmap = db.Insertable(partmap).ExecuteReturnSnowflakeId(); + if (mainandpartmap < 0) + { + db.RollbackTran(); + return default; + } + else + { + if (pumpPropContents != null) + { + foreach (var item in pumpPropContents) + { + item.PartID = result; + } + var content = db.Insertable(pumpPropContents).ExecuteReturnSnowflakeId(); + if (content < 0) + { + db.RollbackTran(); + return default; + } + } + } + } + } + + db.CommitTran(); + return result; + } + catch (Exception ex) + { + db.RollbackTran(); + throw; + } + } + } + + //缂栬緫鎷撳睍 + public bool UpdateEx(Entity.PumpPartMain part, List<Entity.PumpPropContent> pumpPropContents) + { + if (part == null) + { + return default; + } + using (var db = new SqlSugarClient(ConnectionConfig)) + { + try + { + db.BeginTran(); + var result = db.Updateable(part).ExecuteCommandHasChange(); + if (!result) + { + db.RollbackTran(); + return default; + } + else + { + if (pumpPropContents != null) + { + var propresult = db.Updateable(pumpPropContents).ExecuteCommandHasChange(); + if (!propresult) + { + db.RollbackTran(); + return default; + } + } + } + db.CommitTran(); + return result; + } + catch (Exception ex) + { + db.RollbackTran(); + throw; + } + } + } + + //鍒犻櫎鎷撳睍 (鍒犻櫎浜у搧琛ㄥ強灞炴�ц〃) + public bool DeleteEx(Entity.PumpPartMain part, List<Entity.PumpPropContent> pumpPropContents) + { + if (part == null) + { + return default; + } + using (var db = new SqlSugarClient(ConnectionConfig)) + { + try + { + db.BeginTran(); + var result = db.Deleteable(part).ExecuteCommand() > 0; + if (!result) + { + db.RollbackTran(); + return default; + } + else + { + if (pumpPropContents != null) + { + var propresult = db.Deleteable(pumpPropContents).ExecuteCommand() > 0; + if (!propresult) + { + db.RollbackTran(); + return default; + } + } + } + db.CommitTran(); + return result; + } + catch (Exception ex) + { + db.RollbackTran(); + throw; + } + } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPropContent.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPropContent.cs new file mode 100644 index 0000000..f7b6ffe --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpPropContent.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpPropContent : BaseDAL<Entity.PumpPropContent>, IPumpPropContent + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpSeries.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpSeries.cs new file mode 100644 index 0000000..e69c022 --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpSeries.cs @@ -0,0 +1,122 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpSeries : BaseDAL_Paras_Flags_TagName_Sorter_UseStatus<Entity.PumpSeries>, IPumpSeries + { + /// <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 project = db.Queryable<Entity.PumpSeries>().ToList().Find(x => x.ID == ID); + var result = db.Deleteable(project).ExecuteCommand() > 0; + if (!result) + { + db.RollbackTran(); + return default; + } + else + { + var group = db.Queryable<Entity.PumpGroup>().ToList().Find(x => x.PumpSeriesID == project.ID); + if (group != null) + { + var groupresult = db.Deleteable(group).ExecuteCommand() > 0; + if (!groupresult) + { + db.RollbackTran(); + return default; + } + else + { + var map = db.Queryable<Entity.PumpGroupAndMainMap>() + .Where(x => x.PumpGroupID == group.ID) + .ToList(); + var listid = db.Queryable<Entity.PumpGroupAndMainMap>() + .Where(x => x.PumpGroupID == group.ID) + .Select(x => x.PumpMainID) + .ToList(); + if (map.Count > 0) + { + var Modelresult = db.Deleteable(map).ExecuteCommand() > 0; + if (!Modelresult) + { + db.RollbackTran(); + return default; + } + else + { + var main = db.Queryable<Entity.PumpMain>().ToList(); + foreach (var item in main) + { + if (item.PumpSeriesID == project.ID) + { + listid.Add(item.ID); + } + } + var mainresult = db.Deleteable<Entity.PumpMain>() + .In(x => x.ID, listid) + .ExecuteCommand() > 0; + if (!mainresult) + { + db.RollbackTran(); + return default; + } + } + } + } + } + else + { + var listid = new List<long>(); + var main = db.Queryable<Entity.PumpMain>().ToList(); + foreach (var item in main) + { + if (item.PumpSeriesID == project.ID) + { + listid.Add(item.ID); + } + } + if (listid.Count > 0) + { + var mainresult = db.Deleteable<Entity.PumpMain>() + .In(x => x.ID, listid) + .ExecuteCommand() > 0; + if (!mainresult) + { + db.RollbackTran(); + return default; + } + } + } + db.CommitTran(); + return result; + } + } + catch (Exception ex) + { + db.RollbackTran(); + throw; + } + } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpType.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpType.cs new file mode 100644 index 0000000..5d5b92e --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpType.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpType : BaseDAL_Sorter<Entity.PumpType>, IPumpType + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpTypeSeriesMap.cs b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpTypeSeriesMap.cs new file mode 100644 index 0000000..8de724f --- /dev/null +++ b/Service/HStation.Service.Assets.Core/04-dal/03-sqlite/PumpTypeSeriesMap.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary> + public partial class PumpTypeSeriesMap : BaseDAL_Sorter<Entity.PumpTypeSeriesMap>, IPumpTypeSeriesMap + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Assets.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Assets.Core/HStation.Service.Assets.Core.csproj b/Service/HStation.Service.Assets.Core/HStation.Service.Assets.Core.csproj index 2849a90..2901351 100644 --- a/Service/HStation.Service.Assets.Core/HStation.Service.Assets.Core.csproj +++ b/Service/HStation.Service.Assets.Core/HStation.Service.Assets.Core.csproj @@ -13,10 +13,6 @@ </ItemGroup> <ItemGroup> - <Folder Include="04-dal\03-sqlite\" /> - </ItemGroup> - - <ItemGroup> <PackageReference Include="Yw.Service.Basic.Core" Version="3.2.8" /> </ItemGroup> diff --git a/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/EmployeeMain.cs b/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/EmployeeMain.cs new file mode 100644 index 0000000..e0131ef --- /dev/null +++ b/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/EmployeeMain.cs @@ -0,0 +1,73 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary>: + public partial class EmployeeMain : BaseDAL_Paras_Flags_TagName_Sorter<Entity.EmployeeMain>, IEmployeeMain + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Organize.ConfigHelper.PostgreSqlConnectionConfig; } + } + + //鎻掑叆鎷撳睍 + public long InsertEx(Entity.EmployeeMain employeeMain, Entity.UserLoginAccount userLogin, Entity.UserLoginMap loginmap) + { + if (employeeMain == null) + { + return default; + } + using (var db = new SqlSugarClient(ConnectionConfig)) + { + try + { + db.BeginTran(); + employeeMain.AddTime = DateTime.Now.ToString(); + var result = db.Insertable(employeeMain).ExecuteReturnSnowflakeId(); + if (result < 0) + { + db.RollbackTran(); + return default; + } + else + { + if (userLogin != null) + { + userLogin.CreateTime = DateTime.Now.ToString(); + var logjinresult = db.Insertable(userLogin).ExecuteReturnSnowflakeId(); + if (logjinresult < 0) + { + db.RollbackTran(); + return default; + } + else + { + loginmap.LoginID = logjinresult; + loginmap.ObjectID = result; + loginmap.ObjectType = 0; + var mapresult = db.Insertable(loginmap).ExecuteReturnSnowflakeId(); + if (mapresult < 0) + { + db.RollbackTran(); + return default; + } + } + } + } + db.CommitTran(); + return result; + } + catch (Exception ex) + { + db.RollbackTran(); + throw; + } + } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/LoginUserMain.cs b/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/LoginUserMain.cs new file mode 100644 index 0000000..b49cf7b --- /dev/null +++ b/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/LoginUserMain.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary>: + public partial class LoginUserMain : BaseDAL<Entity.UserLoginAccount>, ILoginUserMain + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Organize.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/UserLoginMap.cs b/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/UserLoginMap.cs new file mode 100644 index 0000000..fdcba50 --- /dev/null +++ b/Service/HStation.Service.Organize.Core/04-dal/03-sqlite/UserLoginMap.cs @@ -0,0 +1,18 @@ +锘縰sing Yw.DAL.SQLite; + +namespace HStation.DAL.SQLite +{ + /// <summary> + /// + /// </summary>: + public partial class UserLoginMap : BaseDAL<Entity.UserLoginMap>, IUserLoginMap + { + /// <summary> + /// + /// </summary> + public override ConnectionConfig ConnectionConfig + { + get { return Organize.ConfigHelper.PostgreSqlConnectionConfig; } + } + } +} \ No newline at end of file diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/03-mgr/XhsProjectMgrPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/03-mgr/XhsProjectMgrPage.cs index c7a8904..2891c00 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/03-mgr/XhsProjectMgrPage.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/02-project/03-mgr/XhsProjectMgrPage.cs @@ -21,7 +21,8 @@ this.Load += XhsProjectMgrPage_Load; } - private void XhsProjectMgrPage_Load(object sender, EventArgs e) + private void XhsProjectMgrPage_Load + (object sender, EventArgs e) { repositoryItemImageComboBox1.Items.AddEnum(typeof(XhsProjectMgrViewModel.eFileStatus)); var a = typeof(XhsProjectMgrViewModel.eFileStatus); -- Gitblit v1.9.3