qinchulong
2025-03-29 039a4a5433e7f80adc88b491b549e5d9486e4f9a
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
 
using WIDESEA_Services.IRepositories;
using WIDESEA_Core.BaseProvider;
using WIDESEA_Core.EFDbContext;
using WIDESEA_Core.Extensions.AutofacManager;
using WIDESEA_Entity.DomainModels;
using System.Collections.Generic;
using System.Linq.Expressions;
using System;
using WIDESEA_Common.CutomerModel;
using System.Linq;
 
namespace WIDESEA_Services.Repositories
{
    public partial class VV_DispatchRepository : RepositoryBase<VV_Dispatch>, IVV_DispatchRepository
    {
        public VV_DispatchRepository(VOLContext dbContext)
        : base(dbContext)
        {
 
        }
        public static IVV_DispatchRepository Instance
        {
            get { return AutofacContainerModule.GetService<IVV_DispatchRepository>(); }
        }
 
        public override List<VV_Dispatch> Find(Expression<Func<VV_Dispatch, bool>> predicate)
        {
            return base.Find(predicate);
        }
 
        public List<JobOptions> FindToJobOptions(Expression<Func<VV_Dispatch, bool>> predicate)
        {
            List<JobOptions> jobOptions = new List<JobOptions>();
            List<VV_Dispatch> dispatches = base.Find(predicate);
            List<dt_plcinfohead> heads = dt_plcinfoheadRepository.Instance.Find(x => true);
            var jobs = dispatches.Join(heads, x => x.JobName, y => y.plcinfo_name, (x, y) => new
            {
                AssemblyName = x.AssemblyName,
                BeginTime = x.BeginTime,
                ClassName = x.ClassName,
                Cron = x.Cron,
                CycleRuntiems = x.CycleRuntiems,
                EndTime = x.EndTime,
                IntervalSecond = x.IntervalSecond,
                JobGroup = x.JobGroup,
                JobName = x.JobName,
                Remark = x.Remark,
                TriggerType = x.TriggerType,
            }).ToList();
            for (int i = 0; i < jobs.Count; i++)
            {
                JobOptions options = new JobOptions()
                {
                    AssemblyName = jobs[i].AssemblyName,
                    BeginTime = jobs[i].BeginTime,
                    ClassName = jobs[i].ClassName,
                    Cron = jobs[i].Cron,
                    CycleRunTimes = jobs[i].CycleRuntiems ?? 0,
                    EndTime = jobs[i].EndTime,
                    IntervalSecond = jobs[i].IntervalSecond,
                    IsStart = false,
                    JobGroup = jobs[i].JobGroup,
                    JobName = jobs[i].JobName,
                    JobParams = null,
                    Remark = jobs[i].Remark,
                    TriggerType = jobs[i].TriggerType
                };
                jobOptions.Add(options);
            }
            return jobOptions;
        }
 
        public List<JobOptions> FindJobOptions(Expression<Func<VV_Dispatch, bool>> predicate)
        {
            List<JobOptions> jobOptions = new List<JobOptions>();
            List<VV_Dispatch> dispatches = base.Find(predicate);
 
            for (int i = 0; i < dispatches.Count; i++)
            {
                JobOptions options = new JobOptions()
                {
                    AssemblyName = dispatches[i].AssemblyName,
                    BeginTime = dispatches[i].BeginTime,
                    ClassName = dispatches[i].ClassName,
                    Cron = dispatches[i].Cron,
                    CycleRunTimes = dispatches[i].CycleRuntiems ?? 0,
                    EndTime = dispatches[i].EndTime,
                    IntervalSecond = dispatches[i].IntervalSecond,
                    IsStart = false,
                    JobGroup = dispatches[i].JobGroup,
                    JobName = dispatches[i].JobName,
                    JobParams = null,
                    Remark = dispatches[i].Remark,
                    TriggerType = dispatches[i].TriggerType,
                    PLCConnectState = "δÁ¬½ÓPLC"
                };
                jobOptions.Add(options);
            }
            return jobOptions;
        }
    }
 
}