This commit is contained in:
MeysamMoghaddam
2025-09-28 01:28:44 +03:30
parent 86e4c3b551
commit 1b8a584435
29 changed files with 1086 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>

View File

@@ -0,0 +1,68 @@
using Blazored.LocalStorage;
using Grpc.Core;
using Grpc.Net.Client.Web;
using Grpc.Net.Client;
using MudBlazor.Services;
using System.Text.Json;
using System.Text.Json.Serialization;
using FrontOffice.BFF.Package.Protobuf.Protos.Package;
using FrontOffice.BFF.User.Protobuf.Protos.User;
using FrontOffice.BFF.UserAddress.Protobuf.Protos.UserAddress;
using FrontOffice.BFF.UserOrder.Protobuf.Protos.UserOrder;
namespace Microsoft.Extensions.DependencyInjection;
public static class ConfigureServices
{
public static IServiceCollection AddCommonServices(this IServiceCollection services)
{
services.AddMudServices();
services.AddBlazoredLocalStorage(config =>
{
config.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
config.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
config.JsonSerializerOptions.IgnoreReadOnlyProperties = true;
config.JsonSerializerOptions.PropertyNameCaseInsensitive = true;
config.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
config.JsonSerializerOptions.ReadCommentHandling = JsonCommentHandling.Skip;
config.JsonSerializerOptions.WriteIndented = false;
});
return services;
}
public static IServiceCollection AddGrpcServices(this IServiceCollection services, IConfiguration configuration)
{
var baseUrl = configuration["GwUrl"];
var httpClient = new HttpClient(new GrpcWebHandler(GrpcWebMode.GrpcWeb, new HttpClientHandler()));
httpClient.Timeout = TimeSpan.FromMinutes(10); // TODO Check Timeout
var serviceProvider = services.BuildServiceProvider();
var channel = CreateAuthenticatedChannel(baseUrl, httpClient, serviceProvider);
services.AddSingleton(sp => new PackageContract.PackageContractClient(channel));
services.AddSingleton(sp => new UserContract.UserContractClient(channel));
services.AddSingleton(sp => new UserAddressContract.UserAddressContractClient(channel));
services.AddSingleton(sp => new UserOrderContract.UserOrderContractClient(channel));
return services;
}
private static GrpcChannel CreateAuthenticatedChannel(string address, HttpClient httpClient, IServiceProvider serviceProvider)
{
var credentials = CallCredentials.FromInterceptor(async (context, metadata) =>
{
await Task.CompletedTask;
});
// SslCredentials is used here because this channel is using TLS.
// CallCredentials can't be used with ChannelCredentials.Insecure on non-TLS channels.
var channel = GrpcChannel.ForAddress(address, new GrpcChannelOptions
{
UnsafeUseInsecureChannelCallCredentials = true,
Credentials = ChannelCredentials.Create(new SslCredentials(), credentials),
HttpClient = httpClient,
MaxReceiveMessageSize = 1000 * 1024 * 1024, // 1 GB
MaxSendMessageSize = 1000 * 1024 * 1024 // 1 GB
});
return channel;
}
}

View File

@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Foursat.FrontOffice.BFF.Package.Protobuf" Version="0.0.112" />
<PackageReference Include="Foursat.FrontOffice.BFF.User.Protobuf" Version="0.0.112" />
<PackageReference Include="Foursat.FrontOffice.BFF.UserAddress.Protobuf" Version="0.0.112" />
<PackageReference Include="Foursat.FrontOffice.BFF.UserOrder.Protobuf" Version="0.0.112" />
<PackageReference Include="MudBlazor" Version="7.16.0" />
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Mapster" Version="7.4.0" />
<PackageReference Include="Grpc.Net.Client.Web" Version="2.59.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.59.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Components\" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,42 @@
@page
@model FrontOffice.Main.Pages.ErrorModel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Error</title>
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" />
</head>
<body>
<div class="main">
<div class="content px-4">
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Diagnostics;
namespace FrontOffice.Main.Pages;
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
[IgnoreAntiforgeryToken]
public class ErrorModel : PageModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
private readonly ILogger<ErrorModel> _logger;
public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}
public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}

View File

@@ -0,0 +1,7 @@
@attribute [Route(RouteConstants.Main.MainPage)]
<PageTitle>خانه</PageTitle>
<h1>Hello, world!</h1>
Welcome to your new app.

View File

@@ -0,0 +1,37 @@
@page "/"
@using Microsoft.AspNetCore.Components.Web
@namespace FrontOffice.Main.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html lang="fa">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="~/" />
<link href="css/site.css" rel="stylesheet" />
<link href="FrontOffice.Main.styles.css" rel="stylesheet" />
<link rel="icon" type="image/png" href="favicon.png"/>
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css" rel="stylesheet" />
</head>
<body>
<component type="typeof(App)" render-mode="ServerPrerendered" />
<div id="blazor-error-ui">
<environment include="Staging,Production">
یک خطا رخ داده است. این برنامه ممکن است تا زمان بارگذاری مجدد پاسخگو نباشد.
</environment>
<environment include="Development">
خطای مدیریت‌نشده ای اتفاق افتاده است. برای مشاهده جزئیات، ابزار توسعه (DevTools) مرورگر را بررسی نمایید.
</environment>
<a href="" class="reload">بارگذاری مجدد</a>
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.server.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
</body>
</html>

View File

@@ -0,0 +1,48 @@
using FrontOffice.Main.Utilities;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
#region AddCommonServices
builder.Services.AddCommonServices();
#endregion
#region AddGrpcServices
builder.Services.AddGrpcServices(builder.Configuration);
#endregion
var appSettings = builder.Configuration.Get<AppSettings>();
UrlUtility.DownloadUrl = appSettings.DownloadUrl;
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.MapBlazorHub();
app.MapFallbackToPage("/_Host");
app.Run();
public class AppSettings
{
public string DownloadUrl { get; set; }
}

View File

@@ -0,0 +1,37 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:59107",
"sslPort": 44381
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5268",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:7080;http://localhost:5268",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,16 @@
@inherits LayoutComponentBase
<PageTitle>فرصت</PageTitle>
<MudRTLProvider RightToLeft="true">
<MudThemeProvider @ref="_mudThemeProvider" Theme="CustomMudTheme.CustomMudBlazorTheme" />
<MudPopoverProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
<MudLayout>
<MudMainContent>
@Body
</MudMainContent>
</MudLayout>
</MudRTLProvider>

View File

@@ -0,0 +1,12 @@
using Microsoft.JSInterop;
using MudBlazor;
namespace FrontOffice.Main.Shared;
public partial class MainLayout
{
private MudThemeProvider _mudThemeProvider;
private async void Back()
{
await JSRuntime.InvokeVoidAsync("history.back");
}
}

View File

@@ -0,0 +1,3 @@
body{
}

View File

@@ -0,0 +1,39 @@
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">FrontOffice.Main</a>
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="oi oi-home" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="oi oi-plus" aria-hidden="true"></span> Counter
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="fetchdata">
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data
</NavLink>
</div>
</nav>
</div>
@code {
private bool collapseNavMenu = true;
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
private void ToggleNavMenu()
{
collapseNavMenu = !collapseNavMenu;
}
}

View File

@@ -0,0 +1,182 @@
using MudBlazor;
namespace FrontOffice.Main.Utilities;
public static class CustomMudTheme
{
public static MudTheme CustomMudBlazorTheme { get; set; } = new()
{
PaletteLight = new PaletteLight()
{
Primary = "#0380C0",
//Secondary = CustomColor.Secondary.Default,
//Tertiary = CustomColor.Tertiary.Default,
Background = "#F5F5F5",
AppbarBackground = "#F5F5F5",
//PrimaryContrastText = "#FFFFFF",
//SecondaryContrastText = "#FFFFFF",
//ErrorContrastText = "#FFFFFF",
//SuccessContrastText = "#FFFFFF",
//InfoContrastText = "#FFFFFF",
//WarningContrastText = "#FFFFFF",
TextPrimary = Colors.Gray.Darken3,
//// TextSecondary = "#FFFFFF",
//Error = CustomColor.Error.Default,
//ErrorLighten = CustomColor.Error.Error100,
//// Info = "#3977AD",
//InfoLighten = CustomColor.Info.Lighten,
//InfoDarken = CustomColor.Info.Darken,
//// Success = "#05AF82",
//SuccessDarken = CustomColor.Success.Darken,
//SuccessLighten = CustomColor.Success.Lighten,
////Warning = "#EF7300",
//WarningDarken = CustomColor.Warning.Lighten,
//WarningLighten = CustomColor.Warning.Lighten,
//BackgroundGrey = CustomColor.Other.Background,
//GrayDefault = CustomColor.Other.Background,
//GrayDark = CustomColor.Gray.Gray10,
//GrayLight = CustomColor.Gray.Gray60,
//GrayLighter = CustomColor.Gray.Gray80,
//TextDisabled = CustomColor.Other.DisableText,
//ActionDisabled = CustomColor.Other.DisableText,
//ActionDisabledBackground = CustomColor.Other.DisableBackground,
Surface = "#FFFFFF",
Divider = "#B2BFCB",
},
Typography = new Typography()
{
Default = new Default()
{
FontFamily = new[] { "Vazir" }
},
//Display/Large
H1 = new H1()
{
FontFamily = new[] { "Vazir" },
FontSize = "3.5625rem",
LineHeight = 4,
FontWeight = 500,
LetterSpacing = "0"
},
//Display/Medium
H2 = new H2()
{
FontFamily = new[] { "Vazir" },
FontSize = "2.8125rem",
LineHeight = 3.25,
FontWeight = 500,
LetterSpacing = "0"
},
//Display/Small
H3 = new H3()
{
FontFamily = new[] { "Vazir" },
FontSize = "2.25rem",
LineHeight = 2.75,
FontWeight = 500,
LetterSpacing = "0"
},
//Headline/Large
H4 = new H4()
{
FontFamily = new[] { "Vazir" },
FontSize = "2rem",
LineHeight = 2.5,
FontWeight = 600,
LetterSpacing = "0"
},
//Headline/Medium
H5 = new H5()
{
FontFamily = new[] { "Vazir" },
FontSize = "1.75rem",
LineHeight = 2.25,
FontWeight = 600,
LetterSpacing = "0"
},
//Headline/Small
H6 = new H6()
{
FontFamily = new[] { "Vazir" },
FontSize = "1.5rem",
LineHeight = 2,
FontWeight = 600,
LetterSpacing = "0"
},
Button = new Button
{
FontFamily = new[] { "Vazir" },
FontSize = "0.875rem",
LineHeight = 1.75,
FontWeight = 700,
LetterSpacing = "0"
},
//Body/Large
Body1 = new Body1
{
FontFamily = new[] { "Vazir" },
FontSize = "0.875rem",
LineHeight = 1.75,
FontWeight = 400,
LetterSpacing = "0"
},
//Body/Medium
Body2 = new Body2
{
FontFamily = new[] { "Vazir" },
FontSize = "0.875rem",
LineHeight = 1.43,
FontWeight = 400,
LetterSpacing = "0"
},
//Body/small
Overline = new Overline
{
FontFamily = new[] { "Vazir" },
FontSize = "0.75rem",
LineHeight = 1.33,
FontWeight = 400,
LetterSpacing = "0"
},
//Title/Large
Caption = new Caption
{
FontFamily = new[] { "Vazir" },
FontSize = "1.125rem",
LineHeight = 1.714,
FontWeight = 700,
LetterSpacing = "0"
},
//Title/medium
Subtitle1 = new Subtitle1
{
FontFamily = new[] { "Vazir" },
FontSize = "1rem",
LineHeight = 1.5,
FontWeight = 700,
LetterSpacing = "0.009em"
},
//Title/small
Subtitle2 = new Subtitle2
{
FontFamily = new[] { "Vazir" },
FontSize = "0.875rem",
LineHeight = 1.43,
FontWeight = 700,
LetterSpacing = "0.006em"
}
}
};
}

View File

@@ -0,0 +1,407 @@
using System.ComponentModel.DataAnnotations;
using System.Net;
using System.Reflection;
using System.Text.RegularExpressions;
using Google.Protobuf.WellKnownTypes;
using Microsoft.AspNetCore.Components.Forms;
namespace FrontOffice.Main.Utilities;
public static class Extensions
{
public static string ExtractUserFriendlyMessage(this string errorMessage)
{
// کلیدواژه‌ای که بعد از آن بخش مورد نظر شروع می‌شود
string keyword = "Exception:";
// بررسی وجود کلیدواژه در پیام خطا
int keywordIndex = errorMessage.IndexOf(keyword);
if (keywordIndex >= 0)
{
// استخراج بخش بعد از کلیدواژه
string userFriendlyMessage = errorMessage.Substring(keywordIndex + keyword.Length).Trim();
if (userFriendlyMessage.EndsWith(")"))
{
userFriendlyMessage = userFriendlyMessage.Substring(0, userFriendlyMessage.Length - 2);
}
return userFriendlyMessage;
}
// اگر کلیدواژه وجود نداشت، کل پیام خطا برگردانده شود
return errorMessage;
}
public static string DiffDateTime(this DateTime dateTime)
{
const int SECOND = 1;
const int MINUTE = 60 * SECOND;
const int HOUR = 60 * MINUTE;
const int DAY = 24 * HOUR;
const int MONTH = 30 * DAY;
var ts = new TimeSpan(DateTime.Now.Ticks - dateTime.Ticks);
double delta = Math.Abs(ts.TotalSeconds);
if (delta < 1 * MINUTE)
{
return ts.Seconds == 1 ? "لحظه ای قبل" : ts.Seconds + " ثانیه قبل";
}
if (delta < 2 * MINUTE)
{
return "یک دقیقه قبل";
}
if (delta < 45 * MINUTE)
{
return ts.Minutes + " دقیقه قبل";
}
if (delta < 90 * MINUTE)
{
return "یک ساعت قبل";
}
if (delta < 24 * HOUR)
{
return ts.Hours + " ساعت قبل";
}
if (delta < 48 * HOUR)
{
return "دیروز";
}
if (delta < 30 * DAY)
{
return ts.Days + " روز قبل";
}
if (delta < 12 * MONTH)
{
int months = Convert.ToInt32(Math.Floor((double)ts.Days / 30));
return months <= 1 ? "یک ماه قبل" : months + " ماه قبل";
}
int years = Convert.ToInt32(Math.Floor((double)ts.Days / 365));
return years <= 1 ? "یک سال قبل" : years + " سال قبل";
}
public static string StripHtmlTags(this string html)
{
if (string.IsNullOrEmpty(html))
return string.Empty;
// حذف تمامی تگ‌های HTML
string textOnly = Regex.Replace(html, "<.*?>", string.Empty);
// تبدیل کاراکترهای HTML به متن معمولی (مثلاً &nbsp; -> فضای خالی)
textOnly = WebUtility.HtmlDecode(textOnly);
return textOnly.Trim();
}
public static string ConfuseId(this string? value)
{
if (!string.IsNullOrWhiteSpace(value) && value.Length > 6)
return string.Concat(value[..3], "*****", value.AsSpan(value.Length - 3, 3));
else if (!string.IsNullOrWhiteSpace(value) && value.Length > 4)
return string.Concat(value[..2], "*****", value.AsSpan(value.Length - 2, 2));
else
return value;
}
public static Timestamp DateTimeToTimestamp(this DateTime dateTime)
{
return Timestamp.FromDateTime(DateTime.SpecifyKind(dateTime, DateTimeKind.Utc));
}
public static Timestamp? DateTimeToTimestamp(this DateTime? dateTime)
{
if (dateTime == null)
return null;
return Timestamp.FromDateTime(DateTime.SpecifyKind(dateTime.Value, DateTimeKind.Utc));
}
//public static string ToThousands(this string numberString)
//{
// if (double.TryParse(numberString, out var number))
// {
// return string.Format("{0:#,###0.################}", number);
// }
// return numberString;
//}
public static string ToThousands(this string numberString)
{
if (double.TryParse(numberString, out var number))
{
// حذف اعشار
var integerPart = Math.Truncate(number);
// فرمت‌بندی سه رقمی
return string.Format("{0:#,###0}", integerPart);
}
else
{
if (numberString.Split('.').Length > 1)
return numberString.Split('.')[0];
}
return numberString;
}
public static string ToThousands(this long number)
{
return number.ToString().ToThousands();
}
public static string ToThousands(this long? number)
{
return number?.ToString().ToThousands();
}
public static string ToThousands(this int number)
{
return number.ToString().ToThousands();
}
public static string ToThousands(this int? number)
{
return number?.ToString().ToThousands();
}
public static string ToThousands(this float number)
{
return number.ToString().ToThousands();
}
public static string ToThousands(this float? number)
{
return number?.ToString().ToThousands();
}
public static string ToThousands(this double number)
{
return number.ToString().ToThousands();
}
public static string ToThousands(this double? number)
{
return number?.ToString().ToThousands();
}
public static long ToIRT(this long number)
{
return (long)(number * 0.1);
}
public static string ToCurrencyUnitIRR(this string str) => str + " ریال";
public static string ToCurrencyUnitIRT(this string str) => str + " تومان";
public static string FaToAr(this string str) => str.Replace("ک", "ك").Replace("ی", "ي");
public static string ArToFa(this string str) => str.Replace("ك", "ک").Replace("ي", "ی");
public static string Truncate(this string value, int maxLength, bool isAppendDots = false)
{
if (string.IsNullOrEmpty(value)) return value;
return value.Length <= maxLength ? value : isAppendDots ? value.Substring(0, maxLength) + "..." : value.Substring(0, maxLength);
}
public static string PersianToEnglish(this string persianStr)
{
return persianStr.Replace("۰", "0")
.Replace("۱", "1")
.Replace("۲", "2")
.Replace("۳", "3")
.Replace("۴", "4")
.Replace("۵", "5")
.Replace("۶", "6")
.Replace("۷", "7")
.Replace("۸", "8")
.Replace("۹", "9");
}
public static string GetDisplayName(this System.Enum enumValue)
{
return enumValue.GetType()
.GetMember(enumValue.ToString())
.First()
.GetCustomAttribute<DisplayAttribute>()
.GetName();
}
public static async Task<string> ConvertIBrowserFileToBase64(this IBrowserFile? file)
{
if (file == null)
{
return string.Empty;
}
const long maxAllowedSize = 1024 * 1024 * 200;
var imageBuffers = new byte[file.Size];
using (var stream = file.OpenReadStream(maxAllowedSize))
{
await stream.ReadAsync(imageBuffers);
}
return $"data:{file.ContentType};base64," + Convert.ToBase64String(imageBuffers);
}
public static string GetNumberToPersianString(this string txt)
{
string RET = " ", STRVA = " ";
string[] MainStr = STR_To_Int(txt);
int Q = 0;
for (int i = MainStr.Length - 1; i >= 0; i--)
{
STRVA = " ";
if (RET != " " && RET != null)
STRVA = " و ";
if (string.IsNullOrWhiteSpace(Convert_STR(GETCountStr(MainStr[i]), Q)))
RET = Convert_STR(GETCountStr(MainStr[i]), Q) + RET;
else
RET = Convert_STR(GETCountStr(MainStr[i]), Q) + STRVA + RET;
Q++;
}
if (RET == " " || RET == null || RET == " ")
RET = "صفر";
return RET;
}
private static string[] STR_To_Int(string STR)
{
STR = GETCountStr(STR);
string[] RET = new string[STR.Length / 3];
int Q = 0;
for (int I = 0; I < STR.Length; I += 3)
{
RET[Q] = STR.Substring(I, 3);
Q++;
}
return RET;
}
private static string GETCountStr(string STR)
{
string RET = STR;
int LEN = (STR.Length / 3 + 1) * 3 - STR.Length;
if (LEN < 3)
{
for (int i = 0; i < LEN; i++)
{
RET = "0" + RET;
}
}
if (RET == "")
return "000";
return RET;
}
private static string Convert_STR(string INT, int Count)
{
string RET = "";
//یک صد
if (Count == 0)
{
if (INT.Substring(1, 1) == "1" && INT.Substring(2, 1) != "0")
{
RET = GET_Number(3, Convert.ToInt32(INT.Substring(0, 1)), " ") + GET_Number(1, Convert.ToInt32(INT.Substring(2, 1)), "");
}
else
{
string STR = GET_Number(0, Convert.ToInt32(INT.Substring(2, 1)), "");
RET = GET_Number(3, Convert.ToInt32(INT.Substring(0, 1)), GET_Number(2, Convert.ToInt32(INT.Substring(1, 1)), "") + STR) + GET_Number(2, Convert.ToInt32(INT.Substring(1, 1)), STR) + GET_Number(0, Convert.ToInt32(INT.Substring(2, 1)), "");
}
}
//هزار
else if (Count == 1)
{
RET = Convert_STR(INT, 0);
if (string.IsNullOrWhiteSpace(RET))
return string.Empty;
RET += " هزار";
}
//میلیون
else if (Count == 2)
{
RET = Convert_STR(INT, 0);
if (string.IsNullOrWhiteSpace(RET))
return string.Empty;
RET += " میلیون";
}
//میلیارد
else if (Count == 3)
{
RET = Convert_STR(INT, 0);
if (string.IsNullOrWhiteSpace(RET))
return string.Empty;
RET += " میلیارد";
}
//میلیارد
else if (Count == 4)
{
RET = Convert_STR(INT, 0);
if (string.IsNullOrWhiteSpace(RET))
return string.Empty;
RET += " تیلیارد";
}
//میلیارد
else if (Count == 5)
{
RET = Convert_STR(INT, 0);
if (string.IsNullOrWhiteSpace(RET))
return string.Empty;
RET += " بیلیارد";
}
else
{
RET = Convert_STR(INT, 0);
if (string.IsNullOrWhiteSpace(RET))
return string.Empty;
RET += Count.ToString();
}
return RET;
}
private static string GET_Number(int Count, int Number, string VA)
{
string RET = "";
if (VA != "" && VA != null)
{
VA = " و ";
}
if (Count == 0 || Count == 1)
{
bool IsDah = Convert.ToBoolean(Count);
string[] MySTR = new string[10];
MySTR[1] = IsDah ? "یازده" : "یک" + VA;
MySTR[2] = IsDah ? "دوازده" : "دو" + VA;
MySTR[3] = IsDah ? "سیزده" : "سه" + VA;
MySTR[4] = IsDah ? "چهارده" : "چهار" + VA;
MySTR[5] = IsDah ? "پانزده" : "پنج" + VA;
MySTR[6] = IsDah ? "شانزده" : "شش" + VA;
MySTR[7] = IsDah ? "هفده" : "هفت" + VA;
MySTR[8] = IsDah ? "هجده" : "هشت" + VA;
MySTR[9] = IsDah ? "نوزده" : "نه" + VA;
return MySTR[Number];
}
else if (Count == 2)
{
string[] MySTR = new string[10];
MySTR[1] = "ده";
MySTR[2] = "بیست" + VA;
MySTR[3] = "سی" + VA;
MySTR[4] = "چهل" + VA;
MySTR[5] = "پنجاه" + VA;
MySTR[6] = "شصت" + VA;
MySTR[7] = "هفتاد" + VA;
MySTR[8] = "هشتاد" + VA;
MySTR[9] = "نود" + VA;
return MySTR[Number];
}
else if (Count == 3)
{
string[] MySTR = new string[10];
MySTR[1] = "یکصد" + VA;
MySTR[2] = "دویست" + VA;
MySTR[3] = "سیصد" + VA;
MySTR[4] = "چهارصد" + VA;
MySTR[5] = "پانصد" + VA;
MySTR[6] = "ششصد" + VA;
MySTR[7] = "هفتصد" + VA;
MySTR[8] = "هشتصد" + VA;
MySTR[9] = "نهصد" + VA;
return MySTR[Number];
}
return RET;
}
}

View File

@@ -0,0 +1,9 @@
namespace FrontOffice.Main.Utilities;
public static class GlobalConstants
{
public const string DateFormat = "MMM dd, yyyy";
public const string DateTimeFormat = "MMM dd, yyyy - HH:mm";
public const string SuccessMsg = "با موفقیت انجام شد";
}

View File

@@ -0,0 +1,9 @@
namespace FrontOffice.Main.Utilities;
public static class RouteConstants
{
public static class Main
{
public const string MainPage = "/";
}
}

View File

@@ -0,0 +1,6 @@
namespace FrontOffice.Main.Utilities;
public static class UrlUtility
{
public static string DownloadUrl { get; set; }
}

View File

@@ -0,0 +1,18 @@
@using System.Net.Http
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using FrontOffice.Main
@using FrontOffice.Main.Shared
@using MudBlazor
@using FrontOffice.Main.Utilities
@inject NavigationManager Navigation
@inject IDialogService DialogService
@inject IJSRuntime JSRuntime
@inject ISnackbar Snackbar

View File

@@ -0,0 +1,9 @@
{
"DetailedErrors": true,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,12 @@
{
//"GwUrl": "https://afrinogw.afrino.co",
"GwUrl": "https://localhost:34781",
"DownloadUrl": "https://dl.afrino.co",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,42 @@
/*#region Fonts*/
@font-face {
font-family: 'Vazir';
font-style: normal;
font-weight: 300;
font-display: swap;
src: url(../fonts/Vazir-Light.ttf) format('woff2');
}
@font-face {
font-family: 'Vazir';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(../fonts/Vazir-Regular.ttf) format('woff2');
}
@font-face {
font-family: 'Vazir';
font-style: normal;
font-weight: 500;
font-display: swap;
src: url(../fonts/Vazir-Medium.ttf) format('woff2');
}
@font-face {
font-family: 'Vazir';
font-style: normal;
font-weight: 700;
font-display: swap;
src: url(../fonts/Vazir-Bold.ttf) format('woff2');
}
@font-face {
font-family: 'Vazir';
font-style: normal;
font-weight: 900;
font-display: swap;
src: url(../fonts/Vazir-Bold.ttf) format('woff2');
}
/*#endregion*/

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

22
src/FrontOffice.sln Normal file
View File

@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FrontOffice.Main", "FrontOffice.Main\FrontOffice.Main.csproj", "{D9407E46-027D-4D44-B9FB-1F8DECB14270}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D9407E46-027D-4D44-B9FB-1F8DECB14270}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9407E46-027D-4D44-B9FB-1F8DECB14270}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9407E46-027D-4D44-B9FB-1F8DECB14270}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9407E46-027D-4D44-B9FB-1F8DECB14270}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal