Merge pull request 'dev' (#2) from dev into master

Reviewed-on: #2
master
wenjy 9 months ago
commit 8b5a08d9d6

@ -1,15 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Common
{
public static class CommonSetup
{
public static void AddCommonSetup(this IServiceCollection services)
{
services.AddSingleton<StringChange>();
}
}
}

@ -4,6 +4,28 @@ using System.Linq.Expressions;
using System.Linq;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Common
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Common
{
/// <summary>

@ -5,21 +5,32 @@ using System.IO;
using System.Linq;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Common
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Common
{
public class StringChange
{
//private static readonly Lazy<StringChange> lazy = new Lazy<StringChange>(() => new StringChange());
//public static StringChange Instance
//{
// get
// {
// return lazy.Value;
// }
//}
//private StringChange() { }
/// <summary>
/// 将字符串强制转换成int转换失败则返回0
/// </summary>

@ -2,11 +2,34 @@
using System;
using System.Collections.Generic;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Config
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Config
{
/// <summary>
/// 系统配置
/// </summary>
#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class AppConfig : IOptions<AppConfig>
{
/// <summary>

@ -1,8 +1,31 @@
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Config
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Config
{
/// <summary>
/// PLC配置通过AppConfig进行获取
/// </summary>
#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class PlcConfig
{
/// <summary>

@ -1,4 +1,26 @@
namespace SlnMesnac.Config
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Config
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Config
{
public class RfidConfig
{
@ -10,7 +32,7 @@
/// <summary>
/// 设备 IP
/// </summary>
public string equipIp { get; set; }
public string? equipIp { get; set; }
/// <summary>
/// 设备 Port
@ -20,7 +42,7 @@
/// <summary>
/// 设备 Key
/// </summary>
public string equipKey { get; set; }
public string? equipKey { get; set; }
/// <summary>
/// 是否启用

@ -1,8 +1,31 @@
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Config
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Config
{
/// <summary>
/// Sql连接配置
/// </summary>
#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class SqlConfig
{
/// <summary>

@ -0,0 +1,120 @@
using Autofac;
using SlnMesnac.Repository;
using System.Reflection;
using TouchSocket.Sockets;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Ioc
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Ioc
{
/// <summary>
/// Utility class for configuring dependency injection.
/// </summary>
public static class DependencyConfigurator
{
/// <summary>
/// Configures dependency injection for the application.
/// </summary>
/// <param name="builder">The Autofac container builder.</param>
public static void Configure(ContainerBuilder builder)
{
//注入Repository
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(Repository<>));
RegisterImplementations(builder, Assembly.LoadFrom("SlnMesnac.Repository.dll"));
//注入Plc
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Plc.dll"));
//注入Rfid
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Rfid.dll"));
//注入通用类
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Common.dll"));
//注入MQTT
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Mqtt.dll"));
//注入TouchSocket
builder.RegisterType(typeof(TcpService));
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.TouchSocket.dll"));
//注入业务类
RegisterType(builder, Assembly.LoadFrom("SlnMesnac.Business.dll"));
}
/// <summary>
/// 自动注入接口实现
/// </summary>
/// <param name="builder"></param>
/// <param name="assembly"></param>
private static void RegisterImplementations(ContainerBuilder builder, Assembly assembly)
{
//自动注入仓储层的接口实现类
var types = assembly.GetTypes()
.Where(t => t.IsClass && !t.IsAbstract && !t.IsGenericType)
.ToList();
foreach (var type in types)
{
var interfaces = type.GetInterfaces();
foreach (var @interface in interfaces)
{
builder.RegisterType(type).As(@interface);
}
}
}
/// <summary>
/// 自动注入自定义类、抽象类
/// </summary>
/// <param name="builder"></param>
/// <param name="assembly"></param>
private static void RegisterType(ContainerBuilder builder, Assembly assembly)
{
var types = assembly.GetTypes()
.Where(t => t.IsClass && !t.IsAbstract && !t.IsGenericType)
.ToList();
foreach (var type in types)
{
var interfaces = type.GetInterfaces();
var baseType = type.BaseType;
#region 只注入抽象类 Delete By wenjy 2024-03-27
//if (baseType != null && baseType.IsAbstract && baseType == typeof(PlcAbsractFactory))
//{
// builder.RegisterType(type);
//}
#endregion
if (!typeof(Delegate).IsAssignableFrom(type)) //不注入委托事件
{
builder.RegisterType(type).SingleInstance();
}
}
}
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.TouchSocket\SlnMesnac.TouchSocket.csproj" />
</ItemGroup>
</Project>

@ -5,10 +5,35 @@ using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.domain
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.domain
{
[SugarTable("BasMaterial"), TenantAttribute("mes")]
[DataContract(Name = "BasMaterial 物料信息")]
#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class BaseMaterialInfo
{
/// <summary>

@ -6,6 +6,28 @@ using System.Security.Principal;
using System.Text;
using System.Xml.Linq;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.domain
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.domain
{
/// <summary>
@ -13,6 +35,7 @@ namespace SlnMesnac.Model.domain
///</summary>
[SugarTable("BasUser"), TenantAttribute("mes")]
[DataContract(Name = "BaseUser 人员基础资料")]
#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class BaseUser
{
/// <summary>

@ -1,7 +1,30 @@
using System;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.dto
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Model.dto
{
#pragma warning disable CS8618 // Non-nullable field 'Data' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public class TagInfo
{
public byte[] PC = new byte[2];

@ -7,6 +7,28 @@ using System.Security.Authentication;
using MQTTnet;
using Microsoft.Extensions.Logging;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Mqtt
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Mqtt
{
/// <summary>

@ -1,15 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
namespace SlnMesnac.Mqtt
{
public static class MqttSetup
{
public static void AddMqttSetup(this IServiceCollection services)
{
services.AddSingleton<MqttClient>();
}
}
}

@ -3,6 +3,28 @@ using HslCommunication;
using HslCommunication.Profinet.Inovance;
using SlnMesnac.Common;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc.Factory
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc.Factory
{
public class InovanceFactory:PlcAbsractFactory

@ -3,6 +3,28 @@ using HslCommunication;
using HslCommunication.Profinet.Melsec;
using SlnMesnac.Common;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc.Factory
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc.Factory
{
public class MelsecBinaryFactory:PlcAbsractFactory

@ -3,6 +3,28 @@ using HslCommunication;
using HslCommunication.Profinet.Omron;
using SlnMesnac.Common;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc.Factory
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc.Factory
{
public class OmronNJFactory:PlcAbsractFactory

@ -3,6 +3,28 @@ using HslCommunication;
using HslCommunication.Profinet.Siemens;
using SlnMesnac.Common;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc.Factory
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc.Factory
{
public class SiemensFactory:PlcAbsractFactory

@ -1,4 +1,26 @@
namespace SlnMesnac.Plc
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc
{
public abstract class PlcAbsractFactory
{

@ -5,6 +5,28 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using SlnMesnac.Plc.Factory;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc
{
/// <summary>
@ -15,7 +37,7 @@ namespace SlnMesnac.Plc
private ILogger<PlcPool> _logger;
private readonly AppConfig _appConfig;
private Dictionary<string, PlcAbsractFactory> keyValuePairs = new Dictionary<string, PlcAbsractFactory>();
private Dictionary<string, PlcAbsractFactory> keyValuePairs ;
private readonly InovanceFactory _inovance;
private readonly MelsecBinaryFactory _melsecBinary;
@ -30,6 +52,8 @@ namespace SlnMesnac.Plc
_omronNj = omronNj;
_siemens = siemens;
_appConfig = appConfig;
keyValuePairs = new Dictionary<string, PlcAbsractFactory>();
}
public void Init()
{

@ -1,27 +1,44 @@
using Microsoft.AspNetCore.Builder;
using System.Linq;
using System.Reflection;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Plc.Factory;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Plc
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Plc
{
public static class PlcSetup
{
public static void AddPlcSetup(this IServiceCollection services)
{
services.AddSingleton<PlcPool>();
//services.AddSingleton<PlcAbsractFactory>();
services.AddSingleton<InovanceFactory>();
services.AddSingleton<MelsecBinaryFactory>();
services.AddSingleton<OmronNJFactory>();
services.AddSingleton<SiemensFactory>();
}
public static IApplicationBuilder UsePlcExtensions(this IApplicationBuilder app)
{
var plcPool = app.ApplicationServices.GetService<PlcPool>();
plcPool.Init();
PlcPool? plcPool = app.ApplicationServices.GetService<PlcPool>();
if(plcPool != null)
{
plcPool.Init();
}
return app;
}
}
}

@ -5,6 +5,28 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Quartz.Job
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Quartz.Job
{
internal class Job2 : IJob

@ -5,6 +5,28 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Quartz.Job
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Quartz.Job
{
public class MyJob : IJob

@ -3,6 +3,28 @@ using Quartz;
using SlnMesnac.Quartz.Job;
using System;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Quartz
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Quartz
{
public static class QuartzSetUp

@ -1,6 +1,28 @@
using SqlSugar;
using System;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository
{
public class Repository<T> : SimpleClient<T> where T : class, new()

@ -7,6 +7,28 @@ using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository
{
public static class SqlsugarSetup

@ -3,6 +3,28 @@ using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository.service
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service
{
public interface IBaseMaterialService

@ -3,6 +3,28 @@ using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository.service
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service
{
public interface IBaseUserService

@ -6,6 +6,28 @@ using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository.service.Impl
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service.Impl
{
public class BaseMaterialServiceImpl : IBaseMaterialService

@ -4,6 +4,28 @@ using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Repository.service.Impl
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Repository.service.Impl
{
public class BaseUserServiceImpl : IBaseUserService

@ -1,4 +1,26 @@
namespace SlnMesnac.Rfid.Dto
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Rfid.Dto
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid.Dto
{
public class MessagePack
{

@ -1,4 +1,26 @@
namespace SlnMesnac.Rfid.Enum
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Rfid.Enum
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid.Enum
{
public enum RecvState
{

@ -12,6 +12,28 @@ using SlnMesnac.Rfid.Enum;
using TouchSocket.Core;
using TouchSocket.Sockets;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Rfid.Factory
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid.Factory
{
public class RflyFactory:RfidAbsractFactory

@ -2,6 +2,28 @@
using System.Collections.Generic;
using SlnMesnac.Model.dto;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Rfid
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid
{
/// <summary>

@ -4,6 +4,28 @@ using Microsoft.Extensions.Logging;
using SlnMesnac.Config;
using SlnMesnac.Rfid.Factory;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Rfid
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid
{
public class RfidPool

@ -2,17 +2,32 @@
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Rfid.Factory;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Rfid
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Rfid
{
public static class RfidSetup
{
public static void AddRfidSetup(this IServiceCollection services)
{
services.AddSingleton<RfidPool>();
services.AddSingleton<RflyFactory>();
}
public static IApplicationBuilder UseRfidExtensions(this IApplicationBuilder app)
{
var pool = app.ApplicationServices.GetService<RfidPool>();

@ -6,6 +6,28 @@ using SlnMesnac.Config;
using System;
using System.IO;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Serilog
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.Serilog
{
/// <summary>

@ -5,6 +5,28 @@ using System.Text;
using TouchSocket.Core;
using TouchSocket.Sockets;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.TouchSocket
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.TouchSocket
{
public class TcpServer

@ -5,6 +5,28 @@ using System.Text;
using Microsoft.AspNetCore.Builder;
using TouchSocket.Sockets;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.TouchSocket
* 496f8d2b-70e3-4a05-ae18-a9b0fcd06b82
*
* WenJY
* wenjy@mesnac.com
* 2024-03-27 21:58:35
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.TouchSocket
{
/// <summary>
@ -12,11 +34,6 @@ namespace SlnMesnac.TouchSocket
/// </summary>
public static class TouchSocketSetup
{
public static void AddTouchSocketSetup(this IServiceCollection services)
{
services.AddSingleton<TcpService>();//注册TouchSocket的服务
services.AddSingleton<TcpServer>();
}
public static IApplicationBuilder UseTouchSocketExtensions(this IApplicationBuilder app)
{

@ -5,18 +5,8 @@ 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;
using System.Threading.Tasks;
using System.Windows;
using Autofac.Extensions.DependencyInjection;
using SlnMesnac.Common;
using SlnMesnac.Repository.service;
using SlnMesnac.Repository.service.Impl;
using SlnMesnac.Plc.Factory;
namespace SlnMesnac.WPF
{
@ -25,9 +15,9 @@ namespace SlnMesnac.WPF
/// </summary>
public partial class App : Application
{
private System.Threading.Mutex mutex;
private System.Threading.Mutex? mutex = null;
private LierdaCracker cracker = new LierdaCracker();
public static IServiceProvider ServiceProvider;
public static IServiceProvider? ServiceProvider = null;
// Startup事件
protected override async void OnStartup(StartupEventArgs e)
@ -46,7 +36,6 @@ namespace SlnMesnac.WPF
var host = CreateHostBuilder(e.Args).Build();//生成宿主。
ServiceProvider = host.Services;
//var baseMaterialService = ServiceProvider.GetRequiredService<MelsecBinaryFactory>();
var appConfig = host.Services.GetService<AppConfig>();
var logPath = $"{appConfig.logPath}/Logs/{DateTime.UtcNow:yyyy-MM-dd}/";

@ -19,8 +19,10 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SlnMesnac.Business\SlnMesnac.Business.csproj" />
<ProjectReference Include="..\SlnMesnac.Common\SlnMesnac.Common.csproj" />
<ProjectReference Include="..\SlnMesnac.Config\SlnMesnac.Config.csproj" />
<ProjectReference Include="..\SlnMesnac.Ioc\SlnMesnac.Ioc.csproj" />
<ProjectReference Include="..\SlnMesnac.Model\SlnMesnac.Model.csproj" />
<ProjectReference Include="..\SlnMesnac.Mqtt\SlnMesnac.Mqtt.csproj" />
<ProjectReference Include="..\SlnMesnac.Plc\SlnMesnac.Plc.csproj" />

@ -3,22 +3,14 @@ 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.Reflection;
using System.Text;
using System.Threading.Tasks;
using Autofac;
using Microsoft.Extensions.Configuration;
using SlnMesnac.Mqtt;
using SlnMesnac.Rfid;
using SlnMesnac.TouchSocket;
using SlnMesnac.Ioc;
namespace SlnMesnac.WPF
{
@ -44,50 +36,17 @@ namespace SlnMesnac.WPF
});
//注册通用类
services.AddCommonSetup();
//注册ORM
services.AddSqlSugarSetup();
//注册Quartz
//services.AddQuartzSetUp();
//注册PLC
services.AddPlcSetup();
//注册MQTT
services.AddMqttSetup();
//注册TouchSocket
services.AddTouchSocketSetup();
//注册RFID
services.AddRfidSetup();
}
/// <summary>
/// AutoFac自动注入
/// </summary>
/// <param name="builder"></param>
public void ConfigureContainer(ContainerBuilder builder)
{
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(Repository<>));
RegisterImplementations(builder, typeof(Repository<>).Assembly);
}
private static void RegisterImplementations(ContainerBuilder builder, Assembly assembly)
{
//自动注入仓储层的接口实现类
var types = assembly.GetTypes()
.Where(t => t.IsClass && !t.IsAbstract && !t.IsGenericType)
.ToList();
foreach (var type in types)
{
var interfaces = type.GetInterfaces();
foreach (var @interface in interfaces)
{
builder.RegisterType(type).As(@interface);
}
}
DependencyConfigurator.Configure(builder);
}
/// <summary>

@ -36,7 +36,7 @@
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "cwss",
"isFlage": false
"isFlage": true
}
],
"RfidConfig": [

@ -27,7 +27,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.TouchSocket", "Sl
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Mqtt", "SlnMesnac.Mqtt\SlnMesnac.Mqtt.csproj", "{7D908FF5-88AE-42AB-A193-F2896EF44AB1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Rfid", "SlnMesnac.Rfid\SlnMesnac.Rfid.csproj", "{40D23A4B-8372-4145-936C-08AE63C6D1F9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Rfid", "SlnMesnac.Rfid\SlnMesnac.Rfid.csproj", "{40D23A4B-8372-4145-936C-08AE63C6D1F9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SlnMesnac.Ioc", "SlnMesnac.Ioc\SlnMesnac.Ioc.csproj", "{30A3F86B-774E-4153-9A00-FD3173C710EB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -87,6 +89,10 @@ Global
{40D23A4B-8372-4145-936C-08AE63C6D1F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40D23A4B-8372-4145-936C-08AE63C6D1F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40D23A4B-8372-4145-936C-08AE63C6D1F9}.Release|Any CPU.Build.0 = Release|Any CPU
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30A3F86B-774E-4153-9A00-FD3173C710EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -72,8 +72,6 @@ namespace SlnMesnac
});
//注册通用类
services.AddCommonSetup();
//注册SqlSugar
services.AddSqlSugarSetup();
@ -84,8 +82,6 @@ namespace SlnMesnac
//注册任务调度
services.AddQuartzSetUp();
//注册PLC
services.AddPlcSetup();
}
/// <summary>

Loading…
Cancel
Save