山东雷驰
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.7 KiB

3 months ago
using Kean.Infrastructure.Database.Repository.Default;
using Kean.Infrastructure.Database.Repository.Default.Entities;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Threading.Tasks;
namespace Kean.Infrastructure.Soap.LED
{
public sealed class LedService
{
private readonly ILogger<LedService> _logger; // 日志
/// <summary>
/// 依赖注入
/// </summary>
public LedService(ILogger<LedService> logger,
IDefaultDb database
)
{
_logger = logger;
}
public async Task Invoke(string device, string line1, string line2)
{
try
{
_logger.LogInformation(string.Format("LED信息 参数-{0}", JsonConvert.SerializeObject(new
{
device = device,
line1 = line1,
line2 = line2
})));
var driver = Infrastructure.Database.Configuration.Configure("Default");
using (var context = driver.CreateContext())
{
string updateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
var led = await context.From<T_LED_MAIN>()
.Where(r => r.DEVICE_CODE.Contains(device))
.Single();
await context.From<T_LED_MAIN>()
.Where(r => r.LED_ID == led.LED_ID)
.Update(new
{
IS_SEND = "0",
UPDATE_TIME = updateTime
});
await context.From<T_LED_LIST>()
.Where(r => r.LED_ID == led.LED_ID && r.LINE_NO == "1")
.Update(new
{
LINE_TEXT = line1 + " " + line2,
LED_LIST_REMARK = updateTime
});
await context.From<T_LED_LIST>()
.Where(r => r.LED_ID == led.LED_ID && r.LINE_NO == "2")
.Update(new
{
LINE_TEXT = line2,
LED_LIST_REMARK = updateTime
});
}
}
catch(Exception ex)
{
_logger.LogWarning(string.Format("LED信息 参数-{0} 原因-{1}", JsonConvert.SerializeObject(new
{
device = device,
line1 = line1,
line2 = line2
}), ex.Message));
}
}
}
}