Перенёс в конфиг строки подключения
This commit is contained in:
parent
15abfd3efd
commit
b2743edae5
@ -44,29 +44,6 @@ namespace _1CDataBus.Controllers
|
||||
await SendContractTo1C(sendContract);
|
||||
}
|
||||
|
||||
//[HttpPost("Test")]
|
||||
//public async Task TestDelete()
|
||||
//{
|
||||
// var peoples = await _client
|
||||
// .For("IPersons")
|
||||
// .Filter("Name eq \'Маударбеков Азат Муратбекович\'")
|
||||
// .FindEntriesAsync();
|
||||
// foreach (dynamic person in peoples)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// long Id = person["Id"];
|
||||
// await _client
|
||||
// .For("IPersons")
|
||||
// .Key(Id)
|
||||
// .DeleteEntryAsync();
|
||||
// }
|
||||
// catch (Exception)
|
||||
// {
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
[HttpPost("SendContract")]
|
||||
public async Task SendContractTo1C([FromBody]Contract contract)
|
||||
{
|
||||
|
||||
@ -8,21 +8,23 @@ namespace _1CDataBus.RabbitMQ
|
||||
private readonly IConnection _connection;
|
||||
private readonly IChannel _channel;
|
||||
private IConfiguration _configuration;
|
||||
private string _queueName;
|
||||
public RabbitConnection(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
var section = _configuration.GetSection("RabbitMqSettings");
|
||||
var factory = new ConnectionFactory
|
||||
{
|
||||
HostName = _configuration.GetValue<string>("RabbitMqSettings:HostName"),
|
||||
//HostName = "astsrvrabbit1",
|
||||
UserName = _configuration.GetValue<string>("RabbitMqSettings:UserName"),
|
||||
//UserName = "erp",
|
||||
Password = _configuration.GetValue<string>("RabbitMqSettings:Password"),
|
||||
//Password = @"Z!1;Q5#GE4v",
|
||||
VirtualHost = _configuration.GetValue<string>("RabbitMqSettings:VirtualHost")
|
||||
//VirtualHost = "erp"
|
||||
HostName = section.GetValue<string>("HostName"),
|
||||
UserName = section.GetValue<string>("UserName"),
|
||||
Password = section.GetValue<string>("Password"),
|
||||
VirtualHost = section.GetValue<string>("VirtualHost")
|
||||
};
|
||||
|
||||
#if DEBUG
|
||||
_queueName = section.GetValue<string>("TestQueueName");
|
||||
#else
|
||||
_queueName = section.GetValue<string>("QueueName");
|
||||
#endif
|
||||
_connection = factory.CreateConnectionAsync().Result;
|
||||
_channel = _connection.CreateChannelAsync().Result;
|
||||
}
|
||||
@ -30,13 +32,13 @@ namespace _1CDataBus.RabbitMQ
|
||||
public async Task SendMessage(string body)
|
||||
{
|
||||
await _channel.QueueDeclareAsync(
|
||||
queue: "erp_contracts",
|
||||
queue: _queueName,
|
||||
durable: false,
|
||||
exclusive: false,
|
||||
autoDelete: false,
|
||||
arguments: null);
|
||||
var encoded = Encoding.UTF8.GetBytes(body);
|
||||
await _channel.BasicPublishAsync(string.Empty, "erp_contracts", encoded);
|
||||
await _channel.BasicPublishAsync(string.Empty, _queueName, encoded);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@ -17,6 +17,7 @@ namespace _1CDataBus.Structure
|
||||
public Contract(dynamic contract)
|
||||
{
|
||||
//Name = contract["Name"];
|
||||
Name = GetName();
|
||||
BusinessUnit = contract["BusinessUnit"]["ExternalId"];
|
||||
BusinessUnitBIN = contract["BusinessUnit"]["BINArmadoc"];
|
||||
Counterparty = contract["Counterparty"]["ExternalId"];
|
||||
@ -25,7 +26,6 @@ namespace _1CDataBus.Structure
|
||||
Date = contract["ContractDateSungero"].Date.ToString("yyyy-MM-dd");
|
||||
Currency = contract["Currency"] == null ? "KZT" : contract["Currency"]["AlphaCode"];
|
||||
QDocID = contract["Id"].ToString();
|
||||
Name = GetName();
|
||||
|
||||
string dealKind = contract["DealKindSungero"]["Name"];
|
||||
if (dealKind != null && _orderDealKinds.Contains(dealKind)) Orders = true;
|
||||
|
||||
@ -11,8 +11,11 @@ namespace _1CDataBus.Structure
|
||||
public ODataAccess(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
#if DEBUG
|
||||
var section = _configuration.GetSection("QDocTestSettings");
|
||||
#else
|
||||
var section = _configuration.GetSection("QDocSettings");
|
||||
|
||||
#endif
|
||||
var IntegrationServiceUrl = section.GetValue<string>("Url");
|
||||
var Login = section.GetValue<string>("Login");
|
||||
var Password = section.GetValue<string>("Password");
|
||||
|
||||
@ -10,16 +10,20 @@
|
||||
"HostName": "astsrvrabbit1",
|
||||
"UserName": "erp",
|
||||
"Password": "Z!1;Q5#GE4v",
|
||||
"VirtualHost": "erp"
|
||||
"VirtualHost": "erp",
|
||||
"QueueName": "erp_contracts",
|
||||
//"QueueName": "erp_contract_test",
|
||||
"TestQueueName": "erp_contract_test"
|
||||
},
|
||||
"QDocTestSettings": {
|
||||
"QDocSettings": {
|
||||
"Url": "https://qdoc.solidcore-resources.com/Integration/odata/",
|
||||
"Login": "Administrator",
|
||||
"Password": "MQVuEw9avO"
|
||||
},
|
||||
"QDocSettings": {
|
||||
"QDocTestSettings": {
|
||||
"Url": "https://astsrvqtest.solidcore-resources.com/Integration/odata/",
|
||||
"Login": "Administrator",
|
||||
"Password": "D3cTXol8Se"
|
||||
}
|
||||
},
|
||||
"LogPath": "C:\\log\\contract_exchange"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user