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,7 +475,8 @@ namespace Back.Controllers
// }
// }
try
{
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
@@ -486,52 +487,15 @@ namespace Back.Controllers
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)
catch (Exception ex)
{
if (string.IsNullOrEmpty(ExternalAccessCode))
return NotFound();
System.IO.File.AppendAllText(_configuration["ReportLog"].ToString(), ex.ToString());
throw;
}
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

@@ -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"
}

View File

@@ -78,7 +78,7 @@ namespace Shared.DTOs
public decimal? tbill { get; set; }
public int? BillReference { get; set; }
public bool IsDeleted { get; set; }
public string? ExternalAccessCode { get; set; }
//public string? ExternalAccessCode { get; set; }
public ICollection<InvoiceItemDTO> items { get; set; }=new List<InvoiceItemDTO>();
public ICollection<InvoicePaymentDTO> payments { get; set; } = new List<InvoicePaymentDTO>();
// public ICollection<InvoiceStatusDto> Invoicestatuschanges { get; set; }

View File

@@ -4,16 +4,15 @@
<Preload LoadingText="در حال بارگذاری..." />
<Toasts class="p-3" Messages="messages" Placement="ToastsPlacement.MiddleCenter" />
@layout EmptyLayout
@page "/InvoiceReport/{ExternalAccessCode}"
@page "/InvoiceReport/{InvoiceID:int}"
@using Front.Services
@code {
[Inject] protected PreloadService PreloadService { get; set; } = default!;
List<ToastMessage> messages = new List<ToastMessage>();
[Parameter] public string ExternalAccessCode { get; set; }
[Parameter] public int? InvoiceID { get; set; }
protected async override Task OnParametersSetAsync()
{
if (!string.IsNullOrEmpty(ExternalAccessCode))
await ShowReport();
await base.OnParametersSetAsync();
}
@@ -31,15 +30,19 @@
};
private async Task ShowReport()
{
if (InvoiceID != null && InvoiceID > 0)
{
PreloadService.Show(SpinnerColor.Dark);
var rsp = await hc.Get($"Invoice/GetReportByExternalAccessCode/{ExternalAccessCode}");
var rsp = await hc.Get($"Invoice/GetReport/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
{
var str = await rsp.Content.ReadAsStringAsync();
if (string.IsNullOrEmpty(str))
ShowMessage(ToastType.Warning, "مشکلی در ساخت فایل رخ داده لطفا مجدد تلاش کنید");
else
await DownloadFileFromStream(str, $"{ExternalAccessCode}.pdf");
await DownloadFileFromStream(str, $"{InvoiceID}.pdf");
}
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
ShowMessage(ToastType.Warning, "فاکتوری یافت نشد");
@@ -47,6 +50,11 @@
else ShowMessage(ToastType.Warning, "خطایی در چاپ فاکتور");
PreloadService.Hide();
}
else hc._nav.NavigateTo("Invoice");
}
//for download
private Stream GetFileStream(byte[] bytes)

View File

@@ -343,7 +343,7 @@
<Button class="mt-3" Color="ButtonColor.Primary" @onclick="ShowReport" Type="ButtonType.Button">
pdf
</Button>
<Button class="mt-3" Color="ButtonColor.Info" @onclick="onClickExternalAccessCode" Type="ButtonType.Button">
<Button class="mt-3" Color="ButtonColor.Info" @onclick="onClickLink" Type="ButtonType.Button">
لینک
</Button>
}
@@ -489,44 +489,15 @@
{
if (InvoiceID.HasValue)
{
hc._nav.NavigateTo($"TaxPayerInvoiceItem/{InvoiceID}");
}
}
private async Task onClickExternalAccessCode()
private async Task onClickLink()
{
PreloadService.Show(SpinnerColor.Dark);
if (!string.IsNullOrEmpty(invoice.ExternalAccessCode))
{
ExUrl = $"{fv.Domin}/InvoiceReport/" + invoice.ExternalAccessCode;
ExUrl = $"{fv.Domin}/InvoiceReport/" + InvoiceID;
await Codemodal.ShowAsync();
}
else
{
var rsp = await hc.Put($"Invoice/SetExternalAccessCode/{InvoiceID}");
if (rsp.IsSuccessStatusCode)
{
var str = await rsp.Content.ReadAsStringAsync();
if (string.IsNullOrEmpty(str))
ShowDangerAlert("مشکلی در ساخت فایل رخ داده لطفا مجدد تلاش کنید");
else
{
ExUrl = $"{fv.Domin}/InvoiceReport/" + str;
await Codemodal.ShowAsync();
}
}
else
{
var request = await rsp.Content.ReadFromJsonAsync<List<string>>();
ShowDangerAlert(request[0]);
}
}
PreloadService.Hide();
}
private async Task ShowReport()
{
PreloadService.Show(SpinnerColor.Dark);

View File

@@ -37,10 +37,10 @@ builder.Services.AddScoped(sp => new UserAuthenticationDTO()
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://195.88.208.142:7075/api/") });
//Home
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("https://localhost:7075/api/") });
//farzan
//builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri("http://localhost:5271/api/") });
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("fa-Ir");