提交.Net6版本

This commit is contained in:
橙子
2021-12-25 14:50:54 +08:00
parent aebf12a7ca
commit 6503ad905b
443 changed files with 17839 additions and 712 deletions

View File

@@ -0,0 +1,84 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Yi.Framework.Common.IOCOptions;
using Yi.Framework.Common.Models;
using Yi.Framework.Core;
namespace Yi.Framework.ElasticSearchProcessor
{
public class InitESIndexWorker : BackgroundService
{
private readonly IConfiguration _configuration;
private readonly ILogger<InitESIndexWorker> _logger;
private readonly RabbitMQInvoker _RabbitMQInvoker;
private readonly ElasticSearchInvoker _elasticSearchInvoker;
public InitESIndexWorker(ILogger<InitESIndexWorker> logger, RabbitMQInvoker rabbitMQInvoker, IConfiguration configuration, ElasticSearchInvoker elasticSearchInvoker)
{
this._logger = logger;
this._RabbitMQInvoker = rabbitMQInvoker;
this._configuration = configuration;
this._elasticSearchInvoker = elasticSearchInvoker;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
RabbitMQConsumerModel rabbitMQConsumerModel = new RabbitMQConsumerModel()
{
ExchangeName = RabbitMQExchangeQueueName.SKUCQRS_Exchange,
QueueName = RabbitMQExchangeQueueName.SKUCQRS_Queue_ESIndex
};
HttpClient _HttpClient = new HttpClient();
this._RabbitMQInvoker.RegistReciveAction(rabbitMQConsumerModel, message =>
{
try
{
//<2F><><EFBFBD>õ<EFBFBD>ģ<EFBFBD>͡<EFBFBD>
//SPUCQRSQueueModel spuCQRSQueueModel = JsonConvert.DeserializeObject<SPUCQRSQueueModel>(message);
//<2F><><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ɾ<EFBFBD>ģ<EFBFBD>es<65><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>
//switch (spuCQRSQueueModel.CQRSType)
//{
// case (int)SPUCQRSQueueModelType.Insert:
// case (int)SPUCQRSQueueModelType.Update:
// {
// Goods goods = this._ISearchService.GetGoodsBySpuId(spuCQRSQueueModel.SpuId);
// this._IElasticSearchService.InsertOrUpdata<Goods>(goods);
// break;
// }
// case (int)SPUCQRSQueueModelType.Delete:
// this._IElasticSearchService.Delete<Goods>(spuCQRSQueueModel.SpuId.ToString());
// break;
// default:
// throw new Exception("wrong spuCQRSQueueModel.CQRSType");
//}
this._logger.LogInformation($"{nameof(InitESIndexWorker)}.Init ESIndex succeed SpuId");
return true;
}
catch (Exception ex)
{
LogModel logModel = new LogModel()
{
OriginalClassName = this.GetType().FullName,
OriginalMethodName = nameof(ExecuteAsync),
Remark = "<22><>ʱ<EFBFBD><CAB1>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־"
};
this._logger.LogError(ex, $"{nameof(InitESIndexWorker)}.Init ESIndex failed message={message}, Exception:{ex.Message}", JsonConvert.SerializeObject(logModel));
return false;
}
});
await Task.CompletedTask;
}
}
}