png invoice

This commit is contained in:
mmrbnjd
2025-01-09 16:01:37 +03:30
parent 8f9a30c310
commit 83a690ba6b
7 changed files with 362 additions and 53 deletions

View File

@@ -23,12 +23,14 @@ namespace Back.Controllers
private readonly servUser _servUser;
private readonly AddOrUpdateInvoiceValidation _validationInvoice;
private readonly servTaxPayer _servTaxPayer;
private readonly servReport _servReport;
private readonly IAsyncRepository<rptQueue> _rptQueueRepository;
public InvoiceController(servInvoice servInvoice, servUser servUser
, AddOrUpdateInvoiceValidation validationInvoice
, servTaxPayer servTaxPayer, IConfiguration configuration
, IAsyncRepository<rptQueue> rptQueueRepository)
, IAsyncRepository<rptQueue> rptQueueRepository, servReport servReport)
{
_servReport= servReport;
_servInvoice = servInvoice;
_servUser = servUser;
_validationInvoice = validationInvoice;
@@ -593,7 +595,6 @@ namespace Back.Controllers
[HttpGet("GetReport/{InvoiceID}")]
public async Task<ActionResult<string>> GetReport(int InvoiceID)
{
string output = "";
//-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value;
@@ -604,37 +605,10 @@ namespace Back.Controllers
if (!await _servInvoice.ExistInvoiceByInvoiceID(CompanyID.Value, InvoiceID))
return NotFound();
//if( await _rptQueueRepository.AddBoolResultAsync(new rptQueue
// {
// CompanyID= CompanyID.Value,InvoicID= InvoiceID,
//}))
// {
// Thread.Sleep(2000);
// if(System.IO.File.Exists(_configuration["rptQueue"].ToString()+ InvoiceID + ".txt"))
// {
// output= System.IO.File.ReadAllText(_configuration["rptQueue"].ToString() + InvoiceID + ".txt");
// }
var result = await _servInvoice.GetInvoice(user.RolUsers.First().CompanyID,InvoiceID);
// }
try
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = _configuration["CreateReportFileName"].ToString();
p.StartInfo.Arguments = $"{CompanyID} {InvoiceID}";
p.Start();
output = await p.StandardOutput.ReadToEndAsync();
await p.WaitForExitAsync();
}
catch (Exception ex)
{
System.IO.File.AppendAllText(_configuration["ReportLog"].ToString(), ex.ToString());
}
return Ok(output);
string base64= await _servReport.CreateImage(result, user?.RolUsers.First().Company.Logo==null ?"":Convert.ToBase64String(user?.RolUsers.First().Company.Logo), user?.RolUsers.First().Company.Name);
return Ok(base64);
}
}