using System; using System.Collections.Generic; using System.Linq.Expressions; using WIDESEA_Common.CutomerModel; using WIDESEA_Core.BaseProvider; using WIDESEA_Core.EFDbContext; using WIDESEA_Core.Extensions.AutofacManager; using WIDESEA_Entity.DomainModels; using WIDESEA_Services.IRepositories; namespace WIDESEA_Services.Repositories { public partial class VV_DispatchRepository : RepositoryBase, IVV_DispatchRepository { public VV_DispatchRepository(VOLContext dbContext) : base(dbContext) { } public static IVV_DispatchRepository Instance { get { return AutofacContainerModule.GetService(); } } public override List Find(Expression> predicate) { return base.Find(predicate); } public List FindToJobOptions(Expression> predicate) { List jobOptions = new List(); List dispatches = base.Find(predicate); dispatches.ForEach(t => { jobOptions.Add(new JobOptions() { AssemblyName = t.AssemblyName, BeginTime = t.BeginTime, ClassName = t.ClassName, Cron = t.Cron, CycleRunTimes = 0,//ÖØÊÔ´ÎÊý EndTime = t.EndTime, IntervalSecond = t.IntervalSecond, IsStart = false, JobGroup = t.JobGroup, JobName = t.JobName, JobParams = null, Remark = t.Remark, TriggerType = t.TriggerType }); }); //List 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 FindJobOptions(Expression> predicate) { List jobOptions = new List(); List 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; } } }