using Autofac.Core;
|
using Microsoft.AspNetCore.Components.Routing;
|
using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
using Quartz;
|
using System;
|
using System.Collections.Generic;
|
using System.IdentityModel.Tokens.Jwt;
|
using System.Linq;
|
using System.Reflection.Metadata;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.Helper;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Communicator;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_IBasicInfoRepository;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.ConveyorLine.Enum;
|
using WIDESEAWCS_QuartzJob.DTO;
|
using WIDESEAWCS_QuartzJob.Models;
|
using WIDESEAWCS_QuartzJob.Repository;
|
using WIDESEAWCS_QuartzJob.Service;
|
using WIDESEAWCS_Tasks.DBNames;
|
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
[DisallowConcurrentExecution]
|
public class ConveyorLineJob1 : JobBase, IJob
|
{
|
private readonly ICacheService _cacheService;
|
private readonly ITaskService _taskService;
|
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
|
private readonly ITaskRepository _taskRepository;
|
private readonly IStationMangerRepository _stationMangerRepository;
|
private readonly IRouterRepository _routerRepository;
|
private readonly IRouterService _routerService;
|
private readonly IRouterExtension _routerExtension;
|
|
public ConveyorLineJob1(ICacheService cacheService, ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, ITaskRepository taskRepository, IStationMangerRepository stationMangerRepository, IRouterRepository routerRepository, IRouterService routerService, IRouterExtension routerExtension)
|
{
|
_cacheService = cacheService;
|
_taskService = taskService;
|
_taskExecuteDetailService = taskExecuteDetailService;
|
_taskRepository = taskRepository;
|
_stationMangerRepository = stationMangerRepository;
|
_routerRepository = routerRepository;
|
_routerService = routerService;
|
_routerExtension = routerExtension;
|
}
|
|
public Task Execute(IJobExecutionContext context)
|
{
|
try
|
{
|
bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
|
if (flag && value != null)
|
{
|
OtherDevice device = (OtherDevice)value;
|
List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
|
|
foreach (var item in stationMangers)
|
{
|
byte[] bytesPut = device.Communicator.Read("22", 1);
|
;
|
device.Communicator.Write("22", new byte[] { 2, 0 });
|
byte[] bytesPuted = device.Communicator.Read("22",1);
|
device.Communicator.Write("22", new byte[] { 0, 0 });
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteError(nameof(ConveyorLineJob1), ex.Message);
|
}
|
return Task.CompletedTask;
|
}
|
}
|
}
|