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