|
|
|
@ -1987,37 +1987,40 @@ namespace Myshipping.Application
|
|
|
|
|
public async Task<dynamic> SendLetterYard(long bookingId)
|
|
|
|
|
{
|
|
|
|
|
var entity = _repLetterYard.AsQueryable().Filter(null, true).First(x => x.BookingId == bookingId);
|
|
|
|
|
var json = entity.ToJsonString();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const string MqActionExchangeName = "djy.output.dingcang.ds6";
|
|
|
|
|
const string MqActionQueueName = "djy.output.dingcang.ds6_fangcang";
|
|
|
|
|
ConnectionFactory factory = new ConnectionFactory();
|
|
|
|
|
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
|
|
|
|
|
if (entity!=null) {
|
|
|
|
|
var json = entity.ToJsonString();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const string MqActionExchangeName = "djy.output.dingcang.ds6";
|
|
|
|
|
const string MqActionQueueName = "djy.output.dingcang.ds6_fangcang";
|
|
|
|
|
ConnectionFactory factory = new ConnectionFactory();
|
|
|
|
|
factory.Uri = new Uri(_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault());
|
|
|
|
|
|
|
|
|
|
using (IConnection conn = factory.CreateConnection())
|
|
|
|
|
using (IConnection conn = factory.CreateConnection())
|
|
|
|
|
{
|
|
|
|
|
IModel mqModel = conn.CreateModel();
|
|
|
|
|
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
|
|
|
|
|
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
|
|
|
|
|
mqModel.QueueDeclare(queueName, false, false, false, null);
|
|
|
|
|
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
|
|
|
|
|
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
IBasicProperties props = mqModel.CreateBasicProperties();
|
|
|
|
|
props.DeliveryMode = 2;
|
|
|
|
|
mqModel.BasicPublish(MqActionExchangeName,
|
|
|
|
|
queueName, props,
|
|
|
|
|
messageBodyBytes);
|
|
|
|
|
conn.Close();
|
|
|
|
|
_logger.LogInformation($"放舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
IModel mqModel = conn.CreateModel();
|
|
|
|
|
mqModel.ExchangeDeclare(MqActionExchangeName, ExchangeType.Direct);
|
|
|
|
|
var queueName = $"{MqActionQueueName}.{UserManager.TENANT_ID}";
|
|
|
|
|
mqModel.QueueDeclare(queueName, false, false, false, null);
|
|
|
|
|
mqModel.QueueBind(queueName, MqActionExchangeName, queueName, null);
|
|
|
|
|
byte[] messageBodyBytes = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
IBasicProperties props = mqModel.CreateBasicProperties();
|
|
|
|
|
props.DeliveryMode = 2;
|
|
|
|
|
mqModel.BasicPublish(MqActionExchangeName,
|
|
|
|
|
queueName, props,
|
|
|
|
|
messageBodyBytes);
|
|
|
|
|
conn.Close();
|
|
|
|
|
_logger.LogInformation($"放舱数据回推,已发送数据到消息队列【{_cache.GetAllDictData().Result.Where(x => x.Code == "BookingOrderMQUri").Select(x => x.Value).FirstOrDefault()}】,数据内容:【{json}】");
|
|
|
|
|
_logger.LogError(ex.Message);
|
|
|
|
|
_logger.LogError(ex.StackTrace);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex.Message);
|
|
|
|
|
_logger.LogError(ex.StackTrace);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|