From a6724b1d4afa6650029c205da8dc4a11f5a1f1ad Mon Sep 17 00:00:00 2001 From: liuwf Date: Thu, 10 Oct 2024 15:09:04 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ReadService/MessageClient.cs | 2 +- ReadService/ReadBusiness.cs | 83 ------------------------------------ 2 files changed, 1 insertion(+), 84 deletions(-) delete mode 100644 ReadService/ReadBusiness.cs diff --git a/ReadService/MessageClient.cs b/ReadService/MessageClient.cs index 036119d..70a5933 100644 --- a/ReadService/MessageClient.cs +++ b/ReadService/MessageClient.cs @@ -28,7 +28,7 @@ namespace ReadService public void StartListening() { - Console.WriteLine("Redis启动监听朗读声音服务~~~"); + Console.WriteLine("启动监听朗读声音服务~~~"); _redisHandler.SubscribeToChannel("read_messages", OnMessageReceived); } diff --git a/ReadService/ReadBusiness.cs b/ReadService/ReadBusiness.cs deleted file mode 100644 index 095cf8b..0000000 --- a/ReadService/ReadBusiness.cs +++ /dev/null @@ -1,83 +0,0 @@ -using Microsoft.Extensions.Hosting; -using Serilog; -using SlnMesnac.Common; -using SlnMesnac.Model.domain; -using SlnMesnac.Repository.service; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ReadService -{ - public class ReadBusiness : IHostedService - { - - private IMesProductReadInfoService _mesProductReadInfoService; - - - public ReadBusiness(IMesProductReadInfoService mesProductReadInfoService) - { - _mesProductReadInfoService = mesProductReadInfoService; - } - - - public Task StartAsync(CancellationToken cancellationToken) - { - // 启动你的监听逻辑 - ListenRead(); - return Task.CompletedTask; - } - - public Task StopAsync(CancellationToken cancellationToken) - { - // 对于清理工作,可以在这里实现 - return Task.CompletedTask; - } - - - - public void ListenRead() - { - SpeechStr.Instance.Speak("开始监听朗读业务"); - Console.WriteLine("开始监听朗读业务"); - Task.Run(() => - { - - while (true) - { - try - { - // Log.Information("读取业务"); - MesProductReadInfo? mesProductReadInfo = _mesProductReadInfoService.Query(x => x.UseFlag == 1 && x.ReadStatus != 2).OrderBy(x => x.ReadId).FirstOrDefault(); - if (mesProductReadInfo != null) - { - Log.Information($"总次数:{mesProductReadInfo.ReadTotal} 朗读第次数{mesProductReadInfo.ReadCount} 开始朗读:====>{mesProductReadInfo.ReadInfo}"); - SpeechStr.Instance.Speak(mesProductReadInfo.ReadInfo); - mesProductReadInfo.ReadCount++; - mesProductReadInfo.ReadStatus = 1; - mesProductReadInfo.UpdateTime = DateTime.Now; - if (mesProductReadInfo.ReadCount >= mesProductReadInfo.ReadTotal) - { - mesProductReadInfo.ReadStatus = 2; - mesProductReadInfo.EndTime = DateTime.Now; - } - _mesProductReadInfoService.Update(mesProductReadInfo); - Thread.Sleep(1500); - } - else - { - Thread.Sleep(1000 * 10); - } - } - catch (Exception ex) - { - Log.Error(ex.Message); - } - } - }); - } - - } -}