@@ -3,9 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 | |||
# Visual Studio Version 17 | |||
VisualStudioVersion = 17.3.32804.467 | |||
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 | |||
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 | |||
Global | |||
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}.Release|Any CPU.ActiveCfg = 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 | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -7,6 +7,8 @@ using System.Configuration; | |||
using System.Windows.Controls; | |||
using System.Windows.Threading; | |||
using System.Windows; | |||
using Microsoft.Extensions.Configuration; | |||
using HKCardIN.Helper; | |||
namespace HKCardIN | |||
{ | |||
@@ -17,6 +19,7 @@ namespace HKCardIN | |||
/// </summary> | |||
protected override void OnStart() | |||
{ | |||
HKLog.HKLogImport.Init("HKCardIN"); | |||
} | |||
protected override void ConfigureIoC(IStyletIoCBuilder builder) | |||
@@ -28,6 +31,9 @@ namespace HKCardIN | |||
/// </summary> | |||
protected override void Configure() | |||
{ | |||
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build(); | |||
DataBus.SaasRoute = configer["SaasRoute"]; | |||
DataBus.LockCode = configer["LockCode"]; | |||
base.Configure(); | |||
} | |||
@@ -71,6 +77,7 @@ namespace HKCardIN | |||
/// <param name="e"></param> | |||
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) | |||
{ | |||
HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception); | |||
GC.Collect(); | |||
} | |||
} | |||
@@ -24,9 +24,14 @@ | |||
</ItemGroup> | |||
<ItemGroup> | |||
<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="SqlSugarCore" Version="5.1.2.7" /> | |||
<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> | |||
<Resource Include="HKResouces\头像.png" /> | |||
@@ -13,9 +13,8 @@ namespace HKCardIN.Helper | |||
public class DataBus | |||
{ | |||
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 | |||
{ | |||
@@ -4,6 +4,8 @@ using StyletIoC; | |||
using System; | |||
using System.Windows.Threading; | |||
using System.Windows; | |||
using Microsoft.Extensions.Configuration; | |||
using HKCardOUT.Helper; | |||
namespace HKCardOUT | |||
{ | |||
@@ -14,6 +16,7 @@ namespace HKCardOUT | |||
/// </summary> | |||
protected override void OnStart() | |||
{ | |||
HKLog.HKLogImport.Init("HKCardOUT"); | |||
} | |||
protected override void ConfigureIoC(IStyletIoCBuilder builder) | |||
@@ -25,6 +28,8 @@ namespace HKCardOUT | |||
/// </summary> | |||
protected override void Configure() | |||
{ | |||
var configer = (new ConfigurationBuilder()).AddJsonFile("options.json").Build(); | |||
DataBus.ConnectionString = configer.GetConnectionString("Sqlite"); | |||
base.Configure(); | |||
} | |||
@@ -68,6 +73,7 @@ namespace HKCardOUT | |||
/// <param name="e"></param> | |||
protected override void OnUnhandledException(DispatcherUnhandledExceptionEventArgs e) | |||
{ | |||
HKLog.HKLogImport.WriteError(e.Exception.InnerException != null ? e.Exception.InnerException : e.Exception); | |||
GC.Collect(); | |||
} | |||
} | |||
@@ -19,16 +19,30 @@ | |||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | |||
<DefineConstants>TRACE;Core</DefineConstants> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<None Remove="HKResouces\背景.jpg" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<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="Stylet" Version="1.3.6" /> | |||
<PackageReference Include="SqlSugarCore" Version="5.1.2.7" /> | |||
<PackageReference Include="XExten.Advance" Version="1.2.4.2-preview" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Resource Include="HKResouces\背景.jpg" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Update="options.json"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</None> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="Logic\Model\" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<ProjectReference Include="..\HKLog\HKLog.csproj" /> | |||
</ItemGroup> | |||
</Project> |
@@ -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)); | |||
} | |||
} | |||
} | |||
} |
@@ -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) => | |||
{ | |||
}; | |||
}); | |||
} | |||
} |
@@ -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> |
@@ -1,4 +1,7 @@ | |||
{ | |||
"SaasRoute": "", | |||
"Cron": "" | |||
"Cron": "", | |||
"ConnectionStrings": { | |||
"Sqlite": "HKSQL.db3" | |||
} | |||
} |
@@ -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> |
@@ -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); | |||
} | |||
} | |||
} |