add - SlnMesnac.WPF

master
wenjy 11 months ago
parent bd055f08d7
commit 7cb0a952ac

@ -31,8 +31,6 @@ namespace SlnMesnac.Serilog
.CreateLogger();
app.UseSerilogRequestLogging();
Log.Information($"项目初始化完成,日志存放路径:{appConfig.logPath}");
return app;
}
}

@ -0,0 +1,9 @@
<Application x:Class="SlnMesnac.WPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SlnMesnac.WPF"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,54 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;
using SlnMesnac.Config;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace SlnMesnac.WPF
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public static IServiceProvider ServiceProvider;
// Startup事件
protected override async void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
var host = CreateHostBuilder(e.Args).Build();//生成宿主。
ServiceProvider = host.Services;
await host.StartAsync();
var appConfig = host.Services.GetService<AppConfig>();
var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";
Log.Information($"系统初始化完成,日志存放路径:{appConfig.logPath}");
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
// Exit事件
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
// 释放资源
// ...
}
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,12 @@
<Window x:Class="SlnMesnac.WPF.MainWindow"
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:local="clr-namespace:SlnMesnac.WPF"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace SlnMesnac.WPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Common\SlnMesnac.Common.csproj" />
<ProjectReference Include="..\SlnMesnac.Config\SlnMesnac.Config.csproj" />
<ProjectReference Include="..\SlnMesnac.Model\SlnMesnac.Model.csproj" />
<ProjectReference Include="..\SlnMesnac.Plc\SlnMesnac.Plc.csproj" />
<ProjectReference Include="..\SlnMesnac.Quartz\SlnMesnac.Quartz.csproj" />
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.Serilog\SlnMesnac.Serilog.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,84 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Config;
using SlnMesnac.Common;
using SlnMesnac.Quartz;
using SlnMesnac.Repository;
using SlnMesnac.Plc;
using SlnMesnac.Serilog;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
namespace SlnMesnac.WPF
{
/// <summary>
///
/// </summary>
public class Startup
{
/// <summary>
/// This method gets called by the runtime. Use this method to add services to the container.
/// </summary>
/// <param name="services"></param>
[Obsolete]
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//注册配置类
services.AddSingleton<AppConfig>(provider =>
{
var configuration = provider.GetService<IConfiguration>();
return configuration.GetSection("AppConfig").Get<AppConfig>();
});
//注册通用类
services.AddCommonSetup();
//注册SqlSugar
services.AddSqlSugarSetup();
//注册服务
services.AddServices();
//注册任务调度
services.AddQuartzSetUp();
//注册PLC
services.AddPlcSetup();
}
/// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
//启用Serilog中间件
app.UseSerilogExtensions();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

@ -0,0 +1,15 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "E:\\桌面\\日常代码\\SlnMesnac\\SlnMesnac\\bin\\Debug\\net6.0",
"mesConnStr": "server=.;uid=sa;pwd=123456;database=JiangYinMENS",
"mcsConnStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
}
}

@ -9,15 +9,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Common", "SlnMesn
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Config", "SlnMesnac.Config\SlnMesnac.Config.csproj", "{6EF7F087-7149-4689-885C-E0D05E1A9AA8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Model", "SlnMesnac.Model\SlnMesnac.Model.csproj", "{9EC081B6-971F-418C-A40C-5B8AD2E27417}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Model", "SlnMesnac.Model\SlnMesnac.Model.csproj", "{9EC081B6-971F-418C-A40C-5B8AD2E27417}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Repository", "SlnMesnac.Repository\SlnMesnac.Repository.csproj", "{C892C06A-496B-43B6-AEC7-AF9D70778C0C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Repository", "SlnMesnac.Repository\SlnMesnac.Repository.csproj", "{C892C06A-496B-43B6-AEC7-AF9D70778C0C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Quartz", "SlnMesnac.Quartz\SlnMesnac.Quartz.csproj", "{12ED397C-951E-411C-9C43-CDABA79CA45B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Quartz", "SlnMesnac.Quartz\SlnMesnac.Quartz.csproj", "{12ED397C-951E-411C-9C43-CDABA79CA45B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Serilog", "SlnMesnac.Serilog\SlnMesnac.Serilog.csproj", "{DEE2F305-733C-47C8-891C-502121ABAD00}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Serilog", "SlnMesnac.Serilog\SlnMesnac.Serilog.csproj", "{DEE2F305-733C-47C8-891C-502121ABAD00}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Plc", "SlnMesnac.Plc\SlnMesnac.Plc.csproj", "{D17E9024-9D25-4CE4-8E98-8A6C859CE436}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Plc", "SlnMesnac.Plc\SlnMesnac.Plc.csproj", "{D17E9024-9D25-4CE4-8E98-8A6C859CE436}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.WPF", "SlnMesnac.WPF\SlnMesnac.WPF.csproj", "{B986555B-86D1-457A-95F5-B9135B9FBC55}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -57,6 +59,10 @@ Global
{D17E9024-9D25-4CE4-8E98-8A6C859CE436}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D17E9024-9D25-4CE4-8E98-8A6C859CE436}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D17E9024-9D25-4CE4-8E98-8A6C859CE436}.Release|Any CPU.Build.0 = Release|Any CPU
{B986555B-86D1-457A-95F5-B9135B9FBC55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B986555B-86D1-457A-95F5-B9135B9FBC55}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B986555B-86D1-457A-95F5-B9135B9FBC55}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B986555B-86D1-457A-95F5-B9135B9FBC55}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save