Merge branch 'kub-stage' into production
Build and Deploy to Production / build-and-deploy (push) Successful in 5m44s
Build and Deploy to Production / build-and-deploy (push) Successful in 5m44s
This commit is contained in:
@@ -143,7 +143,7 @@
|
|||||||
<ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" />
|
<ProjectReference Include="../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Condition="!Exists('../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj')">
|
<ItemGroup Condition="!Exists('../../../CMS/src/CMSMicroservice.Protobuf/CMSMicroservice.Protobuf.csproj')">
|
||||||
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.208" />
|
<PackageReference Include="Foursat.CMSMicroservice.Protobuf" Version="0.0.209" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- ============================================================ -->
|
<!-- ============================================================ -->
|
||||||
|
|||||||
@@ -33,12 +33,6 @@
|
|||||||
StartIcon="@Icons.Material.Filled.Refresh">
|
StartIcon="@Icons.Material.Filled.Refresh">
|
||||||
بارگذاری
|
بارگذاری
|
||||||
</MudButton>
|
</MudButton>
|
||||||
<MudButton Variant="Variant.Filled"
|
|
||||||
Color="Color.Success"
|
|
||||||
OnClick="OpenActivateDialog"
|
|
||||||
StartIcon="@Icons.Material.Filled.Add">
|
|
||||||
فعالسازی عضو جدید
|
|
||||||
</MudButton>
|
|
||||||
<MudButton Variant="Variant.Outlined"
|
<MudButton Variant="Variant.Outlined"
|
||||||
Color="Color.Info"
|
Color="Color.Info"
|
||||||
OnClick="ExportToExcel"
|
OnClick="ExportToExcel"
|
||||||
|
|||||||
@@ -62,23 +62,6 @@ public partial class ClubMembers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OpenActivateDialog()
|
|
||||||
{
|
|
||||||
var dialog = await DialogService.ShowAsync<ActivateClubDialog>("فعالسازی عضویت باشگاه", new DialogOptions
|
|
||||||
{
|
|
||||||
CloseButton = true,
|
|
||||||
MaxWidth = MaxWidth.Small,
|
|
||||||
FullWidth = true
|
|
||||||
});
|
|
||||||
|
|
||||||
var result = await dialog.Result;
|
|
||||||
if (!result.Canceled)
|
|
||||||
{
|
|
||||||
Snackbar.Add("عضویت با موفقیت فعال شد", Severity.Success);
|
|
||||||
await ApplyFilter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task ViewDetails(ClubMembershipModel member)
|
private async Task ViewDetails(ClubMembershipModel member)
|
||||||
{
|
{
|
||||||
var parameters = new DialogParameters
|
var parameters = new DialogParameters
|
||||||
|
|||||||
@@ -1,156 +0,0 @@
|
|||||||
@using CMSMicroservice.Protobuf.Protos.ClubMembership
|
|
||||||
@using CMSMicroservice.Protobuf.Protos.Package
|
|
||||||
@using BackOffice.Pages.AutoComplete
|
|
||||||
|
|
||||||
<MudDialog>
|
|
||||||
<DialogContent>
|
|
||||||
<MudForm @ref="_form" @bind-IsValid="_formValid">
|
|
||||||
<MudStack Spacing="3">
|
|
||||||
<UserAutoComplete Label="انتخاب کاربر" @bind-SelectedUserId="_model.UserId" />
|
|
||||||
|
|
||||||
@if (_isLoadingPackages)
|
|
||||||
{
|
|
||||||
<MudSkeleton SkeletonType="SkeletonType.Rectangle" Height="56px" />
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<MudSelect T="long" @bind-Value="_model.PackageId"
|
|
||||||
Label="انتخاب پکیج"
|
|
||||||
Required="true"
|
|
||||||
RequiredError="انتخاب پکیج الزامی است"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
AnchorOrigin="Origin.BottomCenter">
|
|
||||||
@foreach (var pkg in _packages)
|
|
||||||
{
|
|
||||||
<MudSelectItem T="long" Value="pkg.Id">
|
|
||||||
@pkg.Title — @($"{pkg.Price:N0}") ریال
|
|
||||||
</MudSelectItem>
|
|
||||||
}
|
|
||||||
</MudSelect>
|
|
||||||
}
|
|
||||||
|
|
||||||
<MudAlert Severity="Severity.Info" Dense="true">
|
|
||||||
<MudText Typo="Typo.body2">
|
|
||||||
با تایید، عضویت باشگاه برای کاربر فعال میشود.
|
|
||||||
<br/>
|
|
||||||
<small>عضویت باشگاه بدون محدودیت زمانی است.</small>
|
|
||||||
</MudText>
|
|
||||||
</MudAlert>
|
|
||||||
</MudStack>
|
|
||||||
</MudForm>
|
|
||||||
</DialogContent>
|
|
||||||
<DialogActions>
|
|
||||||
<MudButton OnClick="Cancel">لغو</MudButton>
|
|
||||||
<MudButton Color="Color.Success"
|
|
||||||
Variant="Variant.Filled"
|
|
||||||
OnClick="Submit"
|
|
||||||
Disabled="@(!_formValid || _isSubmitting || _isLoadingPackages)">
|
|
||||||
@if (_isSubmitting)
|
|
||||||
{
|
|
||||||
<MudProgressCircular Size="Size.Small" Indeterminate="true" />
|
|
||||||
<MudText Class="ms-2">در حال پردازش...</MudText>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<text>تایید و فعالسازی</text>
|
|
||||||
}
|
|
||||||
</MudButton>
|
|
||||||
</DialogActions>
|
|
||||||
</MudDialog>
|
|
||||||
|
|
||||||
@code {
|
|
||||||
[CascadingParameter] IMudDialogInstance MudDialog { get; set; }
|
|
||||||
[Inject] public ClubMembershipContract.ClubMembershipContractClient ClubContract { get; set; }
|
|
||||||
[Inject] public PackageContract.PackageContractClient PackageClient { get; set; }
|
|
||||||
|
|
||||||
private MudForm _form;
|
|
||||||
private bool _formValid;
|
|
||||||
private bool _isSubmitting;
|
|
||||||
private bool _isLoadingPackages = true;
|
|
||||||
private List<GetAllPackageByFilterResponseModel> _packages = new();
|
|
||||||
private ActivateModel _model = new();
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
await LoadPackages();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task LoadPackages()
|
|
||||||
{
|
|
||||||
_isLoadingPackages = true;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var request = new GetAllPackageByFilterRequest
|
|
||||||
{
|
|
||||||
PaginationState = new CMSMicroservice.Protobuf.Protos.PaginationState
|
|
||||||
{
|
|
||||||
PageNumber = 1,
|
|
||||||
PageSize = 50
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var result = await PackageClient.GetAllPackageByFilterAsync(request);
|
|
||||||
if (result?.Models != null)
|
|
||||||
{
|
|
||||||
_packages = result.Models.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Snackbar.Add($"خطا در بارگذاری پکیجها: {ex.Message}", Severity.Error);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_isLoadingPackages = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Cancel() => MudDialog.Cancel();
|
|
||||||
|
|
||||||
private async Task Submit()
|
|
||||||
{
|
|
||||||
await _form.Validate();
|
|
||||||
if (!_formValid) return;
|
|
||||||
|
|
||||||
if (!_model.UserId.HasValue || _model.UserId.Value <= 0)
|
|
||||||
{
|
|
||||||
Snackbar.Add("لطفاً کاربر را انتخاب کنید.", Severity.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_model.PackageId <= 0)
|
|
||||||
{
|
|
||||||
Snackbar.Add("لطفاً پکیج را انتخاب کنید.", Severity.Warning);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_isSubmitting = true;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var request = new ActivateClubMembershipRequest
|
|
||||||
{
|
|
||||||
UserId = _model.UserId.Value,
|
|
||||||
PackageId = _model.PackageId,
|
|
||||||
ForceActivation = true
|
|
||||||
};
|
|
||||||
|
|
||||||
var response = await ClubContract.ActivateClubMembershipAsync(request);
|
|
||||||
|
|
||||||
Snackbar.Add("عضویت با موفقیت فعال شد.", Severity.Success);
|
|
||||||
MudDialog.Close(DialogResult.Ok(true));
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Snackbar.Add($"خطا: {ex.Message}", Severity.Error);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
_isSubmitting = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class ActivateModel
|
|
||||||
{
|
|
||||||
public long? UserId { get; set; }
|
|
||||||
public long PackageId { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,8 @@
|
|||||||
<col />
|
<col />
|
||||||
<col />
|
<col />
|
||||||
<col />
|
<col />
|
||||||
|
<col style="min-width: 180px;" />
|
||||||
|
<col />
|
||||||
<col style="width: 58px;" />
|
<col style="width: 58px;" />
|
||||||
</ColGroup>
|
</ColGroup>
|
||||||
<ToolBarContent>
|
<ToolBarContent>
|
||||||
@@ -46,8 +48,21 @@
|
|||||||
</CellTemplate>
|
</CellTemplate>
|
||||||
</PropertyColumn>
|
</PropertyColumn>
|
||||||
<PropertyColumn Property="x => x.NationalCode" Title="کدملی" />
|
<PropertyColumn Property="x => x.NationalCode" Title="کدملی" />
|
||||||
|
<TemplateColumn Title="آدرس پیشفرض">
|
||||||
|
<CellTemplate>
|
||||||
|
<MudText Typo="Typo.caption" Style="max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;"
|
||||||
|
Title="@(context.Item.DefaultAddress ?? "")">
|
||||||
|
@(string.IsNullOrWhiteSpace(context.Item.DefaultAddress) ? "-" : context.Item.DefaultAddress)
|
||||||
|
</MudText>
|
||||||
|
</CellTemplate>
|
||||||
|
</TemplateColumn>
|
||||||
|
<TemplateColumn Title="کدپستی پیشفرض">
|
||||||
|
<CellTemplate>
|
||||||
|
<MudText Typo="Typo.caption">
|
||||||
|
@(string.IsNullOrWhiteSpace(context.Item.DefaultPostalCode) ? "-" : context.Item.DefaultPostalCode)
|
||||||
|
</MudText>
|
||||||
|
</CellTemplate>
|
||||||
|
</TemplateColumn>
|
||||||
|
|
||||||
<TemplateColumn StickyLeft="true" Title="عملیات" CellStyle="text-wrap: nowrap;" HeaderStyle="text-wrap: nowrap;">
|
<TemplateColumn StickyLeft="true" Title="عملیات" CellStyle="text-wrap: nowrap;" HeaderStyle="text-wrap: nowrap;">
|
||||||
<CellTemplate>
|
<CellTemplate>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
using CMSMicroservice.Protobuf.Protos.User;
|
using CMSMicroservice.Protobuf.Protos.User;
|
||||||
using BackOffice.Common.BaseComponents;
|
using BackOffice.Common.BaseComponents;
|
||||||
|
using BackOffice.Common.Utilities;
|
||||||
using BackOffice.Pages.User.Components;
|
using BackOffice.Pages.User.Components;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.JSInterop;
|
using Microsoft.JSInterop;
|
||||||
using MudBlazor;
|
using MudBlazor;
|
||||||
using System.Text;
|
|
||||||
using DateTimeConverterCL;
|
|
||||||
using DataModel = CMSMicroservice.Protobuf.Protos.User.GetAllUserByFilterResponseModel;
|
using DataModel = CMSMicroservice.Protobuf.Protos.User.GetAllUserByFilterResponseModel;
|
||||||
|
|
||||||
namespace BackOffice.Pages.User;
|
namespace BackOffice.Pages.User;
|
||||||
@@ -84,51 +83,63 @@ public partial class UserMainPage
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var exportRequest = new GetAllUserByFilterRequest
|
var filter = _request.Filter?.Clone() ?? new();
|
||||||
|
var all = new List<DataModel>();
|
||||||
|
const int pageSize = 200;
|
||||||
|
var page = 1;
|
||||||
|
|
||||||
|
while (page <= 500)
|
||||||
{
|
{
|
||||||
Filter = _request.Filter?.Clone() ?? new(),
|
var result = await UserContract.GetAllUserByFilterAsync(new GetAllUserByFilterRequest
|
||||||
PaginationState = new() { PageNumber = 1, PageSize = 1000 }
|
{
|
||||||
};
|
Filter = filter,
|
||||||
|
PaginationState = new() { PageNumber = page, PageSize = pageSize }
|
||||||
|
});
|
||||||
|
|
||||||
var result = await UserContract.GetAllUserByFilterAsync(exportRequest);
|
var batch = result?.Models?.ToList() ?? new();
|
||||||
|
if (batch.Count == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
if (result?.Models == null || !result.Models.Any())
|
all.AddRange(batch);
|
||||||
|
|
||||||
|
var hasNext = result?.MetaData?.HasNext == true;
|
||||||
|
if (!hasNext || batch.Count < pageSize)
|
||||||
|
break;
|
||||||
|
|
||||||
|
page++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (all.Count == 0)
|
||||||
{
|
{
|
||||||
Snackbar.Add("دادهای برای خروجی وجود ندارد.", Severity.Info);
|
Snackbar.Add("دادهای برای خروجی وجود ندارد.", Severity.Info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
var headers = new[]
|
||||||
sb.AppendLine("شناسه,موبایل,نام,نام خانوادگی,کدملی");
|
|
||||||
|
|
||||||
foreach (var u in result.Models)
|
|
||||||
{
|
{
|
||||||
sb.AppendLine(string.Join(",",
|
"شناسه", "موبایل", "نام", "نام خانوادگی", "کدملی",
|
||||||
u.Id,
|
"آدرس پیشفرض", "کدپستی پیشفرض"
|
||||||
EscapeCsv(u.Mobile),
|
};
|
||||||
EscapeCsv(u.FirstName),
|
|
||||||
EscapeCsv(u.LastName),
|
|
||||||
EscapeCsv(u.NationalCode)));
|
|
||||||
}
|
|
||||||
|
|
||||||
var bytes = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(sb.ToString())).ToArray();
|
var rows = all.Select(u => new object?[]
|
||||||
var base64 = Convert.ToBase64String(bytes);
|
{
|
||||||
var filename = $"users-{DateTime.Now:yyyyMMddHHmmss}.csv";
|
u.Id,
|
||||||
|
u.Mobile,
|
||||||
|
u.FirstName,
|
||||||
|
u.LastName,
|
||||||
|
u.NationalCode,
|
||||||
|
u.DefaultAddress,
|
||||||
|
u.DefaultPostalCode
|
||||||
|
});
|
||||||
|
|
||||||
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename, base64);
|
var filename = $"users-{DateTime.Now:yyyyMMddHHmmss}.xls";
|
||||||
Snackbar.Add("خروجی Excel (CSV) آماده شد.", Severity.Success);
|
await JsRuntime.InvokeVoidAsync("jsSaveAsFile", filename,
|
||||||
|
CsvExportHelper.ToExcelXmlBase64("کاربران", headers, rows));
|
||||||
|
Snackbar.Add($"خروجی Excel آماده شد ({all.Count} کاربر).", Severity.Success);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
Snackbar.Add($"خطا در خروجی Excel: {ex.Message}", Severity.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string EscapeCsv(string value)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(value)) return "";
|
|
||||||
if (value.Contains(',') || value.Contains('"') || value.Contains('\n'))
|
|
||||||
return $"\"{value.Replace("\"", "\"\"")}\"";
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user