@@ -1,4 +1,3 @@ | |||||
using HKLib.DB; | |||||
using HKCardManager.UserPages; | using HKCardManager.UserPages; | ||||
using UHFHelper; | using UHFHelper; | ||||
@@ -13,7 +12,6 @@ namespace HKCardManager | |||||
DataGridViewInit(); | DataGridViewInit(); | ||||
Task.Factory.StartNew(() => | Task.Factory.StartNew(() => | ||||
{ | { | ||||
DbContext.InitTable(); | |||||
var res = UHFCardHelper.GetInstance().OpenPort(); | var res = UHFCardHelper.GetInstance().OpenPort(); | ||||
if (res != null && res.Res) | if (res != null && res.Res) | ||||
MessageLogNotify.GetInstance.ShowError("制卡设备已连接!"); | MessageLogNotify.GetInstance.ShowError("制卡设备已连接!"); | ||||
@@ -1,7 +1,5 @@ | |||||
using HKLib.DB.Model.Entity; | |||||
using HKLib.Dto; | |||||
using HKLib.Dto; | |||||
using HKLib.Interfaces; | using HKLib.Interfaces; | ||||
using HKLib.Logic; | |||||
using Snowflake.Core; | using Snowflake.Core; | ||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
@@ -20,7 +18,7 @@ namespace HKCardManager.UserPages | |||||
public partial class CarMangerPage : UserControl | public partial class CarMangerPage : UserControl | ||||
{ | { | ||||
//List<string> OrgList = new List<string>(); | //List<string> OrgList = new List<string>(); | ||||
List<OrgTable> orgTables = new List<OrgTable>(); | |||||
List<OrgDto> orgTables = new List<OrgDto>(); | |||||
List<string> Personnels = new List<string>(); | List<string> Personnels = new List<string>(); | ||||
public CarMangerPage() | public CarMangerPage() | ||||
{ | { | ||||
@@ -35,7 +33,7 @@ namespace HKCardManager.UserPages | |||||
radioButton1.Checked = true; | radioButton1.Checked = true; | ||||
comboBox2.Visible = false; | comboBox2.Visible = false; | ||||
orgTables = ServiceHandler.GetOrgList(); | |||||
orgTables = HKLibHelper.GetOrg(); | |||||
Global.UserListDtos.ForEach(item => { if (!string.IsNullOrEmpty(item.UserName)) Personnels.Add(item.UserName); }); | Global.UserListDtos.ForEach(item => { if (!string.IsNullOrEmpty(item.UserName)) Personnels.Add(item.UserName); }); | ||||
comboBox2.DataSource = Personnels; | comboBox2.DataSource = Personnels; | ||||
comboBox1.DataSource = Global.OrgList; | comboBox1.DataSource = Global.OrgList; | ||||
@@ -1,5 +1,4 @@ | |||||
using HKLib.Logic; | |||||
using System; | |||||
using System; | |||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.ComponentModel; | using System.ComponentModel; | ||||
using System.Data; | using System.Data; | ||||
@@ -8,6 +7,7 @@ using System.Linq; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using System.Windows.Forms; | using System.Windows.Forms; | ||||
using XExten.Advance.LinqFramework; | |||||
namespace HKCardManager.UserPages | namespace HKCardManager.UserPages | ||||
{ | { | ||||
@@ -36,7 +36,7 @@ namespace HKCardManager.UserPages | |||||
Task.Factory.StartNew(() => | Task.Factory.StartNew(() => | ||||
{ | { | ||||
this.Invoke(() => { button2.Enabled = false; }); | this.Invoke(() => { button2.Enabled = false; }); | ||||
if (ServiceHandler.AddOrg(name)) | |||||
if (!HKLib.Interfaces.HKLibHelper.SetOrg(name).IsNullOrEmpty()) | |||||
{ | { | ||||
Global.OrgList.Add(name); | Global.OrgList.Add(name); | ||||
MessageLogNotify.GetInstance.Show($"【{name}】 机构添加成功"); | MessageLogNotify.GetInstance.Show($"【{name}】 机构添加成功"); | ||||
@@ -1,7 +1,5 @@ | |||||
using HKLib.DB.Model.Entity; | |||||
using HKLib.Dto; | |||||
using HKLib.Dto; | |||||
using HKLib.Interfaces; | using HKLib.Interfaces; | ||||
using HKLib.Logic; | |||||
using System; | using System; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using System.ComponentModel; | using System.ComponentModel; | ||||
@@ -16,14 +14,14 @@ namespace HKCardManager.UserPages | |||||
{ | { | ||||
public partial class PersonnelEntryPage : UserControl | public partial class PersonnelEntryPage : UserControl | ||||
{ | { | ||||
List<OrgTable> orgTables = new List<OrgTable>(); | |||||
List<OrgDto> orgTables = new List<OrgDto>(); | |||||
public PersonnelEntryPage() | public PersonnelEntryPage() | ||||
{ | { | ||||
InitializeComponent(); | InitializeComponent(); | ||||
DataGridViewInit(); | DataGridViewInit(); | ||||
EventInit(); | EventInit(); | ||||
orgTables = ServiceHandler.GetOrgList(); | |||||
orgTables = HKLibHelper.GetOrg(); | |||||
Global.OrgList.Clear(); | Global.OrgList.Clear(); | ||||
orgTables?.ForEach(item => { Global.OrgList.Add(item.Name); }); | orgTables?.ForEach(item => { Global.OrgList.Add(item.Name); }); | ||||
comboBox2.DataSource = Global.OrgList; | comboBox2.DataSource = Global.OrgList; | ||||
@@ -1,44 +0,0 @@ | |||||
using 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 //不设成true要手动close | |||||
}, 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); | |||||
} | |||||
} | |||||
} |
@@ -1,20 +0,0 @@ | |||||
using 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; | |||||
} | |||||
} | |||||
} |
@@ -1,21 +0,0 @@ | |||||
using SqlSugar; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace HKLib.DB.Model.Entity | |||||
{ | |||||
[SugarTable("Org")] | |||||
public class OrgTable : BaseEntity | |||||
{ | |||||
/// <summary> | |||||
/// 机构名称 | |||||
/// </summary> | |||||
public string Name { get; set; } | |||||
/// <summary> | |||||
/// 加盟返回的Id | |||||
/// </summary> | |||||
public string SId { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,31 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace HKLib.Dto | |||||
{ | |||||
public class OrgDto | |||||
{ | |||||
/// <summary> | |||||
/// 机构名称 | |||||
/// </summary> | |||||
public string Name { get; set; } | |||||
/// <summary> | |||||
/// 加盟返回的Id | |||||
/// </summary> | |||||
public string SId { get; set; } | |||||
} | |||||
internal class OrgOutDto | |||||
{ | |||||
/// <summary> | |||||
/// 机构名称 | |||||
/// </summary> | |||||
public string Name { get; set; } | |||||
/// <summary> | |||||
/// 加盟返回的Id | |||||
/// </summary> | |||||
public string Id { get; set; } | |||||
} | |||||
} |
@@ -8,6 +8,5 @@ | |||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> | <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" /> | ||||
<PackageReference Include="Snowflake.Core" Version="2.0.0" /> | <PackageReference Include="Snowflake.Core" Version="2.0.0" /> | ||||
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | <PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | ||||
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | </Project> |
@@ -76,10 +76,21 @@ namespace HKLib.Interfaces | |||||
}).Build().RunStringFirst().ToModel<JObject>()["data"]["data"]["id"].ToString(); | }).Build().RunStringFirst().ToModel<JObject>()["data"]["data"]["id"].ToString(); | ||||
} | } | ||||
//public static string GetKou() | |||||
//{ | |||||
///// api / GateInfo / gatelist ? StoreId = 0c32b2e2 - 0dc9 - 4941 - b73d - 3dc91f7268ab & Current = 1 & PageSize = 10 | |||||
//} | |||||
public static List<OrgDto> GetOrg() | |||||
{ | |||||
var data = IHttpMultiClient.HttpMulti | |||||
.AddNode(t => | |||||
{ | |||||
t.NodePath = $"{Configer.SaasRoute}api/one-card/member-tag-list"; | |||||
t.ReqType = MultiType.GET; | |||||
}).Build().RunStringFirst().ToModel<JObject>()["data"]["data"].ToJson().ToModel<List<OrgOutDto>>(); | |||||
return data.Where(t => !t.Name.IsNullOrEmpty()).Select(t => new OrgDto | |||||
{ | |||||
Name = t.Name, | |||||
SId = t.Id | |||||
}).ToList(); | |||||
} | |||||
/// <summary> | /// <summary> | ||||
/// 修改机构 | /// 修改机构 | ||||
@@ -1,37 +0,0 @@ | |||||
using 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<OrgTable>().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<OrgTable> GetOrgList() | |||||
{ | |||||
return DbContext.Context.Queryable<OrgTable>().ToList(); | |||||
} | |||||
public static bool AlterOrg(string Name, string Id) | |||||
{ | |||||
var s = HKLibHelper.AlterOrg(Name, Id); | |||||
if (s) | |||||
return DbContext.Context.Updateable<OrgTable>().SetColumns(t => t.Name == Name).Where(t => t.SId == Id).ExecuteCommandHasChange(); | |||||
else return false; | |||||
} | |||||
#endregion | |||||
} | |||||
} |