master
CaesarBao 3 months ago
commit 9f8c3344df

@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
</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.Extensions\SlnMesnac.Extensions.csproj" />
<ProjectReference Include="..\SlnMesnac.Generate\SlnMesnac.Generate.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" />
<ProjectReference Include="..\SlnMesnac.Quartz\SlnMesnac.Quartz.csproj" />
<ProjectReference Include="..\SlnMesnac.Redis\SlnMesnac.Redis.csproj" />
<ProjectReference Include="..\SlnMesnac.Repository\SlnMesnac.Repository.csproj" />
<ProjectReference Include="..\SlnMesnac.Rfid\SlnMesnac.Rfid.csproj" />
<ProjectReference Include="..\SlnMesnac.Serilog\SlnMesnac.Serilog.csproj" />
<ProjectReference Include="..\SlnMesnac.TouchSocket\SlnMesnac.TouchSocket.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,34 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Config;
using SlnMesnac.Quartz;
using TouchSocket.Sockets;
using SlnMesnac.Extensions;
using Microsoft.AspNetCore.Hosting;
using Serilog;
using Autofac.Extensions.DependencyInjection;
namespace ConsoleApp
{
internal class Program
{
static void Main(string[] args)
{
var host = CreateHostBuilder(args).Build();//生成宿主。
host.StartAsync();
Console.ReadLine();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

@ -0,0 +1,113 @@
using Autofac;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SlnMesnac.Config;
using SlnMesnac.Ioc;
using SlnMesnac.Extensions;
using SlnMesnac.Serilog;
using SlnMesnac.Quartz;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* T14-GEN3-7895
* ConsoleApp
* 57e1b754-83fd-42ef-ad93-2693dcbebacf
*
* WenJY
*
* 2024-11-08 10:04:52
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace ConsoleApp
{
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();
//注册AppConfig
services.AddSingleton<AppConfig>(provider =>
{
var configuration = provider.GetService<IConfiguration>();
return configuration.GetSection("AppConfig").Get<AppConfig>();
});
//注册ORM
services.AddSqlSugarSetup();
//注册PLC工厂
//services.AddPlcFactorySetup();
//注册httpClient
//services.AddHostedService<AirPorthttpClient>();
//注册TCPServer
//services.AddHostedService<TcpServer>();
//注册RFID工厂
//services.AddRfidFactorySetup();
//注册任务调度
services.AddQuartzSetUp();
}
/// <summary>
/// AutoFac自动注入
/// </summary>
/// <param name="builder"></param>
public void ConfigureContainer(ContainerBuilder builder)
{
DependencyConfigurator.Configure(builder);
}
/// <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.UseTouchSocketExtensions();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}

@ -0,0 +1,89 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"AppConfig": {
"logPath": "F:\\Mesnac\\2023部门项目\\奥特佳-滁州3期\\源码\\HightWay_Middle_Ware\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\log",
"SqlConfig": [
{
"configId": "mes",
"dbType": 1,
"connStr": "server=192.168.1.120;uid=sa;pwd=123456;database=ATJ_581_DB"
},
//{
// "configId": "mcs",
// "dbType": 3,
// "connStr": "Data Source=175.27.215.92/helowin;User ID=aucma_scada;Password=aucma"
//},
{
"configId": "Local",
"dbType": 2,
"connStr": "Data Source=F:\\Mesnac\\2023部门项目\\奥特佳-滁州3期\\源码\\HightWay_Middle_Ware\\SlnMesnac.WPF\\bin\\Debug\\net6.0-windows\\data\\FData.db3"
}
],
"PlcConfig": [
{
"configId": 1,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 6000,
"plcKey": "mcs",
"isFlage": true
},
{
"configId": 2,
"plcType": "MelsecBinaryPlc",
"plcIp": "127.0.0.1",
"plcPort": 6001,
"plcKey": "cwss",
"isFlage": true
}
],
"RfidConfig": [
{
"configId": 1,
"equipIp": "127.0.0.1",
"equipPort": 6003,
"equipKey": "test1",
"isFlage": true
},
{
"configId": 2,
"equipIp": "127.0.0.1",
"equipPort": 6004,
"equipKey": "test2",
"isFlage": true
}
],
"visionConfig": [
{
"VisionId": 1,
"VisionIp": "127.0.0.1",
"VisionPort": 7001,
"AGVID": "1",
"VisionState": "1",
"IsFlag": true
},
{
"VisionId": 2,
"VisionIp": "127.0.0.1",
"VisionPort": 7002,
"AGVID": "2",
"VisionState": "1",
"IsFlag": true
}
],
"AMRIP": "127.0.0.1",
"redisConfig": "175.27.215.92:6379,password=redis@2023",
"AGVIpConfig": "http://192.168.40.81:5102",
"TCPVisionConfig": "127.0.0.1:6000"
}
}

@ -31,12 +31,13 @@ namespace SlnMesnac.Quartz.Job
}
public Task Execute(IJobExecutionContext context)
{
var flag = _appConfig.sqlConfig.Find(x => x.configId == "Local");
_logger.LogError($"任务执行:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
var flag = _appConfig.sqlConfig.Find(x => x.configId == "Local");
if (flag.connStr.Contains("EData"))
{
LoadTaskInfo();
}
else if(flag.connStr.Contains("FData"))
else if (flag.connStr.Contains("FData"))
{
LoadEDataInfo();
}

@ -36,19 +36,16 @@ namespace SlnMesnac.Quartz
services.AddQuartz(q =>
{
q.UseMicrosoftDependencyInjectionJobFactory();
//正式
//q.ScheduleJob<GetTaskInfo_Job>(trigger =>
// trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("GetTaskInfo_Job", "MyJobGroup") // 示例每5s执行一次
//);
// q.ScheduleJob<GetTaskInfo_Job>(trigger =>
// trigger.WithCronSchedule("* * 0/2 * * ? *").WithIdentity("GetTaskInfo_Job", "MyJobGroup") // 示例每5s执行一次
//);
//q.ScheduleJob<MyJob>(trigger =>
// trigger.WithCronSchedule("*/3 * * * * ?").WithIdentity("MyJob", "MyJobGroup") // 示例每3s执行一次
// //trigger.WithCronSchedule("* * 0/2 * * ? *").WithIdentity("GetTaskInfo_Job", "MyJobGroup")
//);
//q.ScheduleJob<Job2>(trigger =>
// trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("Job2", "Job2Group") // 示例每5s执行一次
//);
//测试
q.ScheduleJob<GetTaskInfo_Job>(trigger =>
trigger.WithCronSchedule("*/5 * * * * ?").WithIdentity("GetTaskInfo_Job", "MyJobGroup") // 示例每5s执行一次
);
});
services.AddQuartzHostedService(options => options.WaitForJobsToComplete = true);

@ -37,6 +37,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Extensions", "Sln
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SlnMesnac.Redis", "SlnMesnac.Redis\SlnMesnac.Redis.csproj", "{0E041719-E755-43CD-8A0E-DF62E0B2E463}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{2466355A-44B8-4E1C-91B5-8F9BB978D2AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -111,6 +113,10 @@ Global
{0E041719-E755-43CD-8A0E-DF62E0B2E463}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E041719-E755-43CD-8A0E-DF62E0B2E463}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E041719-E755-43CD-8A0E-DF62E0B2E463}.Release|Any CPU.Build.0 = Release|Any CPU
{2466355A-44B8-4E1C-91B5-8F9BB978D2AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2466355A-44B8-4E1C-91B5-8F9BB978D2AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2466355A-44B8-4E1C-91B5-8F9BB978D2AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2466355A-44B8-4E1C-91B5-8F9BB978D2AB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save