CreateReport
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user