647556386
2026-01-29 6e716593b221337fa189b15da26ca37f98ad1da6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Text;
using WIDESEA.QuartzJob;
using WIDESEA_Core;
using WIDESEA_Core.Helper;
 
namespace WIDESEA_WMSServer
{
    /// <summary>
    /// Quartz 启动服务
    /// </summary>
    public static class QuartzJobMiddleWare
    {
        public static void UseQuartzJobMildd(this IApplicationBuilder app)
        {
            if (app == null) throw new ArgumentNullException(nameof(app));
            var schedulerCenter = app.ApplicationServices.GetService(typeof(ISchedulerCenter)) as ISchedulerCenter;
            try
            {
                var allQzServices = new List<TasksQz>()
                {
                    new TasksQz()
                    {
                         Id = 1,
                         AssemblyName = "WIDESEA_WMSServer",
                         ClassName = "AgvTaskJob",
                         CreateTime = DateTime.Now,
                         IntervalSecond = 3,
                         IsDeleted = false,
                         IsStart = false,
                         JobGroup = "WIDESEA_WMSServer",
                         Name = "AgvTaskJob",
                         TriggerType = 0
                    },
                     new TasksQz()
                    {
                         Id = 2,
                         AssemblyName = "WIDESEA_WMSServer",
                         ClassName = "InventoryLockJob",
                         CreateTime = DateTime.Now,
                         IntervalSecond = 3,
                         IsDeleted = false,
                         IsStart = false,
                         JobGroup = "WIDESEA_WMSServer",
                         Name = "InventoryLockJob",
                         TriggerType = 0
                    },new TasksQz()
                    {
                         Id = 3,
                         AssemblyName = "WIDESEA_WMSServer",
                         ClassName = "ErpJob",
                         CreateTime = DateTime.Now,
                         IntervalSecond = 50000,
                         IsDeleted = false,
                         IsStart = false,
                         JobGroup = "WIDESEA_WMSServer",
                         Name = "ErpJob",
                         TriggerType = 0
                    },
 
                };
 
                if (App.HostEnvironment.IsDevelopment())
                {
                    return;
                }
                foreach (var item in allQzServices)
                {
                    var ResuleModel = schedulerCenter.AddScheduleJobAsync(item).Result;
                    if (ResuleModel.Status)
                    {
                        ConsoleHelper.WriteSuccessLine($"{item.ClassName}启动成功");
                    }
                    else
                    {
                        Console.Out.WriteLine($"QuartzNetJob{item.Name}启动失败!错误信息:{ResuleModel.Message}");
                    }
                }
                schedulerCenter.StartScheduleAsync();
            }
            catch (Exception e)
            {
                throw;
            }
        }
    }
}