diff --git a/HKCardManager/Form1.cs b/HKCardManager/Form1.cs index cb99066..f3c182a 100644 --- a/HKCardManager/Form1.cs +++ b/HKCardManager/Form1.cs @@ -1,4 +1,3 @@ -using HKLib.DB; using HKCardManager.UserPages; using UHFHelper; @@ -13,7 +12,6 @@ namespace HKCardManager DataGridViewInit(); Task.Factory.StartNew(() => { - DbContext.InitTable(); var res = UHFCardHelper.GetInstance().OpenPort(); if (res != null && res.Res) MessageLogNotify.GetInstance.ShowError("制卡设备已连接!"); diff --git a/HKCardManager/UserPages/CarMangerPage.cs b/HKCardManager/UserPages/CarMangerPage.cs index d553972..4fc5b13 100644 --- a/HKCardManager/UserPages/CarMangerPage.cs +++ b/HKCardManager/UserPages/CarMangerPage.cs @@ -1,7 +1,5 @@ -锘縰sing HKLib.DB.Model.Entity; -using HKLib.Dto; +锘縰sing HKLib.Dto; using HKLib.Interfaces; -using HKLib.Logic; using Snowflake.Core; using System; using System.Collections.Generic; @@ -20,7 +18,7 @@ namespace HKCardManager.UserPages public partial class CarMangerPage : UserControl { //List OrgList = new List(); - List orgTables = new List(); + List orgTables = new List(); List Personnels = new List(); public CarMangerPage() { @@ -35,7 +33,7 @@ namespace HKCardManager.UserPages radioButton1.Checked = true; comboBox2.Visible = false; - orgTables = ServiceHandler.GetOrgList(); + orgTables = HKLibHelper.GetOrg(); Global.UserListDtos.ForEach(item => { if (!string.IsNullOrEmpty(item.UserName)) Personnels.Add(item.UserName); }); comboBox2.DataSource = Personnels; comboBox1.DataSource = Global.OrgList; diff --git a/HKCardManager/UserPages/InstitutionalEntryPage.cs b/HKCardManager/UserPages/InstitutionalEntryPage.cs index 0b21213..34e7404 100644 --- a/HKCardManager/UserPages/InstitutionalEntryPage.cs +++ b/HKCardManager/UserPages/InstitutionalEntryPage.cs @@ -1,5 +1,4 @@ -锘縰sing HKLib.Logic; -using System; +锘縰sing System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -8,6 +7,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using XExten.Advance.LinqFramework; namespace HKCardManager.UserPages { @@ -36,7 +36,7 @@ namespace HKCardManager.UserPages Task.Factory.StartNew(() => { this.Invoke(() => { button2.Enabled = false; }); - if (ServiceHandler.AddOrg(name)) + if (!HKLib.Interfaces.HKLibHelper.SetOrg(name).IsNullOrEmpty()) { Global.OrgList.Add(name); MessageLogNotify.GetInstance.Show($"銆恵name}銆 鏈烘瀯娣诲姞鎴愬姛"); diff --git a/HKCardManager/UserPages/PersonnelEntryPage.cs b/HKCardManager/UserPages/PersonnelEntryPage.cs index 730e188..8a8ae93 100644 --- a/HKCardManager/UserPages/PersonnelEntryPage.cs +++ b/HKCardManager/UserPages/PersonnelEntryPage.cs @@ -1,7 +1,5 @@ -锘縰sing HKLib.DB.Model.Entity; -using HKLib.Dto; +锘縰sing HKLib.Dto; using HKLib.Interfaces; -using HKLib.Logic; using System; using System.Collections.Generic; using System.ComponentModel; @@ -16,14 +14,14 @@ namespace HKCardManager.UserPages { public partial class PersonnelEntryPage : UserControl { - List orgTables = new List(); + List orgTables = new List(); public PersonnelEntryPage() { InitializeComponent(); DataGridViewInit(); EventInit(); - orgTables = ServiceHandler.GetOrgList(); + orgTables = HKLibHelper.GetOrg(); Global.OrgList.Clear(); orgTables?.ForEach(item => { Global.OrgList.Add(item.Name); }); comboBox2.DataSource = Global.OrgList; diff --git a/HKLib/DB/DbContext.cs b/HKLib/DB/DbContext.cs deleted file mode 100644 index 4a46eb4..0000000 --- a/HKLib/DB/DbContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -锘縰sing HKLib.DB.Model; -using SqlSugar; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using XExten.Advance.StaticFramework; - -namespace HKLib.DB -{ - public class DbContext - { - public static SqlSugarScope Context = new SqlSugarScope(new ConnectionConfig() - { - ConnectionString = Route, - DbType = DbType.Sqlite,//鏁版嵁搴撶被鍨 - IsAutoCloseConnection = true //涓嶈鎴恡rue瑕佹墜鍔╟lose - }, db => - { - db.Aop.OnLogExecuting = (sql, pars) => - { - - }; - }); - - public static string Route - { - get - { - var dir = SyncStatic.CreateDir(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Database")); - return $"DataSource={SyncStatic.CreateFile(Path.Combine(dir, "Data.db3"))}"; - } - } - public static void InitTable() - { - var Tables = Assembly.GetAssembly(typeof(DbContext)) - .GetTypes().Where(t => t.BaseType == typeof(BaseEntity)).ToArray(); - Context.CodeFirst.InitTables(Tables); - } - } -} diff --git a/HKLib/DB/Model/BaseEntity.cs b/HKLib/DB/Model/BaseEntity.cs deleted file mode 100644 index 3cd1a4a..0000000 --- a/HKLib/DB/Model/BaseEntity.cs +++ /dev/null @@ -1,20 +0,0 @@ -锘縰sing SqlSugar; -using System; -using System.Collections.Generic; -using System.Text; - -namespace HKLib.DB.Model -{ - public class BaseEntity - { - [SugarColumn(IsPrimaryKey = true)] - public Guid Id { get; set; } - [SugarColumn(ColumnDataType = "DATETIME")] - public DateTime CreateTime { get; set; } - public void Create() - { - this.Id = Guid.NewGuid(); - this.CreateTime = DateTime.Now; - } - } -} diff --git a/HKLib/DB/Model/Entity/OrgTable.cs b/HKLib/DB/Model/Entity/OrgTable.cs deleted file mode 100644 index 7254c47..0000000 --- a/HKLib/DB/Model/Entity/OrgTable.cs +++ /dev/null @@ -1,21 +0,0 @@ -锘縰sing SqlSugar; -using System; -using System.Collections.Generic; -using System.Text; - -namespace HKLib.DB.Model.Entity -{ - [SugarTable("Org")] - public class OrgTable : BaseEntity - { - /// - /// 鏈烘瀯鍚嶇О - /// - public string Name { get; set; } - - /// - /// 鍔犵洘杩斿洖鐨処d - /// - public string SId { get; set; } - } -} diff --git a/HKLib/Dto/OrgDto.cs b/HKLib/Dto/OrgDto.cs new file mode 100644 index 0000000..20b17cd --- /dev/null +++ b/HKLib/Dto/OrgDto.cs @@ -0,0 +1,31 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Text; + +namespace HKLib.Dto +{ + public class OrgDto + { + /// + /// 鏈烘瀯鍚嶇О + /// + public string Name { get; set; } + + /// + /// 鍔犵洘杩斿洖鐨処d + /// + public string SId { get; set; } + } + internal class OrgOutDto + { + /// + /// 鏈烘瀯鍚嶇О + /// + public string Name { get; set; } + + /// + /// 鍔犵洘杩斿洖鐨処d + /// + public string Id { get; set; } + } +} diff --git a/HKLib/HKLib.csproj b/HKLib/HKLib.csproj index d28c9f2..cddb581 100644 --- a/HKLib/HKLib.csproj +++ b/HKLib/HKLib.csproj @@ -8,6 +8,5 @@ - diff --git a/HKLib/Interfaces/HKLibHelper.cs b/HKLib/Interfaces/HKLibHelper.cs index 7ac4e2e..6fea82d 100644 --- a/HKLib/Interfaces/HKLibHelper.cs +++ b/HKLib/Interfaces/HKLibHelper.cs @@ -76,10 +76,21 @@ namespace HKLib.Interfaces }).Build().RunStringFirst().ToModel()["data"]["data"]["id"].ToString(); } - //public static string GetKou() - //{ - ///// api / GateInfo / gatelist ? StoreId = 0c32b2e2 - 0dc9 - 4941 - b73d - 3dc91f7268ab & Current = 1 & PageSize = 10 - //} + public static List GetOrg() + { + var data = IHttpMultiClient.HttpMulti + + .AddNode(t => + { + t.NodePath = $"{Configer.SaasRoute}api/one-card/member-tag-list"; + t.ReqType = MultiType.GET; + }).Build().RunStringFirst().ToModel()["data"]["data"].ToJson().ToModel>(); + return data.Where(t => !t.Name.IsNullOrEmpty()).Select(t => new OrgDto + { + Name = t.Name, + SId = t.Id + }).ToList(); + } /// /// 淇敼鏈烘瀯 diff --git a/HKLib/Logic/ServiceHandler.cs b/HKLib/Logic/ServiceHandler.cs deleted file mode 100644 index 0ac4e71..0000000 --- a/HKLib/Logic/ServiceHandler.cs +++ /dev/null @@ -1,37 +0,0 @@ -锘縰sing HKLib.DB; -using HKLib.DB.Model.Entity; -using HKLib.Interfaces; -using System; -using System.Collections.Generic; -using System.Text; - -namespace HKLib.Logic -{ - public class ServiceHandler - { - #region 鏈烘瀯绫 - public static bool AddOrg(string Name) - { - var check = DbContext.Context.Queryable().First(t => t.Name == Name); - if (check != null) return false; - var SiD = HKLibHelper.SetOrg(Name); - return DbContext.Context.Insertable(new OrgTable - { - Name = Name, - SId = SiD - }).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0; - } - public static List GetOrgList() - { - return DbContext.Context.Queryable().ToList(); - } - public static bool AlterOrg(string Name, string Id) - { - var s = HKLibHelper.AlterOrg(Name, Id); - if (s) - return DbContext.Context.Updateable().SetColumns(t => t.Name == Name).Where(t => t.SId == Id).ExecuteCommandHasChange(); - else return false; - } - #endregion - } -}