using Microsoft.Extensions.Hosting;
|
using Quartz;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using WIDESEA_Comm.Http;
|
using WIDESEA_Comm.LogInfo;
|
using WIDESEA_Comm.TaskNo;
|
using WIDESEA_Entity.DomainModels.ApiEntity.Test;
|
using WIDESEA_WCS.WCSClient;
|
|
namespace WIDESEA_WCS
|
{
|
/// <summary>
|
/// 测试调度类
|
/// </summary>
|
[DisallowConcurrentExecution]
|
internal class TestJob : IJob
|
{
|
static int index = 0;
|
public Task Execute(IJobExecutionContext context)
|
{
|
try
|
{
|
var client = context.JobDetail.JobDataMap.Get("JobParams") as PLCClient;
|
if (client == null)
|
{
|
return Task.CompletedTask;
|
}
|
|
//自动重连
|
if (!client.IsConnected)
|
{
|
client.Connect();
|
return Task.CompletedTask;
|
}
|
|
DoAction(client);
|
}
|
catch { }
|
return Task.CompletedTask;
|
}
|
|
private void DoAction(PLCClient client)
|
{
|
try
|
{
|
index++;
|
|
//写入
|
//client.Write("DB10.100", index);
|
client.WriteByOrder("R_request_in", index);
|
client.Write("DB10.105", "abc" + index);
|
|
//读取
|
var res1 = client.Read<int>("DB10.100");
|
var res2 = client.ReadByOrder<int>("R_request_in");
|
var res3 = client.Read<string>("DB10.105", 20);
|
|
//日志写入
|
WriteDBLog.Info("测试调度", res3, "WCS");
|
|
//接口请求
|
//var res = HttpHelper.Post<Weather>("http://apis.juhe.cn/simpleWeather/query", null, "测试接口");
|
//var reee = HttpHelper.Get<object>("https://v0.yiketianqi.com/api", new { unescape = 1, version = "v91", appid = "43656176", appsecret = "I42og6Lm" });
|
|
//获取任务号
|
var taskNo = IdenxManager.GetTaskNo("KH-");
|
|
//执行完成时间
|
Console.WriteLine(DateTime.Now);
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine(ex.Message);
|
}
|
}
|
}
|
}
|