docker
This commit is contained in:
@@ -1,13 +1,8 @@
|
||||
using Back.Common;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using Shared.DTOs;
|
||||
using TaxCollectData.Library.Business;
|
||||
using TaxCollectData.Library.Dto.Config;
|
||||
using TaxCollectData.Library.Dto.Content;
|
||||
using TaxCollectData.Library.Dto.Properties;
|
||||
using TaxCollectData.Library.Dto.Transfer;
|
||||
using TaxCollectData.Library.Enums;
|
||||
|
||||
|
||||
namespace Back.Services
|
||||
{
|
||||
@@ -26,77 +21,77 @@ namespace Back.Services
|
||||
|
||||
public string GenerateTaxid(string FactorNo, string InvoiceDate)
|
||||
{
|
||||
//return "testTaxid";
|
||||
return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
|
||||
Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
|
||||
return "testTaxid";
|
||||
//return TaxApiService.Instance.TaxIdGenerator.GenerateTaxId(_UniqueMemory,
|
||||
// Convert.ToInt64(FactorNo), InvoiceDate.ToMiladi());
|
||||
}
|
||||
public async Task<InquiryResultModel> GetResultByUid(int CompanyID, string uid)
|
||||
{
|
||||
//public async Task<InquiryResultModel> GetResultByUid(int CompanyID, string uid)
|
||||
//{
|
||||
|
||||
var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);
|
||||
var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId });
|
||||
if (inquiryResultModels.Count > 0)
|
||||
return inquiryResultModels[0];
|
||||
return null;
|
||||
}
|
||||
public async Task<TaxCollectData.Library.Dto.HttpResponse<AsyncResponseModel>> SendInvoice(int CompanyID,InvoiceHeaderDto header, List<InvoiceBodyDto> InvoiceBody, List<PaymentDto> payments)
|
||||
{
|
||||
return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List<InvoiceDto>()
|
||||
{
|
||||
new()
|
||||
{
|
||||
Header =header,Body =InvoiceBody,Payments = payments
|
||||
}
|
||||
}
|
||||
, null);
|
||||
}
|
||||
public async Task<EconomicCodeModel?> GetEconomicCodeInformation(string Item)
|
||||
{
|
||||
// var uidAndFiscalId = new UidAndFiscalId(uid, _UniqueMemory);
|
||||
// var inquiryResultModels = TaxApiService.Instance.TaxApis.InquiryByUidAndFiscalId(new() { uidAndFiscalId });
|
||||
// if (inquiryResultModels.Count > 0)
|
||||
// return inquiryResultModels[0];
|
||||
// return null;
|
||||
//}
|
||||
//public async Task<TaxCollectData.Library.Dto.HttpResponse<AsyncResponseModel>> SendInvoice(int CompanyID,InvoiceHeaderDto header, List<InvoiceBodyDto> InvoiceBody, List<PaymentDto> payments)
|
||||
//{
|
||||
// return await TaxApiService.Instance.TaxApis.SendInvoicesAsync(new List<InvoiceDto>()
|
||||
// {
|
||||
// new()
|
||||
// {
|
||||
// Header =header,Body =InvoiceBody,Payments = payments
|
||||
// }
|
||||
// }
|
||||
// , null);
|
||||
//}
|
||||
//public async Task<EconomicCodeModel?> GetEconomicCodeInformation(string Item)
|
||||
//{
|
||||
|
||||
return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item);
|
||||
// return await TaxApiService.Instance.TaxApis.GetEconomicCodeInformationAsync(Item);
|
||||
|
||||
|
||||
}
|
||||
public async Task<FiscalInformationModel?> GetFiscalInformation(string Item)
|
||||
{
|
||||
return await TaxApiService.Instance.TaxApis.GetFiscalInformationAsync(Item);
|
||||
}
|
||||
//}
|
||||
//public async Task<FiscalInformationModel?> GetFiscalInformation(string Item)
|
||||
//{
|
||||
// return await TaxApiService.Instance.TaxApis.GetFiscalInformationAsync(Item);
|
||||
//}
|
||||
//-------------------internal
|
||||
public async Task<bool> login(int CompanyID)
|
||||
{
|
||||
return false;
|
||||
//try
|
||||
//{
|
||||
// #region TokenTax
|
||||
// var resquth = await _servCompany.GetTaxAuth(CompanyID);
|
||||
// if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey))
|
||||
// return false;
|
||||
|
||||
try
|
||||
{
|
||||
#region TokenTax
|
||||
var resquth = await _servCompany.GetTaxAuth(CompanyID);
|
||||
if (string.IsNullOrEmpty(resquth.UniqueMemory) || string.IsNullOrEmpty(resquth.PrivateKey))
|
||||
return false;
|
||||
|
||||
if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey))
|
||||
{
|
||||
// if (!string.IsNullOrEmpty(resquth.UniqueMemory) && !string.IsNullOrEmpty(resquth.PrivateKey))
|
||||
// {
|
||||
|
||||
//string taxapi = _configuration.GetSection("TaxPayerApi").Value;
|
||||
string taxapi = "https://sandboxrc.tax.gov.ir/req/api/";
|
||||
_UniqueMemory = resquth.UniqueMemory;
|
||||
_PrivateKey = resquth.PrivateKey;
|
||||
TaxApiService.Instance.Init(_UniqueMemory,
|
||||
new SignatoryConfig(_PrivateKey, null),
|
||||
new NormalProperties(ClientType.SELF_TSP), taxapi);
|
||||
await TaxApiService.Instance.TaxApis.GetServerInformationAsync();
|
||||
}
|
||||
#endregion
|
||||
// //string taxapi = _configuration.GetSection("TaxPayerApi").Value;
|
||||
// string taxapi = "https://sandboxrc.tax.gov.ir/req/api/";
|
||||
// _UniqueMemory = resquth.UniqueMemory;
|
||||
// _PrivateKey = resquth.PrivateKey;
|
||||
// TaxApiService.Instance.Init(_UniqueMemory,
|
||||
// new SignatoryConfig(_PrivateKey, null),
|
||||
// new NormalProperties(ClientType.SELF_TSP), taxapi);
|
||||
// await TaxApiService.Instance.TaxApis.GetServerInformationAsync();
|
||||
// }
|
||||
// #endregion
|
||||
|
||||
if (TaxApiService.Instance.TaxApis.GetToken() is null)
|
||||
{
|
||||
if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// if (TaxApiService.Instance.TaxApis.GetToken() is null)
|
||||
// {
|
||||
// if (await TaxApiService.Instance.TaxApis.RequestTokenAsync() == null)
|
||||
// return false;
|
||||
// }
|
||||
// return true;
|
||||
//}
|
||||
//catch (Exception)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -16,15 +16,15 @@ namespace Back.Services
|
||||
private readonly IAsyncRepository<Blog> _repoBlog;
|
||||
private readonly IAsyncRepository<Question> _repoQuestion;
|
||||
private readonly IAsyncRepository<SaleLead> _repoSaleLead;
|
||||
private readonly Service.Main _Taxtools;
|
||||
// private readonly Service.Main _Taxtools;
|
||||
public ServBase(IAsyncRepository<Pricing> repoPricing,
|
||||
IAsyncRepository<Blog> repoBlog, IAsyncRepository<Question> repoQuestion
|
||||
, Service.Main taxtools, IAsyncRepository<SaleLead> repoSaleLead)
|
||||
/* , Service.Main taxtools*/, IAsyncRepository<SaleLead> repoSaleLead)
|
||||
{
|
||||
_repoPricing = repoPricing;
|
||||
_repoBlog = repoBlog;
|
||||
_repoQuestion = repoQuestion;
|
||||
_Taxtools = taxtools;
|
||||
// _Taxtools = taxtools;
|
||||
_repoSaleLead = repoSaleLead;
|
||||
}
|
||||
public async Task<List<BasePriceDto>> GetBasePrice()
|
||||
@@ -89,63 +89,63 @@ namespace Back.Services
|
||||
public async Task<TaxToolsDTO?> CreateCsrAndPrivateKey(CsrPrivateKeyDto model)
|
||||
{
|
||||
TaxToolsDTO taxTools = null;
|
||||
List<Service.PrmValue> values = new List<Service.PrmValue>()
|
||||
{
|
||||
new Service.PrmValue(){Prm="CN",Value=model.cn},
|
||||
new Service.PrmValue(){Prm="serialNumber",Value=model.sn},
|
||||
new Service.PrmValue(){Prm="O",Value="Non-Governmental"},
|
||||
new Service.PrmValue(){Prm="3.OU",Value=model.company},
|
||||
new Service.PrmValue(){Prm="2.OU",Value=model.company},
|
||||
new Service.PrmValue(){Prm="1.OU",Value=model.company},
|
||||
new Service.PrmValue(){Prm="C",Value="IR"},
|
||||
};
|
||||
string msg = "";
|
||||
if (_Taxtools.CraeteCnfFile(values, ref msg))
|
||||
{
|
||||
if (_Taxtools.CreateCsrAndPrivateKey(model.cn, ref msg))
|
||||
{
|
||||
taxTools = new TaxToolsDTO();
|
||||
//خواندن
|
||||
Stream stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.Csr", FileMode.Open);
|
||||
byte[] buffer = new byte[stream.Length];
|
||||
stream.Read(buffer, 0, (int)stream.Length);
|
||||
string csr = Encoding.UTF8.GetString(buffer);
|
||||
stream.Flush();
|
||||
stream.Close();
|
||||
taxTools.Base64csr = Convert.ToBase64String(buffer);
|
||||
taxTools.typecsr = "Csr";
|
||||
stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.key", FileMode.Open);
|
||||
buffer = new byte[stream.Length];
|
||||
stream.Read(buffer, 0, (int)stream.Length);
|
||||
string key = Encoding.UTF8.GetString(buffer);
|
||||
taxTools.Base64key = Convert.ToBase64String(buffer);
|
||||
taxTools.typekey = "key";
|
||||
stream.Flush();
|
||||
stream.Close();
|
||||
//List<Service.PrmValue> values = new List<Service.PrmValue>()
|
||||
//{
|
||||
// new Service.PrmValue(){Prm="CN",Value=model.cn},
|
||||
// new Service.PrmValue(){Prm="serialNumber",Value=model.sn},
|
||||
// new Service.PrmValue(){Prm="O",Value="Non-Governmental"},
|
||||
// new Service.PrmValue(){Prm="3.OU",Value=model.company},
|
||||
// new Service.PrmValue(){Prm="2.OU",Value=model.company},
|
||||
// new Service.PrmValue(){Prm="1.OU",Value=model.company},
|
||||
// new Service.PrmValue(){Prm="C",Value="IR"},
|
||||
//};
|
||||
//string msg = "";
|
||||
//if (_Taxtools.CraeteCnfFile(values, ref msg))
|
||||
//{
|
||||
// if (_Taxtools.CreateCsrAndPrivateKey(model.cn, ref msg))
|
||||
// {
|
||||
// taxTools = new TaxToolsDTO();
|
||||
// //خواندن
|
||||
// Stream stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.Csr", FileMode.Open);
|
||||
// byte[] buffer = new byte[stream.Length];
|
||||
// stream.Read(buffer, 0, (int)stream.Length);
|
||||
// string csr = Encoding.UTF8.GetString(buffer);
|
||||
// stream.Flush();
|
||||
// stream.Close();
|
||||
// taxTools.Base64csr = Convert.ToBase64String(buffer);
|
||||
// taxTools.typecsr = "Csr";
|
||||
// stream = File.Open($"C:\\OpenSSL\\bin\\{model.cn}.key", FileMode.Open);
|
||||
// buffer = new byte[stream.Length];
|
||||
// stream.Read(buffer, 0, (int)stream.Length);
|
||||
// string key = Encoding.UTF8.GetString(buffer);
|
||||
// taxTools.Base64key = Convert.ToBase64String(buffer);
|
||||
// taxTools.typekey = "key";
|
||||
// stream.Flush();
|
||||
// stream.Close();
|
||||
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
// TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/CreateCsrAndPrivateKey",
|
||||
// Value = JsonConvert.SerializeObject(model),
|
||||
// Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// Type = "User"
|
||||
//});
|
||||
await _repoSaleLead.AddAsync(new SaleLead
|
||||
{
|
||||
cn = model.cn,
|
||||
company = model.company,
|
||||
csr = csr,
|
||||
Key = key,
|
||||
Mobile = model.Mobile,
|
||||
sn = model.sn
|
||||
});
|
||||
}
|
||||
// //_contextMongodb.InsertItem(new SysLog()
|
||||
// //{
|
||||
// // TraceIdentifierID = _httpContextAccessor.HttpContext.TraceIdentifier,
|
||||
// // Datetime = DateTime.Now.ConvertMiladiToShamsi(),
|
||||
// // Method = $"{_httpContextAccessor.HttpContext.Request.Method}/{this.GetType().FullName}/CreateCsrAndPrivateKey",
|
||||
// // Value = JsonConvert.SerializeObject(model),
|
||||
// // Route = _httpContextAccessor.HttpContext.Request.Path,
|
||||
// // Type = "User"
|
||||
// //});
|
||||
// await _repoSaleLead.AddAsync(new SaleLead
|
||||
// {
|
||||
// cn = model.cn,
|
||||
// company = model.company,
|
||||
// csr = csr,
|
||||
// Key = key,
|
||||
// Mobile = model.Mobile,
|
||||
// sn = model.sn
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
if (string.IsNullOrEmpty(msg))
|
||||
// if (string.IsNullOrEmpty(msg))
|
||||
{
|
||||
//_contextMongodb.InsertItem(new SysLog()
|
||||
//{
|
||||
|
@@ -4,7 +4,6 @@ using Back.Data.Infrastructure.Repository;
|
||||
using Back.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Org.BouncyCastle.Crypto.Tls;
|
||||
using Shared.DTOs;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Data.SqlTypes;
|
||||
|
Reference in New Issue
Block a user