upate reqyest

This commit is contained in:
dibakor 2026-08-06 16:57:29 +06:00
parent 17bd6a7727
commit 83f92ea6c8
12 changed files with 323 additions and 326 deletions

View File

@ -719,6 +719,13 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models
ZDS2 = 3
}
public enum UserTypeEnum : short
{
SuperAdmin = 1,
Admin = 2,
SalesAppOfficer = 3
}
public enum MaterialPriceTypeEnum : short
{
BasePrice = 1,

View File

@ -64,9 +64,8 @@ public class IntegrationCustomerRequest
[EmailAddress(ErrorMessage = "Email address is not valid.")]
public string? EmailAddress { get; set; }
[Required(ErrorMessage = "Business/Tax number is required.")]
[StringLength(16, ErrorMessage = "Business/Tax number cannot exceed 16 characters.")]
public string BusinessTaxNumber { get; set; }
public string? BusinessTaxNumber { get; set; }
[Required(ErrorMessage = "Credit limit is required.")]
[Range(0, 9999999999999.99, ErrorMessage = "Credit limit must be between 0 and 9,999,999,999,999.99.")]

View File

@ -534,16 +534,16 @@ public class IntegrationService : IIntegrationService
DivisionDescription = dr.GetString(12),
MobileNumber = dr.GetString(13),
EmailAddress = dr.GetString(14),
BusinessTaxNumber = dr.GetString(15),
BusinessTaxNumber =dr.IsDBNull(15)? null: dr.GetString(15),
CreditLimit = dr.GetDecimal(16),
SalesGroup = dr.GetString(17),
SalesGroupDescription = dr.GetString(18),
CustomerGroup = dr.GetString(19),
CustomerGroupDescription = dr.GetString(20),
CustomerPriceGroup = dr.GetString(21),
CustomerPriceGroupDescription = dr.GetString(22),
StatusCode = dr.GetString(23),
StatusDescription = dr.GetString(24),
SalesGroup = dr.IsDBNull(17) ? null: dr.GetString(17),
SalesGroupDescription = dr.IsDBNull(18) ? null : dr.GetString(18),
CustomerGroup = dr.IsDBNull(19) ? null : dr.GetString(19),
CustomerGroupDescription = dr.IsDBNull(20) ? null : dr.GetString(20),
CustomerPriceGroup = dr.IsDBNull(21) ? null : dr.GetString(21),
CustomerPriceGroupDescription = dr.IsDBNull(22) ? null : dr.GetString(22),
StatusCode = dr.IsDBNull(23) ? null : dr.GetString(23),
StatusDescription = dr.IsDBNull(24) ? null : dr.GetString(24),
PaymentTerms = dr.GetString(25),
PaymentTermsDescription = dr.GetString(26),
SearchTerm = dr.GetString(27),

View File

@ -1,4 +1,5 @@
using Ease.NetCore.DataAccess;
using DocumentFormat.OpenXml.Office2016.Excel;
using Ease.NetCore.DataAccess;
using Ease.NetCore.DataAccess.SQL;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
@ -10,6 +11,7 @@ using OnlineSalesAutoCrop.CoreAPI.Models.Responses.MobileApp;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.MobileApp;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems;
using Org.BouncyCastle.Asn1.Ocsp;
using System;
using System.Collections.Generic;
using System.Data;
@ -374,10 +376,14 @@ public class MobileMasterDataService : IMobileMasterDataService
decimal totalApprovedAmount = 0;
try
{
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomerApprovedAmount"))
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@CustomerCode", pType: SqlDbType.NVarChar, pValue: customerCode),
SqlHelperExtension.CreateInParam(pName: "@SalesOrgCode", pType: SqlDbType.NVarChar, pValue: salesOrgCode),
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomerApprovedAmount",p))
{
while (dr.Read())
if (dr.Read())
{
totalApprovedAmount = dr.GetDecimal(0);
}

View File

@ -39,88 +39,64 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Systems
public async Task<User> LoginAsync(LoginRequest request, string ipAddress, bool checkPwd)
{
User user = new() { LoginId = request.LoginId, LoginStatus = EnumLoginStatus.Unsuccessful };
//try
try
{
string password = EncryptPassword(password: request.Password);
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
try
{
bool batchEnabled = false;
DateTime sysDate = DateTime.Today.Date;
string appVer = string.Empty, alParams = string.Empty;
int maxTryCount = 5, lockTime = 1, marMonths = 24, idleTime = 0, timeoutTime = 0, pingTime = 0, bmProcessId = 0, prProcessId = 0;
#region Read Params from ThisSystem
using (IDataReader dr = tc.ExecuteReader("SELECT MaxTryCount, LockTime, MarMonths, CAST(GETDATE() as date), AppVersion, AutoLogoutParams, BatchEnabled, BmProcessId, PrProcessId FROM ThisSystem"))
{
if (dr.Read())
{
maxTryCount = dr.GetInt16(0);
lockTime = dr.GetInt16(1);
marMonths = dr.GetInt16(2);
sysDate = dr.GetDateTime(3);
appVer = dr.GetString(4);
alParams = dr.IsDBNull(5) ? string.Empty : dr.GetString(5);
batchEnabled = !dr.IsDBNull(6) && dr.GetInt16(6) != 0;
bmProcessId = dr.IsDBNull(7) ? 0 : dr.GetInt16(7);
prProcessId = dr.IsDBNull(8) ? 0 : dr.GetInt16(8);
}
dr.Close();
}
if (!string.IsNullOrEmpty(alParams))
{
string[] times = alParams.Split(separator: ',', options: StringSplitOptions.RemoveEmptyEntries);
if (times.Length == 3)
{
if (!int.TryParse(times[0], out idleTime))
idleTime = 0;
if (!int.TryParse(times[1], out timeoutTime))
timeoutTime = 0;
if (!int.TryParse(times[2], out pingTime))
pingTime = 0;
}
}
if (!request.LoginId.ToLower().Equals(User.SuperUser_LoginId) && !request.AppVersion.Equals(appVer))
{
user.UnsuccessfulMsg = appVer;
user.LoginStatus = EnumLoginStatus.VersionMismatch;
}
#endregion
//if (user.LoginStatus != EnumLoginStatus.VersionMismatch)
//{
// string password = EncryptPassword(password: request.Password);
// using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
// try
// {
// #region Attendance Login and Valid Ip Address
// if (request.AttendanceLogin && !request.LoginId.ToLower().Equals(User.SuperUser_LoginId))
// {
// string errMsg = string.Empty;
// SqlParameter[] p =
// [
// SqlHelperExtension.CreateInParam(pName: "@IpAddress", pType: SqlDbType.VarChar, pValue: request.IpAddress, size: 20),
// SqlHelperExtension.CreateInParam(pName: "@MacAddress", pType: SqlDbType.VarChar, pValue: request.MacAddress, size: 30),
// SqlHelperExtension.CreateInParam(pName: "@HostName", pType: SqlDbType.VarChar, pValue: request.HostName, size: 100),
// SqlHelperExtension.CreateInParam(pName: "@LoginId", pType: SqlDbType.VarChar, pValue: request.LoginId, size: 50),
// SqlHelperExtension.CreateOutParam(pName: "@ErrMsg", pType: SqlDbType.VarChar, pValue: errMsg, size: 300)
// ];
// _ = tc.ExecuteNonQuerySp(spName: "dbo.IsValidIpOrMacAddress", parameterValues: p);
// errMsg = (p[4] == null || p[4].Value == null || p[4].Value == DBNull.Value) ? string.Empty : Convert.ToString(p[4].Value);
// if (!string.IsNullOrEmpty(errMsg))
// {
// tc.End();
// throw new InvalidOperationException(errMsg);
// }
// }
// #endregion
// bool batchEnabled = false;
// DateTime sysDate = DateTime.Today.Date;
// string appVer = string.Empty, alParams = string.Empty;
// int maxTryCount = 5, lockTime = 1, marMonths = 24, idleTime = 0, timeoutTime = 0, pingTime = 0, bmProcessId = 0, prProcessId = 0;
// #region Read Params from ThisSystem
// using (IDataReader dr = tc.ExecuteReader("SELECT MaxTryCount, LockTime, MarMonths, CAST(GETDATE() as date), AppVersion, AutoLogoutParams, BatchEnabled, BmProcessId, PrProcessId FROM ThisSystem"))
// {
// if (dr.Read())
// {
// maxTryCount = dr.GetInt16(0);
// lockTime = dr.GetInt16(1);
// marMonths = dr.GetInt16(2);
// sysDate = dr.GetDateTime(3);
// appVer = dr.GetString(4);
// alParams = dr.IsDBNull(5) ? string.Empty : dr.GetString(5);
// batchEnabled = !dr.IsDBNull(6) && dr.GetInt16(6) != 0;
// bmProcessId = dr.IsDBNull(7) ? 0 : dr.GetInt16(7);
// prProcessId = dr.IsDBNull(8) ? 0 : dr.GetInt16(8);
// }
// dr.Close();
// }
// if (!string.IsNullOrEmpty(alParams))
// {
// string[] times = alParams.Split(separator: ',', options: StringSplitOptions.RemoveEmptyEntries);
// if (times.Length == 3)
// {
// if (!int.TryParse(times[0], out idleTime))
// idleTime = 0;
// if (!int.TryParse(times[1], out timeoutTime))
// timeoutTime = 0;
// if (!int.TryParse(times[2], out pingTime))
// pingTime = 0;
// }
// }
// if (!request.LoginId.ToLower().Equals(User.SuperUser_LoginId) && !request.AppVersion.Equals(appVer))
// {
// user.UnsuccessfulMsg = appVer;
// user.LoginStatus = EnumLoginStatus.VersionMismatch;
// }
// #endregion
// if (user.LoginStatus != EnumLoginStatus.VersionMismatch)
// {
// #region Read User data using authentication data
// string commandText;
@ -332,22 +308,22 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Systems
// }
// #endregion
// }
// tc.End();
// }
// catch (Exception ie)
// {
// tc?.HandleError();
// throw DBCustomError.GenerateCustomError(ie);
// }
//}
//catch (Exception e)
//{
// throw new InvalidOperationException(e.Message, e);
//}
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return user;
}

View File

@ -0,0 +1,23 @@
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace OnlineSalesAutoCrop.CoreAPI.Converter;
public class EmptyStringToNullConverter : JsonConverter<string>
{
public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
return null;
var value = reader.GetString();
return string.IsNullOrWhiteSpace(value) ? null : value;
}
public override void Write(Utf8JsonWriter writer, string? value, JsonSerializerOptions options)
{
writer.WriteStringValue(value);
}
}

View File

@ -88,12 +88,19 @@ namespace OnlineSalesAutoCrop.CoreAPI
services.AddControllers(options =>
{
options.Filters.Add(new ProducesAttribute("application/json"));
}).AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(
new CoreAPI.Converter.EmptyStringToNullConverter());
});
services.Configure<ApiBehaviorOptions>(options =>
{
options.InvalidModelStateResponseFactory = context =>
{
var logger = context.HttpContext.RequestServices
.GetRequiredService<ILogger<Startup>>();
var errors = context.ModelState
.Where(kvp => kvp.Value?.Errors.Count > 0)
.SelectMany(kvp => kvp.Value!.Errors.Select(e => e.ErrorMessage))
@ -106,6 +113,8 @@ namespace OnlineSalesAutoCrop.CoreAPI
Data = null
};
logger.LogError("Validation Failed. Request: {@Errors}", errors);
return new BadRequestObjectResult(response);
};
});

View File

@ -31,6 +31,7 @@ export class AppMenuComponent implements OnInit, AfterViewInit
ngOnInit()
{
debugger;
this.service.authService.sessionEvent.subscribe(value => this.onAuthenication(value));
if (this.service.authService.currentUserValue)
{

View File

@ -1,7 +1,7 @@
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()" style="background-image:linear-gradient(360deg, #17c3f0,#1D81b1);">
<div class="mb-2 login-body">
<div class="login-content">
<h1 style="color:green;">Ease Taskforce</h1>
<h1 style="color:green;">Auto Crop</h1>
<p style="color: black;">Please use the form to Sign-in.</p>
<div class="mb-3 col-lg-4 col-md-8 col-sm-12">
@ -41,38 +41,7 @@
<input type="checkbox" id="remberMe" name="remberMe" formControlName="remberMe" class="form-check-input" />
<label class="form-check-label" for="remberMe" style="font-weight:500;color:black;">Remember me</label>
</div>
@if (attendanceEnabled)
{
<div class="mb-1 form-check form-switch">
<input type="checkbox" id="atndnceLogin" name="atndnceLogin" formControlName="atndnceLogin" class="form-check-input" (change)="eventCheck($event)" />
<label class="form-check-label" for="atndnceLogin" style="font-weight:500;color:maroon;">Login into Attendance System</label>
</div>
}
@if (remarksRequired && f.atndnceLogin.value)
{
<div class="mb-2 col-lg-4 col-md-8 col-sm-12">
<span class="required" style="color: black;">Late Login Remarks:</span>
<br />
<kendo-combobox [data]="lateLoginRemarks"
id="loginRemarks"
name="loginRemarks"
formControlName="loginRemarks"
[textField]="'itemValue'"
[valueField]="'itemValue'"
[valuePrimitive]="true"
[placeholder]="'Late Login Remarks...'"
[kendoDropDownFilter]="filterSettings"
[ngClass]="{ 'k-invalid': submitted && f.loginRemarks.errors}">
</kendo-combobox>
@if (submitted && f.loginRemarks.errors)
{
<div class="invalid-feedback">
Late Login Remarks is required
</div>
}
</div>
}
<div class="mt-3 mb-4">
<button style="min-width:6.2em;" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-raised ui-button-text-only">

View File

@ -27,6 +27,7 @@ import { AppConfig, ComputerConfig } from '../components/models/app.config.model
})
export class LoginComponent implements OnInit
{
private readonly router = inject(Router);
private readonly route = inject(ActivatedRoute);
private readonly modalService = inject(NgbModal);
@ -58,11 +59,12 @@ export class LoginComponent implements OnInit
constructor()
{
debugger;
this.alertService.clear();
const configSvc = inject(ConfigurationService);
this.appConfig = configSvc.configuration?.appConfig;
this.compConfig = configSvc.configuration?.computerConfig;
debugger;
if (this.authService.currentUserValue?.id)
{
if (this.authService.currentUserValue.dbOnStartup)
@ -79,6 +81,7 @@ export class LoginComponent implements OnInit
ngOnInit(): void
{
debugger;
this.alertService.clear();
this.spinnerService.hide();
this.appVersion = packageJson.version;
@ -132,6 +135,7 @@ export class LoginComponent implements OnInit
private loadLoginRemarks(): void
{
debugger;
const autId = this.fnSvc.cipherData(Api.cipherSecretKey ?? '');
this.authService.getLoginRemarks(autId).subscribe(
{

View File

@ -21,6 +21,7 @@ export class AuthenticationService
constructor()
{
debugger;
this.sessionEvent = new EventEmitter();
this.taskStatusEvent = new EventEmitter();
this.notificationEvent = new EventEmitter();

View File

@ -2,7 +2,9 @@ import { inject, Injectable } from '@angular/core';
import { Base } from '../base/base';
@Injectable()
@Injectable({
providedIn: 'root'
})
export class UserService extends Base
{
public addUser(params: any)