uid bug fixed

This commit is contained in:
SamSys
2025-06-22 11:36:02 +03:30
parent 3a84c65ce1
commit 84ff2bc8f1
7 changed files with 1373 additions and 81 deletions

View File

@@ -10,67 +10,70 @@ namespace _0_Framework.Application.UID;
public class UidService : IUidService
{
private readonly HttpClient _httpClient;
private const string BaseUrl= "https://json-api.uid.ir/api/inquiry/";
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 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");
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);
try
{
if (!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
if (responseResult.BasicInformation != null)
{
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian();
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian();
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian();
}
try
{
var requestResult = await _httpClient.PostAsync("person/v2", contentType);
if (!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync<PersonalInfoResponse>();
if (responseResult.BasicInformation != null)
{
responseResult.BasicInformation.FirstName = responseResult.BasicInformation.FirstName?.ToPersian();
responseResult.BasicInformation.LastName = responseResult.BasicInformation.LastName?.ToPersian();
responseResult.BasicInformation.FatherName = responseResult.BasicInformation.FatherName?.ToPersian();
}
return responseResult;
}
catch
{
return responseResult;
}
catch
{
return null;
}
}
return new PersonalInfoResponse(new UidBasicInformation(),
new IdentificationInformation(default, default, default, default, default), new RegistrationStatus(),
new ResponseContext(new UidStatus(14, "")));
}
}
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");
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 requestResult = await _httpClient.PostAsync("mobile/owner/v2", contentType);
if (!requestResult.IsSuccessStatusCode)
return null;
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
return responseResult;
}
var responseResult = await requestResult.Content.ReadFromJsonAsync<MatchMobileWithNationalCodeResponse>();
return responseResult;
}
}

View File

@@ -26,4 +26,5 @@ public class EmployeeDataFromApiViewModel
/// </summary>
public string IdNumberSeri { get; set; }
public bool AuthorizedCanceled { get; set; }
}

View File

@@ -197,6 +197,7 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return opration.Failed("کد ملی وارد شده تکراری است");
}
}
@@ -1539,7 +1540,11 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
if (employee.IsAuthorized == false)
{
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (apiResult.ResponseContext.Status.Code == 14)
{
return op.Failed("این پرسنل در بانک اطلاعات موجود میباشد");
}
if (apiResult.ResponseContext.Status.Code != 0)
{
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");
@@ -1595,7 +1600,16 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
return op.Succcedded(data);
}
var apiResult = await _uidService.GetPersonalInfo(nationalCode, birthDate);
if (apiResult.ResponseContext.Status.Code == 14)
{
return op.Failed("سامانه احراز هویت در دسترس نمیباشد لطفا اطلاعات پرسنل را به صورت دستی وارد کنید", new EmployeeDataFromApiViewModel() { AuthorizedCanceled = true });
}
if (apiResult.ResponseContext.Status.Code == 3)
{
return op.Failed("کد ملی نامعتبر است");
}
if (apiResult.ResponseContext.Status.Code != 0)
{
return op.Failed("کد ملی و تاریخ تولد با هم همخانی ندارند");

View File

@@ -548,37 +548,105 @@
var codeMelli = $('#iniCodeMelli').val();
try {
const response = await $.ajax({
const response = $.ajax({
url: loadUidInfo,
method: 'POST',
data: { nationalCode: codeMelli, birthDate: birthday },
headers: { "RequestVerificationToken": antiForgeryToken }
headers: { "RequestVerificationToken": antiForgeryToken },
success: function(response) {
debugger;
if (response.success) {
$('#IsAuthorized').val(true);
$('#name').val(response.data.fName);
$('#family').val(response.data.lName);
$('#FatherName').val(response.data.fatherName);
$('#DateOfBirth').val(response.data.birthDate);
$('#code-melli').val(response.data.nationalCode);
$('#IdNumber').val(response.data.idNumber);
$('#IdNumberSerial').val(response.data.idNumberSerial);
$('#IdNumberSeri').val(response.data.idNumberSeri);
if (response.data.gender === 0) {
$('#GenderMale').prop('checked', true);
$('#soldier').prop('disabled', false);
} else if (response.data.gender === 1) {
$('#GenderFemale').prop('checked', true);
$('#soldier').prop('disabled', true);
}
currentStep++;
showStep(currentStep);
}
else if (response.data?.authorizedCanceled) {
$('#name').removeClass("disable");
$('#family').removeClass("disable");
$('#FatherName').removeClass("disable");
$('#DateOfBirth').removeClass("disable");
$('#code-melli').removeClass("disable");
$('#IdNumber').removeClass("disable");
$('#IdNumberSerial').removeClass("disable");
$('#IdNumberSeri').removeClass("disable");
$('#GenderMale').removeClass("disable");
$('#GenderFemale').removeClass("disable");
$('#divGender .radio-box').removeClass('disable');
currentStep++;
showStep(currentStep);
$.Notification.autoHideNotify('error', 'top right', 'خطا', response.message);
return;
}
else {
$.Notification.autoHideNotify('error', 'top right', 'خطا', response.message);
return;
}
},
error:function(error) {
$.Notification.autoHideNotify('error', 'top right', 'خطا', response.message);
return;
}
});
// debugger;
// if (response.success) {
// $('#IsAuthorized').val(true);
// $('#name').val(response.data.fName);
// $('#family').val(response.data.lName);
// $('#FatherName').val(response.data.fatherName);
// $('#DateOfBirth').val(response.data.birthDate);
// $('#code-melli').val(response.data.nationalCode);
// $('#IdNumber').val(response.data.idNumber);
// $('#IdNumberSerial').val(response.data.idNumberSerial);
// $('#IdNumberSeri').val(response.data.idNumberSeri);
// if (response.data.gender === 0) {
// $('#GenderMale').prop('checked', true);
// $('#soldier').prop('disabled', false);
// } else if (response.data.gender === 1) {
// $('#GenderFemale').prop('checked', true);
// $('#soldier').prop('disabled', true);
// }
// }
// else if (response.data.authorizedCanceled) {
if (response.success) {
$('#IsAuthorized').val(true);
$('#name').val(response.data.fName);
$('#family').val(response.data.lName);
$('#FatherName').val(response.data.fatherName);
$('#DateOfBirth').val(response.data.birthDate);
$('#code-melli').val(response.data.nationalCode);
$('#IdNumber').val(response.data.idNumber);
$('#IdNumberSerial').val(response.data.idNumberSerial);
$('#IdNumberSeri').val(response.data.idNumberSeri);
if (response.data.gender === 0) {
$('#GenderMale').prop('checked', true);
$('#soldier').prop('disabled', false);
} else if (response.data.gender === 1) {
$('#GenderFemale').prop('checked', true);
$('#soldier').prop('disabled', true);
}
} else {
$.Notification.autoHideNotify('error', 'top right', 'خطا', response.message);
return;
}
// $('#name').removeClass("disable");
// $('#family').removeClass("disable");
// $('#FatherName').removeClass("disable");
// $('#DateOfBirth').removeClass("disable");
// $('#code-melli').removeClass("disable");
// $('#IdNumber').removeClass("disable");
// $('#IdNumberSerial').removeClass("disable");
// $('#IdNumberSeri').removeClass("disable");
// $('#GenderMale').removeClass("disable");
// $('#GenderFemale').removeClass("disable");
// $('#divGender .radio-box').removeClass('disable');
// currentStep++;
// showStep(currentStep);
// $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message);
// return;
// }
// else {
// $.Notification.autoHideNotify('error', 'top right', 'خطا', response.message);
// return;
// }
currentStep++;
showStep(currentStep);
// currentStep++;
// showStep(currentStep);
} catch (error) {
$.Notification.autoHideNotify('error', 'top right', 'خطا', "ارسال اطلاعات با مشکل مواجه شد.");
return;

File diff suppressed because it is too large Load Diff

View File

@@ -320,7 +320,7 @@
<div id="my_camera"></div>
<div class="col-md-12 m-r-10 top-btns">
<p class="pull-right">
<a permission="10410" id="btnPopModal" href="#showmodal=@Url.Page("/Company/Employees/Index", "Create")" class="btn btn-success btn-rounded waves-effect waves-light m-b-5" style="background-color: #f5f5f5; border-color: #0f9500; font-family: 'Web_Yekan' !important; color: #0f9500 !important;"> <i class="fa fa-user-plus" style="padding-left: 3px; font-size: 14px; color: #0f9500 !important"></i> ایجاد پرسنل جدید </a>
<a permission="10410" id="btnPopModal" href="#showmodal=@Url.Page("/Company/Employees/Index", "CreateEmployee")" class="btn btn-success btn-rounded waves-effect waves-light m-b-5" style="background-color: #f5f5f5; border-color: #0f9500; font-family: 'Web_Yekan' !important; color: #0f9500 !important;"> <i class="fa fa-user-plus" style="padding-left: 3px; font-size: 14px; color: #0f9500 !important"></i> ایجاد پرسنل جدید </a>
</p>
<p class="pull-right">
<a permission="10444" id="btnPopModal" href="#showmodal=@Url.Page("/Company/Employees/Index", "ChangeCode")" class="btn btn-warning btn-rounded waves-effect waves-light m-b-5" style="background-color: #f5f5f5; border-color: #c78c04; font-family: 'Web_Yekan' !important; color: #c78c04 !important; margin-right: 10px"> <i class="fa fa-user-plus" style="padding-left: 7px; font-size: 14px; color: #ffb301 !important"></i>ویرایش گروهی کد پرسنلی </a>

View File

@@ -161,11 +161,16 @@ public class IndexModel : PageModel
#endregion
#region Create Employee File پرونده
public IActionResult OnGetCreate()
{
return Partial("./Create");
}
/// <summary>
/// ایجاد پرسنل پرونده
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public IActionResult OnPostCreate(CreateEmployee command)
{
var children = command.CreateEmployeChildrenList.Count(x => x.DateOfBirth != null);
@@ -188,8 +193,56 @@ public class IndexModel : PageModel
}
return new JsonResult(result);
}
#endregion
#region Create admin Employee
public IActionResult OnGetCreateEmployee()
{
return Partial("./CreateEmployee");
}
/// <summary>
/// ایجاد پرسنل در ادمین
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
public IActionResult OnPostCreateEmployee(CreateEmployee command)
{
var children = command.CreateEmployeChildrenList.Count(x => x.DateOfBirth != null);
command.NumberOfChildren = children.ToString();
var result = new OperationResult();
if (string.IsNullOrWhiteSpace(command.NationalCode))
return new JsonResult(result.Failed("لطفا کد ملی را وارد نمایید"));
if (string.IsNullOrWhiteSpace(command.MaritalStatus))
return new JsonResult(result.Failed("لطفا وضعیت تاهل را مشخص نمایید"));
result = _employeeApplication.Create(command);
Thread.Sleep(1000);
if (result.IsSuccedded)
for (var i = 0; i <= children - 1; i++)
if (command.CreateEmployeChildrenList[i].DateOfBirth != null)
{
var child = new CreateEmployeChildren
{
ParentNationalCode = command.NationalCode,
DateOfBirth = command.CreateEmployeChildrenList[i].DateOfBirth,
FName = command.CreateEmployeChildrenList[i].FName,
EmployeeId = result.SendId
};
_employeeChildrenApplication.Create(child);
}
return new JsonResult(result);
}
#endregion
public IActionResult OnGetEdit(long id)
{