Browse Source

刷卡端

Lishi
xxe 2 years ago
parent
commit
a958d480d1
13 changed files with 154 additions and 21 deletions
  1. +8
    -2
      HKCard.sln
  2. +7
    -0
      HKCardIN/Bootstrapper.cs
  3. +5
    -0
      HKCardIN/HKCardIN.csproj
  4. +2
    -3
      HKCardIN/Helper/DataBus.cs
  5. +6
    -0
      HKCardOUT/Bootstrapper.cs
  6. +14
    -0
      HKCardOUT/HKCardOUT.csproj
  7. BIN
     
  8. +24
    -0
      HKCardOUT/Helper/DataBus.cs
  9. +26
    -0
      HKCardOUT/Logic/DbContext.cs
  10. +21
    -15
      HKCardOUT/Views/RootView.xaml
  11. +4
    -1
      HKCardOUT/options.json
  12. +13
    -0
      HKLog/HKLog.csproj
  13. +24
    -0
      HKLog/HKLogImport.cs

+ 8
- 2
HKCard.sln View File

@@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32804.467 VisualStudioVersion = 17.3.32804.467
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HKCardIN", "HKCardIN\HKCardIN.csproj", "{B1174E5F-41B1-447E-BCDD-3C94E311487D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKCardIN", "HKCardIN\HKCardIN.csproj", "{B1174E5F-41B1-447E-BCDD-3C94E311487D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HKCardOUT", "HKCardOUT\HKCardOUT.csproj", "{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HKCardOUT", "HKCardOUT\HKCardOUT.csproj", "{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HKLog", "HKLog\HKLog.csproj", "{617E076F-D422-44B7-8455-006AA34ECD45}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -21,6 +23,10 @@ Global
{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Debug|Any CPU.Build.0 = Debug|Any CPU {A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Release|Any CPU.ActiveCfg = Release|Any CPU {A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Release|Any CPU.Build.0 = Release|Any CPU {A03F8002-B946-4FD6-BEE7-54EFC199FE4E}.Release|Any CPU.Build.0 = Release|Any CPU
{617E076F-D422-44B7-8455-006AA34ECD45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{617E076F-D422-44B7-8455-006AA34ECD45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{617E076F-D422-44B7-8455-006AA34ECD45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{617E076F-D422-44B7-8455-006AA34ECD45}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE


+ 7
- 0
HKCardIN/Bootstrapper.cs View File

@@ -7,6 +7,8 @@ using System.Configuration;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Threading; using System.Windows.Threading;
using System.Windows; using System.Windows;
using Microsoft.Extensions.Configuration;
using HKCardIN.Helper;


namespace HKCardIN namespace HKCardIN
{ {
@@ -17,6 +19,7 @@ namespace HKCardIN
/// </summary> /// </summary>
protected override void OnStart() protected override void OnStart()
{ {
HKLog.HKLogImport.Init("HKCardIN");
} }


protected override void ConfigureIoC(IStyletIoCBuilder builder) protected override void ConfigureIoC(IStyletIoCBuilder builder)
@@ -28,6 +31,9 @@ namespace HKCardIN
/// </summary> /// </summary>
protected override void Configure() protected override void Configure()
{ {
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
DataBus.SaasRoute = configer["SaasRoute"];
DataBus.LockCode = configer["LockCode"];
base.Configure(); base.Configure();
} }


@@ -71,6 +77,7 @@ namespace HKCardIN
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{ {
HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception);
GC.Collect(); GC.Collect();
} }
} }


+ 5
- 0
HKCardIN/HKCardIN.csproj View File

@@ -24,9 +24,14 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HandyControls" Version="3.4.1" /> <PackageReference Include="HandyControls" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Stylet" Version="1.3.6" /> <PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> <PackageReference Include="SqlSugarCore" Version="5.1.2.7" />
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> <PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HKLog\HKLog.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="HKResouces\头像.png" /> <Resource Include="HKResouces\头像.png" />


+ 2
- 3
HKCardIN/Helper/DataBus.cs View File

@@ -13,9 +13,8 @@ namespace HKCardIN.Helper
public class DataBus public class DataBus
{ {
public static bool NetWordState { get; set; } = false; public static bool NetWordState { get; set; } = false;
public static JObject Option => SyncStatic.ReadFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "options.json")).ToModel<JObject>();
public static string SaasRoute => Option["SaasRoute"].ToString();
public static string LockCode => Option["LockCode"].ToString();
public static string SaasRoute { get; set; }
public static string LockCode { get; set; }
} }
public class ApiRoute public class ApiRoute
{ {


+ 6
- 0
HKCardOUT/Bootstrapper.cs View File

@@ -4,6 +4,8 @@ using StyletIoC;
using System; using System;
using System.Windows.Threading; using System.Windows.Threading;
using System.Windows; using System.Windows;
using Microsoft.Extensions.Configuration;
using HKCardOUT.Helper;


namespace HKCardOUT namespace HKCardOUT
{ {
@@ -14,6 +16,7 @@ namespace HKCardOUT
/// </summary> /// </summary>
protected override void OnStart() protected override void OnStart()
{ {
HKLog.HKLogImport.Init("HKCardOUT");
} }


protected override void ConfigureIoC(IStyletIoCBuilder builder) protected override void ConfigureIoC(IStyletIoCBuilder builder)
@@ -25,6 +28,8 @@ namespace HKCardOUT
/// </summary> /// </summary>
protected override void Configure() protected override void Configure()
{ {
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build();
DataBus.ConnectionString = configer.GetConnectionString("Sqlite");
base.Configure(); base.Configure();
} }


@@ -68,6 +73,7 @@ namespace HKCardOUT
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e)
{ {
HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception);
GC.Collect(); GC.Collect();
} }
} }


+ 14
- 0
HKCardOUT/HKCardOUT.csproj View File

@@ -19,16 +19,30 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DefineConstants>TRACE;Core</DefineConstants> <DefineConstants>TRACE;Core</DefineConstants>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="HKResouces\背景.jpg" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="HandyControls" Version="3.4.1" /> <PackageReference Include="HandyControls" Version="3.4.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Quartz" Version="3.4.0" /> <PackageReference Include="Quartz" Version="3.4.0" />
<PackageReference Include="Stylet" Version="1.3.6" /> <PackageReference Include="Stylet" Version="1.3.6" />
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> <PackageReference Include="SqlSugarCore" Version="5.1.2.7" />
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> <PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="HKResouces\背景.jpg" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="options.json"> <None Update="options.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Logic\Model\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HKLog\HKLog.csproj" />
</ItemGroup>
</Project> </Project>

BIN
View File


+ 24
- 0
HKCardOUT/Helper/DataBus.cs View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XExten.Advance.StaticFramework;

namespace HKCardOUT.Helper
{
public class DataBus
{
private static string _ConnectionString;
public static string ConnectionString
{
get => _ConnectionString;
set
{
var Route = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DATA");
_ConnectionString = SyncStatic.CreateFile(Path.Combine(SyncStatic.CreateDir(Route), value));
}
}
}
}

+ 26
- 0
HKCardOUT/Logic/DbContext.cs View File

@@ -0,0 +1,26 @@
using HKCardOUT.Helper;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HKCardOUT.Logic
{
public class DbContext
{
public static SqlSugarScope Context = new(new ConnectionConfig()
{
ConnectionString = DataBus.ConnectionString,//连接符字串
DbType = DbType.Sqlite,//数据库类型
IsAutoCloseConnection = true //不设成true要手动close
}, db =>
{
db.Aop.OnLogExecuting = (sql, pars) =>
{

};
});
}
}

+ 21
- 15
HKCardOUT/Views/RootView.xaml View File

@@ -1,16 +1,22 @@
<hc:Window x:Class="HKCardOUT.Views.RootView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:HKCardOUT.ViewModels"
xmlns:hc="https://handyorg.github.io/handycontrol"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
Title="{Binding Title}"
WindowStartupLocation="CenterScreen"
ShowTitle="True"
Height="450"
Width="800">
<TextBlock Text="Hello World" HorizontalAlignment="Center" VerticalAlignment="Center" />
<hc:Window
x:Class="HKCardOUT.Views.RootView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:viewModels="clr-namespace:HKCardOUT.ViewModels"
Title="海科智慧一卡通平台"
d:DataContext="{d:DesignInstance Type=viewModels:RootViewModel}"
ShowMaxButton="False"
ShowMinButton="False"
ShowTitle="True"
Topmost="True"
WindowStartupLocation="CenterScreen"
WindowState="Maximized"
mc:Ignorable="d">
<hc:Window.Background>
<ImageBrush ImageSource="/HKResouces/背景.jpg" />
</hc:Window.Background>

</hc:Window> </hc:Window>

+ 4
- 1
HKCardOUT/options.json View File

@@ -1,4 +1,7 @@
{ {
"SaasRoute": "", "SaasRoute": "",
"Cron": ""
"Cron": "",
"ConnectionStrings": {
"Sqlite": "HKSQL.db3"
}
} }

+ 13
- 0
HKLog/HKLog.csproj View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>

</Project>

+ 24
- 0
HKLog/HKLogImport.cs View File

@@ -0,0 +1,24 @@
using Serilog;

namespace HKLog
{
public class HKLogImport
{
public static void Init(string input)
{
//日志
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.File($"Logs/{input}.log", rollingInterval: RollingInterval.Day)
.CreateLogger();
}
public static void WriteInfo(string msg)
{
Log.Logger.Information(msg);
}
public static void WriteError(Exception ex)
{
Log.Logger.Error(ex, ex.Message);
}
}
}

Loading…
Cancel
Save