uid service added - task & ticket file upload max limit changed

This commit is contained in:
SamSys
2025-02-17 17:53:18 +03:30
parent 7cbc770f98
commit c17146e1b3
17 changed files with 211 additions and 12 deletions

View File

@@ -0,0 +1,7 @@
namespace _0_Framework.Application;
public enum Gender
{
Male,
Female
}

View File

@@ -0,0 +1,121 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace _0_Framework.Application.UID;
#region PersonalInfoResponseDTO
/// <summary>
/// ویو مدل اطلاعات شخصی کاربر که از سرویس یو آیدی دریافت می شود
/// </summary>
/// <param name="command"></param>
/// <param name="IdentificationInformation"></param>
/// <param name="RegistrationStatus"></param>
/// <param name="ResponseContext"></param>
public record PersonalInfoResponse(
UidBasicInformation BasicInformation,
IdentificationInformation IdentificationInformation,
RegistrationStatus RegistrationStatus,
ResponseContext ResponseContext);
public class UidBasicInformation
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FatherName { get; set; }
[JsonProperty("gender")]
public string Gender { get; set; }
public Gender GenderEnum => Gender switch
{
"GENDER_MALE" => Application.Gender.Male,
"GENDER_FEMALE" => Application.Gender.Female,
_ => throw new ArgumentOutOfRangeException()
};
}
public record IdentificationInformation(string NationalId, string BirthDate, string ShenasnameSeri, string ShenasnameSerial, string ShenasnamehNumber);
public class RegistrationStatus
{
[JsonProperty("deathStatus")]
public string DeathStatus { get; set; }
public DeathStatus DeathStatusEnum => DeathStatus switch
{
"DEATH_STATUS_ALIVE" => UID.DeathStatus.Alive,
"DEATH_STATUS_DEATH" => UID.DeathStatus.Dead,
_ => throw new ArgumentOutOfRangeException()
};
};
public record ResponseContext(UidStatus Status);
public record UidStatus(int Code, string Message);
public enum DeathStatus
{
Alive,
Dead,
}
#endregion
#region PersonalInfoRequestDTO
/// <summary>
/// درخواست اطلاعات شخصی کاربر از سرویس یو آیدی
/// </summary>
public class PersonalInfoRequest
{
[JsonProperty("requestContext")]
public UidRequestContext RequestContext { get; set; }
[JsonProperty("nationalId")]
public string NationalId { get; set; }
[JsonProperty("birthDate")]
public string BirthDate { get; set; }
[JsonProperty("mobileNumber")]
public string MobileNumber { get; set; }
}
public class UidRequestContext
{
[JsonProperty("apiInfo")]
public ApiInfo ApiInfo => new ApiInfo();
};
public record ApiInfo
{
[JsonProperty("businessToken")]
public string BusinessToken => "5e03dd4e-999d-466f-92d8-7c0b1f66a8e9";
[JsonProperty("businessId")]
public string BusinessId => "98ed67ca-d441-4978-a748-e8bebce010eb";
}
#endregion
public interface IUidService
{
Task<PersonalInfoResponse> GetPersonalInfo(string nationalCode , string birthDate);
Task<MatchMobileWithNationalCodeResponse> IsMachPhoneWithNationalCode(string nationalCode , string phoneNumber);
}
public class MatchMobileWithNationalCodeResponse
{
[JsonProperty("isMatched")] public bool IsMatched { get; set; }
public ResponseContext ResponseContext { get; set; }
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace _0_Framework.Application.UID;
public class UidService : IUidService
{
private readonly HttpClient _httpClient;
private const string BaseUrl= "https://json-api.uid.ir/api/inquiry/";
public UidService()
{
_httpClient = new HttpClient()
{
BaseAddress = new Uri(BaseUrl)
};
}
public async Task<PersonalInfoResponse> GetPersonalInfo(string nationalCode, string birthDate)
{
var request = new PersonalInfoRequest
{
BirthDate = birthDate ,
NationalId = nationalCode,
RequestContext = new UidRequestContext()
};
var json = JsonConvert.SerializeObject(request);
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
var requestResult = await _httpClient.PostAsync("person/v2", contentType);
if(!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
return responseResult;
}
public async Task<MatchMobileWithNationalCodeResponse> IsMachPhoneWithNationalCode(string nationalCode, string phoneNumber)
{
var request = new PersonalInfoRequest
{
MobileNumber = phoneNumber,
NationalId = nationalCode,
RequestContext = new UidRequestContext()
};
var json = JsonConvert.SerializeObject(request);
var contentType = new StringContent(json, Encoding.UTF8, "application/json");
var requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType);
if (!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
return responseResult;
}
}

View File

@@ -928,8 +928,8 @@ public class TaskApplication : ITaskApplication
public OperationResult UploadMedia(IFormFile mediaFile, long senderId)
{
var operation = new OperationResult();
if ((mediaFile.Length > 5000000))
return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد");
if ((mediaFile.Length > 50000000))
return operation.Failed("حجم فایل نمیتواند از 50 مگابایت بیشتر باشد");
var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
"temp", $"{senderId}");
Directory.CreateDirectory(path);

View File

@@ -446,8 +446,8 @@ public class TicketApplication : ITicketApplication
public OperationResult UploadMedia(IFormFile mediaFile, long senderId)
{
var operation = new OperationResult();
if ((mediaFile.Length > 5000000) || (mediaFile.Length > 5000000) || (mediaFile.Length > 5000000))
return operation.Failed("حجم فایل نمیتواند از 5 مگابایت بیشتر باشد");
if ((mediaFile.Length > 50000000) || (mediaFile.Length > 50000000) || (mediaFile.Length > 50000000))
return operation.Failed("حجم فایل نمیتواند از 50 مگابایت بیشتر باشد");
var path = Path.Combine($"{_taskRepository.GetWebEnvironmentPath()}", "Storage",
"temp", $"{senderId}");
Directory.CreateDirectory(path);

View File

@@ -436,7 +436,7 @@ public class LeaveRepository : RepositoryBase<long, Leave>, ILeaveRepository
var leftCheck = _context.LeftWorkList
.Where(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId)
.Where(x => x.StartWorkDate <= startLeav && x.LeftWorkDate > startLeav && x.StartWorkDate < endLeav &&
.Where(x => x.StartWorkDate <= startLeav && x.LeftWorkDate > startLeav && x.StartWorkDate <= endLeav &&
x.LeftWorkDate > endLeav).ToList();

View File

@@ -434,6 +434,7 @@
$('#hiddenBaseYearToEditModal').val(row.find('td:eq(10)').attr("data-BaseYears"));
$('#hiddendaailyWagePlusBaseYear').val(row.find('td:eq(11)').attr("data-DailyWagePlusBaseYears"));
$('#hiddenMonthlySalaryPlusBaseYear').val(row.find('td:eq(8)').attr("data-MonthlySalaryPlusBaseyear"));
$('#hiddenMarriedAllowance').val(row.find('td:eq(9)').attr("data-MarriedAllowance"));
}

View File

@@ -393,6 +393,7 @@
$('#hiddenBaseYearToEditModal').val(row.find('td:eq(10)').attr("data-BaseYears"));
$('#hiddendaailyWagePlusBaseYear').val(row.find('td:eq(11)').attr("data-DailyWagePlusBaseYears"));
$('#hiddenMonthlySalaryPlusBaseYear').val(row.find('td:eq(8)').attr("data-MonthlySalaryPlusBaseyear"));
$('#hiddenMarriedAllowance').val(row.find('td:eq(9)').attr("data-MarriedAllowance"));
}

Binary file not shown.

Binary file not shown.

View File

@@ -7,6 +7,7 @@ using AccountManagement.Domain.AccountAgg;
using Microsoft.AspNetCore.Http;
using Newtonsoft.Json;
using System.Security.Claims;
using _0_Framework.Application.UID;
using AccountManagement.Application.Contracts.CameraAccount;
using CompanyManagment.EFCore;
using Company.Domain.EmployeeAgg;
@@ -43,11 +44,12 @@ namespace ServiceHost.Pages
private readonly ICameraAccountApplication _cameraAccountApplication;
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IAndroidApkVersionApplication _androidApkVersionApplication;
private readonly IUidService _uidService;
public IndexModel(ILogger<IndexModel> logger, IAccountApplication accountApplication, IGoogleRecaptcha googleRecaptcha, ISmsService smsService, IWorker worker,
IAuthHelper authHelper, ICameraAccountApplication cameraAccountApplication, IWebHostEnvironment webHostEnvironment,
IAndroidApkVersionApplication androidApkVersionApplication)
IAndroidApkVersionApplication androidApkVersionApplication, IUidService uidService)
{
_logger = logger;
_accountApplication = accountApplication;
@@ -58,12 +60,16 @@ namespace ServiceHost.Pages
_cameraAccountApplication = cameraAccountApplication;
_webHostEnvironment = webHostEnvironment;
_androidApkVersionApplication = androidApkVersionApplication;
_uidService = uidService;
}
public IActionResult OnGet()
{
//_uidService.GetPersonalInfo("2669318622","1363/02/25").GetAwaiter().GetResult();
//_uidService.IsMachPhoneWithNationalCode("2669318622","09114221321").GetAwaiter().GetResult();
HasApkToDownload = _androidApkVersionApplication.HasAndroidApkToDownload();
if (User.Identity is { IsAuthenticated: true })
{

View File

@@ -16,6 +16,7 @@ using Query.Bootstrapper;
using ServiceHost.Hubs;
using ServiceHost.MiddleWare;
using WorkFlow.Infrastructure.Config;
using _0_Framework.Application.UID;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorPages()
@@ -38,6 +39,7 @@ builder.Services.AddTransient<IFileUploader, FileUploader>();
builder.Services.AddTransient<IAuthHelper, AuthHelper>();
builder.Services.AddTransient<IGoogleRecaptcha, GoogleRecaptcha>();
builder.Services.AddTransient<ISmsService, SmsService>();
builder.Services.AddTransient<IUidService, UidService>();
//services.AddSingleton<IWorkingTest, WorkingTest>();
//services.AddHostedService<JobWorker>();

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 357 KiB

View File

@@ -546,8 +546,8 @@ function attachFileChangeHandler(fileInput, index) {
$(fileInput).off('change').on('change', function () {
let file = fileInput.files[0];
if (file.size > 5000000) {
showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 5 مگابایت را انتخاب کنید.', 3500);
if (file.size > 50000000) {
showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 50 مگابایت را انتخاب کنید.', 3500);
$(`#EditTask_Document${index}`).val('');
return;
}

View File

@@ -626,8 +626,8 @@ function attachFileChangeHandler(fileInput, id, boxClass) {
e.preventDefault();
var fileInputFile = fileInput.files[0];
if (fileInputFile.size > 5000000) {
showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 5 مگابایت را انتخاب کنید.', 3500);
if (fileInputFile.size > 50000000) {
showAlertMessage('.alert-msg', 'لطفا فایل حجم کمتر از 50 مگابایت را انتخاب کنید.', 3500);
$(`#Command_Document${id}`).val('');
return;
}