CreateReport

This commit is contained in:
mmrbnjd
2024-07-01 15:39:40 +03:30
parent 3702145d02
commit 06496f8442
2 changed files with 120 additions and 60 deletions

View File

@@ -8,6 +8,7 @@ using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Shared.DTOs;
using Shared.DTOs.Serch;
using System.Diagnostics;
namespace Back.Controllers
{
@@ -441,11 +442,30 @@ namespace Back.Controllers
return Ok(await _servTaxPayer.GetPatterns());
}
[HttpGet("GetReport/{InvoiceID}")]
public IActionResult GetReport(int InvoiceID)
public async Task<ActionResult<string>> GetReport(int InvoiceID)
{
var reportPath = $"Reports\\invoice.mrt";
var bytes = System.IO.File.ReadAllBytes(reportPath);
return new FileContentResult(bytes, "application/xml");
string output = "";
//-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
var CompanyID= user?.RolUsers.First().CompanyID;
if (await _servInvoice.ExistInvoiceByInvoiceID(CompanyID.Value, InvoiceID))
return NotFound();
// 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 = "C:\\CreateReport\\CreateReport.exe";
p.StartInfo.Arguments = $"{CompanyID} {InvoiceID}";
p.Start();
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return Ok(output);
}
}
}