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);
}
}
}

View File

@@ -97,7 +97,7 @@ namespace Back.Data.Models
#endregion
#region fild
public string? ExternalAccessCode { get; set; }
// public string? ExternalAccessCode { get; set; }
public string Title { get; set; }
public string? Des { get; set; }
public InvoiceType invoiceType { get; set; }

View File

@@ -34,7 +34,7 @@ namespace Back.Services
#endregion
//-----------------------
return await invok
return await invok
.Include(inc => inc.invoiceDetails)
.ThenInclude(inc => inc.cODItem)
.ThenInclude(inc => inc.CODUnit)
@@ -43,7 +43,7 @@ namespace Back.Services
.Include(inc => inc.pattern)
.Select(s => new InvoiceDTO()
{
ExternalAccessCode=s.ExternalAccessCode,
// ExternalAccessCode=s.ExternalAccessCode,
IsDeleted=s.IsDeleted,
PatternID = s.PatternID,
PatternTitle = s.pattern.Title,
@@ -105,6 +105,7 @@ namespace Back.Services
,
})
.FirstOrDefaultAsync();
}
public async Task<PagingDto<InvoiceGridDTO>?> GetInvoices(int CompanyID, ItemSerchGetInvoices itemSerch)
{
@@ -162,11 +163,7 @@ namespace Back.Services
return await _invoiceRepo.Get(w => w.ID == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();
}
public async Task<Invoice> GetInvoiceByExternalAccessCode( string ExternalAccessCode)
{
return await _invoiceRepo.Get(w => w.ExternalAccessCode == ExternalAccessCode && !w.IsDeleted).FirstOrDefaultAsync();
}
public async Task<bool> checkFatherInvoiceByInvoiceID(int CompanyID, int InvoiceID)
{
return await _invoiceRepo.Get(w => w.BillReference == InvoiceID && w.CompanyID == CompanyID && !w.IsDeleted).AnyAsync();

View File

@@ -12,5 +12,6 @@
"Fixedvalues": {
"Jwt_Lifetime_Minutes": "144000"
},
"CreateReportFileName": "E:\\CreateReport\\CreateReport.exe"
"CreateReportFileName": "E:\\CreateReport\\CreateReport.exe",
"ReportLog": "E:\\Report\\log.txt"
}

View File

@@ -13,5 +13,5 @@
"Jwt_Lifetime_Minutes": "144000"
},
"CreateReportFileName": "E:\\CreateReport\\CreateReport.exe",
"rptQueue": "E:\\Report\\ResponseQueue"
"ReportLog": "E:\\Report\\log.txt"
}