123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using Apache.NMS;
- using Apache.NMS.ActiveMQ;
- using Apache.NMS.Util;
- using Serilog;
- using System.Runtime.InteropServices;
- using wms.console;
- Console.WriteLine("主程序开始执行");
- // See https://aka.ms/new-console-template for more information
- Log.Logger = new LoggerConfiguration()
- .MinimumLevel.Information()
- //.WriteTo.Console()
- .WriteTo.File($"logs\\log.txt",
- rollingInterval: RollingInterval.Day,
- rollOnFileSizeLimit:true,
- shared:true,
- fileSizeLimitBytes: 102400000,
- outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} {SourceContext} {ThreadId} [{Level:u3}] {Message:lj}{NewLine}{Exception}"
- )
- .CreateLogger();
- string fjqueuesName = "ESB.OUT.163LFJ.Q";//分拣队列
- string sxqueuesName = "ESB.OUT.163KSX.Q";//时效队列
- string cpqueuesName = "ESB.OUT.163JCP.Q";//成品队列
- string ptqueuesName = "ESB.OUT.163IPT.Q";//盘条队列
- string hjqueuesName = "ESB.OUT.163DHJ.Q";//盘条队列
- var fjcon = new HouseConsumer(fjqueuesName);
- var sxcon = new HouseConsumer(sxqueuesName);
- var cpcon = new HouseConsumer(cpqueuesName);
- var ptcon = new HouseConsumer(ptqueuesName);
- var hjcon = new HouseConsumer(hjqueuesName);
- fjcon.CreateConsumer();
- sxcon.CreateConsumer();
- cpcon.CreateConsumer();
- ptcon.CreateConsumer();
- hjcon.CreateConsumer();
- Console.WriteLine("主程序启动完成");
- Timer timer = new Timer(RestartProgram, null, TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1));
- AppDomain.CurrentDomain.ProcessExit += (object? sender, EventArgs e) => {
- Log.Information("控制台关闭");
- fjcon?.Stop();
- sxcon?.Stop();
- cpcon?.Stop();
- ptcon?.Stop();
- hjcon?.Stop();
- };
- while (!Console.ReadLine().ToUpper().Contains("CLOSE")) continue;
- Environment.Exit(0);
- static void RestartProgram(object state)
- {
- var curtime = DateTime.Now;
- if (curtime.DayOfWeek == DayOfWeek.Wednesday && curtime.Hour == 10 && curtime.Minute == 0 && curtime.Second == 0)
- {
- Console.WriteLine("消息接收程序自动停止");
- Environment.Exit(0);
- }
- }
|