...
This commit is contained in:
@@ -4,17 +4,16 @@
|
||||
<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 ShowReport();
|
||||
await base.OnParametersSetAsync();
|
||||
}
|
||||
|
||||
@@ -31,22 +30,31 @@
|
||||
};
|
||||
private async Task ShowReport()
|
||||
{
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
var rsp = await hc.Get($"Invoice/GetReportByExternalAccessCode/{ExternalAccessCode}");
|
||||
if (rsp.IsSuccessStatusCode)
|
||||
if (InvoiceID != null && InvoiceID > 0)
|
||||
{
|
||||
var str = await rsp.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrEmpty(str))
|
||||
ShowMessage(ToastType.Warning, "مشکلی در ساخت فایل رخ داده لطفا مجدد تلاش کنید");
|
||||
else
|
||||
await DownloadFileFromStream(str, $"{ExternalAccessCode}.pdf");
|
||||
|
||||
PreloadService.Show(SpinnerColor.Dark);
|
||||
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, $"{InvoiceID}.pdf");
|
||||
|
||||
}
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
ShowMessage(ToastType.Warning, "فاکتوری یافت نشد");
|
||||
|
||||
else ShowMessage(ToastType.Warning, "خطایی در چاپ فاکتور");
|
||||
|
||||
PreloadService.Hide();
|
||||
|
||||
}
|
||||
else if (rsp.StatusCode == System.Net.HttpStatusCode.NotFound)
|
||||
ShowMessage(ToastType.Warning, "فاکتوری یافت نشد");
|
||||
else hc._nav.NavigateTo("Invoice");
|
||||
|
||||
else ShowMessage(ToastType.Warning, "خطایی در چاپ فاکتور");
|
||||
|
||||
PreloadService.Hide();
|
||||
|
||||
}
|
||||
//for download
|
||||
private Stream GetFileStream(byte[] bytes)
|
||||
|
@@ -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,43 +489,14 @@
|
||||
{
|
||||
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;
|
||||
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();
|
||||
ExUrl = $"{fv.Domin}/InvoiceReport/" + InvoiceID;
|
||||
await Codemodal.ShowAsync();
|
||||
}
|
||||
private async Task ShowReport()
|
||||
{
|
||||
|
@@ -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");
|
||||
|
||||
|
Reference in New Issue
Block a user