This commit is contained in:
mmrbnjd
2024-07-06 16:18:23 +03:30
parent d4410ea328
commit e175d83c2a
9 changed files with 60 additions and 119 deletions

View File

@@ -32,7 +32,7 @@ namespace Back.Controllers
_servInvoice = servInvoice;
_servUser = servUser;
_validationInvoice = validationInvoice;
_configuration=configuration;
_configuration = configuration;
_servTaxPayer = servTaxPayer;
_rptQueueRepository = rptQueueRepository;
@@ -475,63 +475,27 @@ namespace Back.Controllers
// }
// }
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());
throw;
}
// 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();
return Ok(output);
}
[HttpPut("SetExternalAccessCode/{InvoiceID}")]
public async Task<ActionResult<string>> SetExternalAccessCode(int InvoiceID)
{ //-----GetUserAndCompany
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
var UserID = claim.Value;
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
var code = DateTime.Now.ToString($"yMMdd{InvoiceID}Hmmss{user.RolUsers.First().CompanyID}");
Invoice? Invoice = await _servInvoice.GetInvoiceByInvoiceID(user.RolUsers.First().CompanyID, InvoiceID);
if (Invoice == null) return NotFound();
if (!string.IsNullOrEmpty(Invoice.ExternalAccessCode))
return Ok(Invoice.ExternalAccessCode);
Invoice.ExternalAccessCode = code;
if (await _servInvoice.UpdateInvoice(Invoice))
return Ok(code.ToString());
return BadRequest(new List<string> { "خطایی سرور" });
}
[HttpGet("GetReportByExternalAccessCode/{xternalAccessCode}")]
[AllowAnonymous]
public async Task<ActionResult<string>> GetReportByExternalAccessCode(string ExternalAccessCode)
{
if (string.IsNullOrEmpty(ExternalAccessCode))
return NotFound();
string output = "";
var invoice = await _servInvoice.GetInvoiceByExternalAccessCode(ExternalAccessCode);
if (invoice == null)
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 = $"{invoice.CompanyID} {invoice.ID}";
p.Start();
output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
return Ok(output);
}
}
}